how to select spheres using the cursor

Started by
2 comments, last by Kaesebrot 21 years, 8 months ago
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..
Advertisement
Maybe using selection buffer would be easier.

Homepage.
quote:Original post by Kamil
Maybe using selection buffer would be easier.


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

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:

http://www.mvps.org/directx/articles/rayproj.htm

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


-=[ Megahertz ]=-
-=[Megahertz]=-

This topic is closed to new replies.

Advertisement