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 00039 // Forward decl 00040 class ParticleSystemFactory; 00041 00067 class _OgreExport ParticleSystemManager: 00068 public Singleton<ParticleSystemManager>, public ScriptLoader 00069 { 00070 friend class ParticleSystemFactory; 00071 public: 00072 typedef std::map<String, ParticleSystem*> ParticleTemplateMap; 00073 typedef std::map<String, ParticleAffectorFactory*> ParticleAffectorFactoryMap; 00074 typedef std::map<String, ParticleEmitterFactory*> ParticleEmitterFactoryMap; 00075 typedef std::map<String, ParticleSystemRendererFactory*> ParticleSystemRendererFactoryMap; 00076 protected: 00078 ParticleTemplateMap mSystemTemplates; 00079 00081 ParticleEmitterFactoryMap mEmitterFactories; 00082 00084 ParticleAffectorFactoryMap mAffectorFactories; 00085 00087 ParticleSystemRendererFactoryMap mRendererFactories; 00088 00089 StringVector mScriptPatterns; 00090 00091 // Factory instance 00092 ParticleSystemFactory* mFactory; 00093 00095 void parseNewEmitter(const String& type, DataStreamPtr& chunk, ParticleSystem* sys); 00097 void parseNewAffector(const String& type, DataStreamPtr& chunk, ParticleSystem* sys); 00099 void parseAttrib(const String& line, ParticleSystem* sys); 00101 void parseEmitterAttrib(const String& line, ParticleEmitter* sys); 00103 void parseAffectorAttrib(const String& line, ParticleAffector* sys); 00105 void skipToNextCloseBrace(DataStreamPtr& chunk); 00107 void skipToNextOpenBrace(DataStreamPtr& chunk); 00108 00110 ParticleSystem* createSystemImpl(const String& name, size_t quota, 00111 const String& resourceGroup); 00113 ParticleSystem* createSystemImpl(const String& name, const String& templateName); 00115 void destroySystemImpl(ParticleSystem* sys); 00116 00117 00118 public: 00119 00120 ParticleSystemManager(); 00121 virtual ~ParticleSystemManager(); 00122 00140 void addEmitterFactory(ParticleEmitterFactory* factory); 00141 00159 void addAffectorFactory(ParticleAffectorFactory* factory); 00160 00169 void addRendererFactory(ParticleSystemRendererFactory* factory); 00170 00187 void addTemplate(const String& name, ParticleSystem* sysTemplate); 00188 00201 ParticleSystem* createTemplate(const String& name, const String& resourceGroup); 00202 00208 ParticleSystem* getTemplate(const String& name); 00209 00220 ParticleEmitter* _createEmitter(const String& emitterType, ParticleSystem* psys); 00221 00230 void _destroyEmitter(ParticleEmitter* emitter); 00231 00242 ParticleAffector* _createAffector(const String& affectorType, ParticleSystem* psys); 00243 00252 void _destroyAffector(ParticleAffector* affector); 00253 00262 ParticleSystemRenderer* _createRenderer(const String& rendererType); 00263 00272 void _destroyRenderer(ParticleSystemRenderer* renderer); 00273 00275 bool frameStarted(const FrameEvent &evt); 00276 00278 bool frameEnded(const FrameEvent &evt); 00279 00285 void _initialise(void); 00286 00288 const StringVector& getScriptPatterns(void) const; 00290 void parseScript(DataStreamPtr& stream, const String& groupName); 00292 Real getLoadingOrder(void) const; 00293 00294 typedef MapIterator<ParticleAffectorFactoryMap> ParticleAffectorFactoryIterator; 00295 typedef MapIterator<ParticleEmitterFactoryMap> ParticleEmitterFactoryIterator; 00296 typedef MapIterator<ParticleSystemRendererFactoryMap> ParticleRendererFactoryIterator; 00298 ParticleAffectorFactoryIterator getAffectorFactoryIterator(void); 00300 ParticleEmitterFactoryIterator getEmitterFactoryIterator(void); 00302 ParticleRendererFactoryIterator getRendererFactoryIterator(void); 00303 00304 00305 typedef MapIterator<ParticleTemplateMap> ParticleSystemTemplateIterator; 00307 ParticleSystemTemplateIterator getTemplateIterator(void) 00308 { 00309 return ParticleSystemTemplateIterator( 00310 mSystemTemplates.begin(), mSystemTemplates.end()); 00311 } 00312 00314 ParticleSystemFactory* _getFactory(void) { return mFactory; } 00315 00331 static ParticleSystemManager& getSingleton(void); 00347 static ParticleSystemManager* getSingletonPtr(void); 00348 00349 }; 00350 00352 class _OgreExport ParticleSystemFactory : public MovableObjectFactory 00353 { 00354 protected: 00355 MovableObject* createInstanceImpl(const String& name, const NameValuePairList* params); 00356 public: 00357 ParticleSystemFactory() {} 00358 ~ParticleSystemFactory() {} 00359 00360 static String FACTORY_TYPE_NAME; 00361 00362 const String& getType(void) const; 00363 void destroyInstance( MovableObject* obj); 00364 00365 }; 00366 00367 } 00368 00369 #endif 00370
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:46 2006