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-2006 Torus Knot Software Ltd
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 You may alternatively use this source under the terms of a specific version of
00025 the OGRE Unrestricted License provided you have obtained such a license from
00026 Torus Knot Software Ltd.
00027 -----------------------------------------------------------------------------
00028 */
00029 #ifndef __ParticleSystemManager_H__
00030 #define __ParticleSystemManager_H__
00031 
00032 
00033 #include "OgrePrerequisites.h"
00034 #include "OgreParticleSystem.h"
00035 #include "OgreFrameListener.h"
00036 #include "OgreSingleton.h"
00037 #include "OgreIteratorWrappers.h"
00038 #include "OgreScriptLoader.h"
00039 #include "OgreResourceGroupManager.h"
00040 
00041 namespace Ogre {
00042 
00043     // Forward decl
00044     class ParticleSystemFactory;
00045     
00071     class _OgreExport ParticleSystemManager: 
00072         public Singleton<ParticleSystemManager>, public ScriptLoader
00073     {
00074         friend class ParticleSystemFactory;
00075     public:
00076         typedef std::map<String, ParticleSystem*> ParticleTemplateMap;
00077         typedef std::map<String, ParticleAffectorFactory*> ParticleAffectorFactoryMap;
00078         typedef std::map<String, ParticleEmitterFactory*> ParticleEmitterFactoryMap;
00079         typedef std::map<String, ParticleSystemRendererFactory*> ParticleSystemRendererFactoryMap;
00080     protected:
00081         OGRE_AUTO_MUTEX
00083         ParticleTemplateMap mSystemTemplates;
00084         
00086         ParticleEmitterFactoryMap mEmitterFactories;
00087 
00089         ParticleAffectorFactoryMap mAffectorFactories;
00090 
00092         ParticleSystemRendererFactoryMap mRendererFactories;
00093 
00094         StringVector mScriptPatterns;
00095 
00096         // Factory instance
00097         ParticleSystemFactory* mFactory;
00098 
00100         void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00102         void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00104         void parseAttrib(const String& line, ParticleSystem* sys);
00106         void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
00108         void parseAffectorAttrib(const String& line, ParticleAffector* sys);
00110         void skipToNextCloseBrace(DataStreamPtr& chunk);
00112         void skipToNextOpenBrace(DataStreamPtr& chunk);
00113 
00115         ParticleSystem* createSystemImpl(const String& name, size_t quota, 
00116             const String& resourceGroup);
00118         ParticleSystem* createSystemImpl(const String& name, const String& templateName);
00120         void destroySystemImpl(ParticleSystem* sys);
00121         
00122         
00123     public:
00124 
00125         ParticleSystemManager();
00126         virtual ~ParticleSystemManager();
00127 
00145         void addEmitterFactory(ParticleEmitterFactory* factory);
00146 
00164         void addAffectorFactory(ParticleAffectorFactory* factory);
00165 
00174         void addRendererFactory(ParticleSystemRendererFactory* factory);
00175 
00192         void addTemplate(const String& name, ParticleSystem* sysTemplate);
00193 
00204         void removeTemplate(const String& name, bool deleteTemplate = true);
00205 
00212         void removeAllTemplates(bool deleteTemplate = true);
00213 
00226         ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
00227 
00233         ParticleSystem* getTemplate(const String& name);
00234 
00245         ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
00246 
00255         void _destroyEmitter(ParticleEmitter* emitter);
00256 
00267         ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
00268 
00277         void _destroyAffector(ParticleAffector* affector);
00278 
00287         ParticleSystemRenderer* _createRenderer(const String& rendererType);
00288 
00297         void _destroyRenderer(ParticleSystemRenderer* renderer);
00298 
00304         void _initialise(void);
00305 
00307         const StringVector& getScriptPatterns(void) const;
00309         void parseScript(DataStreamPtr& stream, const String& groupName);
00311         Real getLoadingOrder(void) const;
00312 
00313         typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator;
00314         typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator;
00315         typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator;
00317         ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
00319         ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
00321         ParticleRendererFactoryIterator getRendererFactoryIterator(void);
00322 
00323 
00324         typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator;
00326         ParticleSystemTemplateIterator getTemplateIterator(void)
00327         {
00328             return ParticleSystemTemplateIterator(
00329                 mSystemTemplates.begin(), mSystemTemplates.end());
00330         } 
00331 
00333         ParticleSystemFactory* _getFactory(void) { return mFactory; }
00334         
00350         static ParticleSystemManager& getSingleton(void);
00366         static ParticleSystemManager* getSingletonPtr(void);
00367 
00368     };
00369 
00371     class _OgreExport ParticleSystemFactory : public MovableObjectFactory
00372     {
00373     protected:
00374         MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params);
00375     public:
00376         ParticleSystemFactory() {}
00377         ~ParticleSystemFactory() {}
00378         
00379         static String FACTORY_TYPE_NAME;
00380 
00381         const String& getType(void) const;
00382         void destroyInstance( MovableObject* obj);  
00383 
00384     };
00385     
00386 }
00387 
00388 #endif
00389 

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 Sat May 10 16:25:01 2008