Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Ogre::ParticleSystemManager Class Reference

Manages particle systems, particle system scripts (templates) and the available emitter & affector factories. More...

#include <OgreParticleSystemManager.h>

Inheritance diagram for Ogre::ParticleSystemManager:

Ogre::Singleton< ParticleSystemManager > Ogre::ScriptLoader List of all members.

Public Types

typedef std::map< String,
ParticleSystem * > 
ParticleTemplateMap
typedef std::map< String,
ParticleAffectorFactory * > 
ParticleAffectorFactoryMap
typedef std::map< String,
ParticleEmitterFactory * > 
ParticleEmitterFactoryMap
typedef std::map< String,
ParticleSystemRendererFactory * > 
ParticleSystemRendererFactoryMap
typedef MapIterator< ParticleAffectorFactoryMapParticleAffectorFactoryIterator
typedef MapIterator< ParticleEmitterFactoryMapParticleEmitterFactoryIterator
typedef MapIterator< ParticleSystemRendererFactoryMapParticleRendererFactoryIterator
typedef MapIterator< ParticleTemplateMapParticleSystemTemplateIterator

Public Member Functions

 ParticleSystemManager ()
virtual ~ParticleSystemManager ()
void addEmitterFactory (ParticleEmitterFactory *factory)
 Adds a new 'factory' object for emitters to the list of available emitter types.

void addAffectorFactory (ParticleAffectorFactory *factory)
 Adds a new 'factory' object for affectors to the list of available affector types.

void addRendererFactory (ParticleSystemRendererFactory *factory)
 Registers a factory class for creating ParticleSystemRenderer instances.

void addTemplate (const String &name, ParticleSystem *sysTemplate)
 Adds a new particle system template to the list of available templates.

ParticleSystemcreateTemplate (const String &name, const String &resourceGroup)
 Create a new particle system template.

ParticleSystemgetTemplate (const String &name)
 Retrieves a particle system template for possible modification.

ParticleEmitter_createEmitter (const String &emitterType, ParticleSystem *psys)
 Internal method for creating a new emitter from a factory.

void _destroyEmitter (ParticleEmitter *emitter)
 Internal method for destroying an emitter.

ParticleAffector_createAffector (const String &affectorType, ParticleSystem *psys)
 Internal method for creating a new affector from a factory.

void _destroyAffector (ParticleAffector *affector)
 Internal method for destroying an affector.

ParticleSystemRenderer_createRenderer (const String &rendererType)
 Internal method for creating a new renderer from a factory.

void _destroyRenderer (ParticleSystemRenderer *renderer)
 Internal method for destroying a renderer.

bool frameStarted (const FrameEvent &evt)
 Frame event.

bool frameEnded (const FrameEvent &evt)
 Frame event.

void _initialise (void)
 Init method to be called by OGRE system.

const StringVectorgetScriptPatterns (void) const
 
Remarks:
This method is called when a resource group is loaded if you use ResourceGroupManager::_registerScriptLoader.
Returns:
A list of file patterns, in the order they should be searched in.


void parseScript (DataStreamPtr &stream, const String &groupName)
 
Parameters:
stream Weak reference to a data stream which is the source of the script
groupName The name of a resource group which should be used if any resources are created during the parse of this script.


Real getLoadingOrder (void) const
 
Remarks:
There are dependencies between some kinds of scripts, and to enforce this all implementors of this interface must define a loading order.
Returns:
A value representing the relative loading order of these scripts compared to other script users, where higher values load later.


ParticleAffectorFactoryIterator getAffectorFactoryIterator (void)
 Return an iterator over the affector factories currently registered.

ParticleEmitterFactoryIterator getEmitterFactoryIterator (void)
 Return an iterator over the emitter factories currently registered.

ParticleRendererFactoryIterator getRendererFactoryIterator (void)
 Return an iterator over the renderer factories currently registered.

ParticleSystemTemplateIterator getTemplateIterator (void)
 Gets an iterator over the list of particle system templates.

ParticleSystemFactory_getFactory (void)
 Get an instance of ParticleSystemFactory (internal use).


Static Public Member Functions

ParticleSystemManagergetSingleton (void)
 Override standard Singleton retrieval.

