View Full Version : How do I identify the point beyond the object?

03-29-2004, 06:33 PM
i want to use gluUnproject() to convert Screen coordinates to world coordinates(3D coordinate),
the program goes that:when i move the mouse on the object, then coordinates information displays
but a problem occurs,when i move the mouse on screen beyond the object,it also display the coordinate information,
how do i identify the point that beyond the object?

any exciting suggestions?

03-30-2004, 07:47 AM
You could try reading color info or better yet destination alpha information and begin by setting alpha to zero. OTOH you could check the depth value and see if it's zfar of check if eyespace z is at the far clip, just so long as your object doesn't get that far out.

03-30-2004, 10:04 AM
Why was this answered in the advanced forum?

Anyway, un-projecting device coordinates give you a ray in world space (or whatever modelview space you happen to have set if you go all the way back).

Run this ray through your scene hierarchy, checking what it collides with. If it doesn't intersect with whatever you're interested in, your logic should do whatever is appropriate (such as ignoring it).

This is pretty much zero related to OpenGL, and much more related to higher-level scene graphs and other such geometry management APIs.

03-31-2004, 12:07 PM
This is related to OpenGL in my opinion. Advanced, well perhaps not, but I'm not the only one to reply :-)