Gorilla.Particle.Explosion Unit Reference

Pre-configured explosion particle emitter with outward burst effect.

TGorillaExplosionParticleEmitter

Dynamic explosion effect with configurable burst direction and intensity.

Inheritance: TGorillaParticleEmitter → TGorillaExplosionParticleEmitter

Platforms: All Gorilla platforms

Unit: Gorilla.Particle.Explosion

Constructor/Destructor

Create

constructor Create(AOwner: TComponent); override;

Creates explosion emitter with preconfigured settings:

  • Outward burst in all directions
  • Random colors
  • Gravity influence
  • Limited emission duration
  • Growing particles

Destroy

destructor Destroy(); override;

Cleans up explosion emitter resources.

Properties

SpawnSize

property SpawnSize: Single;

Relative spawning area size (0.0 - 1.0) for explosion origin.

Default: 0.01 (1% - very concentrated)

Usage:

// Point explosion
LExplosion.SpawnSize := 0.01;

// Larger explosion origin
LExplosion.SpawnSize := 0.05;

Speed

property Speed: Single;

Explosion expansion speed multiplier.

Default: 1.0

Range: 0.1 - 10.0+

Usage:

// Fast explosion
LExplosion.Speed := 2.0;

// Slow explosion
LExplosion.Speed := 0.5;

Axis

property Axis: TPosition3D;

Direction vector controlling explosion axis.

Default: Point3D(1, -1, 1) - Upward with XZ spread

Usage:

// Spherical explosion (all directions)
LExplosion.Axis.Point := Point3D(1, 1, 1);

// Horizontal only
LExplosion.Axis.Point := Point3D(1, 0, 1);

// Upward cone
LExplosion.Axis.Point := Point3D(0.5, -2, 0.5);

Gravity (Read-Only)

property Gravity: TGorillaGravityParticleInfluencer read FGravity;

Integrated gravity influencer for downward arc.

Usage:

// Stronger gravity
LExplosion.Gravity.Ratio := 0.02;

// Disable gravity
LExplosion.Gravity.Enabled := False;

ParticleMaterial (Read-Only)

property ParticleMaterial: TGorillaParticleMaterialSource read GetParticleMaterial;

Attached particle material source for explosion textures.

Default Configuration

The explosion emitter is preconfigured with these settings:

Property Value Description
EmitParticles 100 Particles per burst
MaxParticles 2000 Maximum active particles
MaxAutoEmitTime 1750ms 1.75 second burst
AutoEmit True Auto-burst on Start()
Reuse True Particle caching enabled
ParticleSize 1-2 Small fragments
ParticleGrowth 0-1 Growing particles
ParticleLifeTime 0.25-2.5 seconds Lifetime range
Axis (1, -1, 1) Upward explosion
Speed 1.0 Normal speed
SpawnSize 0.01 Point origin
SpriteSheet 8×8 Animated sprites

Integrated Influencers

  • TGorillaGravityParticleInfluencer - Downward gravity for arc
  • TGorillaRandomColorParticleInfluencer - Random particle colors

Examples

Basic Explosion

var
  LExplosion: TGorillaExplosionParticleEmitter;
begin
  LExplosion := TGorillaExplosionParticleEmitter.Create(Self);
  LExplosion.Parent := GorillaViewport1;
  LExplosion.Camera := Camera1;
  LExplosion.Position.Point := Point3D(0, 0, 0);

  LExplosion.Start();
  // Auto-stops after 1.75 seconds
end;

Large Explosion

var
  LLargeExplosion: TGorillaExplosionParticleEmitter;
begin
  LLargeExplosion := TGorillaExplosionParticleEmitter.Create(Self);
  LLargeExplosion.Parent := GorillaViewport1;
  LLargeExplosion.Camera := Camera1;
  LLargeExplosion.Position.Point := Point3D(0, 0, 0);

  // More particles
  LLargeExplosion.EmitParticles := 300;
  LLargeExplosion.MaxParticles := 5000;

  // Larger particles
  LLargeExplosion.ParticleSize.Preset(2, 5, 1, False);

  // Faster expansion
  LLargeExplosion.Speed := 2.0;

  // Longer duration
  LLargeExplosion.MaxAutoEmitTime := 3000;

  LLargeExplosion.Start();
end;

Spherical Explosion

var
  LSphere: TGorillaExplosionParticleEmitter;
begin
  LSphere := TGorillaExplosionParticleEmitter.Create(Self);
  LSphere.Parent := GorillaViewport1;
  LSphere.Camera := Camera1;

  // All directions equally
  LSphere.Axis.Point := Point3D(1, 1, 1);

  // Disable gravity for perfect sphere
  LSphere.Gravity.Enabled := False;

  LSphere.Start();
end;

Ground Explosion

var
  LGroundExp: TGorillaExplosionParticleEmitter;
begin
  LGroundExp := TGorillaExplosionParticleEmitter.Create(Self);
  LGroundExp.Parent := GorillaViewport1;
  LGroundExp.Camera := Camera1;
  LGroundExp.Position.Y := 0;

  // Upward cone
  LGroundExp.Axis.Point := Point3D(1, -3, 1);

  // Strong upward velocity
  LGroundExp.ParticleVelocity.RangeY.Preset(0, 2000, 10000, False);

  LGroundExp.Start();
