PDA

View Full Version : Using glreadpixels to find coords?



Dr_Davenstein
01-27-2007, 05:00 PM
Well, here is what I'm attempting to do. I have a sphere that can be rotated with a trackball. It looks like this...
http://qbnz.com/dr_davenstein/WebSnaps/sphere_pick.jpg

When the user clicks on the sphere, I need to get the texture coordinates of the area they clicked. The reason I need the coordinates, Is I plan to use an array of 2D lines to create polyon shapes that mimic the continents. I would then take the texture coords and do an intersection test to see if the user clicked on a certain continent. I was hoping to use a method like this so I could avoid creating a really high poly sphere. Thanks!

Also, here's a link to the test program, if anyone is interested.
http://qbnz.com/dr_davenstein/Sphere0.rar

sqrt[-1]
01-28-2007, 01:00 AM
I would personally just do the maths.

Eg. cast a ray from the camera through the mouse click position (that is a maths ray, nothng to do with OpenGL) and calculate the intersection point of the sphere.

Most intersection libraries should have ray-> sphere collision.

From the collision point, you need to project it into texture coordinates (will depend on how you have textured the sphere)