Archived

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

Interacting with objects in 3D?

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

I know this has been discussed before, but I couldn''t find enough information about this subject when I did a search. I need to know how to work out which object in world-space a camera (player) is looking at - like when you pick up objects in Deus Ex - the objects are highlighted with a white box, and a description is given, or opening doors in Thief - the doors are highlighted by making them brighter. I think it has something to do with ''back projection'' or looking at the what area of the screen the camera''s focus (or crosshair) is centered upon, then trying to work out its camera coordinates, then world-coordinates. Can someone give me a description of the process you follow? Thanks, Paulcoz.

Share this post


Link to post
Share on other sites
I quick but slow way would be to check which polygons the mouse is in(using the polygon''s screen coords). Then find the closest polygon to the camera.

Share this post


Link to post
Share on other sites
Also I think there''s something called a "selection buffer" or something like that in OpenGL, but I don''t know anything about it.

wolfman8k

Share this post


Link to post
Share on other sites
gluUnproject is what you are looking for. Never used it but it is in the red book which I assume you don''t have since you asked this question.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

Share this post


Link to post
Share on other sites
I was hoping someone could explain to me the process I should follow to do this, and what maths is involved - I am not using planning on using pre-written functions (or OpenGL).

"Then find the closest polygon to the camera."

It would be useful if someone could tell me how to do this. I do understand that to work out which object I am looking at I have to find the object with the nearest z value for a particular x,y in camera space.

More ideas please.
Paulcoz.

Share this post


Link to post
Share on other sites
If you know where your viewport in 3d space is located then you can just cast a ray in the direction that you are looking and check for polygons that are intersected. It is easy to figure out which poly is the closest after that. Look at some ray-tracing code to see how set up the ray and the algorithms for poly intersection.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

Share this post


Link to post
Share on other sites
GKW - that sounds like what I am looking for, thanks - I''ll see what I can find out.

Paulcoz.

Share this post


Link to post
Share on other sites