Jump to content
  • Advertisement
Sign in to follow this  
dxdotnet1

picking in dx

This topic is 4845 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

can anyone show me a sample on how to pick in directx? i just tried picking a mesh since dx has its build in function for testing a ray and a mesh.. but i dont knw how to perform picking in an ordinary polygon like for example a triangle

Share this post


Link to post
Share on other sites
Advertisement
Calculate the ray through the camera and the mousecursor position on the front plane, then do a simple ray-triangle intersection.

Share this post


Link to post
Share on other sites
Hiya dxdotnet1, How are you doing bud?

[The Problem]
picking in DX

[The Solution]
Just to extend on what the other guys have posted already. Here is a simple description of picking and how to achieve it in theory.

Picking My Terrain

I hope this helps a bit bud,
Keep cool.

Share this post


Link to post
Share on other sites
I noticed your name was called dotnet...so in case you are using managed direct X (or have access to it) there is an intersection test function within D3dX namespace to test against a triangle, and also various bounding volumes. You could also take a look at the code to those functions for some inspiration. When I do picking on the terrain in my current project, I create a ray using the pointer location and near plane in the view frustrum and then check for intersection with the triangles within my viewport. Determining which polys are in the viewport is a whole different ball of wax for sure, but since intersection tests can be costly on the cpu you might want to trivial reject these.

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!