Complete Geosphere

Started by
3 comments, last by Narf the Mouse 11 years, 10 months ago
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. smile.png

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.
Advertisement
*Poke*?

I can probably do the indices and division by graphing it, now that I have graph paper.
All I have left is figuring out how to calculate the UV coordinates.

Shouldn't be too hard.

Really glad I asked for help, everyone. Love the responses.
I'm not sure but perhaps this help

http://iquilezles.org/www/articles/patchedsphere/patchedsphere.htm

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. :)

This topic is closed to new replies.

Advertisement