View Full Version : Ray/Object Determination

03-08-2009, 09:31 AM
Does OpenGL have a function which allows you to query what object appears at a certain location in screen-coordinates?
Naturally, any ray tracer would inherently know which object in a scene was "first hit" by a particular ray.
It could of course be custom written, but I'm wondering if there is anything built into OpenGL...
Ideally a function that would take a (x, y) screen coord and return the (name?) or address of the first visible object at that coord.

Abdallah DIB
03-08-2009, 09:58 AM
gluUnproject will return a 3d point from a window coordinate point. the 3d point returned is in the object coordinate and u can here verify if it hits ur object or no .

Abdallah DIB
03-08-2009, 10:04 AM
to finish .just as an idea u can construct a bounding area ( bounding box or sphere) for ur object and than u can verify if the 3d point returned from gluUnproject is in the bounding area or no .