Jump to content
  • Advertisement

Archived

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

aboeing

making a sphere

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey, im sure we have all written code to do this a few million times, im getting a bit sick of it, so i figured someone somewhere must have written code to produce a nice evenly spaced sphere. (or close-to-evenly - [from memory perfectly evenly spaced is close-to-impossible/pain-in-the-a$$?] [i do want to be able to generate the sphere in a short time period..]) also, i was contemplating trying to make the sphere into one big triangle strip (is there much point to this? performance enhancements?) [i want texture coords aswell btw] thanks guys!

Share this post


Link to post
Share on other sites
Advertisement
you can produce even spheres, by using a docedahedron (20 faces), and recursively split the triangles into 4 triangles, by taking the midpoint of each edges and joining them. You need to ''normalise'' the midpoints (push them up a bit so the are on the surface of the ideal sphere), or else you''re gonna end up with a very tesselated dodecahedron. Not very useful

You can produce a LOD very simply like that (just reduce the recursion).

Note that you have to be careful about the way you texture it. As everyone knows, it''s pretty hard to apply a 2D texture to a sphere (squeeze at the poles, stretch at the equator, ...). I would suggest you don''t try to map the whole dodecahedron as a continuous strip of triangles, but rather, brake it in a few bits, to reduce the stretching. As if you literally took it apart and laid the bits flat on the table.

You could split the texture into 20 triangles, where each triangle of the dodecahedron would map directly to it. So you''ll have to duplicate the 20 vertices, to have a set of unique texture coords for each vertices, and each triangle would map to a triangle on the texture. After that, when recursing, you batch a single LOD of a each base triangles in one strip. So 20 strips * number of LODs. You don''t have to go to such extremes, and brake the dodecahedron into 4 or 5 parts.

An interesting part of this technique, is if you go pretty far in the LOD, you can directly produce terrain vertices, or make the sphere not so perfect easily, with even deformations.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!