Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreParticleSystem.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 __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 _OgrePrivate CmdQuota : public ParamCommand
00058         {
00059         public:
00060             String doGet(const void* target) const;
00061             void doSet(void* target, const String& val);
00062         };
00064         class _OgrePrivate CmdMaterial : public ParamCommand
00065         {
00066         public:
00067             String doGet(const void* target) const;
00068             void doSet(void* target, const String& val);
00069         };
00071         class _OgrePrivate CmdCull : public ParamCommand
00072         {
00073         public:
00074             String doGet(const void* target) const;
00075             void doSet(void* target, const String& val);
00076         };
00078         class _OgrePrivate CmdWidth : public ParamCommand
00079         {
00080         public:
00081             String doGet(const void* target) const;
00082             void doSet(void* target, const String& val);
00083         };
00085         class _OgrePrivate CmdHeight : public ParamCommand
00086         {
00087         public:
00088             String doGet(const void* target) const;
00089             void doSet(void* target, const String& val);
00090         };
00092         class _OgrePrivate 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 
00430         void setBounds(const AxisAlignedBox& aabb);
00431 
00448         void setBoundsAutoUpdated(bool autoUpdate, Real stopIn = 0.0f);
00449 
00463         void _updateBounds(void);
00464 
00465     protected:
00466 
00468         static CmdCull msCullCmd;
00469         static CmdHeight msHeightCmd;
00470         static CmdMaterial msMaterialCmd;
00471         static CmdQuota msQuotaCmd;
00472         static CmdWidth msWidthCmd;
00473         static CmdRenderer msRendererCmd;
00474 
00475 
00476         AxisAlignedBox mAABB;
00477         Real mBoundingRadius;
00478         bool mBoundsAutoUpdate;
00479         Real mBoundsUpdateTime;
00480 
00482         AxisAlignedBox mWorldAABB;
00483 
00485         String mName;
00487         String mResourceGroupName;
00489         String mMaterialName;
00491         bool mIsRendererConfigured;
00493         MaterialPtr mpMaterial;
00495         Real mDefaultWidth;
00497         Real mDefaultHeight;
00499         Real mSpeedFactor;
00500 
00501         typedef std::list<Particle*> ActiveParticleList;
00502         typedef std::deque<Particle*> FreeParticleQueue;
00503         typedef std::vector<Particle*> ParticlePool;
00504 
00514         ActiveParticleList mActiveParticles;
00515 
00524         FreeParticleQueue mFreeParticles;
00525 
00530         ParticlePool mParticlePool;
00531 
00532         typedef std::vector<ParticleEmitter*> ParticleEmitterList;
00533         typedef std::vector<ParticleAffector*> ParticleAffectorList;
00534         
00536         ParticleEmitterList mEmitters;
00538         ParticleAffectorList mAffectors;
00539 
00541         ParticleSystemRenderer* mRenderer;
00542 
00544         bool mCullIndividual;
00545 
00547         String mRendererType;
00548         
00550         size_t mPoolSize;
00551 
00553         String mOrigin;
00554 
00555 
00557         void _expire(Real timeElapsed);
00558 
00560         void _triggerEmitters(Real timeElapsed);
00561 
00563         void _applyMotion(Real timeElapsed);
00564 
00566         void _triggerAffectors(Real timeElapsed);
00567 
00569         void increasePool(size_t size);
00570 
00572         void initParameters(void);
00573 
00575         void configureRenderer(void);
00576 
00578         void createVisualParticles(size_t poolstart, size_t poolend);
00580         void destroyVisualParticles(size_t poolstart, size_t poolend);
00581 
00582 
00583     };
00584 
00585 }
00586 
00587 #endif

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