ParticleSystemManagergetSingletonPtr (void)
 Override standard Singleton retrieval.


Protected Member Functions

void parseNewEmitter (const String &type, DataStreamPtr &chunk, ParticleSystem *sys)
 Internal script parsing method.

void parseNewAffector (const String &type, DataStreamPtr &chunk, ParticleSystem *sys)
 Internal script parsing method.

void parseAttrib (const String &line, ParticleSystem *sys)
 Internal script parsing method.

void parseEmitterAttrib (const String &line, ParticleEmitter *sys)
 Internal script parsing method.

void parseAffectorAttrib (const String &line, ParticleAffector *sys)
 Internal script parsing method.

void skipToNextCloseBrace (DataStreamPtr &chunk)
 Internal script parsing method.

void skipToNextOpenBrace (DataStreamPtr &chunk)
 Internal script parsing method.

ParticleSystemcreateSystemImpl (const String &name, size_t quota, const String &resourceGroup)
 Internal implementation of createSystem.

ParticleSystemcreateSystemImpl (const String &name, const String &templateName)
 Internal implementation of createSystem.

void destroySystemImpl (ParticleSystem *sys)
 Internal implementation of destroySystem.


Protected Attributes

ParticleTemplateMap mSystemTemplates
 Templates based on scripts.

ParticleEmitterFactoryMap mEmitterFactories
 Factories for named emitter types (can be extended using plugins).

ParticleAffectorFactoryMap mAffectorFactories
 Factories for named affector types (can be extended using plugins).

ParticleSystemRendererFactoryMap mRendererFactories
 Map of renderer types to factories.

StringVector mScriptPatterns
ParticleSystemFactorymFactory

Static Protected Attributes

ParticleSystemManagerms_Singleton

Friends

class ParticleSystemFactory

Detailed Description

Manages particle systems, particle system scripts (templates) and the available emitter & affector factories.

Remarks:
This singleton class is responsible for creating and managing particle systems. All particle systems must be created and destroyed using this object, although the user interface to creating them is via SceneManager. Remember that like all other MovableObject subclasses, ParticleSystems do not get rendered until they are attached to a SceneNode object.
This class also manages factories for ParticleEmitter and ParticleAffector classes. To enable easy extensions to the types of emitters (particle sources) and affectors (particle modifiers), the ParticleSystemManager lets plugins or applications register factory classes which submit new subclasses to ParticleEmitter and ParticleAffector. Ogre comes with a number of them already provided, such as cone, sphere and box-shaped emitters, and simple affectors such as constant directional force and colour faders. However using this registration process, a plugin can create any behaviour required.
This class also manages the loading and parsing of particle system scripts, which are text files describing named particle system templates. Instances of particle systems using these templates can then be created easily through the createParticleSystem method.

Definition at line 67 of file OgreParticleSystemManager.h.


Member Typedef Documentation

typedef MapIterator<ParticleAffectorFactoryMap> Ogre::ParticleSystemManager::ParticleAffectorFactoryIterator
 

Definition at line 294 of file OgreParticleSystemManager.h.

typedef std::map<String, ParticleAffectorFactory*> Ogre::ParticleSystemManager::ParticleAffectorFactoryMap
 

Definition at line 73 of file OgreParticleSystemManager.h.

typedef MapIterator<ParticleEmitterFactoryMap> Ogre::ParticleSystemManager::ParticleEmitterFactoryIterator
 

Definition at line 295 of file OgreParticleSystemManager.h.

typedef std::map<String, ParticleEmitterFactory*> Ogre::ParticleSystemManager::ParticleEmitterFactoryMap
 

Definition at line 74 of file OgreParticleSystemManager.h.

typedef MapIterator<ParticleSystemRendererFactoryMap> Ogre::ParticleSystemManager::ParticleRendererFactoryIterator
 

Definition at line 296 of file OgreParticleSystemManager.h.

typedef std::map<String, ParticleSystemRendererFactory*> Ogre::ParticleSystemManager::ParticleSystemRendererFactoryMap
 

Definition at line 75 of file OgreParticleSystemManager.h.

typedef MapIterator<ParticleTemplateMap> Ogre::ParticleSystemManager::ParticleSystemTemplateIterator
 

