Jump to content
  • Advertisement
Sign in to follow this  
gorgorath

OpenGL picking right point by mouse clicking

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

hi, i need help with selecting points in openGL. I have a reasonable (array)list of vertices, in the amount of 10.000(not any spatial algortithm applied to it). Now i need to find the nearest/closest point when an user clicks on a location. I read about the GL_SELECTION part, to create a ray that intersect with plane/ray collision. but how to (quickly) select individual points. cheers, P

Share this post


Link to post
Share on other sites
Advertisement
You can calculate the distance of a point to a ray (or line) using the formula numbered 9 of the description at mathworld.

One way to find the closest point, is to compare the distances of all points to the ray. This brute-force method will perform terrible (esp. with thousands of points). It can probably be optimized by (hierarchically) grouping the points in clusters and performing brute-force only within clusters that are near the ray. This may get tricky though, especially if the points are highly dynamic.

Tom

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!