Sign in to follow this  

Object Selection

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

What is the best way to determine when a mouse click lands on an object in a 3d world? In OpenGl, is using gluUnProject() a viable option? (And then using the object coordinates it returns to determine which object the coordinates are closest to) As another option, creating a ray, modifying it by the projection matrix and tracing it through the scene to find the nearest collision. But this doesn't seem like it would perform as well as the first method. Are there any other methods?

Share this post


Link to post
Share on other sites
The methods I'm familiar with (in OpenGL at least) are:

- Using OpenGL feedback mode
- Using color buffer tricks
- Using a pick ray (as you mentioned)

I don't know of any data comparing performance between the methods, but my guess would be that the last would perform as well or better than the others since it doesn't require any extra rendering passes.

Also note that unprojecting a single point probably won't work, since a mouse click corresponds to a ray, not a point. So I'd recommend the ray-tracing method. You can use gluUnproject() to build the ray, and then intersect it with the bounding volumes of your objects. Depending on the number of objects in your scene, you might also add a broad-phase pass to improve performance.

Share this post


Link to post
Share on other sites

This topic is 4196 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this