Definition at line 305 of file OgreParticleSystemManager.h.

Referenced by getTemplateIterator().

typedef std::map<String, ParticleSystem*> Ogre::ParticleSystemManager::ParticleTemplateMap
 

Definition at line 72 of file OgreParticleSystemManager.h.


Constructor & Destructor Documentation

Ogre::ParticleSystemManager::ParticleSystemManager  ) 
 

virtual Ogre::ParticleSystemManager::~ParticleSystemManager  )  [virtual]
 


Member Function Documentation

ParticleAffector* Ogre::ParticleSystemManager::_createAffector const String affectorType,
ParticleSystem psys
 

Internal method for creating a new affector from a factory.

Remarks:
Used internally by the engine to create new ParticleAffector instances from named factories. Applications should use the ParticleSystem::addAffector method instead, which calls this method to create an instance.
Parameters:
effectorType String name of the affector type to be created. A factory of this type must have been registered.
psys The particle system it is being created for

ParticleEmitter* Ogre::ParticleSystemManager::_createEmitter const String emitterType,
ParticleSystem psys
 

Internal method for creating a new emitter from a factory.

Remarks:
Used internally by the engine to create new ParticleEmitter instances from named factories. Applications should use the ParticleSystem::addEmitter method instead, which calls this method to create an instance.
Parameters:
emitterType String name of the emitter type to be created. A factory of this type must have been registered.
psys The particle system this is being created for

ParticleSystemRenderer* Ogre::ParticleSystemManager::_createRenderer const String rendererType  ) 
 

Internal method for creating a new renderer from a factory.

Remarks:
Used internally by the engine to create new ParticleSystemRenderer instances from named factories. Applications should use the ParticleSystem::setRenderer method instead, which calls this method to create an instance.
Parameters:
rendererType String name of the renderer type to be created. A factory of this type must have been registered.

void Ogre::ParticleSystemManager::_destroyAffector ParticleAffector affector  ) 
 

Internal method for destroying an affector.

Remarks:
Because affectors are created by factories which may allocate memory from separate heaps, the memory allocated must be freed from the same place. This method is used to ask the factory to destroy the instance passed in as a pointer.
Parameters:
affector Pointer to affector to be destroyed. On return this pointer will point to invalid (freed) memory.

void Ogre::ParticleSystemManager::_destroyEmitter ParticleEmitter emitter  ) 
 

Internal method for destroying an emitter.

Remarks:
Because emitters are created by factories which may allocate memory from separate heaps, the memory allocated must be freed from the same place. This method is used to ask the factory to destroy the instance passed in as a pointer.
Parameters:
emitter Pointer to emitter to be destroyed. On return this pointer will point to invalid (freed) memory.

void Ogre::ParticleSystemManager::_destroyRenderer ParticleSystemRenderer renderer  ) 
 

Internal method for destroying a renderer.

Remarks:
Because renderer are created by factories which may allocate memory from separate heaps, the memory allocated must be freed from the same place. This method is used to ask the factory to destroy the instance passed in as a pointer.
Parameters:
renderer Pointer to renderer to be destroyed. On return this pointer will point to invalid (freed) memory.

ParticleSystemFactory* Ogre::ParticleSystemManager::_getFactory void   ) 
 

Get an instance of ParticleSystemFactory (internal use).

Definition at line 314 of file OgreParticleSystemManager.h.

void Ogre::ParticleSystemManager::_initialise void   ) 
 

Init method to be called by OGRE system.

Remarks:
Due to dependencies between various objects certain initialisation tasks cannot be done on construction. OGRE will call this method when the rendering subsystem is initialised.

void Ogre::ParticleSystemManager::addAffectorFactory ParticleAffectorFactory factory  ) 
 

Adds a new 'factory' object for affectors to the list of available affector types.

Remarks:
This method allows plugins etc to add new particle affector types to Ogre. Particle affectors modify the particles in a system a certain way such as affecting their direction or changing their colour, lifespan etc. Plugins would create new subclasses of ParticleAffector which affect particles a certain way, and register a subclass of ParticleAffectorFactory to create them.
All particle affector factories have an assigned name which is used to identify the affector type. This must be unique.
Note that the object passed to this function will not be destroyed by the ParticleSystemManager, since it may have been allocted on a different heap in the case of plugins. The caller must destroy the object later on, probably on plugin shutdown.
Parameters:
factory Pointer to a ParticleAffectorFactory subclass created by the plugin or application code.

