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

OgreParticleSystemManager.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE 
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under 
00011 the terms of the GNU Lesser General Public License as published by the Free Software 
00012 Foundation; either version 2 of the License, or (at your option) any later 
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT 
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with 
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __ParticleSystemManager_H__
00026 #define __ParticleSystemManager_H__
00027 
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreParticleSystem.h"
00031 #include "OgreFrameListener.h"
00032 #include "OgreSingleton.h"
00033 #include "OgreIteratorWrappers.h"
00034 #include "OgreScriptLoader.h"
00035 #include "OgreResourceGroupManager.h"
00036 
00037 namespace Ogre {
00038 
00039     // Forward decl
00040     class ParticleSystemFactory;
00041     
00067     class _OgreExport ParticleSystemManager: 
00068         public Singleton<ParticleSystemManager>, public ScriptLoader
00069     {
00070         friend class ParticleSystemFactory;
00071     public:
00072         typedef std::map<String, ParticleSystem*> ParticleTemplateMap;
00073         typedef std::map<String, ParticleAffectorFactory*> ParticleAffectorFactoryMap;
00074         typedef std::map<String, ParticleEmitterFactory*> ParticleEmitterFactoryMap;
00075         typedef std::map<String, ParticleSystemRendererFactory*> ParticleSystemRendererFactoryMap;
00076     protected:
00078         ParticleTemplateMap mSystemTemplates;
00079         
00081         ParticleEmitterFactoryMap mEmitterFactories;
00082 
00084         ParticleAffectorFactoryMap mAffectorFactories;
00085 
00087         ParticleSystemRendererFactoryMap mRendererFactories;
00088 
00089         StringVector mScriptPatterns;
00090 
00091         // Factory instance
00092         ParticleSystemFactory* mFactory;
00093 
00095         void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00097         void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00099         void parseAttrib(const String& line, ParticleSystem* sys);
00101         void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
00103         void parseAffectorAttrib(const String& line, ParticleAffector* sys);
00105         void skipToNextCloseBrace(DataStreamPtr& chunk);
00107         void skipToNextOpenBrace(DataStreamPtr& chunk);
00108 
00110         ParticleSystem* createSystemImpl(const String& name, size_t quota, 
00111             const String& resourceGroup);
00113         ParticleSystem* createSystemImpl(const String& name, const String& templateName);
00115         void destroySystemImpl(ParticleSystem* sys);
00116         
00117         
00118     public:
00119 
00120         ParticleSystemManager();
00121         virtual ~ParticleSystemManager();
00122 
00140         void addEmitterFactory(ParticleEmitterFactory* factory);
00141 
00159         void addAffectorFactory(ParticleAffectorFactory* factory);
00160 
00169         void addRendererFactory(ParticleSystemRendererFactory* factory);
00170 
00187         void addTemplate(const String& name, ParticleSystem* sysTemplate);
00188 
00201         ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
00202 
00208         ParticleSystem* getTemplate(const String& name);
00209 
00220         ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
00221 
00230         void _destroyEmitter(ParticleEmitter* emitter);
00231 
00242         ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
00243 
00252         void _destroyAffector(ParticleAffector* affector);
00253 
00262         ParticleSystemRenderer* _createRenderer(const String& rendererType);
00263 
00272         void _destroyRenderer(ParticleSystemRenderer* renderer);
00273 
00279         void _initialise(void);
00280 
00282         const StringVector& getScriptPatterns(void) const;
00284         void parseScript(DataStreamPtr& stream, const String& groupName);
00286         Real getLoadingOrder(void) const;
00287 
00288         typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator;
00289         typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator;
00290         typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator;
00292         ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
00294         ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
00296         ParticleRendererFactoryIterator getRendererFactoryIterator(void);
00297 
00298 
00299         typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator;
00301         ParticleSystemTemplateIterator getTemplateIterator(void)
00302         {
00303             return ParticleSystemTemplateIterator(
00304                 mSystemTemplates.begin(), mSystemTemplates.end());
00305         } 
00306 
00308         ParticleSystemFactory* _getFactory(void) { return mFactory; }
00309         
00325         static ParticleSystemManager& getSingleton(void);
00341         static ParticleSystemManager* getSingletonPtr(void);
00342 
00343     };
00344 
00346     class _OgreExport ParticleSystemFactory : public MovableObjectFactory
00347     {
00348     protected:
00349         MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params);
00350     public:
00351         ParticleSystemFactory() {}
00352         ~ParticleSystemFactory() {}
00353         
00354         static String FACTORY_TYPE_NAME;
00355 
00356         const String& getType(void) const;
00357         void destroyInstance( MovableObject* obj);  
00358 
00359     };
00360     
00361 }
00362 
00363 #endif
00364 

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 Nov 12 10:50:12 2006