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 __ParticleSystem_H__ 00026 #define __ParticleSystem_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 00030 #include "OgreVector3.h" 00031 #include "OgreString.h" 00032 #include "OgreParticleIterator.h" 00033 #include "OgreStringInterface.h" 00034 #include "OgreMovableObject.h" 00035 00036 namespace Ogre { 00037 00052 class _OgreExport ParticleSystem : public StringInterface, public MovableObject 00053 { 00054 public: 00055 00057 class CmdQuota : public ParamCommand 00058 { 00059 public: 00060 String doGet(const void* target) const; 00061 void doSet(void* target, const String& val); 00062 }; 00064 class CmdMaterial : public ParamCommand 00065 { 00066 public: 00067 String doGet(const void* target) const; 00068 void doSet(void* target, const String& val); 00069 }; 00071 class CmdCull : public ParamCommand 00072 { 00073 public: 00074 String doGet(const void* target) const; 00075 void doSet(void* target, const String& val); 00076 }; 00078 class CmdWidth : public ParamCommand 00079 { 00080 public: 00081 String doGet(const void* target) const; 00082 void doSet(void* target, const String& val); 00083 }; 00085 class CmdHeight : public ParamCommand 00086 { 00087 public: 00088 String doGet(const void* target) const; 00089 void doSet(void* target, const String& val); 00090 }; 00092 class CmdRenderer : public ParamCommand 00093 { 00094 public: 00095 String doGet(const void* target) const; 00096 void doSet(void* target, const String& val); 00097 }; 00098 00100 ParticleSystem(); 00106 ParticleSystem(const String& name, const String& resourceGroupName); 00107 00108 virtual ~ParticleSystem(); 00109 00119 void setRenderer(const String& typeName); 00120 00122 ParticleSystemRenderer* getRenderer(void) const; 00124 const String& getRendererName(void) const; 00125 00135 ParticleEmitter* addEmitter(const String& emitterType); 00136 00146 ParticleEmitter* getEmitter(unsigned short index) const; 00147 00149 unsigned short getNumEmitters(void) const; 00150 00159 void removeEmitter(unsigned short index); 00160 00162 void removeAllEmitters(void); 00163 00164 00174 ParticleAffector* addAffector(const String& affectorType); 00175 00185 ParticleAffector* getAffector(unsigned short index) const; 00186 00188 unsigned short getNumAffectors(void) const; 00189 00198 void removeAffector(unsigned short index); 00199 00201 void removeAllAffectors(void); 00202 00205 void clear(); 00206 00214 size_t getNumParticles(void) const; 00215 00227 Particle* createParticle(void); 00228 00235 Particle* getParticle(size_t index); 00236 00241 size_t getParticleQuota(void) const; 00242 00253 void setParticleQuota(size_t quota); 00254 00255 00261 ParticleSystem& operator=(const ParticleSystem& rhs); 00262 00269 void _update(Real timeElapsed); 00270 00277 ParticleIterator _getIterator(void); 00278 00283 virtual void setMaterialName(const String& name); 00284 00288 virtual const String& getMaterialName(void) const; 00289 00294 virtual void _notifyCurrentCamera(Camera* cam); 00295 00300 void _notifyAttached(Node* parent, bool isTagPoint = false); 00301 00306 virtual const AxisAlignedBox& getBoundingBox(void) const { return mAABB; } 00307 00312 virtual Real getBoundingRadius(void) const { return mBoundingRadius; } 00313 00318 virtual void _updateRenderQueue(RenderQueue* queue); 00319 00321 const String& getName(void) const { return mName; } 00322 00335 void fastForward(Real time, Real interval = 0.1); 00336 00345 void setSpeedFactor(Real speedFactor) { mSpeedFactor = speedFactor; } 00346 00349 Real getSpeedFactor(void) const { return mSpeedFactor; } 00350 00351 00353 const String& getMovableType(void) const; 00354 00357 virtual void _notifyParticleResized(void); 00358 00361 virtual void _notifyParticleRotated(void); 00362 00373 virtual void setDefaultDimensions(Real width, Real height); 00374 00376 virtual void setDefaultWidth(Real width); 00378 virtual Real getDefaultWidth(void) const; 00380 virtual void setDefaultHeight(Real height); 00382 virtual Real getDefaultHeight(void) const; 00384 virtual bool getCullIndividually(void) const; 00405 virtual void setCullIndividually(bool cullIndividual); 00407 virtual const String& getResourceGroupName(void) const { return mResourceGroupName; } 00414 const String& getOrigin(void) const { return mOrigin; } 00416 void _notifyOrigin(const String& origin) { mOrigin = origin; } 00417 00419 void setRenderQueueGroup(RenderQueueGroupID queueID); 00420 00421 00422 protected: 00423 00425 static CmdCull msCullCmd; 00426 static CmdHeight msHeightCmd; 00427 static CmdMaterial msMaterialCmd; 00428 static CmdQuota msQuotaCmd; 00429 static CmdWidth msWidthCmd; 00430 static CmdRenderer msRendererCmd; 00431 00432 00433 AxisAlignedBox mAABB; 00434 Real mBoundingRadius; 00435 bool mBoundsAutoUpdate; 00436 Real mBoundsUpdateTime; 00437 00439 AxisAlignedBox mWorldAABB; 00440 00442 String mName; 00444 String mResourceGroupName; 00446 String mMaterialName; 00448 bool mIsRendererConfigured; 00450 MaterialPtr mpMaterial; 00452 Real mDefaultWidth; 00454 Real mDefaultHeight; 00456 Real mSpeedFactor; 00457 00458 typedef std::list<Particle*> ActiveParticleList; 00459 typedef std::deque<Particle*> FreeParticleQueue; 00460 typedef std::vector<Particle*> ParticlePool; 00461 00471 ActiveParticleList mActiveParticles; 00472 00481 FreeParticleQueue mFreeParticles; 00482 00487 ParticlePool mParticlePool; 00488 00489 typedef std::vector<ParticleEmitter*> ParticleEmitterList; 00490 typedef std::vector<ParticleAffector*> ParticleAffectorList; 00491 00493 ParticleEmitterList mEmitters; 00495 ParticleAffectorList mAffectors; 00496 00498 ParticleSystemRenderer* mRenderer; 00499 00501 bool mCullIndividual; 00502 00504 String mRendererType; 00505 00507 size_t mPoolSize; 00508 00510 String mOrigin; 00511 00512 00514 void _expire(Real timeElapsed); 00515 00517 void _triggerEmitters(Real timeElapsed); 00518 00520 void _applyMotion(Real timeElapsed); 00521 00523 void _triggerAffectors(Real timeElapsed); 00524 00526 void increasePool(size_t size); 00527 00529 void initParameters(void); 00530 00532 void configureRenderer(void); 00533 00535 void createVisualParticles(size_t poolstart, size_t poolend); 00537 void destroyVisualParticles(size_t poolstart, size_t poolend); 00538 00548 void setBounds(const AxisAlignedBox& aabb); 00549 00566 void setBoundsAutoUpdated(bool autoUpdate, Real stopIn = 0.0f); 00567 00581 void _updateBounds(void); 00582 00583 }; 00584 00585 } 00586 00587 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:19 2005