Jump to content
  • Advertisement
Sign in to follow this  
simotix

Ray Picking Question.

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

I have been working on ray picking the last few days (with limited articles, I can't seem to find a good one). I have encountered two problems. 1) Maybe what I was reading was wrong, but do I call a picking equation on every object on the screen? 2) Some times when I have to objects sitting right next to each other, then I look at a side view I can select the object behind it. Does anyone know how to only select the first object? (I was thinking of just checking in order of z). Also, if anyone could point me to any good examples or tutorials on ray picking so that what I can make sure I am doing it the right way it would be very appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
1) Maybe what I was reading was wrong, but do I call a picking equation on every object on the screen?
Well you'd typically convert a mouse-click coordinate into a ray in world space and then check it against each object, but as you can probably tell this is a bit slow. Spacial partitioning tests (such as BSP or Octree) as well as heirarchical bounding-volume tests. Try to reject groups of incorrect objects with as few tests as possible.

Quote:
Does anyone know how to only select the first object? (I was thinking of just checking in order of z).
You've got the right idea - sort/select by lowest depth value or shortest distance from the start of your ray.

Quote:
if anyone could point me to any good examples or tutorials on ray picking so that what I can make sure I am doing it the right way it would be very appreciated.
I'll move this to the 'Graphics Programming & Theory' forum for further discussion. It's not really a DirectX-specific question and equally its not quite general/game programming or pure 'maths & physics'...

hth
Jack

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!