Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


how to select spheres using the cursor

This topic is 5967 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 want that the user is able to select spheres. I want to do it this way: -- 1 -- Extract the position of the camera out of the modelview-matrix. how can I do this? -- 2 -- Project the position of the cursor on the nearplane. I am using gluUnProject(...) but I get strange values -- 3 -- Define a ray which goes through these points and test this ray for intersection whith each sphere. no problem please help..

Share this post

Link to post
Share on other sites
Original post by Kamil
Maybe using selection buffer would be easier.

It is, but I don''t want to do it this way...

Share this post

Link to post
Share on other sites
Theres a lot of reasons for not relying solely on the selection buffer. Probablly the number one reason is if theres a large number of objects to consider for selection (i.e. > 30).

Whenever you run the selection code you''ll get a hitch in the framerate as it tries to figure out what you''re clicking on. This gets worse as the number of objects you''re considering for selection goes up.

In cases such as these it''s probablly better to do some manual selection using the method Kaesebrot describes above using a ray and the bounding boxes/spheres of the objects to eliminate alot of the objects. Then if you need more detail as far as what object you hit, run those objects through the selection buffer.

Here''s a good article on this:


It''s DirectX oriented but the technique is easily adaptable to OpenGL.

-=[ Megahertz ]=-

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!