void Ogre::ParticleSystemManager::addEmitterFactory ParticleEmitterFactory factory  ) 
 

Adds a new 'factory' object for emitters to the list of available emitter types.

Remarks:
This method allows plugins etc to add new particle emitter types to Ogre. Particle emitters are sources of particles, and generate new particles with their start positions, colours and momentums appropriately. Plugins would create new subclasses of ParticleEmitter which emit particles a certain way, and register a subclass of ParticleEmitterFactory to create them (since multiple emitters can be created for different particle systems).
All particle emitter factories have an assigned name which is used to identify the emitter type. This must be unique.
Note that the object passed to this function will not be destroyed by the ParticleSystemManager, since it may have been allocted on a different heap in the case of plugins. The caller must destroy the object later on, probably on plugin shutdown.
Parameters:
factory Pointer to a ParticleEmitterFactory subclass created by the plugin or application code.

void Ogre::ParticleSystemManager::addRendererFactory ParticleSystemRendererFactory factory  ) 
 

Registers a factory class for creating ParticleSystemRenderer instances.

Note that the object passed to this function will not be destroyed by the ParticleSystemManager, since it may have been allocted on a different heap in the case of plugins. The caller must destroy the object later on, probably on plugin shutdown.
Parameters:
factory Pointer to a ParticleSystemRendererFactory subclass created by the plugin or application code.

void Ogre::ParticleSystemManager::addTemplate const String name,
ParticleSystem sysTemplate
 

Adds a new particle system template to the list of available templates.

Remarks:
Instances of particle systems in a scene are not normally unique - often you want to place the same effect in many places. This method allows you to register a ParticleSystem as a named template, which can subsequently be used to create instances using the createSystem method.
Note that particle system templates can either be created programmatically by an application and registered using this method, or they can be defined in a script file (*.particle) which is loaded by the engine at startup, very much like Material scripts.
Parameters:
name The name of the template. Must be unique across all templates.
sysTemplate A pointer to a particle system to be used as a template. The manager will take over ownership of this pointer.

ParticleSystem* Ogre::ParticleSystemManager::createSystemImpl const String name,
const String templateName
[protected]
 

Internal implementation of createSystem.

ParticleSystem* Ogre::ParticleSystemManager::createSystemImpl const String name,
size_t  quota,
const String resourceGroup
[protected]
 

Internal implementation of createSystem.

ParticleSystem* Ogre::ParticleSystemManager::createTemplate const String name,
const String resourceGroup
 

Create a new particle system template.

Remarks:
This method is similar to the addTemplate method, except this just creates a new template and returns a pointer to it to be populated. Use this when you don't already have a system to add as a template and just want to create a new template which you will build up in-place.
Parameters:
name The name of the template. Must be unique across all templates.
resourceGroup The name of the resource group which will be used to load any dependent resources.

void Ogre::ParticleSystemManager::destroySystemImpl ParticleSystem sys  )  [protected]
 

Internal implementation of destroySystem.

bool Ogre::ParticleSystemManager::frameEnded const FrameEvent evt  ) 
 

Frame event.

bool Ogre::ParticleSystemManager::frameStarted const FrameEvent evt  ) 
 

Frame event.

ParticleAffectorFactoryIterator Ogre::ParticleSystemManager::getAffectorFactoryIterator void   ) 
 

Return an iterator over the affector factories currently registered.

ParticleEmitterFactoryIterator Ogre::ParticleSystemManager::getEmitterFactoryIterator void   ) 
 

Return an iterator over the emitter factories currently registered.

Real Ogre::ParticleSystemManager::getLoadingOrder void   )  const [virtual]
 

Remarks:
There are dependencies between some kinds of scripts, and to enforce this all implementors of this interface must define a loading order.
Returns:
A value representing the relative loading order of these scripts compared to other script users, where higher values load later.

Implements Ogre::ScriptLoader.

