Classes | Public Types

deParticleEmitter Class Reference

Particle Emitter. More...

#include <deParticleEmitter.h>

Inheritance diagram for deParticleEmitter:
deResource deObject

List of all members.

Classes

struct  sParticle

Public Types

enum  eParameters {
  epTimeToLive, epInterval, epCastAngleX, epCastAngleY,
  epSize, epRed, epGreen, epBlue,
  epTransparency, epEmissivity, epMass, epRotation,
  epLinearVelocity, epAngularVelocity, epBrownMotion, epDamping,
  epDrag, epGravityX, epGravityY, epGravityZ,
  epLocalGravity, epElasticity, epRoughness, EP_COUNT
}

Public Member Functions

Constructors and Destructors
 deParticleEmitter (deParticleEmitterManager *manager)
 Creates a new particle emitter.
virtual ~deParticleEmitter ()
 Cleans up the particle emitter.
Management
const decDVectorGetPosition () const
 Retrieves the position.
void SetPosition (const decDVector &position)
 Sets the position.
const decQuaternionGetOrientation () const
 Retrieves the orientation.
void SetOrientation (const decQuaternion &orientation)
 Sets the orientation.
bool GetEnableCasting () const
 Determines if casting particles is enabled.
void SetEnableCasting (bool enable)
 Sets if casting particles is enabled.
deComponentGetComponent () const
 Retrieves the component used for casting or NULL.
void SetComponent (deComponent *component)
 Sets the component used for casting or NULL.
deSkinGetSkin () const
 Retrieves the skin of the particle instances or NULL.
void SetSkin (deSkin *skin)
 Sets the mode of the particle instances or NULL.
deDynamicSkinGetDynamicSkin () const
 Retrieves the dynamic skin or null if not used.
void SetDynamicSkin (deDynamicSkin *dynamicSkin)
 Sets the dynamic skin or null if not used.
decLayerMaskGetLayerMask ()
 Retrieves the layer mask.
const decLayerMaskGetLayerMask () const
void NotifyLayerMaskChanged ()
 Notifies the peers that the layer mask changed.
int GetGroupNumber () const
 Retrieves the group number or 0 if not set.
void SetGroupNumber (int groupNumber)
 Sets the group number or 0 if not set.
bool CanHit (const decLayerMask &layerMask, int groupNumber) const
 Determines if a particle instance can be hit by another object represented by a layer mask and a group number.
float GetPhysicsSize () const
 Retrieves the physics size of the particle.
void SetPhysicsSize (float size)
 Sets the physics size of the particle.
float GetMaxLinearVelocity () const
 Retrieves the maximum linear velocity for mapping as requested by the graphic module.
void SetMaxLinearVelocity (float maxLinearVelocity)
 Sets the maximum linear velocity for mapping as requested by the graphic module.
float GetMaxAngularVelocity () const
 Retrieves the maximum angular velocity for mapping as requested by the graphic module.
void SetMaxAngularVelocity (float maxAngularVelocity)
 Sets the maximum angular velocity for mapping as requested by the graphic module.
bool GetSquareVelocities () const
 Determines if velocities have to be squared as requested by the graphic module.
void SetSquareVelocities (bool squareVelocities)
 Sets if velocities have to be squared as requested by the graphic module.
bool GetGraphicModuleSimulates () const
 Determines if the graphic module takes care of simulation.
void SetGraphicModuleSimulates (bool graphicModuleSimulates)
 Sets if the graphic module takes care of simulation.
int GetControllerCount () const
 Retrieves the count of controllers.
void SetControllerCount (int count)
 Sets the number of controllers.
deParticleEmitterControllerGetControllerAt (int index)
 Retrieves the controller at the given index.
const deParticleEmitterControllerGetControllerAt (int index) const
void NotifyControllerChangedAt (int controller)
 Notifies that the controller at the given index changed.
deParticleEmitterParameterGetParameter (int parameter)
 Retrieves a parameter.
const deParticleEmitterParameterGetParameter (int parameter) const
void NotifyParameterChanged (int parameter)
 Notifies all that a parameter changed.
void CastParticles (int count)
 Cast particles burst like.
void KillAllParticles ()
 Kill all particles.
sParticleGetParticleArray () const
 Retrieves the particle array or NULL if not set.
