28#ifndef __ParticleSystem_H__
29#define __ParticleSystem_H__
396 bool debugRenderables =
false);
478 { msDefaultNonvisibleTimeout = timeout; }
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
Abstract class defining a movable object in a scene.
Class representing a general-purpose node an articulated scene graph.
Abstract class which is command object which gets/sets parameters.
Abstract class defining the interface to be implemented by particle affectors.
Abstract class defining the interface to be implemented by particle emitters.
Convenience class to make it easy to step through all particles in a ParticleSystem.
Abstract class defining the interface required to be implemented by classes which provide rendering c...
Command object for cull_each (see ParamCommand).
void doSet(void *target, const String &val)
String doGet(const void *target) const
Command object for emittedEmitterQuota (see ParamCommand).
void doSet(void *target, const String &val)
String doGet(const void *target) const
Command object for particle_height (see ParamCommand).
void doSet(void *target, const String &val)
String doGet(const void *target) const
Command object for iteration interval(see ParamCommand).
String doGet(const void *target) const
void doSet(void *target, const String &val)
Command object for local space (see ParamCommand).
String doGet(const void *target) const
void doSet(void *target, const String &val)
Command object for material (see ParamCommand).
String doGet(const void *target) const
void doSet(void *target, const String &val)
Command object for nonvisible timeout (see ParamCommand).
void doSet(void *target, const String &val)
String doGet(const void *target) const
Command object for quota (see ParamCommand).
void doSet(void *target, const String &val)
String doGet(const void *target) const
Command object for renderer (see ParamCommand).
String doGet(const void *target) const
void doSet(void *target, const String &val)
Command object for sorting (see ParamCommand).
void doSet(void *target, const String &val)
String doGet(const void *target) const
Command object for particle_width (see ParamCommand).
String doGet(const void *target) const
void doSet(void *target, const String &val)
Class defining particle system based special effects.
virtual bool getCullIndividually(void) const
Returns whether or not particles in this are tested individually for culling.
void initialiseEmittedEmitters(void)
Create a pool of emitted emitters and assign them to the free emitter list.
String mRendererType
The name of the type of renderer used to render this system.
size_t mEmittedEmitterPoolSize
The number of emitted emitters in the pool.
virtual Real getBoundingRadius(void) const
Overridden from MovableObject.
void increaseEmittedEmitterPool(size_t size)
Resize the internal pool of emitted emitters.
Real mDefaultWidth
Default width of each particle.
Particle * getParticle(size_t index)
Retrieve a particle from the system for manual tweaking.
void increasePool(size_t size)
Resize the internal pool of particles.
void addFreeEmittedEmitters(void)
Add emitters from the pool to the free emitted emitter queue.
void setKeepParticlesInLocalSpace(bool keepLocal)
Sets whether particles (and any affector effects) remain relative to the node the particle system is ...
virtual ~ParticleSystem()
Real getIterationInterval(void) const
Gets a 'iteration interval' on this particle system.
ActiveEmittedEmitterList mActiveEmittedEmitters
Active emitted emitter list.
void _triggerAffectors(Real timeElapsed)
Applies the effects of affectors.
FreeParticleList mFreeParticles
Free particle queue.
FreeEmittedEmitterList * findFreeEmittedEmitter(const String &name)
Find the list with free emitted emitters.
Particle * createEmitterParticle(const String &emitterName)
Manually add an emitter particle to the system.
unsigned short getNumEmitters(void) const
Returns the number of emitters for this particle system.
AxisAlignedBox mWorldAABB
World AABB, only used to compare world-space positions to calc bounds.
size_t getParticleQuota(void) const
Returns the maximum number of particles this system is allowed to have active at once.
String mOrigin
Optional origin of this particle system (eg script name)
void removeAllAffectors(void)
Removes all the affectors from this system.
void _sortParticles(Camera *cam)
Sort the particles in the system.
void removeAllEmittedEmitters(void)
Removes all emitted emitters from this system.
static CmdQuota msQuotaCmd
void removeFromActiveEmittedEmitters(ParticleEmitter *emitter)
Removes an emitter from the active emitted emitter list.
void destroyVisualParticles(size_t poolstart, size_t poolend)
Internal method for destroying ParticleVisualData instances for the pool.
ParticleSystemRenderer * getRenderer(void) const
Gets the ParticleRenderer to be used to render this particle system.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
void _notifyAttached(Node *parent, bool isTagPoint=false)
Overridden from MovableObject.
virtual void _notifyCurrentCamera(Camera *cam)
Overridden from MovableObject.
vector< Particle * >::type ParticlePool
ParticleEmitterList mEmitters
List of particle emitters, ie sources of particles.
ParticleEmitter * addEmitter(const String &emitterType)
Adds an emitter to this particle system.
ParticleSystem & operator=(const ParticleSystem &rhs)
Assignment operator for copying.
void _update(Real timeElapsed)
Updates the particles in the system based on time elapsed.
Real getSpeedFactor(void) const
Gets the 'speed factor' on this particle system.
ParticlePool mParticlePool
Pool of particle instances for use and reuse in the active particle list.
Real getNonVisibleUpdateTimeout(void) const
Gets when the particle system should stop updating after it hasn't been visible for a while.
void removeAllEmitters(void)
Removes all the emitters from this system.
map< String, EmittedEmitterList >::type EmittedEmitterPool
virtual Real getDefaultHeight(void) const
See setDefaultDimensions - this gets 1 component individually.
virtual void setCullIndividually(bool cullIndividual)
Sets whether culling tests particles in this individually as well as in a group.
ParticleSystemRenderer * mRenderer
The renderer used to render this particle system.
void setRenderer(const String &typeName)
Sets the ParticleRenderer to be used to render this particle system.
ParticleAffector * addAffector(const String &affectorType)
Adds an affector to this particle system.
static Real msDefaultIterationInterval
Default iteration interval.
ParticleEmitter * getEmitter(unsigned short index) const
Retrieves an emitter by it's index (zero-based).
static CmdNonvisibleTimeout msNonvisibleTimeoutCmd
list< Particle * >::type FreeParticleList
void _applyMotion(Real timeElapsed)
Updates existing particle based on their momentum.
virtual void setMaterialName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Sets the name of the material to be used for this billboard set.
void setBoundsAutoUpdated(bool autoUpdate, Real stopIn=0.0f)
Sets whether the bounds will be automatically updated for the life of the particle system.
void fastForward(Real time, Real interval=0.1)
Fast-forwards this system by the required number of seconds.
Real mSpeedFactor
Speed factor.
EmittedEmitterPool mEmittedEmitterPool
Pool of emitted emitters for use and reuse in the active emitted emitter list.
const String & getMovableType(void) const
Overridden from MovableObject.
ParticleAffectorList mAffectors
List of particle affectors, ie modifiers of particles.
static CmdIterationInterval msIterationIntervalCmd
virtual void _notifyParticleResized(void)
Internal callback used by Particles to notify their parent that they have been resized.
void removeEmitter(unsigned short index)
Removes an emitter from the system.
unsigned long mLastVisibleFrame
Last frame in which known to be visible.
bool mIsRendererConfigured
Have we set the material etc on the renderer?
void clear()
Empties this set of all particles.
String mMaterialName
Name of the material to use.
Real mDefaultHeight
Default height of each particle.
void _executeTriggerEmitters(ParticleEmitter *emitter, unsigned requested, Real timeElapsed)
Helper function that actually performs the emission of particles.
const String & getRendererName(void) const
Gets the name of the ParticleRenderer to be used to render this particle system.
bool mLocalSpace
Particles in local space?
ParticleIterator _getIterator(void)
Returns an iterator for stepping through all particles in this system.
bool mCullIndividual
Do we cull each particle individually?
bool getEmitting() const
Returns true if the particle system emitting flag is turned on.
void setRenderQueueGroup(uint8 queueID)
Sets the render queue group this entity will be rendered through.
virtual const String & getMaterialName(void) const
Sets the name of the material to be used for this billboard set.
void addActiveEmittedEmittersToFreeList(void)
Moves all emitted emitters from the active list to the free list.
void setEmittedEmitterQuota(size_t quota)
Sets the maximum number of emitted emitters this system is allowed to have active at once.
void setBounds(const AxisAlignedBox &aabb)
Set the (initial) bounds of the particle system manually.
void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority)
Sets the render queue group and group priority this entity will be rendered through.
void removeAffector(unsigned short index)
Removes an affector from the system.
static CmdHeight msHeightCmd
static CmdWidth msWidthCmd
static Real msDefaultNonvisibleTimeout
Default nonvisible update timeout.
bool mEmittedEmitterPoolInitialised
Indication whether the emitted emitter pool (= pool with particle emitters that are emitted) is initi...
size_t getNumParticles(void) const
Gets the number of individual particles in the system right now.
virtual void setDefaultDimensions(Real width, Real height)
Sets the default dimensions of the particles in this set.
Particle * createParticle(void)
Manually add a particle to the system.
static CmdMaterial msMaterialCmd
bool mSorted
Particles sorted according to camera?
ParticleSystem(const String &name, const String &resourceGroupName)
Creates a particle system with no emitters or affectors.
ParticleSystem()
Default constructor required for STL creation in manager.
static CmdEmittedEmitterQuota msEmittedEmitterQuotaCmd
bool mNonvisibleTimeoutSet
Update timeout when nonvisible set? Otherwise track default.
Real mIterationInterval
Iteration interval.
virtual void setDefaultHeight(Real height)
See setDefaultDimensions - this sets 1 component individually.
static Real getDefaultNonVisibleUpdateTimeout(void)
Get the default nonvisible timeout for all ParticleSystem instances.
virtual void _updateRenderQueue(RenderQueue *queue)
Overridden from MovableObject.
Real mTimeSinceLastVisible
Amount of time non-visible so far.
uint32 getTypeFlags(void) const
Override to return specific type flag.
void createVisualParticles(size_t poolstart, size_t poolend)
Internal method for creating ParticleVisualData instances for the pool.
void setSortingEnabled(bool enabled)
Set whether or not particles are sorted according to the camera.
virtual void setDefaultWidth(Real width)
See setDefaultDimensions - this sets 1 component individually.
list< ParticleEmitter * >::type ActiveEmittedEmitterList
void setParticleQuota(size_t quota)
Sets the maximum number of particles this system is allowed to have active at once.
ActiveParticleList mActiveParticles
Active particle list.
size_t getEmittedEmitterQuota(void) const
Returns the maximum number of emitted emitters this system is allowed to have active at once.
virtual void _notifyParticleRotated(void)
Internal callback used by Particles to notify their parent that they have been rotated.
Controller< Real > * mTimeController
Controller for time update.
void initialiseEmittedEmitterPool(void)
Determine which emitters in the Particle Systems main emitter become a template for creating an pool ...
void _notifyOrigin(const String &origin)
Notify this particle system of it's origin.
FreeEmittedEmitterMap mFreeEmittedEmitters
Free emitted emitter list.
list< ParticleEmitter * >::type FreeEmittedEmitterList
virtual const AxisAlignedBox & getBoundingBox(void) const
Overridden from MovableObject.
virtual const String & getResourceGroupName(void) const
Return the resource group to be used to load dependent resources.
void configureRenderer(void)
Internal method to configure the renderer.
vector< ParticleEmitter * >::type EmittedEmitterList
void _updateBounds(void)
Internal method for updating the bounds of the particle system.
static CmdCull msCullCmd
Command objects.
bool getSortingEnabled(void) const
Gets whether particles are sorted relative to the camera.
size_t mPoolSize
The number of particles in the pool.
void _expire(Real timeElapsed)
Internal method used to expire dead particles.
vector< ParticleAffector * >::type ParticleAffectorList
vector< ParticleEmitter * >::type ParticleEmitterList
void setNonVisibleUpdateTimeout(Real timeout)
Sets when the particle system should stop updating after it hasn't been visible for a while.
void initParameters(void)
Internal method for initialising string interface.
static void setDefaultIterationInterval(Real iterationInterval)
Set the default iteration interval for all ParticleSystem instances.
const String & getOrigin(void) const
Get the origin of this particle system, e.g.
unsigned short getNumAffectors(void) const
Returns the number of affectors for this particle system.
map< String, FreeEmittedEmitterList >::type FreeEmittedEmitterMap
static RadixSort< ActiveParticleList, Particle *, float > mRadixSorter
list< Particle * >::type ActiveParticleList
void setEmitting(bool v)
This is used to turn on or off particle emission for this system.
static CmdRenderer msRendererCmd
static CmdLocalSpace msLocalSpaceCmd
MaterialPtr mMaterial
Pointer to the material to use.
bool getKeepParticlesInLocalSpace(void) const
Gets whether particles (and any affector effects) remain relative to the node the particle system is ...
static CmdSorted msSortedCmd
static void setDefaultNonVisibleUpdateTimeout(Real timeout)
Set the default nonvisible timeout for all ParticleSystem instances.
String mResourceGroupName
Name of the resource group to use to load materials.
void setIterationInterval(Real iterationInterval)
Sets a 'iteration interval' on this particle system.
Real mNonvisibleTimeout
Update timeout when nonvisible (0 for no timeout)
void _triggerEmitters(Real timeElapsed)
Spawn new particles based on free quota and emitter requirements.
ParticleAffector * getAffector(unsigned short index) const
Retrieves an affector by it's index (zero-based).
static Real getDefaultIterationInterval(void)
Get the default iteration interval for all ParticleSystem instances.
virtual Real getDefaultWidth(void) const
See setDefaultDimensions - this gets 1 component individually.
bool mIterationIntervalSet
Iteration interval set? Otherwise track default.
bool mIsEmitting
Used to control if the particle system should emit particles or not.
void _notifyReorganiseEmittedEmitterData(void)
This function clears all data structures that are used in combination with emitted emitters and sets ...
void setSpeedFactor(Real speedFactor)
Sets a 'speed factor' on this particle system, which means it scales the elapsed real time which has ...
Class representing a single particle instance.
Class for performing a radix sort (fast comparison-less sort based on byte value) on various standard...
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Class defining the common interface which classes can use to present a reflection-style,...
Standard 3-dimensional vector.
float Real
Software floating point type.
Sort by direction functor.
SortByDirectionFunctor(const Vector3 &dir)
Vector3 sortDir
Direction to sort in.
float operator()(Particle *p) const
Sort by distance functor.
SortByDistanceFunctor(const Vector3 &pos)
float operator()(Particle *p) const
Vector3 sortPos
Position to sort in.