View Full Version : Getting Coordinates of points on Sphere

11-19-2002, 04:17 PM
I'm trying to calculate the real world coordinates of a point on a sphere with texture map, from the coordinates of a mouse click.

I have experimented with gluUnproject but I seem to be getting nonsense for output!
I'm not really sure how to use glDepthRange() to get the z coordinates - I've tried using glReadPixel to get this but I always seem to get the same value wherever I click the mouse.

Any help would be greatly appreciated!

[This message has been edited by gevans2000 (edited 11-19-2002).]

11-20-2002, 12:18 AM
As far as I remember equeation is as follows: x^2+y^2+z^2=R^2 so if you have x,y & of course you know R then it's just the math you need http://www.opengl.org/discussion_boards/ubb/smile.gif

11-20-2002, 12:31 AM
real world as in screen coords? If you want screen coords use gluunproject, if you want the x,y,z then use gluproject with the mouse x, y.

11-22-2002, 06:52 AM
I have used gluUnpoject and I'm getting the z value from glReadPixels. This always seems to give the same value though. I've read somewhere that if the near clip frame is to close to the camera position then glReadpixels can be inaccurate - any ideas how close it means. At the moment my sphere has radius 1.0 and my camera is at (0.0,0.0,3.0) with the near clip frame 1.0 away from the camera. Is this too close? Could this cause the z value read from glReadPixels to always be the same (very small) number?