00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 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 00033 namespace Ogre { 00034 00053 class _OgreExport ParticleSystemManager: public Singleton<ParticleSystemManager>, public FrameListener 00054 { 00055 protected: 00056 typedef std::map<String, ParticleSystem> ParticleTemplateMap; 00058 ParticleTemplateMap mSystemTemplates; 00059 00060 typedef std::map<String, ParticleSystem*> ParticleSystemMap; 00062 ParticleSystemMap mSystems; 00063 00064 typedef std::map<String, ParticleEmitterFactory*> ParticleEmitterFactoryMap; 00066 ParticleEmitterFactoryMap mEmitterFactories; 00067 00068 typedef std::map<String, ParticleAffectorFactory*> ParticleAffectorFactoryMap; 00070 ParticleAffectorFactoryMap mAffectorFactories; 00071 00073 Real mTimeFactor; 00074 00076 void parseNewEmitter(const String& type, DataChunk& chunk, ParticleSystem* sys); 00078 void parseNewAffector(const String& type, DataChunk& chunk, ParticleSystem* sys); 00080 void parseAttrib(const String& line, ParticleSystem* sys); 00082 void parseEmitterAttrib(const String& line, ParticleEmitter* sys); 00084 void parseAffectorAttrib(const String& line, ParticleAffector* sys); 00086 void skipToNextCloseBrace(DataChunk& chunk); 00088 void skipToNextOpenBrace(DataChunk& chunk); 00089 public: 00090 00091 ParticleSystemManager(); 00092 virtual ~ParticleSystemManager(); 00093 00111 void addEmitterFactory(ParticleEmitterFactory* factory); 00112 00130 void addAffectorFactory(ParticleAffectorFactory* factory); 00131 00149 void addTemplate(const String& name, const ParticleSystem& sysTemplate); 00150 00160 ParticleSystem* createTemplate(const String& name); 00161 00167 ParticleSystem* getTemplate(const String& name); 00168 00186 ParticleSystem* createSystem(const String& name, unsigned int quota = 500); 00187 00209 ParticleSystem* createSystem(const String& name, const String& templateName, unsigned int quota = 500); 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); 00296 static ParticleSystemManager& getSingleton(void); 00297 00300 void parseScript(DataChunk& chunk); 00301 00304 void parseAllSources(const String& extension = ".particle"); 00305 00310 Real getTimeFactor(void); 00311 00320 void setTimeFactor(Real tf); 00321 00322 }; 00323 00324 } 00325 00326 #endif 00327
Copyright © 2002 by The OGRE Team