int GetParticleCount () const
 Retrieves the number of particles.
void SetParticleArray (sParticle *particleArray, int count)
 Sets the particle array and number of particles.
void NotifyParticlesChanged ()
 Notifies the Graphic Module that the particles array changed.
void NotifyLastParticleDied ()
 Notifies the Scripting Module that the last particle died.
System Peers
deBaseGraphicParticleEmitterGetGraphicPeer () const
 Retrieves the graphic system peer object or NULL if not assigned.
void SetGraphicPeer (deBaseGraphicParticleEmitter *peer)
 Sets the graphic system peer object or NULL if not assigned.
deBasePhysicsParticleEmitterGetPhysicsPeer () const
 Retrieves the physics system peer object or NULL if not assigned.
void SetPhysicsPeer (deBasePhysicsParticleEmitter *peer)
 Sets the physics system peer object or NULL if not assigned.
deBaseScriptingParticleEmitterGetScriptingPeer () const
 Retrieves the scripting system peer object or NULL if not assigned.
void SetScriptingPeer (deBaseScriptingParticleEmitter *peer)
 Sets the scripting system peer object or NULL if not assigned.
Linked List
deWorldGetParentWorld () const
 Retrieves the parent world or NULL.
void SetParentWorld (deWorld *world)
 Sets the parent world or NULL.
deParticleEmitterGetLLWorldPrev () const
 Retrieves the previous particle emitter in the parent world linked list.
void SetLLWorldPrev (deParticleEmitter *emitter)
 Sets the next particle emitter in the parent world linked list.
deParticleEmitterGetLLWorldNext () const
 Retrieves the next particle emitter in the parent world linked list.
void SetLLWorldNext (deParticleEmitter *emitter)
 Sets the next particle emitter in the parent world linked list.

Detailed Description

Particle Emitter.

Emits particles in the form of billboards. The position and orientation of the particle emitter defines where particles are produced and in which direction they are cast. The cast parameters are picked randomly between the minimum and maximum value. The state of particles is stored individually by the physics module. The Physics module has to provide the graphics related particle states for the Graphics module in addition to any internal states required for the simulation. This shared information has to be provided using an array of sParticle elements. The position of the particles are relative to the emitter position. The Scripting Module will be notified by the Physics Module about collisions of particles with world.

Intermodule Communication
The Physics and Graphic module require communication dealing with particles to make them fast. This communication breaks up into different stages. First the Graphic Module stores in the particle emitter how the particle states have to be stored. This is done using the graphic module request parameters. Using these the Physics Module can provide the states in the favorable way. Once the Physics Module has done a simulation step it creates or updates a particle array. This array is then stored in the particle emitter. The array stays valid until the next time the Physics Module simulates the particles. In the mean time the Graphic Module can use the particle array stored in the emitter to render the particles.
Graphic Module Requests
The Graphic Module can place a couple of requests in the particle emitter for the Physics Module to respect. The data in the particles array are stored in compressed form using mostly bytes for individual parameters where possible. This not only reduces the amount of memory required and transfered it also allows Graphic Modules to place particle data in textures. Graphic Modules have in general two possible ways to handle a large amount of particles and this is either by storing the data inside an input-stream type GPU memory or inside textures. This system allows the Graphic Module to drive particle rendering either way without the Physics Module requiring to know. Due to the compressed nature though limits are required to define a proper mapping. The linear velocity is split into four values three defining the direction and the fourthed defining the magnitude of the velocity. The direction is stored stored with each component as bytes mapping -1 to char -127 and 1 to char 127. The magnitude maps 0 m/s to byte 0 and the maximum linear velocity to byte 255. The maximum velocity is set using SetMaxLinearVelocity and defaults to 1 m/s. The rotation maps 0° to byte 0 and 360° to byte 255. This gives a step of roughly 1.4° per byte which is not a big problem for particles as they are in general small objects. A problem would arise with large particles like smoke but for these objects exists resources on their own simulating them better than particles can do. The angular velocity maps -maxAngularVelocity to char -127 and maxAngularVelocity to char 127. The maximum angular velocity can be set using SetMaxAngularVelocity. For the velocities exists an additional option to store them squared instead of their true value. Using squared velocities a finer grained step size is used for velocities close to 0 while larger velocities have a coarser grained step size. To request squared velocities use SetSquareVelocities. The cast time parameters map the lower cast value to char -127 and the upper cast value to char 127. No additional limits are required since these cast value boundaries provide already a mapping. If the upper and lower cast value is the same or nearly the same any value can be used as all values map to the same cast parameter value. Typically char 0 is though used. In addition to these request parameters the Graphic Module can request to drive particle simulation on its own instead of handing this off to the Physics Module. This can be done using SetGraphicModuleSimulates. If set the Graphic Module is responsible to drive the entire simulation. The Physics Module is going to ignore this particle emitter altogether. This is useful for particle emitters not affected by physics like for example spell casting particle effects. For these simplified simulations can be used which often can be driven entirely on the GPU.
Author:
Plüss Roland
Version:
1.0
Date:
2010

