Drag[en]gine Game Engine  1.21
deParticleEmitter Class Reference

Particle Emitter. More...

#include <deParticleEmitter.h>

Inheritance diagram for deParticleEmitter:
deResource deObject

Public Types

typedef deTObjectReference< deParticleEmitterRef
 Type holding strong reference. More...
 
- Public Types inherited from deResource
typedef deTObjectReference< deResourceRef
 Type holding strong reference. More...
 
- Public Types inherited from deObject
typedef deTObjectReference< deObjectRef
 Type holding strong reference. More...
 

Public Member Functions

Management
float GetBurstLifetime () const
 Burst lifetime of the emitter. More...
 
void SetBurstLifetime (float lifetime)
 Set burst lifetime of the emitter. More...
 
bool GetEmitBurst () const
 Particles are emit as burst (particle count curve) or continuous (interval curve). More...
 
void SetEmitBurst (bool emitBurst)
 Set if particles are emit as burst (particle count curve) or continuous (interval curve). More...
 
int GetTypeCount () const
 Count of types. More...
 
void SetTypeCount (int count)
 Set number of types. More...
 
deParticleEmitterTypeGetTypeAt (int index)
 Type at the given index. More...
 
const deParticleEmitterTypeGetTypeAt (int index) const
 
void NotifyTypeChangedAt (int type)
 Notifies that the type at the given index changed. More...
 
bool GetGraphicModuleSimulates () const
 Graphic module takes care of simulation. More...
 
void SetGraphicModuleSimulates (bool graphicModuleSimulates)
 Set if graphic module takes care of simulation. More...
 
Controller Management
int GetControllerCount () const
 Count of controllers. More...
 
deParticleEmitterControllerGetControllerAt (int index) const
 Controller at index. More...
 
int IndexOfController (deParticleEmitterController *controller) const
 Index of controller or -1 if absent. More...
 
int IndexOfControllerNamed (const char *controller) const
 Index of named controller or -1 if absent. More...
 
bool HasController (deParticleEmitterController *controller) const
 Controller is present. More...
 
void AddController (deParticleEmitterController *controller)
 Add controller. More...
 
void RemoveController (deParticleEmitterController *controller)
 Remove controller. More...
 
void RemoveAllControllers ()
 Remove all controllers. More...
 
void NotifyControllerChangedAt (int index)
 Notify peers controller changed. More...
 
System Peers
deBaseGraphicParticleEmitterGetPeerGraphic () const
 Graphic system peer object or NULL if not assigned. More...
 
void SetPeerGraphic (deBaseGraphicParticleEmitter *peer)
 Set graphic system peer object or NULL if not assigned. More...
 
deBasePhysicsParticleEmitterGetPeerPhysics () const
 Physics system peer object or NULL if not assigned. More...
 
void SetPeerPhysics (deBasePhysicsParticleEmitter *peer)
 Set physics system peer object or NULL if not assigned. More...
 
- 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)
 Create new particle emitter. More...
 
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.

Member Typedef Documentation

◆ Ref

Type holding strong reference.

Constructor & Destructor Documentation

◆ deParticleEmitter()

deParticleEmitter::deParticleEmitter ( deParticleEmitterManager manager)

Create 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

◆ AddController()

void deParticleEmitter::AddController ( deParticleEmitterController controller)

Add controller.

◆ GetBurstLifetime()

float deParticleEmitter::GetBurstLifetime ( ) const
inline

Burst lifetime of the emitter.

◆ GetControllerAt()

deParticleEmitterController* deParticleEmitter::GetControllerAt ( int  index) const

Controller at index.

◆ GetControllerCount()

int deParticleEmitter::GetControllerCount ( ) const
inline

Count of controllers.

◆ GetEmitBurst()

bool deParticleEmitter::GetEmitBurst ( ) const
inline

Particles are emit as burst (particle count curve) or continuous (interval curve).

◆ GetGraphicModuleSimulates()

bool deParticleEmitter::GetGraphicModuleSimulates ( ) const
inline

Graphic module takes care of simulation.

◆ GetPeerGraphic()

deBaseGraphicParticleEmitter* deParticleEmitter::GetPeerGraphic ( ) const
inline

Graphic system peer object or NULL if not assigned.

◆ GetPeerPhysics()

deBasePhysicsParticleEmitter* deParticleEmitter::GetPeerPhysics ( ) const
inline

Physics system peer object or NULL if not assigned.

◆ GetTypeAt() [1/2]

deParticleEmitterType& deParticleEmitter::GetTypeAt ( int  index)

Type at the given index.

◆ GetTypeAt() [2/2]

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

◆ GetTypeCount()

int deParticleEmitter::GetTypeCount ( ) const
inline

Count of types.

◆ HasController()

bool deParticleEmitter::HasController ( deParticleEmitterController controller) const

Controller is present.

◆ IndexOfController()

int deParticleEmitter::IndexOfController ( deParticleEmitterController controller) const

Index of controller or -1 if absent.

◆ IndexOfControllerNamed()

int deParticleEmitter::IndexOfControllerNamed ( const char *  controller) const

Index of named controller or -1 if absent.

◆ NotifyControllerChangedAt()

void deParticleEmitter::NotifyControllerChangedAt ( int  index)

Notify peers controller changed.

◆ NotifyTypeChangedAt()

void deParticleEmitter::NotifyTypeChangedAt ( int  type)

Notifies that the type at the given index changed.

◆ RemoveAllControllers()

void deParticleEmitter::RemoveAllControllers ( )

Remove all controllers.

◆ RemoveController()

void deParticleEmitter::RemoveController ( deParticleEmitterController controller)

Remove controller.

◆ SetBurstLifetime()

void deParticleEmitter::SetBurstLifetime ( float  lifetime)

Set burst lifetime of the emitter.

◆ SetEmitBurst()

void deParticleEmitter::SetEmitBurst ( bool  emitBurst)

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

◆ SetGraphicModuleSimulates()

void deParticleEmitter::SetGraphicModuleSimulates ( bool  graphicModuleSimulates)

Set if graphic module takes care of simulation.

◆ SetPeerGraphic()

void deParticleEmitter::SetPeerGraphic ( deBaseGraphicParticleEmitter peer)

Set graphic system peer object or NULL if not assigned.

◆ SetPeerPhysics()

void deParticleEmitter::SetPeerPhysics ( deBasePhysicsParticleEmitter peer)

Set physics system peer object or NULL if not assigned.

◆ SetTypeCount()

void deParticleEmitter::SetTypeCount ( int  count)

Set number of types.


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