Archived

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

Sphere in D3D

This topic is 6938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Does someone have a function that creates a 3d sphere in VB (Direct3D)? I need it to do planets, stars etc.

Share on other sites
I don''t know a d3d function for it, but you could calculate the vertices with
x = r*cos(u)*cos(v)
y = r*sin(u)*cos(v)
z = r*sin(v)

with u and v running from 0° to 360°

GA

Share on other sites
Actually, you forgot to turn degrees into radians.

Try this:

Function Circle3D(Radius As Single, AngleA As Single, AngleB As Single) As D3DVECTOR
On Error Resume Next
Dim AA As Single
Dim AB As Single
AA = AngleA * 3.14 / 180
AB = AngleB * 3.14 / 180

With Circle3D
.X = Radius * Cos(AA) * Cos(AB)
.Z = Radius * Sin(AA) * Cos(AB)
End With
End Function

AngleAA is Horizontal and AngleAB is Vertical. This is straight from my program so the variables are kinda screwy

Share on other sites
I didn''t forget it, I think ° means *PI/180

GA

Share on other sites
The D3DX library has a D3DXCreateSphere function.

Share on other sites
Unfortunately D3DX doesn''t work with VB.

WitchLord

• 10
• 13
• 52
• 11
• 15