Table of Contents

Class ParticleEmitter

Namespace
Stride.Particles
Assembly
Stride.Particles.dll

The ParticleEmitter is the base manager for any given pool of particles, holding all particles and initializers, updaters, spawners, materials and shape builders associated with the particles.

[DataContract("ParticleEmitter")]
public class ParticleEmitter : IDisposable
Inheritance
ParticleEmitter
Implements
Extension Methods

Constructors

ParticleEmitter()

Default constructor. Initializes the pool and all collections contained in the ParticleEmitter

public ParticleEmitter()

Fields

Initializers

List of ParticleInitializer within this ParticleEmitter. Adjusts the required fields automatically.

[DataMember(200)]
[Display("Initializers", null)]
public readonly FastTrackingCollection<ParticleInitializer> Initializers

Field Value

FastTrackingCollection<ParticleInitializer>

Spawners

List of ParticleSpawner to spawn particles in this ParticleEmitter

[DataMember(55)]
[Display("Spawners", null)]
public readonly FastTrackingCollection<ParticleSpawner> Spawners

Field Value

FastTrackingCollection<ParticleSpawner>

Updaters

List of ParticleUpdater within this ParticleEmitter. Adjusts the required fields automatically.

[DataMember(300)]
[Display("Updaters", null)]
public readonly FastTrackingCollection<ParticleUpdater> Updaters

Field Value

FastTrackingCollection<ParticleUpdater>

Properties

CanEmitParticles

Indicates if the emitter is allowed to emit new particles or not.

public bool CanEmitParticles { get; set; }

Property Value

bool

DelayParticleDeath

If positive, forces particles to stay one frame more when they are about ot expire

public int DelayParticleDeath { get; set; }

Property Value

int

DrawPriority

DrawPriority is used to sort emitters at the same position based on a user defined key and determine the order in which they will be drawn

[DataMember(33)]
[Display("Draw Priority", null)]
public byte DrawPriority { get; set; }

Property Value

byte

EmitterName

The emitter name is used to uniquely identify this emitter within the same particle system

[DataMember(1)]
[Display("Emitter Name", null)]
public string EmitterName { get; set; }

Property Value

string

Enabled

Gets or sets a value indicating whether this ParticleEmitter is enabled.

[DataMember(-10)]
public bool Enabled { get; set; }

Property Value

bool

true if enabled; otherwise, false.

LivingParticles

Gets the current living particles from this emitter's pool

public int LivingParticles { get; }

Property Value

int

Material

The ParticleMaterial may update the vertex buffer, and it also applies the Effect required for rendering

[DataMember(50)]
[Display("Material", null)]
public ParticleMaterial Material { get; set; }

Property Value

ParticleMaterial

MaxParticles

Maximum number of particles this ParticleEmitter can have at any given time

public int MaxParticles { get; }

Property Value

int

MaxParticlesOverride

Maximum particles (if positive) overrides the maximum particle count limitation

[DataMember(5)]
[Display("Max particles", null)]
public int MaxParticlesOverride { get; set; }

Property Value

int

ParticleLifetime

[DataMember(7)]
[Display("Lifespan", null)]
public Vector2 ParticleLifetime { get; set; }

Property Value

Vector2

RandomSeedMethod

Random numbers in the ParticleSystem are generated based on a seed, which in turn can be generated using several methods.

[DataMember(12)]
[Display("Randomize", null)]
public EmitterRandomSeedMethod RandomSeedMethod { get; set; }

Property Value

EmitterRandomSeedMethod

ShapeBuilder

The ShapeBuilder expands all living particles to vertex buffers for rendering

[DataMember(40)]
[Display("Shape", null)]
public ShapeBuilder ShapeBuilder { get; set; }

Property Value

ShapeBuilder

SimulationSpace

Simulation space defines if the particles should be born in world space, or local to the emitter

[DataMember(11)]
[Display("Space", null)]
public EmitterSimulationSpace SimulationSpace { get; set; }

Property Value

EmitterSimulationSpace

SortingPolicy

How and if particles are sorted, and how they are access during rendering

[DataMember(35)]
[Display("Sorting", null)]
public EmitterSortingPolicy SortingPolicy { get; set; }

Property Value

EmitterSortingPolicy

Methods

BuildVertexBuffer(IntPtr, ref Matrix, ref Matrix)

Build the vertex buffer from particle data

public void BuildVertexBuffer(IntPtr sharedBufferPtr, ref Matrix invViewMatrix, ref Matrix viewProj)

Parameters

sharedBufferPtr IntPtr

The shared vertex buffer position where the particle data should be output

invViewMatrix Matrix

The current camera's inverse view matrix

viewProj Matrix

DelayedInitialization(ParticleSystem)

Some parameters should be initialized when the emitter first runs, rather than in the constructor

protected void DelayedInitialization(ParticleSystem parentSystem)

Parameters

parentSystem ParticleSystem

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

EmitParticles(int)

Requests the emitter to spawn several new particles. The particles are buffered and will be spawned during the Update(float, ParticleSystem) step

public void EmitParticles(int count)

Parameters

count int

InvalidateRelations()

Invalidates relation of this emitter to any other emitters that might be referenced

public void InvalidateRelations()

PreUpdate()

Updates all data changes before the emitter is updated this frame. This method is not thread-safe!

public void PreUpdate()

PrepareForDraw(out bool, out int, out int)

PrepareForDraw(out bool, out int, out int) prepares and updates the Material, ShapeBuilder and VertexBuilder if necessary

public void PrepareForDraw(out bool vertexBufferHasChanged, out int vertexSize, out int vertexCount)

Parameters

vertexBufferHasChanged bool
vertexSize int
vertexCount int

ResetSimulation()

Resets the simulation, deleting all particles and starting from Time = 0

public void ResetSimulation()

Update(float, ParticleSystem)

Updates the emitter and all its particles, and applies all updaters and spawners.

public void Update(float dt, ParticleSystem parentSystem)

Parameters

dt float

Delta time, elapsed time since the last call, in seconds

parentSystem ParticleSystem

The parent ParticleSystem containing this emitter

UpdatePaused(ParticleSystem)

Call this update when the ParticleSystem is paused to only update the renreding information

public void UpdatePaused(ParticleSystem parentSystem)

Parameters

parentSystem ParticleSystem

The parent ParticleSystem containing this emitter