Jump to content
• ### What is your GameDev Story?

• Advertisement

#### Archived

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

# creating a 3D sphere

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

Hi all!. ok , my story is like that: im trying to build a function that will create 3D sphere vertices. its looks like that: void Objects::CreateHalf3DSphere(D3DVERTEX *D3DSphereVrtx,D3DVECTOR SphereOrigin,float Radius,int Segments,int Levels,bool Up) { D3DVECTOR SVertex; D3DVECTOR n; float phi; float theta; for(theta = -90; theta < 91; theta += 10) { for(phi = 0; phi < 361; phi += 72) { SVertex = D3DVECTOR(cos(phi) * sin(theta), sin(phi), cos(phi) * cos(theta)) * Radius; n = Normalize(SVertex - SphereOrigin); *D3DSphereVrtx++ = D3DVERTEX(SVertex , n ,0.0f,0.0f); } } } now , when i rendering it with POINTLIST its looks like that:

as you can see (its hard to see it ) some points is stafe right , and some to left , and there is places without points at all. somebody know why and what is the problem? thamks a lot! Posted By Xeno. Kobe Bryant - "Just believe in yourself" Visit my web site : VSoft

#### Share this post

##### Share on other sites
Advertisement
You''ve got the right idea, but you need to use radians, not degrees for the angles.
Replace -90 with -PI/2, 90 with PI/2, and 360 with 2*PI. To make things easy use <= rather than < in the "for" statements.

#### Share this post

##### Share on other sites
ohhhhhhhhh!!!!
i was so angry about that so i didnt even noticed it
thanks a lot
its seems to work fine now

Posted By Xeno.
Kobe Bryant - "Just believe in yourself"

Visit my web site : VSoft

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 13
• 9
• 9
• 15
• 14
• Advertisement
• ### Forum Statistics

• Total Topics
634070
• Total Posts
3015335
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!