Blitz3D+ Command Reference

ParticleSize emitter,start#,end#[,variation#]

Parameters

emitter - CPU or GPU particle emitter entity

start# - half-size at birth, in world units. Negative values are treated as 0

end# - half-size at death, in world units. Negative values are treated as 0

variation# (optional) - per-particle random scale, from 1-variation to 1+variation; 0 (default)

Description

Sets the size a particle grows or shrinks between over its life.

The two sizes are the half-extent of the billboard, so a size of 0.5 draws a quad one unit across. Particles interpolate smoothly from the start size to the end size as they age. Smoke usually grows (0.18 to 0.75) because a puff expands as it cools; fire usually shrinks (0.11 to 0.025) because a flame tapers as it rises.

The variation is what stops a plume looking like a row of identical stamps. Each particle picks its own multiplier between 1-variation and 1+variation and keeps it for life, so 0.3 gives a natural spread of roughly 30% either way. The multiplier is never negative, so large variations simply produce some very small particles.

In mesh render mode the same numbers scale the particle mesh instead of a quad, so a size of 1 draws the mesh at its authored size and 0.25 draws it quarter-scale.

Gotcha: the growth is spread over the particle's lifetime, so shortening ParticleLifetime makes it grow faster. Big soft particles are also the fastest way to burn fill rate - if an effect tanks the frame rate, try halving the size before reducing the count.

Requires Extended mode.

See also: ParticleColor, ParticleLifetime, ParticleRenderMode, ParticleMesh, ParticlePreset.

Example

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

; A smoke column - each puff starts small and grows as it rises
emitter=CreateParticleEmitter(600)
PositionEntity emitter,0,0.5,0
ParticleEmissionRate emitter,60
ParticleLifetime emitter,2.5,3.5
ParticleVelocity emitter,0,1.2,0,0.3,0.2,0.3
ParticleColor emitter,180,180,190,0.8,120,120,130,0
EntityBlend emitter,2

start_size#=0.08
end_size#=0.5

While Not KeyDown(1)

    ; [ / ] change the end size - below the start size puffs shrink instead
    If KeyDown(26) And end_size>0.02 Then end_size=end_size-0.01
    If KeyDown(27) And end_size<1.5 Then end_size=end_size+0.01

    ; Half-size interpolates from start to end over each lifetime
    ParticleSize emitter,start_size,end_size,0.25

    ; 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   [ / ] : end size   Esc: exit"
    Text 0,20,"ParticleSize emitter,"+start_size+","+end_size+",0.25"

    Flip

Wend

End

Index