OGRE-Next: Ogre::ParticleSystemManager Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Ogre::ParticleSystemManager Class Reference
Core » Effects

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

`#include <OgreParticleSystemManager.h>`

Inheritance diagram for Ogre::ParticleSystemManager:
[legend]

## Public Types
typedef MapIterator< ParticleAffectorFactoryMap > | ParticleAffectorFactoryIterator
typedef map< String, ParticleAffectorFactory * >::type | ParticleAffectorFactoryMap
typedef MapIterator< ParticleEmitterFactoryMap > | ParticleEmitterFactoryIterator
typedef map< String, ParticleEmitterFactory * >::type | ParticleEmitterFactoryMap
typedef MapIterator< ParticleSystemRendererFactoryMap > | ParticleRendererFactoryIterator
typedef map< String, ParticleSystemRendererFactory * >::type | ParticleSystemRendererFactoryMap
typedef MapIterator< ParticleTemplateMap > | ParticleSystemTemplateIterator
typedef map< String, ParticleSystem * >::type | ParticleTemplateMap

## Public Member Functions
| ParticleSystemManager ()
| ~ParticleSystemManager () override
ParticleAffector * | _createAffector (const String &affectorType, ParticleSystem *psys)
| Internal method for creating a new affector from a factory.
ParticleEmitter * | _createEmitter (const String &emitterType, ParticleSystem *psys)
| Internal method for creating a new emitter from a factory.
ParticleSystemRenderer * | _createRenderer (const String &rendererType, SceneManager *sceneManager)
| Internal method for creating a new renderer from a factory.
void | _destroyAffector (ParticleAffector *affector)
| Internal method for destroying an affector.
void | _destroyEmitter (ParticleEmitter *emitter)
| Internal method for destroying an emitter.
void | _destroyRenderer (ParticleSystemRenderer *renderer)
| Internal method for destroying a renderer.
ParticleSystemFactory * | _getFactory ()
| Get an instance of ParticleSystemFactory (internal use).
void | _initialise ()
| Init method to be called by OGRE system.
void | addAffectorFactory (ParticleAffectorFactory *factory)
| Adds a new 'factory' object for affectors to the list of available affector types.
void | addEmitterFactory (ParticleEmitterFactory *factory)
| Adds a new 'factory' object for emitters to the list of available emitter 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.
ParticleSystem * | createTemplate (const String &name, const String &resourceGroup)
| Create a new particle system template.
ParticleAffectorFactoryIterator | getAffectorFactoryIterator ()
| Return an iterator over the affector factories currently registered.
ParticleEmitterFactoryIterator | getEmitterFactoryIterator ()
| Return an iterator over the emitter factories currently registered.
Real | getLoadingOrder () const override
| Gets the relative loading order of scripts of this type.
ParticleRendererFactoryIterator | getRendererFactoryIterator ()
| Return an iterator over the renderer factories currently registered.
const StringVector & | getScriptPatterns () const override
| Gets the file patterns which should be used to find scripts for this class.
Real | getSimulationTickRate () const
| See setSimulationTickRate()
ParticleSystem * | getTemplate (const String &name)
| Retrieves a particle system template for possible modification.
ParticleSystemTemplateIterator | getTemplateIterator ()
| Gets an iterator over the list of particle system templates.
void | parseScript (DataStreamPtr &stream, const String &groupName) override
| Parse a script file.
void | removeAllTemplates (bool deleteTemplate=true)
| Removes a specified template from the ParticleSystemManager.
void | removeTemplate (const String &name, bool deleteTemplate=true)
| Removes a specified template from the ParticleSystemManager.
void | removeTemplatesByResourceGroup (const String &resourceGroup)
| Removes all templates that belong to a secific Resource Group from the ParticleSystemManager.
void | setSimulationTickRate (Real tickRate)
| Sets the simulation tick rate.
Public Member Functions inherited from Ogre::Singleton< ParticleSystemManager >
| Singleton ()
| ~Singleton ()
Public Member Functions inherited from Ogre::ScriptLoader
virtual | ~ScriptLoader ()

## Static Public Member Functions
static ParticleSystemManager & | getSingleton ()
| Override standard Singleton retrieval.
static ParticleSystemManager * | getSingletonPtr ()
| Override standard Singleton retrieval.
Static Public Member Functions inherited from Ogre::Singleton< ParticleSystemManager >
static ParticleSystemManager & | getSingleton ()
static ParticleSystemManager * | getSingletonPtr ()

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

## Member Typedef Documentation

## ◆ ParticleAffectorFactoryIterator

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

## ◆ ParticleAffectorFactoryMap

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

## ◆ ParticleEmitterFactoryIterator

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

## ◆ ParticleEmitterFactoryMap

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

## ◆ ParticleRendererFactoryIterator

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

## ◆ ParticleSystemRendererFactoryMap

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

## ◆ ParticleSystemTemplateIterator

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

## ◆ ParticleTemplateMap

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

## Constructor & Destructor Documentation

## ◆ ParticleSystemManager()

Ogre::ParticleSystemManager::ParticleSystemManager | ( |  | ) |

Referenced by getSingleton(), and getSingletonPtr().

## ◆ ~ParticleSystemManager()

Ogre::ParticleSystemManager::~ParticleSystemManager | ( |  | ) |
| override

