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

OgreParticleEmitter.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 © 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 __ParticleEmitter_H__
00026 #define __ParticleEmitter_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreString.h"
00030 #include "OgreVector3.h"
00031 #include "OgreColourValue.h"
00032 #include "OgreStringInterface.h"
00033 #include "OgreParticleEmitterCommands.h"
00034 #include "OgreParticle.h"
00035 
00036 
00037 namespace Ogre {
00038 
00039 
00062     class _OgreExport ParticleEmitter : public StringInterface
00063     {
00064     protected:
00065 
00066         // Command object for setting / getting parameters
00067         static EmitterCommands::CmdAngle msAngleCmd;
00068         static EmitterCommands::CmdColour msColourCmd;
00069         static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd;
00070         static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd;
00071         static EmitterCommands::CmdDirection msDirectionCmd;
00072         static EmitterCommands::CmdEmissionRate msEmissionRateCmd;
00073         static EmitterCommands::CmdMaxTTL msMaxTTLCmd;
00074         static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd;
00075         static EmitterCommands::CmdMinTTL msMinTTLCmd;
00076         static EmitterCommands::CmdMinVelocity msMinVelocityCmd;
00077         static EmitterCommands::CmdPosition msPositionCmd;
00078         static EmitterCommands::CmdTTL msTTLCmd;
00079         static EmitterCommands::CmdVelocity msVelocityCmd;
00080         static EmitterCommands::CmdDuration msDurationCmd;
00081         static EmitterCommands::CmdMinDuration msMinDurationCmd;
00082         static EmitterCommands::CmdMaxDuration msMaxDurationCmd;
00083         static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd;
00084         static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd;
00085         static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd;
00086 
00087 
00089         Vector3 mPosition;
00091         Real mEmissionRate;
00093         String mType;
00095         Vector3 mDirection;
00096         // Notional up vector, just used to speed up generation of variant directions
00097         Vector3 mUp;
00099         Real mAngle;
00101         Real mMinSpeed;
00103         Real mMaxSpeed;
00105         Real mMinTTL;
00107         Real mMaxTTL;
00109         ColourValue mColourRangeStart;
00111         ColourValue mColourRangeEnd;
00112 
00114         bool mEnabled;
00115 
00117         Real mStartTime;
00119         Real mDurationMin;
00121         Real mDurationMax;
00123         Real mDurationRemain;
00124 
00126         Real mRepeatDelayMin;
00127         Real mRepeatDelayMax;
00129         Real mRepeatDelayRemain;
00130 
00131         // Fractions of particles wanted to be emitted last time
00132         Real mRemainder;
00133 
00134         // NB Method below here are to help out people implementing emitters by providing the
00135         // most commonly used approaches as piecemeal methods
00136 
00140         virtual void genEmissionDirection(Vector3& destVector);
00141 
00146         virtual void genEmissionVelocity(Vector3& destVector);
00147 
00149         virtual Real genEmissionTTL(void);
00150 
00152         virtual void genEmissionColour(ColourValue& destColour);
00153 
00155         virtual unsigned short genConstantEmissionCount(Real timeElapsed);
00156 
00165         void addBaseParameters(void);
00166 
00168         void initDurationRepeat(void);
00169 
00170 
00171     public:
00172         ParticleEmitter();
00174         virtual ~ParticleEmitter();
00175 
00177         virtual void setPosition(const Vector3& pos);
00178 
00180         virtual const Vector3& getPosition(void) const;
00181 
00191         virtual void setDirection(const Vector3& direction);
00192 
00194         virtual const Vector3& getDirection(void) const;
00195 
00206         virtual void setAngle(Real degrees);
00207 
00209         virtual Real getAngle(void) const;
00210 
00218         virtual void setParticleVelocity(Real speed);
00219 
00220 
00230         virtual void setParticleVelocity(Real min, Real max);
00232         virtual void setMinParticleVelocity(Real min);
00234         virtual void setMaxParticleVelocity(Real max);
00235 
00237         virtual Real getParticleVelocity(void) const;
00238 
00240         virtual Real getMinParticleVelocity(void) const;
00241 
00243         virtual Real getMaxParticleVelocity(void) const;
00244 
00257         virtual void setEmissionRate(Real particlesPerSecond);
00258 
00260         virtual Real getEmissionRate(void) const;
00261 
00272         virtual void setTimeToLive(Real ttl);
00286         virtual void setTimeToLive(Real minTtl, Real maxTtl);
00287 
00289         virtual void setMinTimeToLive(Real min);
00291         virtual void setMaxTimeToLive(Real max);
00292         
00294         virtual Real getTimeToLive(void) const;
00295 
00297         virtual Real getMinTimeToLive(void) const;
00299         virtual Real getMaxTimeToLive(void) const;
00300 
00308         virtual void setColour(const ColourValue& colour);
00318         virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
00320         virtual void setColourRangeStart(const ColourValue& colour);
00322         virtual void setColourRangeEnd(const ColourValue& colour);
00324         virtual const ColourValue& getColour(void) const;
00326         virtual const ColourValue& getColourRangeStart(void) const;
00328         virtual const ColourValue& getColourRangeEnd(void) const;
00329 
00342         virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
00343 
00353         virtual void _initParticle(Particle* pParticle) {
00354             // Initialise size incase it's been altered
00355             pParticle->resetDimensions();
00356         }
00357 
00358 
00364         String getType(void) { return mType; }
00365 
00370         virtual void setEnabled(bool enabled);
00371 
00373         virtual bool getEnabled(void) const;
00374 
00382         virtual void setStartTime(Real startTime);
00384         virtual Real getStartTime(void) const;
00385 
00397         virtual void setDuration(Real duration);
00398 
00400         virtual Real getDuration(void) const;
00401 
00413         virtual void setDuration(Real min, Real max);
00415         virtual void setMinDuration(Real min);
00417         virtual void setMaxDuration(Real max);
00419         virtual Real getMinDuration(void) const;
00421         virtual Real getMaxDuration(void) const;
00422 
00432         virtual void setRepeatDelay(Real duration);
00433 
00435         virtual Real getRepeatDelay(void) const;
00436 
00448         virtual void setRepeatDelay(Real min, Real max);
00450         virtual void setMinRepeatDelay(Real min);
00452         virtual void setMaxRepeatDelay(Real max);
00454         virtual Real getMinRepeatDelay(void) const;
00456         virtual Real getMaxRepeatDelay(void) const;
00457 
00458 
00459 
00460     };
00461 
00462 }
00463 
00464 
00465 #endif
00466 

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:31 2004