Blitz3D+ Command Reference

ParticleEmitterShape emitter,shape[,x#][,y#][,z#]

Parameters

emitter - CPU or GPU particle emitter entity

shape - volume new particles spawn in
0: point - all particles start at the emitter origin
1: box - x, y and z are the full width, height and depth
2: sphere - x is the radius; y and z are unused
3: cone - x is the radius at the top, y is the height; z is unused

x# (optional) - first dimension; 1 (default)

y# (optional) - second dimension; 1 (default)

z# (optional) - third dimension; 1 (default)

Description

Chooses the volume that new particles spawn inside.

The shape decides where an effect starts, which usually matters more than it sounds. A point emitter is right for a spark shower or a magic bolt. A box is right for anything that should fill an area - rain over the play field, dust in a room, bubbles across the top of a pool. A sphere gives you a soft blob for an explosion core or an aura. A cone aims the spawn area itself, which suits a shower head, a flamethrower muzzle or a smoke funnel.

Dimensions are in world units and are measured on the emitter's own axes, so rotating the emitter rotates the spawn volume with it. The box is centred on the emitter, the sphere fills its radius evenly, and the cone starts as a point at the emitter and widens to radius x at height y along the emitter's up axis.

Shape controls only where particles appear, never where they go. Aim them with ParticleVelocity and bend their paths with ParticleGravity, ParticleDrag or ParticleAttractor. A wide box with a straight downward velocity gives you rain; the same box with an outward velocity variation gives you a dust cloud.

Gotcha: dimensions the shape does not use are ignored, and negative values are treated as 0 - a sphere with radius 0 behaves exactly like a point emitter. Shape numbers outside 0-3 are clamped into range.

Requires Extended mode.

See also: ParticleVelocity, ParticleGravity, ParticleSpace, ParticlePreset, CreateParticleEmitter.

Example

; ParticleEmitterShape 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

; Shape names for the overlay
Dim shape_name$(3)
shape_name$(0)="0 point"
shape_name$(1)="1 box 3x0.5x3"
shape_name$(2)="2 sphere radius 1.5"
shape_name$(3)="3 cone 1.5x1.5x1.5"

; Slow glowing motes so the emission volume is easy to see
emitter=CreateParticleEmitter(1000)
PositionEntity emitter,0,1.5,0
ParticleEmissionRate emitter,250
ParticleLifetime emitter,1,1.5
ParticleVelocity emitter,0,0.3,0,0.1,0.1,0.1
ParticleColor emitter,150,220,255,1,80,120,255,0
ParticleSize emitter,0.06,0.03,0.2
EntityBlend emitter,3

shape=2
ParticleEmitterShape emitter,2,1.5,1.5,1.5

While Not KeyDown(1)

    ; Keys 1-4 select point, box, sphere or cone emission
    If KeyHit(2)
        shape=0
        ParticleEmitterShape emitter,0
    EndIf
    If KeyHit(3)
        shape=1
        ParticleEmitterShape emitter,1,3,0.5,3
    EndIf
    If KeyHit(4)
        shape=2
        ParticleEmitterShape emitter,2,1.5,1.5,1.5
    EndIf
    If KeyHit(5)
        shape=3
        ParticleEmitterShape emitter,3,1.5,1.5,1.5
    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/4: emitter shape   Esc: exit"
    Text 0,20,"ParticleEmitterShape: "+shape_name$(shape)

    Flip

Wend

End

Index