Obi  6.4
Unified particle physics for Unity
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Obi.ObiEmitter Class Reference
Inheritance diagram for Obi.ObiEmitter:
Obi.ObiActor Obi.IObiParticleCollection

Public Types

enum  EmissionMethod { EmissionMethod.STREAM, EmissionMethod.BURST }
 

Public Member Functions

delegate void EmitterParticleCallback (ObiEmitter emitter, int particleIndex)
 
override void LoadBlueprint (ObiSolver solver)
 Loads this actor's blueprint into a given solver. Automatically called by ObiSolver. More...
 
void AddShape (ObiEmitterShape shape)
 Adds a shape trough which to emit particles. This is called automatically by ObiEmitterShape. More...
 
void RemoveShape (ObiEmitterShape shape)
 Removes a shape trough which to emit particles. This is called automatically by ObiEmitterShape. More...
 
void UpdateEmitterDistribution ()
 Updates the spawn point distribution of all shapes used by this emitter. More...
 
void UpdateParticleMaterial ()
 
override void SetSelfCollisions (bool selfCollisions)
 Updates particle phases in the solver at runtime, including or removing the self-collision flag. More...
 
bool EmitParticle (float offset, float deltaTime)
 Asks the emitter to emit a new particle. Returns whether the emission was succesful. More...
 
bool KillParticle (int index)
 Asks the emiter to kill a particle. Returns whether it was succesful. More...
 
void KillAll ()
 Kills all particles in the emitter, and returns them to the emission pool. More...
 
override void BeginStep (float stepTime)
 
- Public Member Functions inherited from Obi.ObiActor
delegate void ActorCallback (ObiActor actor)
 
delegate void ActorStepCallback (ObiActor actor, float stepTime)
 
delegate void ActorBlueprintCallback (ObiActor actor, ObiActorBlueprint blueprint)
 
void AddToSolver ()
 Adds this actor to its solver, if any. Automatically called by ObiSolver. More...
 
void RemoveFromSolver ()
 Remove this actor from its solver, if any. Automatically called by ObiSolver. More...
 
virtual bool CopyParticle (int actorSourceIndex, int actorDestIndex)
 Copies all data (position, velocity, phase, etc) from one particle to another one. More...
 
void TeleportParticle (int actorIndex, Vector3 position)
 Teleports one actor particle to a certain position in solver space. More...
 
virtual void Teleport (Vector3 position, Quaternion rotation)
 Teleports the entire actor to a new location / orientation. More...
 
bool ActivateParticle (int actorIndex)
 Activates one particle. More...
 
bool DeactivateParticle (int actorIndex)
 Deactivates one particle. More...
 
bool IsParticleActive (int actorIndex)
 Returns whether a given particle is active. More...
 
virtual void SetOneSided (bool oneSided)
 Updates particle phases in the solver at runtime, including or removing the one-sided flag. More...
 
void SetSimplicesDirty ()
 Marks simplices dirty. More...
 
void SetConstraintsDirty (Oni.ConstraintType constraintType)
 Marks a given constraint type as dirty. More...
 
IObiConstraints GetConstraintsByType (Oni.ConstraintType type)
 Returns the data representation of constraints of a given type being simulated by this solver. More...
 
virtual void UpdateParticleProperties ()
 Call when some particle properties have been modified and need updating. More...
 
int GetParticleRuntimeIndex (int actorIndex)
 Returns the index of this particle in the solver arrays. More...
 
Vector3 GetParticlePosition (int solverIndex)
 Given a solver particle index, returns the position of that particle in world space. More...
 
Quaternion GetParticleOrientation (int solverIndex)
 Given a solver particle index, returns the orientation of that particle in world space. More...
 
void GetParticleAnisotropy (int solverIndex, ref Vector4 b1, ref Vector4 b2, ref Vector4 b3)
 Given a solver particle index, returns the anisotropic frame of that particle in world space. More...
 
float GetParticleMaxRadius (int solverIndex)
 Given a solver particle index, returns the maximum world space radius of that particle, in any axis. More...
 
Color GetParticleColor (int solverIndex)
 Given a solver particle index, returns the color of that particle. More...
 
void SetFilterCategory (int newCategory)
 Sets a given category value for all particles in the actor. More...
 
void SetFilterMask (int newMask)
 Sets a given mask value for all particles in the actor. More...
 
void SetMass (float mass)
 Sets the inverse mass of each particle so that the total actor mass matches the one passed by parameter. More...
 
float GetMass (out Vector3 com)
 Returns the actor's mass (sum of all particle masses), and the position of its center of mass. More...
 
void AddForce (Vector3 force, ForceMode forceMode)
 Adds an external force to all particles in the actor. More...
 
void AddTorque (Vector3 force, ForceMode forceMode)
 Adds a torque to the actor. More...
 
void ResetParticles ()
 Resets the position and velocity of all particles, to the values stored in the blueprint. More...
 
