Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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 
00057     class _OgreExport ParticleSystemManager: public Singleton<ParticleSystemManager>, 
00058         public FrameListener, public ScriptLoader
00059     {
00060     public:
00061         typedef std::map<String, ParticleSystem*> ParticleTemplateMap;
00062         typedef std::map<String, ParticleAffectorFactory*> ParticleAffectorFactoryMap;
00063         typedef std::map<String, ParticleEmitterFactory*> ParticleEmitterFactoryMap;
00064         typedef std::map<String, ParticleSystemRendererFactory*> ParticleSystemRendererFactoryMap;
00065     protected:
00067         ParticleTemplateMap mSystemTemplates;
00068         
00069         typedef std::map<String, ParticleSystem*> ParticleSystemMap;
00071         ParticleSystemMap mSystems;
00072 
00074         ParticleEmitterFactoryMap mEmitterFactories;
00075 
00077         ParticleAffectorFactoryMap mAffectorFactories;
00078 
00080         ParticleSystemRendererFactoryMap mRendererFactories;
00081 
00082         StringVector mScriptPatterns;
00083 
00085         Real mTimeFactor;
00086 
00088         void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00090         void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys);
00092         void parseAttrib(const String& line, ParticleSystem* sys);
00094         void parseEmitterAttrib(const String& line, ParticleEmitter* sys);
00096         void parseAffectorAttrib(const String& line, ParticleAffector* sys);
00098         void skipToNextCloseBrace(DataStreamPtr& chunk);
00100         void skipToNextOpenBrace(DataStreamPtr& chunk);
00101     public:
00102 
00103         ParticleSystemManager();
00104         virtual ~ParticleSystemManager();
00105 
00123         void addEmitterFactory(ParticleEmitterFactory* factory);
00124 
00142         void addAffectorFactory(ParticleAffectorFactory* factory);
00143 
00152         void addRendererFactory(ParticleSystemRendererFactory* factory);
00153 
00170         void addTemplate(const String& name, ParticleSystem* sysTemplate);
00171 
00184         ParticleSystem* createTemplate(const String& name, const String& resourceGroup);
00185 
00191         ParticleSystem* getTemplate(const String& name);
00192 
00212         ParticleSystem* createSystem(const String& name, size_t quota = 500, 
00213             const String& resourceGroup = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
00214 
00234         ParticleSystem* createSystem(const String& name, const String& templateName);
00235 
00243         void destroySystem(const String& name);
00244 
00252         void destroySystem(ParticleSystem* sys);
00253 
00255         ParticleSystem* getSystem(const String& name);
00256 
00257 
00268         ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys);
00269 
00278         void _destroyEmitter(ParticleEmitter* emitter);
00279 
00290         ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys);
00291 
00300         void _destroyAffector(ParticleAffector* affector);
00301 
00310         ParticleSystemRenderer* _createRenderer(const String& rendererType);
00311 
00320         void _destroyRenderer(ParticleSystemRenderer* renderer);
00321 
00323         bool frameStarted(const FrameEvent &evt);
00324 
00326         bool frameEnded(const FrameEvent &evt);
00327 
00333         void _initialise(void);
00334 
00336         const StringVector& getScriptPatterns(void) const;
00338         void parseScript(DataStreamPtr& stream, const String& groupName);
00340         Real getLoadingOrder(void) const;
00341 
00342         typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator;
00343         typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator;
00344         typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator;
00346         ParticleAffectorFactoryIterator getAffectorFactoryIterator(void);
00348         ParticleEmitterFactoryIterator getEmitterFactoryIterator(void);
00350         ParticleRendererFactoryIterator getRendererFactoryIterator(void);
00351 
00352 
00357         Real getTimeFactor(void) const;
00358 
00367         void setTimeFactor(Real tf);
00368 
00369         typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator;
00371         ParticleSystemTemplateIterator getTemplateIterator(void)
00372         {
00373             return ParticleSystemTemplateIterator(
00374                 mSystemTemplates.begin(), mSystemTemplates.end());
00375         } 
00376 
00392         static ParticleSystemManager& getSingleton(void);
00408         static ParticleSystemManager* getSingletonPtr(void);
00409 
00410     };
00411 
00412 }
00413 
00414 #endif
00415 

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 Feb 12 12:59:49 2006