ParticleEmitter Class
Namespace: Stride.ParticlesAssembly: 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
              | Name | Description | |
|---|---|---|
| Constructors | ||
| ParticleEmitter() | Default constructor. Initializes the pool and all collections contained in the ParticleEmitter  | 
                          |
| Fields | ||
| Initializers | List of ParticleInitializer within thie ParticleEmitter. Adjust Stride.Particles.ParticleEmitter.requiredFields automatically  | 
                          |
| Spawners | List of ParticleSpawner to spawn particles in this ParticleEmitter  | 
                          |
| Updaters | List of ParticleUpdater within thie ParticleEmitter. Adjust Stride.Particles.ParticleEmitter.requiredFields automatically  | 
                          |
| Properties | ||
| CanEmitParticles | Indicates if the emitter is allowed to emit new particles or not.  | 
                          |
| DelayParticleDeath | If positive, forces particles to stay one frame more when they are about ot expire  | 
                          |
| 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  | 
                          |
| EmitterName | The emitter name is used to uniquely identify this emitter within the same particle system  | 
                          |
| Enabled | Gets or sets a value indicating whether this ParticleEmitter is enabled.  | 
                          |
| LivingParticles | Gets the current living particles from this emitter's pool  | 
                          |
| Material | The ParticleMaterial may update the vertex buffer, and it also applies the Effect required for rendering  | 
                          |
| MaxParticles | Maximum number of particles this ParticleEmitter can have at any given time  | 
                          |
| MaxParticlesOverride | Maximum particles (if positive) overrides the maximum particle count limitation  | 
                          |
| ParticleLifetime | ||
| RandomSeedMethod | Random numbers in the ParticleSystem are generated based on a seed, which in turn can be generated using several methods.  | 
                          |
| ShapeBuilder | The ShapeBuilder expands all living particles to vertex buffers for rendering  | 
                          |
| SimulationSpace | Simulation space defines if the particles should be born in world space, or local to the emitter  | 
                          |
| SortingPolicy | How and if particles are sorted, and how they are access during rendering  | 
                          |
| Methods | ||
| BuildVertexBuffer(IntPtr, ref Matrix, ref Matrix) | Build the vertex buffer from particle data  | 
                          |
| DelayedInitialization(ParticleSystem) | Some parameters should be initialized when the emitter first runs, rather than in the constructor  | 
                          |
| Dispose() | ||
| EmitParticles(Int32) | Requests the emitter to spawn several new particles. The particles are buffered and will be spawned during the Update(Single, ParticleSystem) step  | 
                          |
| InvalidateRelations() | Invalidates relation of this emitter to any other emitters that might be referenced  | 
                          |
| PrepareForDraw(out Boolean, out Int32, out Int32) | PrepareForDraw(out Boolean, out Int32, out Int32) prepares and updates the Material, ShapeBuilder and VertexBuilder if necessary  | 
                          |
| PreUpdate() | Updates all data changes before the emitter is updated this frame. This method is not thread-safe!  | 
                          |
| ResetSimulation() | Resets the simulation, deleting all particles and starting from Time = 0  | 
                          |
| Update(Single, ParticleSystem) | Updates the emitter and all its particles, and applies all updaters and spawners.  | 
                          |
| UpdatePaused(ParticleSystem) | Call this update when the ParticleSystem is paused to only update the renreding information  | 
                          |
Constructors
ParticleEmitter()
Default constructor. Initializes the pool and all collections contained in the ParticleEmitter
public ParticleEmitter()
              Fields
Initializers
List of ParticleInitializer within thie ParticleEmitter. Adjust Stride.Particles.ParticleEmitter.requiredFields automatically
[DataMember(200)]
[Display("Initializers", null)]
public readonly FastTrackingCollection<ParticleInitializer> Initializers
              Field Value