ParticleRendererFactoryIterator Ogre::ParticleSystemManager::getRendererFactoryIterator void   ) 
 

Return an iterator over the renderer factories currently registered.

const StringVector& Ogre::ParticleSystemManager::getScriptPatterns void   )  const [virtual]
 

Remarks:
This method is called when a resource group is loaded if you use ResourceGroupManager::_registerScriptLoader.
Returns:
A list of file patterns, in the order they should be searched in.

Implements Ogre::ScriptLoader.

ParticleSystemManager& Ogre::ParticleSystemManager::getSingleton void   )  [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from Ogre::Singleton< ParticleSystemManager >.

ParticleSystemManager* Ogre::ParticleSystemManager::getSingletonPtr void   )  [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from Ogre::Singleton< ParticleSystemManager >.

ParticleSystem* Ogre::ParticleSystemManager::getTemplate const String name  ) 
 

Retrieves a particle system template for possible modification.

Remarks:
Modifying a template does not affect the settings on any ParticleSystems already created from this template.

ParticleSystemTemplateIterator Ogre::ParticleSystemManager::getTemplateIterator void   ) 
 

Gets an iterator over the list of particle system templates.

Definition at line 307 of file OgreParticleSystemManager.h.

References ParticleSystemTemplateIterator.

void Ogre::ParticleSystemManager::parseAffectorAttrib const String line,
ParticleAffector sys
[protected]
 

Internal script parsing method.

void Ogre::ParticleSystemManager::parseAttrib const String line,
ParticleSystem sys
[protected]
 

Internal script parsing method.

void Ogre::ParticleSystemManager::parseEmitterAttrib const String line,
ParticleEmitter sys
[protected]
 

Internal script parsing method.

void Ogre::ParticleSystemManager::parseNewAffector const String type,
DataStreamPtr chunk,
ParticleSystem sys
[protected]
 

Internal script parsing method.

void Ogre::ParticleSystemManager::parseNewEmitter const String type,
DataStreamPtr chunk,
ParticleSystem sys
[protected]
 

Internal script parsing method.

void Ogre::ParticleSystemManager::parseScript DataStreamPtr stream,
const String groupName
[virtual]
 

Parameters:
stream Weak reference to a data stream which is the source of the script
groupName The name of a resource group which should be used if any resources are created during the parse of this script.

Implements Ogre::ScriptLoader.

void Ogre::ParticleSystemManager::skipToNextCloseBrace DataStreamPtr chunk  )  [protected]
 

Internal script parsing method.

void Ogre::ParticleSystemManager::skipToNextOpenBrace DataStreamPtr chunk  )  [protected]
 

Internal script parsing method.


Friends And Related Function Documentation

friend class ParticleSystemFactory [friend]
 

Definition at line 70 of file OgreParticleSystemManager.h.


Member Data Documentation

ParticleAffectorFactoryMap Ogre::ParticleSystemManager::mAffectorFactories [protected]
 

Factories for named affector types (can be extended using plugins).

Definition at line 84 of file OgreParticleSystemManager.h.

ParticleEmitterFactoryMap Ogre::ParticleSystemManager::mEmitterFactories [protected]
 

Factories for named emitter types (can be extended using plugins).

Definition at line 81 of file OgreParticleSystemManager.h.

ParticleSystemFactory* Ogre::ParticleSystemManager::mFactory [protected]
 

Definition at line 92 of file OgreParticleSystemManager.h.

ParticleSystemRendererFactoryMap Ogre::ParticleSystemManager::mRendererFactories [protected]
 

Map of renderer types to factories.

Definition at line 87 of file OgreParticleSystemManager.h.

ParticleSystemManager * Ogre::Singleton< ParticleSystemManager >::ms_Singleton [static, protected, inherited]
 

Definition at line 54 of file OgreSingleton.h.

StringVector Ogre::ParticleSystemManager::mScriptPatterns [protected]
 

Definition at line 89 of file OgreParticleSystemManager.h.

ParticleTemplateMap Ogre::ParticleSystemManager::mSystemTemplates [protected]
 

Templates based on scripts.

Definition at line 78 of file OgreParticleSystemManager.h.


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

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:41:19 2006