Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
glut provide some usfule api to build sphere such as glutSolidSphere() and glutWireSphere(). i want to build a 3D earth like google earth, the texture can change with diffrent resolution and can get the latitude and longitude frome the mouse move. i can not do it with only the glut api.
how can i get some knowledge about it ? thanks. :)
Posted

1 solution

Getting the latitude and longitude from the mouse position shouldn't be too difficult. The general approach would be to use gluUnProject() twice with the mouse position as input (once at the near plane and one at the far plane) to get 2 points. use these 2 points to define a line / ray. Then determine where the line intersects the sphere the first time.
(a line can intersect a sphere once, twice or not at all). Use that 3d point to get the correct latitude and longitude. (I don't know how to go about doing that, but a quick google search will probably help.)

About the texture, I am assuming you mean you want a variable level of detail on the earth texture. A simple way to do this is to get the distance from the camera to the sphere and change the texture based on the distance. A more precise way is to look up the precise depth value of the earth pixels on screen with glReadPixel() (if the camera is stationary, thus you know which pixels are the rendered earth).

If you were hoping to end up with something similar to Google Earth then there is a lot more that you need to do besides what I explained.

To answer your question more accurately:
Google Reading list:
- gluUnproject()
- glReadPixel()
- line sphere intersection
- point on sphere to longitude & latitude

I hope this brainstorm helps. good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900