Drag[en]gine Game Engine  1.0
deParticleEmitter Class Reference

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. More...

#include <deParticleEmitter.h>

Inheritance diagram for deParticleEmitter:
deResource deObject

Public Member Functions

Management
int GetControllerCount () const
 
void SetControllerCount (int count)
 
deParticleEmitterControllerGetControllerAt (int index)
 
const deParticleEmitterControllerGetControllerAt (int index) const
 
void NotifyControllerChangedAt (int controller)
 
float GetBurstLifetime () const
 
void SetBurstLifetime (float lifetime)
 
bool GetEmitBurst () const
 
void SetEmitBurst (bool emitBurst)
 
decCollisionFilterGetCollisionFilter ()
 Retrieves the collision filter. More...
 
const decCollisionFilterGetCollisionFilter () const
 
void NotifyCollisionFilterChanged ()
 Notifies the peers that the collision filter changed. More...
 
int GetTypeCount () const
 
void SetTypeCount (int count)
 
deParticleEmitterTypeGetTypeAt (int index)
 
const deParticleEmitterTypeGetTypeAt (int index) const
 
void NotifyTypeChangedAt (int type)
 
bool GetGraphicModuleSimulates () const
 
void SetGraphicModuleSimulates (bool graphicModuleSimulates)
 
System Peers
deBaseGraphicParticleEmitterGetGraphicPeer () const
 
void SetGraphicPeer (deBaseGraphicParticleEmitter *peer)
 
deBasePhysicsParticleEmitterGetPhysicsPeer () const
 
void SetPhysicsPeer (deBasePhysicsParticleEmitter *peer)
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
 
deEngineGetEngine () const
 Game engine object from resource manager. More...
 
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
 
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
 
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
void MarkLeaking ()
 Marks the resource leaking. More...
 
 deResource (deResourceManager *resourceManager)
 Create resource. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 

Constructors and Destructors

 deParticleEmitter (deParticleEmitterManager *manager)
 
virtual ~deParticleEmitter ()
 Clean up particle emitter. More...
 

Additional Inherited Members

- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

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

Constructor & Destructor Documentation

◆ deParticleEmitter()

deParticleEmitter::deParticleEmitter ( deParticleEmitterManager manager)

Creates a new particle emitter.

◆ ~deParticleEmitter()

virtual deParticleEmitter::~deParticleEmitter ( )
protectedvirtual

Clean up particle emitter.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ GetBurstLifetime()

float deParticleEmitter::GetBurstLifetime ( ) const
inline

Retrieves the burst lifetime of the emitter.

References SetBurstLifetime().

◆ GetCollisionFilter() [1/2]

decCollisionFilter& deParticleEmitter::GetCollisionFilter ( )
inline

Retrieves the collision filter.

Call NotifyCollisionFilterChanged if you change the collision filter.

◆ GetCollisionFilter() [2/2]

const decCollisionFilter& deParticleEmitter::GetCollisionFilter ( ) const
inline

◆ GetControllerAt() [1/2]

deParticleEmitterController& deParticleEmitter::GetControllerAt ( int  index)

Retrieves the controller at the given index.

Referenced by GetControllerCount().

◆ GetControllerAt() [2/2]

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

◆ GetControllerCount()

int deParticleEmitter::GetControllerCount ( ) const
inline

Retrieves the count of controllers.

References GetControllerAt(), NotifyControllerChangedAt(), and SetControllerCount().

◆ GetEmitBurst()

bool deParticleEmitter::GetEmitBurst ( ) const
inline

Determines if particles are emit as burst (using particle count curve) or continuous (using interval curve).

References SetEmitBurst().

◆ GetGraphicModuleSimulates()

bool deParticleEmitter::GetGraphicModuleSimulates ( ) const
inline

Determines if the graphic module takes care of simulation.

References SetGraphicModuleSimulates().

◆ GetGraphicPeer()

deBaseGraphicParticleEmitter* deParticleEmitter::GetGraphicPeer ( ) const
inline

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

References SetGraphicPeer().

◆ GetPhysicsPeer()

deBasePhysicsParticleEmitter* deParticleEmitter::GetPhysicsPeer ( ) const
inline

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

References SetPhysicsPeer().

◆ GetTypeAt() [1/2]

deParticleEmitterType& deParticleEmitter::GetTypeAt ( int  index)

Retrieves the type at the given index.

Referenced by GetTypeCount().

◆ GetTypeAt() [2/2]

const deParticleEmitterType& deParticleEmitter::GetTypeAt ( int  index) const

◆ GetTypeCount()

int deParticleEmitter::GetTypeCount ( ) const
inline

Retrieves the count of types.

References GetTypeAt(), NotifyTypeChangedAt(), and SetTypeCount().

◆ NotifyCollisionFilterChanged()

void deParticleEmitter::NotifyCollisionFilterChanged ( )

Notifies the peers that the collision filter changed.

Referenced by GetCollisionFilter().

◆ NotifyControllerChangedAt()

void deParticleEmitter::NotifyControllerChangedAt ( int  controller)

Notifies that the controller at the given index changed.

Referenced by GetControllerCount().

◆ NotifyTypeChangedAt()

void deParticleEmitter::NotifyTypeChangedAt ( int  type)

Notifies that the type at the given index changed.

Referenced by GetTypeCount().

◆ SetBurstLifetime()

void deParticleEmitter::SetBurstLifetime ( float  lifetime)

Sets the burst lifetime of the emitter.

Referenced by GetBurstLifetime().

◆ SetControllerCount()

void deParticleEmitter::SetControllerCount ( int  count)

Sets the number of controllers.

Referenced by GetControllerCount().

◆ SetEmitBurst()

void deParticleEmitter::SetEmitBurst ( bool  emitBurst)

Sets if particles are emit as burst (using particle count curve) or continuous (using interval curve).

Referenced by GetEmitBurst().

◆ SetGraphicModuleSimulates()

void deParticleEmitter::SetGraphicModuleSimulates ( bool  graphicModuleSimulates)

Sets if the graphic module takes care of simulation.

Referenced by GetGraphicModuleSimulates().

◆ SetGraphicPeer()

void deParticleEmitter::SetGraphicPeer ( deBaseGraphicParticleEmitter peer)

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

Referenced by GetGraphicPeer().

◆ SetPhysicsPeer()

void deParticleEmitter::SetPhysicsPeer ( deBasePhysicsParticleEmitter peer)

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

Referenced by GetPhysicsPeer().

◆ SetTypeCount()

void deParticleEmitter::SetTypeCount ( int  count)

Sets the number of types.

Referenced by GetTypeCount().


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