# 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-2009 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028 #ifndef __ParticleSystemManager_H__
    00029 #define __ParticleSystemManager_H__
    00030
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreParticleSystem.h"
    00034 #include "OgreFrameListener.h"
    00035 #include "OgreSingleton.h"
    00036 #include "OgreIteratorWrappers.h"
    00037 #include "OgreScriptLoader.h"
    00038 #include "OgreResourceGroupManager.h"
    00039
    00040 namespace Ogre {
    00041
    00042     // Forward decl
    00043     class ParticleSystemFactory;
    00044
    00076     class _OgreExport ParticleSystemManager:
    00077         public Singleton<ParticleSystemManager>, public ScriptLoader, public FXAlloc
    00078     {
    00079         friend class ParticleSystemFactory;
    00080     public:
    00081         typedef map<String, ParticleSystem*>::type ParticleTemplateMap;
    00082         typedef map<String, ParticleAffectorFactory*>::type ParticleAffectorFactoryMap;
    00083         typedef map<String, ParticleEmitterFactory*>::type ParticleEmitterFactoryMap;
    00084         typedef map<String, ParticleSystemRendererFactory*>::type ParticleSystemRendererFactoryMap;
    00085     protected:
    00086         OGRE_AUTO_MUTEX
    00087
    00089         ParticleTemplateMap mSystemTemplates;
    00090
    00092         ParticleEmitterFactoryMap mEmitterFactories;
    00093
    00095         ParticleAffectorFactoryMap mAffectorFactories;
    00096
    00098         ParticleSystemRendererFactoryMap mRendererFactories;
    00099
    00100         StringVector mScriptPatterns;
    00101
    00102         // Factory instance
    00103         ParticleSystemFactory* mFactory;
    00104
    00106         void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
    00108         void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
    00110         void parseAttrib(const String& line, ParticleSystem* sys);
    00112         void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
    00114         void parseAffectorAttrib(const String& line, ParticleAffector* sys);
    00116         void skipToNextCloseBrace(DataStreamPtr& chunk);
    00118         void skipToNextOpenBrace(DataStreamPtr& chunk);
    00119
    00121         ParticleSystem* createSystemImpl(const String& name, size_t quota,
    00122             const String& resourceGroup);
    00124         ParticleSystem* createSystemImpl(const String& name, const String& templateName);
    00126         void destroySystemImpl(ParticleSystem* sys);
    00127
    00128
    00129     public:
    00130
    00131         ParticleSystemManager();
    00132         virtual ~ParticleSystemManager();
    00133
    00151         void addEmitterFactory(ParticleEmitterFactory* factory);
    00152
    00170         void addAffectorFactory(ParticleAffectorFactory* factory);
    00171
    00180         void addRendererFactory(ParticleSystemRendererFactory* factory);
    00181
    00198         void addTemplate(const String& name, ParticleSystem* sysTemplate);
    00199
    00210         void removeTemplate(const String& name, bool deleteTemplate = true);
    00211
    00218         void removeAllTemplates(bool deleteTemplate = true);
    00219
    00220
    00227         void removeTemplatesByResourceGroup(const String& resourceGroup);
    00228
    00241         ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
    00242
    00248         ParticleSystem* getTemplate(const String& name);
    00249
    00260         ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
    00261
    00270         void _destroyEmitter(ParticleEmitter* emitter);
    00271
    00282         ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
    00283
    00292         void _destroyAffector(ParticleAffector* affector);
    00293
    00302         ParticleSystemRenderer* _createRenderer(const String& rendererType);
    00303
    00312         void _destroyRenderer(ParticleSystemRenderer* renderer);
    00313
    00319         void _initialise(void);
    00320
    00322         const StringVector& getScriptPatterns(void) const;
    00324         void parseScript(DataStreamPtr& stream, const String& groupName);
    00326         Real getLoadingOrder(void) const;
    00327
    00328         typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator;
    00329         typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator;
    00330         typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator;
    00332         ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
    00334         ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
    00336         ParticleRendererFactoryIterator getRendererFactoryIterator(void);
    00337
    00338
    00339         typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator;
    00341         ParticleSystemTemplateIterator getTemplateIterator(void)
    00342         {
    00343             return ParticleSystemTemplateIterator(
    00344                 mSystemTemplates.begin(), mSystemTemplates.end());
    00345         }
    00346
    00348         ParticleSystemFactory* _getFactory(void) { return mFactory; }
    00349
    00365         static ParticleSystemManager& getSingleton(void);
    00381         static ParticleSystemManager* getSingletonPtr(void);
    00382
    00383     };
    00384
    00386     class _OgreExport ParticleSystemFactory : public MovableObjectFactory
    00387     {
    00388     protected:
    00389         MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params);
    00390     public:
    00391         ParticleSystemFactory() {}
    00392         ~ParticleSystemFactory() {}
    00393
    00394         static String FACTORY_TYPE_NAME;
    00395
    00396         const String& getType(void) const;
    00397         void destroyInstance( MovableObject* obj);
    00398
    00399     };
    00403 }
    00404
    00405 #endif
    00406

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52