Graphics3D 800,600,32,2
SetBuffer BackBuffer()
camera = CreateCamera()
MoveEntity camera,0,0,-20
Layers = 20
Dim s(Layers )
For n=0 To Layers
s(n) = CreateBall()
scale# = 1.0-((Float(n+1))/50.0)
ScaleEntity s(n),scale,scale,scale
Next
Repeat
For n=0 To Layers
RotateEntity s(n),0,-Float((MilliSecs()))/20,-Float((MilliSecs()))/30
Next
RenderWorld
VWait
Flip False
Until KeyHit(1)
Function CreateBall()
Q = CreateMesh()
SQ = CreateSurface(Q)
p = CreatePivot()
For n=0 To 1000
PositionEntity p,0,0,0
TurnEntity p,Rnd(-359,359),Rnd(-359,359),Rnd(-359,359)
MoveEntity p,0,0,10
MoveEntity p,-.1,-.1,0
v1 = AddVertex(SQ ,EntityX(p),EntityY(p),EntityZ(p),0,0)
MoveEntity p,.2,0,0
v2 = AddVertex(SQ ,EntityX(p),EntityY(p),EntityZ(p),1,0)
MoveEntity p,-.2,.2,0
v3 = AddVertex(SQ ,EntityX(p),EntityY(p),EntityZ(p),0,1)
MoveEntity p,.2,0,0
v4 = AddVertex(SQ ,EntityX(p),EntityY(p),EntityZ(p),1,1)
AddTriangle(SQ ,v1,v2,v4)
AddTriangle(SQ ,v1,v4,v3)
c=Rand(0,3)
If c=0 Then r=255:g=0:b=0
If c=1 Then r=0:g=255:b=0
If c=2 Then r=0:g=0:b=255
If c=3 Then r=0:g=100:b=255
VertexColor SQ,(n*4)+0,r,g,b
VertexColor SQ,(n*4)+1,r,g,b
VertexColor SQ,(n*4)+2,r,g,b
VertexColor SQ,(n*4)+3,r,g,b
Next
EntityBlend q,3
EntityFX q,18
FreeEntity p
Return q
End Function
|