Member Enumeration Documentation

Enumerator:
epTimeToLive 
epInterval 
epCastAngleX 
epCastAngleY 
epSize 
epRed 
epGreen 
epBlue 
epTransparency 
epEmissivity 
epMass 
epRotation 
epLinearVelocity 
epAngularVelocity 
epBrownMotion 
epDamping 
epDrag 
epGravityX 
epGravityY 
epGravityZ 
epLocalGravity 
epElasticity 
epRoughness 
EP_COUNT 

Constructor & Destructor Documentation

deParticleEmitter::deParticleEmitter ( deParticleEmitterManager manager )

Creates a new particle emitter.

virtual deParticleEmitter::~deParticleEmitter (  ) [virtual]

Cleans up the particle emitter.


Member Function Documentation

bool deParticleEmitter::CanHit ( const decLayerMask layerMask,
int  groupNumber 
) const

Determines if a particle instance can be hit by another object represented by a layer mask and a group number.

The layer mask and the group number of both entities are checked for a match. Group numbers match only if neither of them is 0.

void deParticleEmitter::CastParticles ( int  count )

Cast particles burst like.

deComponent* deParticleEmitter::GetComponent (  ) const [inline]

Retrieves the component used for casting or NULL.

const deParticleEmitterController& deParticleEmitter::GetControllerAt ( int  index ) const
deParticleEmitterController& deParticleEmitter::GetControllerAt ( int  index )

Retrieves the controller at the given index.

int deParticleEmitter::GetControllerCount (  ) const [inline]

Retrieves the count of controllers.

deDynamicSkin* deParticleEmitter::GetDynamicSkin (  ) const [inline]

Retrieves the dynamic skin or null if not used.

bool deParticleEmitter::GetEnableCasting (  ) const [inline]

Determines if casting particles is enabled.

bool deParticleEmitter::GetGraphicModuleSimulates (  ) const [inline]

Determines if the graphic module takes care of simulation.

deBaseGraphicParticleEmitter* deParticleEmitter::GetGraphicPeer (  ) const [inline]

Retrieves the graphic system peer object or NULL if not assigned.

int deParticleEmitter::GetGroupNumber (  ) const [inline]

Retrieves the group number or 0 if not set.

decLayerMask& deParticleEmitter::GetLayerMask (  ) [inline]

Retrieves the layer mask.

const decLayerMask& deParticleEmitter::GetLayerMask (  ) const [inline]
deParticleEmitter* deParticleEmitter::GetLLWorldNext (  ) const [inline]

Retrieves the next particle emitter in the parent world linked list.

deParticleEmitter* deParticleEmitter::GetLLWorldPrev (  ) const [inline]

Retrieves the previous particle emitter in the parent world linked list.

float deParticleEmitter::GetMaxAngularVelocity (  ) const [inline]

Retrieves the maximum angular velocity for mapping as requested by the graphic module.

float deParticleEmitter::GetMaxLinearVelocity (  ) const [inline]

Retrieves the maximum linear velocity for mapping as requested by the graphic module.

const decQuaternion& deParticleEmitter::GetOrientation (  ) const [inline]

Retrieves the orientation.

deParticleEmitterParameter& deParticleEmitter::GetParameter ( int  parameter )

Retrieves a parameter.

const deParticleEmitterParameter& deParticleEmitter::GetParameter ( int  parameter ) const
deWorld* deParticleEmitter::GetParentWorld (  ) const [inline]

