PDA

View Full Version : Ray/Object Determination



PollyPocket4eva
03-08-2009, 08: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.
Thanks

Abdallah DIB
03-08-2009, 08: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 .
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/unproject.html

Abdallah DIB
03-08-2009, 09: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 .