PDA

View Full Version : Picked Position



halo
01-08-2005, 08:11 PM
I am using glSelectBuffer to pick onscreen objects, with no problem. Part of my program is a physics editor that allows the user to push and pull objects around in real time. For this, I need to know the position of the pick, so that I can apply force with the right position and vector.

How can I get the point in 3D space that was picked, or at least the z-distance in front of the camera that was picked (so I can transform it to 3D space)? gluUnproject takes a z-parameter, so I can't try to use it without knowing how far away my picked point is.

halo
01-08-2005, 08:48 PM
I got some information with glReadPixels, but I don't understand how a clamped value [0-1] represents a depth relative to my camera. My range is like 60,000, and I am getting values of 1.0 and a little bit less, at a depth like 1000 in front of my camera.

zed
01-08-2005, 08:57 PM
http://www.opengl.org/resources/faq/technical/transformations.htm#tran0110

halo
01-08-2005, 09:13 PM
It works. Thanks!