Spheres

Started by
2 comments, last by Gyzmo 23 years, 1 month ago
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
Gyzmo=============================="Well is the world standard" - The Alchemist"Not in Canada!" - jonnyfish
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[j].y = sin(longitude)*radius;<br> vertex[j].z = cos(latitude)*cos(longitude)*radius;<br> }<br>} <br><br>then every triangle links three vertex, and every for vertex make a square:<br><br><br>vertex[j], vertex[i+1][j], vertex[i+1][j+1] vetrex[j+1] make a square.<br><br>fede<br> </i>
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?
Gyzmo=============================="Well is the world standard" - The Alchemist"Not in Canada!" - jonnyfish
G''day!

If you''re using DX8, you can use D3DXCreateSphere().


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement