Advertisement

Creating an LOD Sphere

Started by February 13, 2000 01:09 AM
1 comment, last by nes8bit 24 years, 7 months ago
How can I create a sphere that uses some form of LOD. Creation Parameters would be pretty much (LOD, Radius). I was attempting to do this myself with triangle strips, but I made a cone instead. I searched through a lot of places and find myself tiredly talking to myself for no reason. Please no complex equations. They hurt my brain. The sphere is for a sky dome. Yes, I already saw the flipcode doc and the code confused me.
I don''t understand why you want to have LOD on your skydome as it is always on the same distance from the camera.

If you know your trigonometry (i.e. cosinus and sinus) you should be able to make sphere''s with different LOD. Just use fewer subdivisions to make a sphere with less detail.

A point on the sphere is computed with:

x = radius*cos(a)*cos(b)
y = radius*sin(b)
z = radius*sin(a)*cos(b)
Advertisement
Thank you soooo much. That saved me another 6 hours of coding. Now I can move on to multiple moving mirrors!!!! fun fun fun. For you VB''ers here is the code.

Sub CreateSkyGod(Radius As Single)
Dim AngleA As Single
Dim AngleB As Single
Dim CurVert As Long
Const StepLoop As Single = 20
ReDim DomeVerts((360 / StepLoop) * (360 / StepLoop) * 6)

For AngleB = 0 To 360 - StepLoop Step StepLoop
For AngleA = 0 To 360 - StepLoop Step StepLoop
DomeVerts(CurVert) = Circle3D(Radius, AngleA, AngleB + StepLoop)
DomeVerts(CurVert + 1) = Circle3D(Radius, AngleA + StepLoop, AngleB + StepLoop)
DomeVerts(CurVert + 2) = Circle3D(Radius, AngleA + StepLoop, AngleB)

DomeVerts(CurVert + 3) = Circle3D(Radius, AngleA, AngleB + StepLoop)
DomeVerts(CurVert + 4) = Circle3D(Radius, AngleA + StepLoop, AngleB)
DomeVerts(CurVert + 5) = Circle3D(Radius, AngleA, AngleB)

CurVert = CurVert + 6
Next
Next
DomeVertCount = UBound(DomeVerts)
End Sub
Function Circle3D(Radius As Single, AngleA As Single, AngleB As Single) As D3DVECTOR
Dim AA As Single
Dim AB As Single
AA = AngleA * PI / 180
AB = AngleB * PI / 180

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

Render as a triangle list.

This topic is closed to new replies.

Advertisement