# 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, public FXAlloc
    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
    00082
    00084         ParticleTemplateMap mSystemTemplates;
    00085
    00087         ParticleEmitterFactoryMap mEmitterFactories;
    00088
    00090         ParticleAffectorFactoryMap mAffectorFactories;
    00091
    00093         ParticleSystemRendererFactoryMap mRendererFactories;
    00094
    00095         StringVector mScriptPatterns;
    00096
    00097         // Factory instance
    00098         ParticleSystemFactory* mFactory;
    00099
    00101         void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
    00103         void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
    00105         void parseAttrib(const String& line, ParticleSystem* sys);
    00107         void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
    00109         void parseAffectorAttrib(const String& line, ParticleAffector* sys);
    00111         void skipToNextCloseBrace(DataStreamPtr& chunk);
    00113         void skipToNextOpenBrace(DataStreamPtr& chunk);
    00114
    00116         ParticleSystem* createSystemImpl(const String& name, size_t quota,
    00117             const String& resourceGroup);
    00119         ParticleSystem* createSystemImpl(const String& name, const String& templateName);
    00121         void destroySystemImpl(ParticleSystem* sys);
    00122
    00123
    00124     public:
    00125
    00126         ParticleSystemManager();
    00127         virtual ~ParticleSystemManager();
    00128
    00146         void addEmitterFactory(ParticleEmitterFactory* factory);
    00147
    00165         void addAffectorFactory(ParticleAffectorFactory* factory);
    00166
    00175         void addRendererFactory(ParticleSystemRendererFactory* factory);
    00176
    00193         void addTemplate(const String& name, ParticleSystem* sysTemplate);
    00194
    00205         void removeTemplate(const String& name, bool deleteTemplate = true);
    00206
    00213         void removeAllTemplates(bool deleteTemplate = true);
    00214
    00227         ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
    00228
    00234         ParticleSystem* getTemplate(const String& name);
    00235
    00246         ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
    00247
    00256         void _destroyEmitter(ParticleEmitter* emitter);
    00257
    00268         ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
    00269
    00278         void _destroyAffector(ParticleAffector* affector);
    00279
    00288         ParticleSystemRenderer* _createRenderer(const String& rendererType);
    00289
    00298         void _destroyRenderer(ParticleSystemRenderer* renderer);
    00299
    00305         void _initialise(void);
    00306
    00308         const StringVector& getScriptPatterns(void) const;
    00310         void parseScript(DataStreamPtr& stream, const String& groupName);
    00312         Real getLoadingOrder(void) const;
    00313
    00314         typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator;
    00315         typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator;
    00316         typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator;
    00318         ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
    00320         ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
    00322         ParticleRendererFactoryIterator getRendererFactoryIterator(void);
    00323
    00324
    00325         typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator;
    00327         ParticleSystemTemplateIterator getTemplateIterator(void)
    00328         {
    00329             return ParticleSystemTemplateIterator(
    00330                 mSystemTemplates.begin(), mSystemTemplates.end());
    00331         }
    00332
    00334         ParticleSystemFactory* _getFactory(void) { return mFactory; }
    00335
    00351         static ParticleSystemManager& getSingleton(void);
    00367         static ParticleSystemManager* getSingletonPtr(void);
    00368
    00369     };
    00370
    00372     class _OgreExport ParticleSystemFactory : public MovableObjectFactory
    00373     {
    00374     protected:
    00375         MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params);
    00376     public:
    00377         ParticleSystemFactory() {}
    00378         ~ParticleSystemFactory() {}
    00379
    00380         static String FACTORY_TYPE_NAME;
    00381
    00382         const String& getType(void) const;
    00383         void destroyInstance( MovableObject* obj);
    00384
    00385     };
    00386
    00387 }
    00388
    00389 #endif
    00390

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat Apr 11 14:26:44 2009