Jump to content
  • Advertisement

Archived

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

Gyzmo

Spheres

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

I''d like a function that generates a (triangulated)sphere, like in 3d-modeling programs where you say ''Give me a sphere with X-segment or detail level X'' if you know an algo, or a link to info I''d appreciate it. Gyzmo ======================== Having a ''sig''-crisis

Share this post


Link to post
Share on other sites
Advertisement
it'' simple...
you have to think thata a sphere is like Earth: you can subdivide it in many squares like latitude e longitude.

every square has 4 vertex and 2 triangle that link them.
eache vertex may be opthaind so:

for(i = 0; i < x; i++){
for(j = 0; j < x; j++){
latitude = (6.28 / x * i);
longitude = (3.14 / x * j);
vertex[j].x = sin(latitude)*cos(longitude)*radius;
vertex[i][j].y = sin(longitude)*radius;
vertex[i][j].z = cos(latitude)*cos(longitude)*radius;
}
}

then every triangle links three vertex, and every for vertex make a square:


vertex[i][j], vertex[i+1][j], vertex[i+1][j+1] vetrex[i][j+1] make a square.

fede

Share this post


Link to post
Share on other sites
quote:
Original post by federickrex
for(i = 0; i < x; i++){
for(j = 0; j < x; j++){
latitude = (6.28 / x * i);
longitude = (3.14 / x * j);



Thanks, I haven''t tried it, but this WILL give a division by zero, I take it it must be something like


for(i = 1; i <= x; i++){
for(j = 1; j <= x; j++){
latitude = (6.28 / x * i);
longitude = (3.14 / x * j);


am I right?

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.

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!