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         Radian 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(const Radian& angle);
    00207 #ifndef OGRE_FORCE_ANGLE_TYPES
    00208         inline void setAngle(Real angle) {
    00209             setAngle ( Angle(angle) );
    00210         }
    00211 #endif//OGRE_FORCE_ANGLE_TYPES
    00212
    00214         virtual const Radian& getAngle(void) const;
    00215
    00223         virtual void setParticleVelocity(Real speed);
    00224
    00225
    00235         virtual void setParticleVelocity(Real min, Real max);
    00237         virtual void setMinParticleVelocity(Real min);
    00239         virtual void setMaxParticleVelocity(Real max);
    00240
    00242         virtual Real getParticleVelocity(void) const;
    00243
    00245         virtual Real getMinParticleVelocity(void) const;
    00246
    00248         virtual Real getMaxParticleVelocity(void) const;
    00249
    00262         virtual void setEmissionRate(Real particlesPerSecond);
    00263
    00265         virtual Real getEmissionRate(void) const;
    00266
    00277         virtual void setTimeToLive(Real ttl);
    00291         virtual void setTimeToLive(Real minTtl, Real maxTtl);
    00292
    00294         virtual void setMinTimeToLive(Real min);
    00296         virtual void setMaxTimeToLive(Real max);
    00297
    00299         virtual Real getTimeToLive(void) const;
    00300
    00302         virtual Real getMinTimeToLive(void) const;
    00304         virtual Real getMaxTimeToLive(void) const;
    00305
    00313         virtual void setColour(const ColourValue& colour);
    00323         virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
    00325         virtual void setColourRangeStart(const ColourValue& colour);
    00327         virtual void setColourRangeEnd(const ColourValue& colour);
    00329         virtual const ColourValue& getColour(void) const;
    00331         virtual const ColourValue& getColourRangeStart(void) const;
    00333         virtual const ColourValue& getColourRangeEnd(void) const;
    00334
    00347         virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
    00348
    00358         virtual void _initParticle(Particle* pParticle) {
    00359             // Initialise size incase it's been altered
    00360             pParticle->resetDimensions();
    00361         }
    00362
    00363
    00369         String getType(void) { return mType; }
    00370
    00375         virtual void setEnabled(bool enabled);
    00376
    00378         virtual bool getEnabled(void) const;
    00379
    00387         virtual void setStartTime(Real startTime);
    00389         virtual Real getStartTime(void) const;
    00390
    00402         virtual void setDuration(Real duration);
    00403
    00405         virtual Real getDuration(void) const;
    00406
    00418         virtual void setDuration(Real min, Real max);
    00420         virtual void setMinDuration(Real min);
    00422         virtual void setMaxDuration(Real max);
    00424         virtual Real getMinDuration(void) const;
    00426         virtual Real getMaxDuration(void) const;
    00427
    00437         virtual void setRepeatDelay(Real duration);
    00438
    00440         virtual Real getRepeatDelay(void) const;
    00441
    00453         virtual void setRepeatDelay(Real min, Real max);
    00455         virtual void setMinRepeatDelay(Real min);
    00457         virtual void setMaxRepeatDelay(Real max);
    00459         virtual Real getMinRepeatDelay(void) const;
    00461         virtual Real getMaxRepeatDelay(void) const;
    00462
    00463
    00464
    00465     };
    00466
    00467 }
    00468
    00469
    00470 #endif
    00471

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:37 2004