## Member Function Documentation

## ◆ _createAffector()

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

  affectorType | 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

## ◆ _createEmitter()

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

## ◆ _createRenderer()

ParticleSystemRenderer * Ogre::ParticleSystemManager::_createRenderer | ( | const String & | rendererType,
|  | SceneManager * | sceneManager )

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.

## ◆ _destroyAffector()

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.

## ◆ _destroyEmitter()

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.

## ◆ _destroyRenderer()

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.

## ◆ _getFactory()

ParticleSystemFactory * Ogre::ParticleSystemManager::_getFactory | ( |  | ) |
| inline

Get an instance of ParticleSystemFactory (internal use).

References ParticleSystemFactory.

## ◆ _initialise()

void Ogre::ParticleSystemManager::_initialise | ( |  | ) |

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.

## ◆ addAffectorFactory()

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

## ◆ addEmitterFactory()

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

## ◆ addRendererFactory()

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

## ◆ addTemplate()

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.

## ◆ createTemplate()

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.

## ◆ getAffectorFactoryIterator()

ParticleAffectorFactoryIterator Ogre::ParticleSystemManager::getAffectorFactoryIterator | ( |  | ) |

Return an iterator over the affector factories currently registered.

## ◆ getEmitterFactoryIterator()

ParticleEmitterFactoryIterator Ogre::ParticleSystemManager::getEmitterFactoryIterator | ( |  | ) |

Return an iterator over the emitter factories currently registered.

## ◆ getLoadingOrder()

Real Ogre::ParticleSystemManager::getLoadingOrder | ( |  | ) | const
| overridevirtual

Gets the relative loading order of scripts of this type.

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.

## ◆ getRendererFactoryIterator()

ParticleRendererFactoryIterator Ogre::ParticleSystemManager::getRendererFactoryIterator | ( |  | ) |

Return an iterator over the renderer factories currently registered.

## ◆ getScriptPatterns()

const StringVector & Ogre::ParticleSystemManager::getScriptPatterns | ( |  | ) | const
| overridevirtual

Gets the file patterns which should be used to find scripts for this class.

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.

## ◆ getSimulationTickRate()

Real Ogre::ParticleSystemManager::getSimulationTickRate | ( |  | ) | const
| inline

See setSimulationTickRate()

## ◆ getSingleton()

static ParticleSystemManager & Ogre::ParticleSystemManager::getSingleton | ( |  | ) |
| 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.

References ParticleSystemManager().

## ◆ getSingletonPtr()

static ParticleSystemManager * Ogre::ParticleSystemManager::getSingletonPtr | ( |  | ) |
| 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.

References ParticleSystemManager().

## ◆ getTemplate()

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.

## ◆ getTemplateIterator()

ParticleSystemTemplateIterator Ogre::ParticleSystemManager::getTemplateIterator | ( |  | ) |
| inline

Gets an iterator over the list of particle system templates.

## ◆ parseScript()

void Ogre::ParticleSystemManager::parseScript | ( | DataStreamPtr & | stream,
|  | const String & | groupName )
| overridevirtual

Parse a script file.

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.

## ◆ removeAllTemplates()

void Ogre::ParticleSystemManager::removeAllTemplates | ( | bool | deleteTemplate = true | ) |

Removes a specified template from the ParticleSystemManager.

Remarks
  This method removes all templates from the ParticleSystemManager.

Parameters

  deleteTemplate | Whether or not to delete the templates before removing them.

## ◆ removeTemplate()

void Ogre::ParticleSystemManager::removeTemplate | ( | const String & | name,
|  | bool | deleteTemplate = true )

Removes a specified template from the ParticleSystemManager.

Remarks
  This method removes a given template from the particle system manager, optionally deleting the template if the deleteTemplate method is called. Throws an exception if the template could not be found.

Parameters

  name | The name of the template to remove.
  deleteTemplate | Whether or not to delete the template before removing it.

## ◆ removeTemplatesByResourceGroup()

void Ogre::ParticleSystemManager::removeTemplatesByResourceGroup | ( | const String & | resourceGroup | ) |

Removes all templates that belong to a secific Resource Group from the ParticleSystemManager.

Remarks
  This method removes all templates that belong in a particular resource group from the ParticleSystemManager.

Parameters

  resourceGroup | Resource group to delete templates for

## ◆ setSimulationTickRate()

void Ogre::ParticleSystemManager::setSimulationTickRate | ( | Real | tickRate | ) |
| inline

Sets the simulation tick rate.

Remarks
  Toggling tickRate from variable to fixed will not affect existing particles, only new ones.

However for particle FXs which were created as fixed tick rate, changes take effect immediately.

Parameters

  tickRate | A value <= 0 means we will use variable rate. That means that if a second has elapsed between two frames, then we will issue a single update() call with 1 second to the particle FXs.

A value > 0 means we will use fixed tick rate / time step. That means that if a second has elapsed between two frames and the value is 0.1f, then we will issue 10 updates of 10ms each to simulate the particle FXs.

Fixed tick rate is much more stable but may consume more resources. It also allows for deterministic simulations, which is impossible with variable rate.

The default value is 0 A sensible value is 1.0 / 60.0 (for 60hz updates)

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

- OgreParticleSystemManager.h