Archived

This topic is now archived and is closed to further replies.

Wyrframe

GeoSphere creation

Recommended Posts

Wyrframe    2426
I need to generate a Geosphere at run-time, but I''m not sure how to do it... other than, of course, hard-coding every vertex and polygon. Could someone help me with finding a starting point for doing this? NOTE: Texture mapping coords not needed. ALSO NOTE: I don''t need much theory... I just need a starting point so that I can wrap my brain around it myself...

Share this post


Link to post
Share on other sites
Wyrframe    2426
*bump*, and a solution for those who come by this in the future;

Easiest method; take a simple 6-sided 12-triangle cube, with its center at the origin and its corners at (±1,±1,±1). Tesselate it, such that each quad (pair of triangles) becomes four quads (eight triangles) meeting in the center of the original. Repeat as desired, essentially doubling detail each time.

+-------+           +---+---+
|\ | |\ |\ |
| \ | | \ | \ |
| \ | | \| \|
| \ | becomes +---+---+
| \ | |\ |\ |
| \ | | \ | \ |
| \| | \| \|
+-------+ +---+---+


Now, take every vertex and normalize its position. I really can't think of why I didn't think of this when I first stared down at a wireframe of a geosphere.

What you will get is a geosphere; in the shape of a sphere but with six distinct groups of triangles, and with a very even vertex distribution. The vertices that were after the first (and every subsequent) tesselation will still be at their original location, since they are at unit vectors (ie (1,0,0), (0,-1,0), etc), and every other vertex will end up where it would be if it were on the surface of a sphere.

For those who don't know, "normalize" means take a vector and make its length exactly one by dividing each component (X,Y,Z) by the pre-normalization length (sqrt(X*X + Y*Y + Z*Z)).

Hope this helps!

Against TCPA!

I am a signature virus. Please add me to your signature so that I may multiply.

[edited by - Wyrframe on March 1, 2004 2:22:23 AM]

Share this post


Link to post
Share on other sites
Eelco    301
the best method, leading to the most even spacing afaik, is to take a isocahedron, which has 20 equal triangular faces. you can apply to the same principle to these faces as you would to a cube, but since it has more faces, the faces span a smaller part of the sphere, and thus are less affected by distortion.

ive implemented this once, and the difference in size between the smallest and largest triangle was just 8%. this was with some additional measures to counter distortion when normalizing the vertex positions though.

Share this post


Link to post
Share on other sites