end;

Directional Blast

var
  LBlast: TGorillaExplosionParticleEmitter;
begin
  LBlast := TGorillaExplosionParticleEmitter.Create(Self);
  LBlast.Parent := GorillaViewport1;
  LBlast.Camera := Camera1;

  // Forward direction
  LBlast.Axis.Point := Point3D(0, 0, -5);

  // Concentrated cone
  LBlast.SpawnSize := 0.05;

  // Fast particles
  LBlast.Speed := 3.0;

  LBlast.Start();
end;

Firework

var
  LFirework: TGorillaExplosionParticleEmitter;
begin
  LFirework := TGorillaExplosionParticleEmitter.Create(Self);
  LFirework.Parent := GorillaViewport1;
  LFirework.Camera := Camera1;
  LFirework.Position.Point := Point3D(0, 20, 0);

  // Spherical burst
  LFirework.Axis.Point := Point3D(1, 1, 1);

  // Many colorful particles
  LFirework.EmitParticles := 200;

  // Additive blending for brightness
  LFirework.BlendFunc := TBlendEquationFunc.befAdd;
  LFirework.BlendSource := TBlendFactor.bfOne;
  LFirework.BlendDest := TBlendFactor.bfOne;

  // Longer trails
  LFirework.ParticleLifeTime.Preset(1000, 3000, 1000, False);

  LFirework.Start();
end;

Repeating Explosions

var
  LRepeat: TGorillaExplosionParticleEmitter;
  LTimer: TTimer;
begin
  LRepeat := TGorillaExplosionParticleEmitter.Create(Self);
  LRepeat.Parent := GorillaViewport1;
  LRepeat.Camera := Camera1;

  // Timer for repeated bursts
  LTimer := TTimer.Create(Self);
  LTimer.Interval := 2000;  // Every 2 seconds
  LTimer.OnTimer := procedure(Sender: TObject)
  begin
    LRepeat.Clear();  // Clear previous particles
    LRepeat.Stop();
    LRepeat.Start();  // New explosion
  end;
  LTimer.Enabled := True;

  LRepeat.Start();
end;

Colored Explosion

var
  LColored: TGorillaExplosionParticleEmitter;
  LColorInfl: TGorillaColoredParticleInfluencer;
begin
  LColored := TGorillaExplosionParticleEmitter.Create(Self);
  LColored.Parent := GorillaViewport1;
  LColored.Camera := Camera1;

  // Remove random color influencer
  LColored.Influencers.Clear();

  // Add specific color transition
  LColorInfl := TGorillaColoredParticleInfluencer.Create(LColored);
  LColorInfl.Emitter := LColored;
  LColorInfl.StartColor := TAlphaColorRec.Yellow;
  LColorInfl.EndColor := TAlphaColorRec.Red;

  LColored.Start();
end;

Tips

Performance

  • Adjust MaxParticles based on explosion scale
  • Use smaller ParticleLifeTime for quick bursts
  • Reduce EmitParticles on mobile devices

Visual Quality

  • Combine with flash/light effects
  • Add camera shake for impact
  • Use sound effects for immersion
  • Layer multiple explosions for complexity

Timing

  • MaxAutoEmitTime controls burst duration
  • Shorter time = sudden explosion
  • Longer time = sustained explosion

Direction Control

Axis Examples:

  • (1, 1, 1) - Spherical
  • (1, -2, 1) - Upward cone
  • (1, 0, 1) - Horizontal disk
  • (0, -1, 0) - Vertical column

Common Combinations

Explosion with Flash

var
  LExplosion: TGorillaExplosionParticleEmitter;
  LFlash: TGorillaSpotParticleEmitter;
begin
  LExplosion := TGorillaExplosionParticleEmitter.Create(Self);
  // Configure explosion...

  // Bright flash
  LFlash := TGorillaSpotParticleEmitter.Create(Self);
  LFlash.Position := LExplosion.Position;
  LFlash.ParticleSize.Preset(100, 200, 1, False);
  LFlash.ParticleLifeTime.Preset(50, 100, 1000, False);
  LFlash.BlendFunc := TBlendEquationFunc.befAdd;

  LExplosion.Start();
  LFlash.EmitParticle(LFlash.Position.Point);
end;

Explosion with Smoke

var
  LExplosion: TGorillaExplosionParticleEmitter;
  LSmoke: TGorillaSmokeParticleEmitter;
begin
  LExplosion := TGorillaExplosionParticleEmitter.Create(Self);
  LExplosion.Start();

  // Delayed smoke
  TThread.CreateAnonymousThread(procedure
  begin
    TThread.Sleep(500);
    TThread.Synchronize(nil, procedure
    begin
      LSmoke := TGorillaSmokeParticleEmitter.Create(Self);
      LSmoke.Parent := GorillaViewport1;
      LSmoke.Position := LExplosion.Position;
      LSmoke.MaxAutoEmitTime := 3000;
      LSmoke.Start();
    end);
  end).Start();
end;

See Also