void SaveStateToBlueprint (ObiActorBlueprint bp)
 Resets the position and velocity of all particles, to the values stored in the blueprint. More...
 
void ClearState ()
 
virtual void UnloadBlueprint (ObiSolver solver)
 Unloads this actor's blueprint from a given solver. Automatically called by ObiSolver. More...
 
virtual void PrepareFrame ()
 
virtual void PrepareStep (float stepTime)
 
virtual void Substep (float substepTime)
 
virtual void EndStep (float substepTime)
 
virtual void Interpolate ()
 
virtual void OnSolverVisibilityChanged (bool visible)
 

Public Attributes

ObiEmitterBlueprintBase emitterBlueprint
 
EmissionMethod emissionMethod = EmissionMethod.STREAM
 Emission method used by this emitter. More...
 
float minPoolSize = 0.5f
 Minimum amount of inactive particles available before the emitter is allowed to resume emission. More...
 
float speed = 0.25f
 Speed (in meters/second) at which fluid is emitter. More...
 
float lifespan = 4
 Particle lifespan in seconds. More...
 
float randomVelocity = 0
 Amount of random velocity added to particles when emitted. More...
 
bool useShapeColor = true
 Use the emitter shape color to tint particles upon emission. More...
 
float[] life
 Per particle remaining life (in seconds). More...
 
- Public Attributes inherited from Obi.ObiActor
int[] solverIndices
 Index of each one of the actor's particles in the solver. More...
 
List< int >[] solverBatchOffsets
 For each of the actor's constraint types, offset of every batch in the solver. More...
 

Protected Member Functions

override void OnValidate ()
 
override void SwapWithFirstInactiveParticle (int actorIndex)
 
- Protected Member Functions inherited from Obi.ObiActor
virtual void Awake ()
 
virtual void OnDestroy ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
void SetSolver (ObiSolver newSolver)
 Forcibly changed the solver in charge of this actor More...
 
virtual void OnBlueprintRegenerate (ObiActorBlueprint blueprint)
 
void UpdateCollisionMaterials ()
 
void StoreState ()
 

Properties

override ObiActorBlueprint sourceBlueprint [get]
 The base actor blueprint used by this actor. More...
 
int Filter [get, set]
 Collision filter value used by fluid particles. More...
 
bool isEmitting [get]
 Whether the emitter is currently emitting particles. More...
 
override bool surfaceCollisions [get, set]
 Whether to use simplices (triangles, edges) for contact generation. More...
 
override bool usesCustomExternalForces [get]
 Whether this actor applies external forces in a custom way. More...
 
override bool usesAnisotropicParticles [get]
 Whether this actor makes use of particle anisotropy More...
 
- Properties inherited from Obi.ObiActor
ObiSolver solver [get]
 The solver in charge of simulating this actor. More...
 
bool isLoaded [get]
 True if the actor blueprint has been loaded into a solver. If true, it guarantees actor.solver, actor.solverIndices and actor.solverBatchOffsets won't be null. More...
 
ObiCollisionMaterial collisionMaterial [get, set]
 The collision material being used by this actor. More...
 
virtual bool surfaceCollisions [get, set]
 Whether to use simplices (triangles, edges) for contact generation. More...
 
int particleCount [get]
 Amount of particles allocated by this actor. More...
 
int activeParticleCount [get]
 Amount of particles in use by this actor. More...
 
bool usesOrientedParticles [get]
 Whether this actors makes use of particle orientations or not. More...
 
virtual bool usesAnisotropicParticles [get]
 If true, it means particles may not be completely spherical, but ellipsoidal. More...
 
virtual bool usesCustomExternalForces [get]
 If true, it means external forces aren't applied to the particles directly. More...
 
Matrix4x4 actorLocalToSolverMatrix [get]
 Matrix that transforms from the actor's local space to the solver's local space. More...
 
Matrix4x4 actorSolverToLocalMatrix [get]
 Matrix that transforms from the solver's local space to the actor's local space. More...
 
abstract ObiActorBlueprint sourceBlueprint [get]
 Reference to the blueprint asset used by this actor. More...
 
ObiActorBlueprint sharedBlueprint [get]
 Reference to the blueprint in use by this actor. More...
 
ObiActorBlueprint blueprint [get]
 Returns a unique instance of this actor's sourceBlueprint. More...
 
- Properties inherited from Obi.IObiParticleCollection
int particleCount [get]
 
int activeParticleCount [get]
 
bool usesOrientedParticles [get]
 

Events

EmitterParticleCallback OnEmitParticle
 
EmitterParticleCallback OnKillParticle
 
- Events inherited from Obi.ObiActor
ActorBlueprintCallback OnBlueprintLoaded
 Called when the actor blueprint has been loaded into the solver. More...
 
