• ### Announcements

#### Archived

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

# Spheres

## Recommended Posts

Gyzmo    162
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 on other sites
federickrex    122
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);
}
}

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 on other sites
Gyzmo    162
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 on other sites
DrunkenHyena    805
G''day!

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

Stay Casual,

Ken
Drunken Hyena