Jump to content
  • Advertisement
Sign in to follow this  
kenjinsakura

Point Polygon collision

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

Hey all, I need to know if my cursor is over a polygon in 3d space. There's more than one polygon and I need to find the closest one that hits. The method I've come up with is: For each polygon Project the polygon vertices onto the screen (view, transform, projection matrices known) Using odd-even test, determine if cursor is in projected polygon. If it does then check the distance and compare to the distance of closest polygon found. I'm wondering if there was a better way to do it. Or if there's something wrong with the algorithm. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

Hi,

The method you describe should work just fine.

Another way of doing the same thing is to create a 3d ray from the mouse pointer coordinates and do ray-triangle hit test for each polygon.

this thread describes how to get the ray.

You can google for the ray-triangle hit test.

This method is useful also for raytracing and is maybe a bit more efficient since you don't need to project your triangles.

Good luck!

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!