[edit] lol. bot builder beat me to it! :P
Ah, I see. That method must be using alot of polys though, isn't it?
They tend to flicker and vanish as you move away from them.
That's probably because the ring meshes are very 'thin' and become too thin to render properly when far away from the camera.
I'd really like to find another way of doing it - like perhaps drawing them directly to the 2d portion of the screen if I can figure out a way.
I don't think drawing the rings with 2D is going to be a solution. The rings need to be z-buffered so that they're not visible when they go behind the planets, etc., yes?
One solution may be to use 3D lines. Below is a simple demo of this.
The up-side to this method:
- the rings (should) always render properly, no matter how far away they are (no flickering).
- uses minimal amount of polys.
Possible down-side:
- requires a 2-pass render: 1 in wireframe mode and 1 in normal, solid mode.
Anyway, let me know if it's of any use. :)
Graphics3D 800,600,32
SetBuffer BackBuffer()
SeedRnd MilliSecs()
fps_timer = CreateTimer(60)
wiref_piv = CreatePivot()
solid_piv = CreatePivot()
cam = CreateCamera()
PositionEntity cam,0,0,-5
light = CreateLight()
planet = CreateSphere(16,solid_piv)
EntityColor planet,0,100,200
For n=1 To 10
ring = create_ring(100,ring,1.2+(n*Rnd(.3,.4)), 0,255,0)
Next
EntityParent ring,wiref_piv
; Main loop
While Not KeyHit(1)
TurnEntity ring,1,1,1
; Render wireframe objects.
WireFrame 1
PositionEntity wiref_piv,0,0,0,1
PositionEntity solid_piv,0,0,10000,1
CameraClsMode cam,1,1
RenderWorld
; Render solid objects.
WireFrame 0
PositionEntity solid_piv,0,0,0,1
PositionEntity wiref_piv,0,0,10000,1
CameraClsMode cam,0,0
RenderWorld
WaitTimer(fps_timer)
Flip(1)
Wend
End
;
;
;
;
Function create_ring(segs%,mesh=0,rad#=1,r%=255,g%=255,b%=255)
rstep# = 360.0/segs
last_ang# = 0
For i = 1 To segs
new_ang# = last_ang + rstep
mesh = create_3D_line(mesh, Cos(last_ang)*rad,0,Sin(last_ang)*rad, Cos(new_ang)*rad,0,Sin(new_ang)*rad, r,g,b)
last_ang = new_ang
Next
Return mesh
End Function
;
; Adds a 3D line to the specified mesh.
; Note: 3D lines are only properly visible when rendered in wireframe mode!
;
; Params:
; mesh - Mesh to add 3D line to. If 0, a new mesh is created.
; x0,y0,z0 - Start point of line.
; x1,y2,z1 - End point of line.
; r,g,b - Line colour.
;
; Returns:
; Handle of mesh the 3D line was added to.
;
Function create_3D_line(mesh,x0#,y0#,z0#,x1#,y1#,z1#,r%=255,g%=255,b%=255)
If mesh = 0
mesh = CreateMesh()
surf = CreateSurface(mesh)
EntityFX mesh,1+2+16
Else
last_surf = CountSurfaces(mesh)
surf = GetSurface(mesh,last_surf)
If CountVertices(surf) > 30000 Then surf = CreateSurface(mesh)
End If
v0 = AddVertex(surf,x0,y0,z0)
v1 = AddVertex(surf,x1,y1,z1)
v2 = AddVertex(surf,x0,y0,z0)
AddTriangle surf,v0,v1,v2
VertexColor surf,v0,r,g,b
VertexColor surf,v1,r,g,b
VertexColor surf,v2,r,g,b
Return mesh
End Function