Jump to content
  • Advertisement
Sign in to follow this  
jstark05

Directx + picking

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i am trying to build a simple cad program,and since i decided to build it in managed code (C#), i would like to ask you if directx offers picking (picking lines, curves etc) capabilities. I was told that opengl has some picking capabilities but i would like to stay with managed code. Thank you

Share this post


Link to post
Share on other sites
Advertisement
I can't offer much help, but I would hate to see this thread die with no replies. You may get better replies in the DirectX forum.

OpenGL apparently automates the picking procedure. In DirectX, you have to code this procedure yourself; however, this isn't as hard as it sounds. If you paid attention when learning about the rendering pipeline (particularly, the transformations between coordinate systems, such as world transform, view transform, etc), then you'll be fine. Picking is the inverse of projection.

You can try googling for a guide on picking in Direct3D. I was able to find this (scroll all the way down, it's under "TwistyCube"), and I'm sure there are more guides.

Share this post


Link to post
Share on other sites
As far as I know there is no "automated" way, but this is something you want to write yourself (at least as far as the search goes).

The first step is to convert the coordinate of the mouse to world/object space, and you can do that using "Vector3.Unproject". Then you can get the direction of the ray by subtracting the camera position from what you got by unprojecting. That gives you a line in 3D to work with.

Once you have that you need to search through the objects you have to find the correct object that intersects it. There are a lot of things to help you though, like "Mesh.Intersect" that will tell you if a ray intersects the mesh. You can also take advantage of whatever partitioning you may be using to speed up this search.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!