ActorBlueprintCallback OnBlueprintUnloaded
 Called when the actor blueprint has been unloaded from the solver. More...
 
ActorCallback OnPrepareFrame
 Called at the start of the solver's FixedUpdate (for Fixed and LateFixed updaters) or the solver's Update (for Late updaters) More...
 
ActorStepCallback OnPrepareStep
 Called at the beginning of a time step, before dirty constraints and active particles have been updated. More...
 
ActorStepCallback OnBeginStep
 Called at the beginning of a time step, after dirty constraints and active particles have been updated. More...
 
ActorStepCallback OnSubstep
 Called at the beginning of each substep. More...
 
ActorStepCallback OnEndStep
 Called at the end of a timestep, after external forces have been reset and collision callbacks called. More...
 
ActorCallback OnInterpolate
 Called at the end of each frame. More...
 

Additional Inherited Members

- Protected Attributes inherited from Obi.ObiActor
int m_ActiveParticleCount = 0
 
ObiSolver m_Solver
 
bool m_Loaded = false
 
ObiCollisionMaterial m_CollisionMaterial
 
bool m_SurfaceCollisions = false
 

Member Enumeration Documentation

Enumerator
STREAM 

Continously emits particles until there are no particles left to emit.

BURST 

Emits a single burst of particles from the emitter, and does not emit any more until all alive particles have died.

Member Function Documentation

void Obi.ObiEmitter.AddShape ( ObiEmitterShape  shape)

Adds a shape trough which to emit particles. This is called automatically by ObiEmitterShape.

bool Obi.ObiEmitter.EmitParticle ( float  offset,
float  deltaTime 
)

Asks the emitter to emit a new particle. Returns whether the emission was succesful.

Parameters
offsetDistance from the emitter surface at which the particle should be emitted.
deltaTimeDuration of the last step in seconds.
Returns
If at least one particle was in the emission pool and it could be emitted, will return true. False otherwise.
void Obi.ObiEmitter.KillAll ( )

Kills all particles in the emitter, and returns them to the emission pool.

bool Obi.ObiEmitter.KillParticle ( int  index)

Asks the emiter to kill a particle. Returns whether it was succesful.

Returns
True if the particle could be killed. False if it was already inactive.
override void Obi.ObiEmitter.LoadBlueprint ( ObiSolver  solver)
virtual

Loads this actor's blueprint into a given solver. Automatically called by ObiSolver.

Reimplemented from Obi.ObiActor.

void Obi.ObiEmitter.RemoveShape ( ObiEmitterShape  shape)

Removes a shape trough which to emit particles. This is called automatically by ObiEmitterShape.

override void Obi.ObiEmitter.SetSelfCollisions ( bool  selfCollisions)
virtual

Updates particle phases in the solver at runtime, including or removing the self-collision flag.

Reimplemented from Obi.ObiActor.

void Obi.ObiEmitter.UpdateEmitterDistribution ( )

Updates the spawn point distribution of all shapes used by this emitter.

Member Data Documentation

EmissionMethod Obi.ObiEmitter.emissionMethod = EmissionMethod.STREAM

Emission method used by this emitter.

Can be either STREAM or BURST.

float [] Obi.ObiEmitter.life

Per particle remaining life (in seconds).

float Obi.ObiEmitter.lifespan = 4

Particle lifespan in seconds.

Particles older than this value will become inactive and go back to the solver's emission pool, making them available for reuse.

float Obi.ObiEmitter.minPoolSize = 0.5f

Minimum amount of inactive particles available before the emitter is allowed to resume emission.

float Obi.ObiEmitter.randomVelocity = 0

Amount of random velocity added to particles when emitted.

float Obi.ObiEmitter.speed = 0.25f

Speed (in meters/second) at which fluid is emitter.

Note this affects both the speed and the amount of particles emitted per second, to ensure flow is as smooth as possible. Set it to zero to deactivate emission.

bool Obi.ObiEmitter.useShapeColor = true

Use the emitter shape color to tint particles upon emission.

Property Documentation

int Obi.ObiEmitter.Filter
getset

Collision filter value used by fluid particles.

bool Obi.ObiEmitter.isEmitting
get

Whether the emitter is currently emitting particles.

override ObiActorBlueprint Obi.ObiEmitter.sourceBlueprint
get

The base actor blueprint used by this actor.

This is the same as emitterBlueprint.

override bool Obi.ObiEmitter.surfaceCollisions
getset

Whether to use simplices (triangles, edges) for contact generation.

override bool Obi.ObiEmitter.usesAnisotropicParticles
get

Whether this actor makes use of particle anisotropy

In case of fluid, this is true as particles adapt their shape to fit the fluid's surface.

override bool Obi.ObiEmitter.usesCustomExternalForces
get

Whether this actor applies external forces in a custom way.

In case of fluid, this is true as forces are interpreted as wind and affected by athmospheric drag.


The documentation for this class was generated from the following file: