Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Const SLICES = 10
- Const BANDS = 10
- Const PI = 3.14159
- Type Vert3D
- x As Single
- y As Single
- z As Single
- End Type
- Type Quad3D
- v1 As Vert3D
- v2 As Vert3D
- v3 As Vert3D
- v4 As Vert3D
- End Type
- Dim Shared v(SLICES*BANDS) As Vert3D
- Dim Shared sphere As Quad3D Ptr = 0
- sphere = Allocate(1)
- Sub CreateSphere(ByRef model As Quad3D Ptr)
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim sliceloop As Integer
- Dim bandloop As Integer
- Dim phi As Single
- Dim theta As Single
- Dim radius As Single
- radius = 10
- For sliceloop = 0 To SLICES - 1
- phi = PI / SLICES * sliceloop
- For bandloop = 0 To BANDS - 1
- theta = 2 * -PI / BANDS * bandloop
- v(i).x = radius * Sin(phi) * Cos(theta)
- v(i).y = radius * Sin(phi) * Sin(theta)
- v(i).z = radius * Cos(phi)
- i = i + 1
- Next
- Next
- For i = 0 To SLICES * BANDS - 1
- 'Get lowest tens value of i and store it in j, then add the index of v2 and v3 to j
- j = (i \ 10) * 10
- ReAllocate(model, i * SizeOf(Quad3D))
- model[i].v1 = v(i)
- model[i].v2 = v(j+((i+1) Mod SLICES))
- model[i].v3 = v(j+1+((i+1) Mod SLICES))
- model[i].v4 = v((i+SLICES) Mod (SLICES * BANDS-1)) 'v(i+SLICES) ' Maybe
- Next
- End Sub
- Print "A"
- CreateSphere(sphere)
- Dim i As Integer
- Print "B"
- For i = 0 To (SLICES * BANDS - 1)
- Print "Q[";i;"]: P1: X=";sphere[i].v1.x;"; Y=";sphere[i].v1.y;" Z=";sphere[i].v1.z
- Print "Q[";i;"]: P2: X=";sphere[i].v2.x;"; Y=";sphere[i].v2.y;" Z=";sphere[i].v2.z
- Print "Q[";i;"]: P3: X=";sphere[i].v3.x;"; Y=";sphere[i].v3.y;" Z=";sphere[i].v3.z
- Print "Q[";i;"]: P4: X=";sphere[i].v4.x;"; Y=";sphere[i].v4.y;" Z=";sphere[i].v4.z
- Sleep 100
- Next
- Print "Done!"
- Print "Press escape to quit!"
- Dim done As Byte
- While done <> 1
- If MultiKey(&H01) Then
- done = 1
- EndIf
- Wend
Add Comment
Please, Sign In to add comment