; ParticleMesh Example ; -------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-6 CameraClsColor camera,8,12,24 ; Mesh particles are lit like normal geometry light=CreateLight() RotateEntity light,45,-30,0 floor=CreatePlane() EntityColor floor,30,34,44 ; Hidden source meshes - the emitter copies their first surface cube=CreateCube() HideEntity cube cone=CreateCone(6) HideEntity cone ball=CreateSphere(4) HideEntity ball ; A loot geyser tossing spinning 3D pieces in one batched draw emitter=CreateParticleEmitter(500) PositionEntity emitter,0,0.5,0 ParticleEmissionRate emitter,60 ParticleLifetime emitter,2,3 ParticleVelocity emitter,0,4,0,1,0.5,1 ParticleGravity emitter,0,-4,0 ParticleColor emitter,255,200,60,1,255,120,40,1 ParticleSize emitter,0.15,0.1,0.3 ParticleRotation emitter,0,360,-180,180 ; Start with cube-shaped particles ParticleMesh emitter,cube mesh_name$="1 cube" While Not KeyDown(1) ; Keys 1-3 swap the particle mesh If KeyHit(2) ParticleMesh emitter,cube mesh_name$="1 cube" EndIf If KeyHit(3) ParticleMesh emitter,cone mesh_name$="2 cone" EndIf If KeyHit(4) ParticleMesh emitter,ball mesh_name$="3 sphere" EndIf ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 ; UpdateWorld also advances the particle simulation UpdateWorld RenderWorld Text 0,0,"Arrow keys: move camera 1/2/3: particle mesh Esc: exit" Text 0,20,"ParticleMesh source: "+mesh_name$ Flip Wend End