Jump to content
  • Advertisement
Sign in to follow this  
kdworld

Fast Object selection in 3D Scene

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

Hello Friends, I am now facing a problem . It is about selecting objects in a 3D scene. In my scene i need to move object when the user clicks the axis ( local axis of the object x,y and z). So when mouse pointer comes around the axis i need to highlight the axis ( For a better user experience) . I am developing this program using opengl . OpenglGl pciking is slow. Any other good methods ? Thanks in advance KD

Share this post


Link to post
Share on other sites
Advertisement
Most physics engines (or collision detection libraries) have very fast routines for testing if a ray (3d line) intersects with an object. There are free physics engines you could use to do this.

Otherwise you could program a picking test yourself (although I wouldn't recommend it when a physics engine can do it for you). Topics to research include converting a screen-space point into a world-space ray, and how to find the intersection-point between a ray and a cylinder/sphere/box/triangle.

Share this post


Link to post
Share on other sites
Just test the ray for collision with a bounding box or bounding sphere. Both are easy to do and require just a little math.

Share this post


Link to post
Share on other sites
There is another method, but nobody likes it.

It involves assigning unique 32 bit IDs to each objects in the scene, rendering them without any shading, aliasing, just pure flat colour fill, using the 32 bit ID as the colour. Then looking at the colour of the pixel underneath the position of the mouse cursor will give the object id.

But really, ray-cast from the scren to the mouse cursor, and do ray-intersect tests with bounding boxes, bounding spheres should be enough. There is a function in OpenGL to convert a 2D screen coordinate into a 3D coordinate (gluUnProject / gluProject?).

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!