ParticleRotation emitter,minimum#,maximum#[,speed_minimum#][,speed_maximum#]
Parameters
|
emitter - CPU or GPU particle emitter entity minimum# - smallest starting angle in degrees maximum# - largest starting angle in degrees; a value below the minimum is raised to it speed_minimum# (optional) - slowest spin in degrees per second; 0 (default). Negative values spin the other way speed_maximum# (optional) - fastest spin in degrees per second; 0 (default). A value below speed_minimum is raised to it |
Description
|
Sets the random starting angle and spin speed of each particle. Without rotation every particle shows its texture the same way up, and a smoke plume made from one sprite looks like a stack of photocopies. Giving each particle a random start angle between 0 and 360 breaks that up instantly, and a slow random spin on top makes smoke, dust and debris churn as they drift. Each particle picks one starting angle and one spin speed when it is born and keeps them for life, so the spread between the minimum and maximum is what creates variety. A speed range that crosses zero, such as -90 to 90, makes roughly half the particles turn each way, which reads as tumbling rather than as a rotating machine. For billboards the angle spins the sprite around the direction you are looking, exactly like rotating a 2D image. For mesh particles it turns the mesh about its own up axis, which is a good way to stop scattered debris chunks all facing the same direction. Gotcha: velocity-stretched particles take their orientation from the direction they are moving, so rotation has no visible effect on a moving stretched particle - use it with billboard or mesh mode instead. Spin is measured in simulated seconds like the rest of the simulation. Requires Extended mode. See also: ParticleRenderMode, ParticleAnimation, ParticleSize, ParticleMesh, ParticlePreset. |
Example
; ParticleRotation Example ; ------------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-6 CameraClsColor camera,8,12,24 floor=CreatePlane() EntityColor floor,30,34,44 ; Big drifting embers - large squares make the spin easy to see emitter=CreateParticleEmitter(400) PositionEntity emitter,0,0.5,0 ParticleEmissionRate emitter,40 ParticleLifetime emitter,2.5,3.5 ParticleVelocity emitter,0,1.2,0,0.6,0.3,0.6 ParticleColor emitter,255,180,80,1,255,80,20,0 ParticleSize emitter,0.35,0.15,0.2 EntityBlend emitter,3 spin#=90 While Not KeyDown(1) ; [ / ] change the random angular speed range in degrees per second If KeyDown(26) And spin>0 Then spin=spin-2 If KeyDown(27) And spin<720 Then spin=spin+2 ; Random start angle 0-360, spin speed between -spin and +spin ParticleRotation emitter,0,360,-spin,spin ; 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 [ / ] : spin speed Esc: exit" Text 0,20,"ParticleRotation emitter,0,360,"+(-spin)+","+spin Flip Wend End
Index