Retrieves the parent world or NULL.

sParticle* deParticleEmitter::GetParticleArray (  ) const [inline]

Retrieves the particle array or NULL if not set.

int deParticleEmitter::GetParticleCount (  ) const [inline]

Retrieves the number of particles.

deBasePhysicsParticleEmitter* deParticleEmitter::GetPhysicsPeer (  ) const [inline]

Retrieves the physics system peer object or NULL if not assigned.

float deParticleEmitter::GetPhysicsSize (  ) const [inline]

Retrieves the physics size of the particle.

const decDVector& deParticleEmitter::GetPosition (  ) const [inline]

Retrieves the position.

deBaseScriptingParticleEmitter* deParticleEmitter::GetScriptingPeer (  ) const [inline]

Retrieves the scripting system peer object or NULL if not assigned.

deSkin* deParticleEmitter::GetSkin (  ) const [inline]

Retrieves the skin of the particle instances or NULL.

bool deParticleEmitter::GetSquareVelocities (  ) const [inline]

Determines if velocities have to be squared as requested by the graphic module.

void deParticleEmitter::KillAllParticles (  )

Kill all particles.

void deParticleEmitter::NotifyControllerChangedAt ( int  controller )

Notifies that the controller at the given index changed.

void deParticleEmitter::NotifyLastParticleDied (  )

Notifies the Scripting Module that the last particle died.

void deParticleEmitter::NotifyLayerMaskChanged (  )

Notifies the peers that the layer mask changed.

void deParticleEmitter::NotifyParameterChanged ( int  parameter )

Notifies all that a parameter changed.

void deParticleEmitter::NotifyParticlesChanged (  )

Notifies the Graphic Module that the particles array changed.

void deParticleEmitter::SetComponent ( deComponent component )

Sets the component used for casting or NULL.

void deParticleEmitter::SetControllerCount ( int  count )

Sets the number of controllers.

void deParticleEmitter::SetDynamicSkin ( deDynamicSkin dynamicSkin )

Sets the dynamic skin or null if not used.

void deParticleEmitter::SetEnableCasting ( bool  enable )

Sets if casting particles is enabled.

void deParticleEmitter::SetGraphicModuleSimulates ( bool  graphicModuleSimulates )

Sets if the graphic module takes care of simulation.

void deParticleEmitter::SetGraphicPeer ( deBaseGraphicParticleEmitter peer )

Sets the graphic system peer object or NULL if not assigned.

void deParticleEmitter::SetGroupNumber ( int  groupNumber )

Sets the group number or 0 if not set.

void deParticleEmitter::SetLLWorldNext ( deParticleEmitter emitter )

Sets the next particle emitter in the parent world linked list.

void deParticleEmitter::SetLLWorldPrev ( deParticleEmitter emitter )

Sets the next particle emitter in the parent world linked list.

void deParticleEmitter::SetMaxAngularVelocity ( float  maxAngularVelocity )

Sets the maximum angular velocity for mapping as requested by the graphic module.

void deParticleEmitter::SetMaxLinearVelocity ( float  maxLinearVelocity )

Sets the maximum linear velocity for mapping as requested by the graphic module.

void deParticleEmitter::SetOrientation ( const decQuaternion orientation )

Sets the orientation.

void deParticleEmitter::SetParentWorld ( deWorld world )

Sets the parent world or NULL.

void deParticleEmitter::SetParticleArray ( sParticle particleArray,
int  count 
)

Sets the particle array and number of particles.

Used by the Physics Module to set the particle array for the Graphic Module to render later on.

void deParticleEmitter::SetPhysicsPeer ( deBasePhysicsParticleEmitter peer )

Sets the physics system peer object or NULL if not assigned.

void deParticleEmitter::SetPhysicsSize ( float  size )

Sets the physics size of the particle.

void deParticleEmitter::SetPosition ( const decDVector position )

Sets the position.

void deParticleEmitter::SetScriptingPeer ( deBaseScriptingParticleEmitter peer )

Sets the scripting system peer object or NULL if not assigned.

void deParticleEmitter::SetSkin ( deSkin skin )

Sets the mode of the particle instances or NULL.

void deParticleEmitter::SetSquareVelocities ( bool  squareVelocities )

Sets if velocities have to be squared as requested by the graphic module.


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