View Full Version : Texture map a icosahedron
01-31-2003, 12:31 AM
I'm trying a map an image of the Earth onto an icosahedron. I got the code tess.c and sphere.c from the glut distribution. The sphere looks much better than a gluSphere.
Has anybody already done this? The test code I wrote yesterday doesn't handle the places where the texture has to wrap, the triangles don't line up with the edge of the texture, and I'm slightly concerned with the poles.
01-31-2003, 05:04 AM
I would convert the vertex coordinates into polar coordinates, map longitude and latitudes from 0 to 1 (edit: for triangle vertices wich cross the border you need to either add or subtract 1 to get the wrapping right!), set GL_TEXTURE_WRAP_S to GL_REPEAT, that should solve the border not fitting argument for longitudes,
and GL_TEXTURE_WRAP_T to GL_CLAMP_TO_EDGE.
And there is an orientation of the icosahedron where you have a vertex on north and south pole.
The usual planet textures are mapping the poles to a full line anyway, so the texture is already distorted.
If you have a better map, you need to inverse there projection to a sphere.
[This message has been edited by Relic (edited 01-31-2003).]
01-31-2003, 06:14 AM
Everything works except for where a triangle has vertices on either side of the texture boundary because the longitude wraps 0-2*PI.
I'll have to check the vertices of all my triangle strips to see which ones wrap.
01-31-2003, 08:35 PM
Decide on a longitude, and duplicate your vertices down that longitude; one set has a u coordinate that's 1 greater than the other set. Then the other vertices have values inbetween, and texture repeat will match it all up for you.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.