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 © 2000-2002 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 00035 namespace Ogre { 00036 00055 class _OgreExport ParticleSystemManager: public Singleton<ParticleSystemManager>, public FrameListener 00056 { 00057 protected: 00058 typedef std::map<String, ParticleSystem> ParticleTemplateMap; 00060 ParticleTemplateMap mSystemTemplates; 00061 00062 typedef std::map<String, ParticleSystem*> ParticleSystemMap; 00064 ParticleSystemMap mSystems; 00065 00066 typedef std::map<String, ParticleEmitterFactory*> ParticleEmitterFactoryMap; 00068 ParticleEmitterFactoryMap mEmitterFactories; 00069 00070 typedef std::map<String, ParticleAffectorFactory*> ParticleAffectorFactoryMap; 00072 ParticleAffectorFactoryMap mAffectorFactories; 00073 00075 Real mTimeFactor; 00076 00078 void parseNewEmitter(const String& type, DataChunk& chunk, ParticleSystem* sys); 00080 void parseNewAffector(const String& type, DataChunk& chunk, ParticleSystem* sys); 00082 void parseAttrib(const String& line, ParticleSystem* sys); 00084 void parseEmitterAttrib(const String& line, ParticleEmitter* sys); 00086 void parseAffectorAttrib(const String& line, ParticleAffector* sys); 00088 void skipToNextCloseBrace(DataChunk& chunk); 00090 void skipToNextOpenBrace(DataChunk& chunk); 00091 public: 00092 00093 ParticleSystemManager(); 00094 virtual ~ParticleSystemManager(); 00095 00113 void addEmitterFactory(ParticleEmitterFactory* factory); 00114 00132 void addAffectorFactory(ParticleAffectorFactory* factory); 00133 00151 void addTemplate(const String& name, const ParticleSystem& sysTemplate); 00152 00162 ParticleSystem* createTemplate(const String& name); 00163 00169 ParticleSystem* getTemplate(const String& name); 00170 00188 ParticleSystem* createSystem(const String& name, unsigned int quota = 500); 00189 00209 ParticleSystem* createSystem(const String& name, const String& templateName); 00210 00218 void destroySystem(const String& name); 00219 00227 void destroySystem(ParticleSystem* sys); 00228 00230 ParticleSystem* getSystem(const String& name); 00231 00232 00241 ParticleEmitter* _createEmitter(const String& emitterType); 00242 00251 void _destroyEmitter(ParticleEmitter* emitter); 00252 00261 ParticleAffector* _createAffector(const String& affectorType); 00262 00271 void _destroyAffector(ParticleAffector* affector); 00272 00274 bool frameStarted(const FrameEvent &evt); 00275 00277 bool frameEnded(const FrameEvent &evt); 00278 00284 void _initialise(void); 00285 00288 void parseScript(DataChunk& chunk); 00289 00292 void parseAllSources(const String& extension = ".particle"); 00293 00298 Real getTimeFactor(void) const; 00299 00308 void setTimeFactor(Real tf); 00309 00310 typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator; 00312 ParticleSystemTemplateIterator getTemplateIterator(void) 00313 { 00314 return ParticleSystemTemplateIterator( 00315 mSystemTemplates.begin(), mSystemTemplates.end()); 00316 } 00317 00333 static ParticleSystemManager& getSingleton(void); 00349 static ParticleSystemManager* getSingletonPtr(void); 00350 00351 }; 00352 00353 } 00354 00355 #endif 00356
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:38 2004