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-2013 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 #include "OgreHeaderPrefix.h"
00040 
00041 namespace Ogre {
00042 
00043     // Forward decl
00044     class ParticleSystemFactory;
00045     
00077     class _OgreExport ParticleSystemManager: 
00078         public Singleton<ParticleSystemManager>, public ScriptLoader, public FXAlloc
00079     {
00080         friend class ParticleSystemFactory;
00081     public:
00082         typedef map<String, ParticleSystem*>::type ParticleTemplateMap;
00083         typedef map<String, ParticleAffectorFactory*>::type ParticleAffectorFactoryMap;
00084         typedef map<String, ParticleEmitterFactory*>::type ParticleEmitterFactoryMap;
00085         typedef map<String, ParticleSystemRendererFactory*>::type ParticleSystemRendererFactoryMap;
00086     protected:
00087         OGRE_AUTO_MUTEX;
00088             
00090         ParticleTemplateMap mSystemTemplates;
00091         
00093         ParticleEmitterFactoryMap mEmitterFactories;
00094 
00096         ParticleAffectorFactoryMap mAffectorFactories;
00097 
00099         ParticleSystemRendererFactoryMap mRendererFactories;
00100 
00101         StringVector mScriptPatterns;
00102 
00103         // Factory instance
00104         ParticleSystemFactory* mFactory;
00105 
00107         void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00109         void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00111         void parseAttrib(const String& line, ParticleSystem* sys);
00113         void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
00115         void parseAffectorAttrib(const String& line, ParticleAffector* sys);
00117         void skipToNextCloseBrace(DataStreamPtr& chunk);
00119         void skipToNextOpenBrace(DataStreamPtr& chunk);
00120 
00122         ParticleSystem* createSystemImpl(const String& name, size_t quota, 
00123             const String& resourceGroup);
00125         ParticleSystem* createSystemImpl(const String& name, const String& templateName);
00127         void destroySystemImpl(ParticleSystem* sys);
00128         
00129         
00130     public:
00131 
00132         ParticleSystemManager();
00133         virtual ~ParticleSystemManager();
00134 
00152         void addEmitterFactory(ParticleEmitterFactory* factory);
00153 
00171         void addAffectorFactory(ParticleAffectorFactory* factory);
00172 
00181         void addRendererFactory(ParticleSystemRendererFactory* factory);
00182 
00199         void addTemplate(const String& name, ParticleSystem* sysTemplate);
00200 
00211         void removeTemplate(const String& name, bool deleteTemplate = true);
00212 
00219         void removeAllTemplates(bool deleteTemplate = true);
00220 
00221 
00228         void removeTemplatesByResourceGroup(const String& resourceGroup);
00229 
00242         ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
00243 
00249         ParticleSystem* getTemplate(const String& name);
00250 
00261         ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
00262 
00271         void _destroyEmitter(ParticleEmitter* emitter);
00272 
00283         ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
00284 
00293         void _destroyAffector(ParticleAffector* affector);
00294 
00303         ParticleSystemRenderer* _createRenderer(const String& rendererType);
00304 
00313         void _destroyRenderer(ParticleSystemRenderer* renderer);
00314 
00320         void _initialise(void);
00321 
00323         const StringVector& getScriptPatterns(void) const;
00325         void parseScript(DataStreamPtr& stream, const String& groupName);
00327         Real getLoadingOrder(void) const;
00328 
00329         typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator;
00330         typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator;
00331         typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator;
00333         ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
00335         ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
00337         ParticleRendererFactoryIterator getRendererFactoryIterator(void);
00338 
00339 
00340         typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator;
00342         ParticleSystemTemplateIterator getTemplateIterator(void)
00343         {
00344             return ParticleSystemTemplateIterator(
00345                 mSystemTemplates.begin(), mSystemTemplates.end());
00346         } 
00347 
00349         ParticleSystemFactory* _getFactory(void) { return mFactory; }
00350         
00366         static ParticleSystemManager& getSingleton(void);
00382         static ParticleSystemManager* getSingletonPtr(void);
00383 
00384     };
00385 
00387     class _OgreExport ParticleSystemFactory : public MovableObjectFactory
00388     {
00389     protected:
00390         MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params);
00391     public:
00392         ParticleSystemFactory() {}
00393         ~ParticleSystemFactory() {}
00394         
00395         static String FACTORY_TYPE_NAME;
00396 
00397         const String& getType(void) const;
00398         void destroyInstance( MovableObject* obj);  
00399 
00400     };
00404 }
00405 
00406 #include "OgreHeaderSuffix.h"
00407 
00408 #endif
00409 

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:44