Jump to content
  • Advertisement
Sign in to follow this  
Lode

Sphere

This topic is 4820 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

How to make a sphere out of triangles, and map a texture on it in a good way?

Share this post


Link to post
Share on other sites
Advertisement
In what context? Is this a sphere you intend to load in modeling software to compose with other models? Is it something you want to render yourself in your own application? If so, what formats does you application support? What kind of modeling software do you want to use to generate the sphere and the texture?

Share this post


Link to post
Share on other sites
It's one I want to render myself in OpenGL (but this applies for D3D too). I remember there's a built in sphere drawing thing in some extension of OpenGL, however I'd like to try to do it myself, to work my way to more complex sphere based shapes that way.

All of this is in the preparation for some fancy thing I'm making :)

Share this post


Link to post
Share on other sites
The built-in sphere is in GLU I believe, something with gluQuadric. If you want to generate a sphere yourself there are two approaches:

1) A sweep algorithm which sweeps a vertical meridian around the sphere, if you know what I mean. This produces a sphere with a vertex at the top and at the bottom tips.

2) An approximation algorith which starts with a simpler sphere approximation and refines it. The approximation is usually an isocahedron or a twenty-sided regular polyhedron. The appriximation can be done by replacing each triangle by three new and smaller triangles and displacing the vertices -- this is done by knowing each vertex has unit distance to the origin.

The latter produces a sphere with equal-sized triangles which is nice in many cases (for example a skydome).

If you use google on either you will find code for either eventually. I did a while a go and it took some time but eventually I found it. Of course I did not bother to save it...

[EDIT: but I found it again]

Greetz,

Illco

Share this post


Link to post
Share on other sites
I made the sphere using the same system as in the link http://www.neubert.net/Htmapp/SPHEmesh.htm that was posted here. I recursively break it up into triangles.

Without texturing, this is very easy and fast.

With textures, I found no other way to do it than to calculate the texture coordinates based on the angles and locations the vertices of the triangles have at the moment the triangle is going to be drawn in the recursive function. This makes it a lot slower however, because now it's calculating 3 texture coorinates at the end of each recursion, and each calculations involves dot products, acos functions, normalizations and so on.

So it works perfect, but is not very fast. (with recursion depth 5: almost 200 fps with no texturing, only 40 fps with texturing)

Is there a faster way to do the texturing when drawing the sphere this way? I like it a lot more than the type of sphere drawn in this article http://astronomy.swin.edu.au/~pbourke/opengl/sphere/ or by gluQuadratic.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!