| Type | Description | 
|---|---|
| FastTrackingCollection<ParticleInitializer> | 
Spawners
List of ParticleSpawner to spawn particles in this ParticleEmitter
[DataMember(55)]
[Display("Spawners", null)]
public readonly FastTrackingCollection<ParticleSpawner> Spawners
              Field Value
| Type | Description | 
|---|---|
| FastTrackingCollection<ParticleSpawner> | 
Updaters
List of ParticleUpdater within thie ParticleEmitter. Adjust Stride.Particles.ParticleEmitter.requiredFields automatically
[DataMember(300)]
[Display("Updaters", null)]
public readonly FastTrackingCollection<ParticleUpdater> Updaters
              Field Value
| Type | Description | 
|---|---|
| FastTrackingCollection<ParticleUpdater> | 
Properties
CanEmitParticles
Indicates if the emitter is allowed to emit new particles or not.
public bool CanEmitParticles { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
DelayParticleDeath
If positive, forces particles to stay one frame more when they are about ot expire
public int DelayParticleDeath { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
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
| Type | Description | 
|---|---|
| System.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
| Type | Description | 
|---|---|
| System.String | 
Enabled
Gets or sets a value indicating whether this ParticleEmitter is enabled.
[DataMember(-10)]
public bool Enabled { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
                  
LivingParticles
Gets the current living particles from this emitter's pool
public int LivingParticles { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
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
| Type | Description | 
|---|---|
| ParticleMaterial | 
MaxParticles
Maximum number of particles this ParticleEmitter can have at any given time
public int MaxParticles { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
MaxParticlesOverride
Maximum particles (if positive) overrides the maximum particle count limitation
[DataMember(5)]
[Display("Max particles", null)]
public int MaxParticlesOverride { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
ParticleLifetime
[DataMember(7)]
[Display("Lifespan", null)]
public Vector2 ParticleLifetime { get; set; }
              Property Value
| Type | Description | 
|---|---|
| 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
| Type | Description | 
|---|---|
| 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
| Type | Description | 
|---|---|
| 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
| Type | Description | 
|---|---|
| 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
| Type | Description | 
|---|---|
| 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
| Type | Name | Description | 
|---|---|---|
| System.IntPtr | sharedBufferPtr | The shared vertex buffer position where the particle data should be output  | 
                  
| Matrix | invViewMatrix | The current camera's inverse view matrix  | 
                  
| Matrix | viewProj | 
DelayedInitialization(ParticleSystem)
Some parameters should be initialized when the emitter first runs, rather than in the constructor
protected void DelayedInitialization(ParticleSystem parentSystem)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ParticleSystem | parentSystem | 
Dispose()
public void Dispose()
              EmitParticles(Int32)
Requests the emitter to spawn several new particles. The particles are buffered and will be spawned during the Update(Single, ParticleSystem) step
public void EmitParticles(int count)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | count | 
InvalidateRelations()
Invalidates relation of this emitter to any other emitters that might be referenced
public void InvalidateRelations()
              PrepareForDraw(out Boolean, out Int32, out Int32)
PrepareForDraw(out Boolean, out Int32, out Int32) prepares and updates the Material, ShapeBuilder and VertexBuilder if necessary
public void PrepareForDraw(out bool vertexBufferHasChanged, out int vertexSize, out int vertexCount)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | vertexBufferHasChanged | |
| System.Int32 | vertexSize | |
| System.Int32 | vertexCount | 
PreUpdate()
Updates all data changes before the emitter is updated this frame. This method is not thread-safe!
public void PreUpdate()
              ResetSimulation()
Resets the simulation, deleting all particles and starting from Time = 0
public void ResetSimulation()
              Update(Single, ParticleSystem)
Updates the emitter and all its particles, and applies all updaters and spawners.
public void Update(float dt, ParticleSystem parentSystem)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Single | dt | Delta time, elapsed time since the last call, in seconds  | 
                  
| ParticleSystem | parentSystem | 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
| Type | Name | Description | 
|---|---|---|
| ParticleSystem | parentSystem | The parent ParticleSystem containing this emitter  |