OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreParticleSystemManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __ParticleSystemManager_H__
29 #define __ParticleSystemManager_H__
30 
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreSingleton.h"
34 #include "OgreScriptLoader.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
39 
40  // Forward decl
41  class ParticleSystemFactory;
42 
75  public Singleton<ParticleSystemManager>, public ScriptLoader, public FXAlloc
76  {
77  friend class ParticleSystemFactory;
78  public:
83  protected:
85 
88 
91 
94 
97 
99 
100  // Factory instance
102 
104 
106  void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
108  void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
110  void parseAttrib(const String& line, ParticleSystem* sys);
112  void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
114  void parseAffectorAttrib(const String& line, ParticleAffector* sys);
116  void skipToNextCloseBrace(DataStreamPtr& chunk);
118  void skipToNextOpenBrace(DataStreamPtr& chunk);
119 
121  ParticleSystem* createSystemImpl(IdType id, ObjectMemoryManager *objectMemoryManager,
122  size_t quota, const String& resourceGroup);
124  ParticleSystem* createSystemImpl(IdType id, ObjectMemoryManager *objectMemoryManager,
125  const String& templateName);
127  void destroySystemImpl(ParticleSystem* sys);
128 
129 
130  public:
131 
133  virtual ~ParticleSystemManager();
134 
152  void addEmitterFactory(ParticleEmitterFactory* factory);
153 
171  void addAffectorFactory(ParticleAffectorFactory* factory);
172 
181  void addRendererFactory(ParticleSystemRendererFactory* factory);
182 
199  void addTemplate(const String& name, ParticleSystem* sysTemplate);
200 
211  void removeTemplate(const String& name, bool deleteTemplate = true);
212 
219  void removeAllTemplates(bool deleteTemplate = true);
220 
221 
228  void removeTemplatesByResourceGroup(const String& resourceGroup);
229 
242  ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
243 
249  ParticleSystem* getTemplate(const String& name);
250 
261  ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
262 
271  void _destroyEmitter(ParticleEmitter* emitter);
272 
283  ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
284 
293  void _destroyAffector(ParticleAffector* affector);
294 
303  ParticleSystemRenderer* _createRenderer(const String& rendererType);
304 
313  void _destroyRenderer(ParticleSystemRenderer* renderer);
314 
320  void _initialise(void);
321 
323  const StringVector& getScriptPatterns(void) const;
325  void parseScript(DataStreamPtr& stream, const String& groupName);
327  Real getLoadingOrder(void) const;
328 
333  ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
335  ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
337  ParticleRendererFactoryIterator getRendererFactoryIterator(void);
338 
339 
343  {
345  mSystemTemplates.begin(), mSystemTemplates.end());
346  }
347 
349  ParticleSystemFactory* _getFactory(void) { return mFactory; }
350 
366  static ParticleSystemManager& getSingleton(void);
382  static ParticleSystemManager* getSingletonPtr(void);
383 
384  };
385 
388  {
389  protected:
390  virtual MovableObject* createInstanceImpl( IdType id, ObjectMemoryManager *objectMemoryManager,
391  const NameValuePairList* params = 0 );
392  public:
395 
397 
398  const String& getType(void) const;
399  void destroyInstance( MovableObject* obj);
400 
401  };
405 }
406 
407 #include "OgreHeaderSuffix.h"
408 
409 #endif
410 
Class defining particle system based special effects.
ParticleSystemTemplateIterator getTemplateIterator(void)
Gets an iterator over the list of particle system templates.
MapIterator< ParticleEmitterFactoryMap > ParticleEmitterFactoryIterator
float Real
Software floating point type.
Abstract class defining the interface to be implemented by creators of ParticleEmitter subclasses...
Abstract class defining the interface required to be implemented by classes which provide rendering c...
#define _OgreExport
Definition: OgrePlatform.h:255
ParticleTemplateMap mSystemTemplates
Templates based on scripts.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
MapIterator< ParticleSystemRendererFactoryMap > ParticleRendererFactoryIterator
ParticleSystemFactory * _getFactory(void)
Get an instance of ParticleSystemFactory (internal use).
Abstract class definition of a factory object for ParticleSystemRenderer.
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue.
Abstract class defining a movable object in a scene.
map< String, ParticleAffectorFactory * >::type ParticleAffectorFactoryMap
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
map< String, ParticleEmitterFactory * >::type ParticleEmitterFactoryMap
Abstract class defining the interface used by classes which wish to perform script loading to define ...
map< String, ParticleSystem * >::type ParticleTemplateMap
Ogre::uint32 IdType
Big projects with lots, lots of units for very long periods of time (MMORPGs?) may want to define thi...
Definition: OgreId.h:36
map< String, ParticleSystemRendererFactory * >::type ParticleSystemRendererFactoryMap
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
vector< String >::type StringVector
Abstract class defining the interface to be implemented by particle emitters.
Manages particle systems, particle system scripts (templates) and the available emitter & affector fa...
ParticleAffectorFactoryMap mAffectorFactories
Factories for named affector types (can be extended using plugins)
Abstract class defining the interface to be implemented by particle affectors.
Abstract class defining the interface to be implemented by creators of ParticleAffector subclasses...
ParticleEmitterFactoryMap mEmitterFactories
Factories for named emitter types (can be extended using plugins)
_StringBase String
Definition: OgreCommon.h:53
ParticleSystemRendererFactoryMap mRendererFactories
Map of renderer types to factories.
MapIterator< ParticleTemplateMap > ParticleSystemTemplateIterator
Factory object for creating ParticleSystem instances.
MapIterator< ParticleAffectorFactoryMap > ParticleAffectorFactoryIterator