# OpenGL Complete Geosphere

This topic is 2225 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've managed to cobble up a Geosphere creation algorithm, mostly from the OpenGL Programming Guide.

And it looks like this link wil give me the UV coordinates. However, from the sounds of it, it could be improved.

Google says maybe a cubemap might be best for geosphere/icosahedron texturing. Not quite sure how to apply a cubemap. Could hack it out on a cube pretty easy, but a geosphere? Lost. If anyone's got a ready tutorial, it would be appreciated.

And, indexing an icosahedron. Need to know how to automatically generate indices for a subdivided icosahedron - Or maybe just for a triangle subdivided in four.

 float X = 0.525731112119133606F ; float Z = 0.850650808352039932F ; Vector3F vp ; vertices = new Vertex[ 12 ] { new Vertex( vp = new Vector3F( -X, 0, Z ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( X, 0, Z ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( -X, 0, -Z ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( X, 0, -Z ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( 0, Z, X ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( 0, Z, -X ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( 0, -Z, X ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( 0, -Z, -Z ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( Z, X, 0 ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( -Z, X, 0 ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( Z, -X, 0 ), vp, Vector2F.Zero ), new Vertex( vp = new Vector3F( -Z, -X, 0 ), vp, Vector2F.Zero ), } ; indices = new short[ 60 ] { 1, 4, 0, 4, 9, 0, 4, 5, 9, 8, 5, 4, 1, 8, 4, 1, 10, 8, 10, 3, 8, 8, 3, 5, 3, 2, 5, 3, 7, 2, 3, 10, 7, 10, 6, 7, 6, 11, 7, 6, 0, 11, 6, 1, 0, 10, 1, 6, 11, 0, 9, 2, 11, 9, 5, 2, 9, 11, 2, 7 } ; for (int i = 0 ; i < indices.Length ; i += 3 ) { Vector3F one = Vector3F.Zero, two = Vector3F.Zero, normal ; for ( int j = 0; j < 3 ; ++j ) { one[j] = vertices[ indices[ i + 0 ] ].VertexPosition[ j ] - vertices[ indices[ i + 1 ] ].VertexPosition[ j ] ; two[j] = vertices[ indices[ i + 1 ] ].VertexPosition[ j ] - vertices[ indices[ i + 2 ] ].VertexPosition[ j ] ; } normal = Vector3F.Cross( one.Normalized( ), two.Normalized( ) ) ; vertices[ indices[ i ] ].VertexNormal = normal ; } 

Thanks.

##### Share on other sites
*Poke*?

I can probably do the indices and division by graphing it, now that I have graph paper.

##### Share on other sites
All I have left is figuring out how to calculate the UV coordinates.

Shouldn't be too hard.

##### Share on other sites

I'm not sure but perhaps this help

http://iquilezles.or...tchedsphere.htm

Sorry, that's not a geosphere. But I think I've got it pretty well worked out.

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
15
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631776
• Total Posts
3002300
×