Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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 (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 __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         ParticleSystem* mParent;
00091         Vector3 mPosition;
00093         Real mEmissionRate;
00095         String mType;
00097         Vector3 mDirection;
00098         // Notional up vector, just used to speed up generation of variant directions
00099         Vector3 mUp;
00101         Radian mAngle;
00103         Real mMinSpeed;
00105         Real mMaxSpeed;
00107         Real mMinTTL;
00109         Real mMaxTTL;
00111         ColourValue mColourRangeStart;
00113         ColourValue mColourRangeEnd;
00114 
00116         bool mEnabled;
00117 
00119         Real mStartTime;
00121         Real mDurationMin;
00123         Real mDurationMax;
00125         Real mDurationRemain;
00126 
00128         Real mRepeatDelayMin;
00129         Real mRepeatDelayMax;
00131         Real mRepeatDelayRemain;
00132 
00133         // Fractions of particles wanted to be emitted last time
00134         Real mRemainder;
00135 
00136         // NB Method below here are to help out people implementing emitters by providing the
00137         // most commonly used approaches as piecemeal methods
00138 
00142         virtual void genEmissionDirection(Vector3& destVector);
00143 
00148         virtual void genEmissionVelocity(Vector3& destVector);
00149 
00151         virtual Real genEmissionTTL(void);
00152 
00154         virtual void genEmissionColour(ColourValue& destColour);
00155 
00157         virtual unsigned short genConstantEmissionCount(Real timeElapsed);
00158 
00167         void addBaseParameters(void);
00168 
00170         void initDurationRepeat(void);
00171 
00172 
00173     public:
00174         ParticleEmitter(ParticleSystem* psys);
00176         virtual ~ParticleEmitter();
00177 
00179         virtual void setPosition(const Vector3& pos);
00180 
00182         virtual const Vector3& getPosition(void) const;
00183 
00193         virtual void setDirection(const Vector3& direction);
00194 
00196         virtual const Vector3& getDirection(void) const;
00197 
00208         virtual void setAngle(const Radian& angle);
00209 #ifndef OGRE_FORCE_ANGLE_TYPES
00210         inline void setAngle(Real angle) {
00211             setAngle ( Angle(angle) );
00212         }
00213 #endif//OGRE_FORCE_ANGLE_TYPES
00214 
00216         virtual const Radian& getAngle(void) const;
00217 
00225         virtual void setParticleVelocity(Real speed);
00226 
00227 
00237         virtual void setParticleVelocity(Real min, Real max);
00239         virtual void setMinParticleVelocity(Real min);
00241         virtual void setMaxParticleVelocity(Real max);
00242 
00244         virtual Real getParticleVelocity(void) const;
00245 
00247         virtual Real getMinParticleVelocity(void) const;
00248 
00250         virtual Real getMaxParticleVelocity(void) const;
00251 
00264         virtual void setEmissionRate(Real particlesPerSecond);
00265 
00267         virtual Real getEmissionRate(void) const;
00268 
00279         virtual void setTimeToLive(Real ttl);
00293         virtual void setTimeToLive(Real minTtl, Real maxTtl);
00294 
00296         virtual void setMinTimeToLive(Real min);
00298         virtual void setMaxTimeToLive(Real max);
00299         
00301         virtual Real getTimeToLive(void) const;
00302 
00304         virtual Real getMinTimeToLive(void) const;
00306         virtual Real getMaxTimeToLive(void) const;
00307 
00315         virtual void setColour(const ColourValue& colour);
00325         virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
00327         virtual void setColourRangeStart(const ColourValue& colour);
00329         virtual void setColourRangeEnd(const ColourValue& colour);
00331         virtual const ColourValue& getColour(void) const;
00333         virtual const ColourValue& getColourRangeStart(void) const;
00335         virtual const ColourValue& getColourRangeEnd(void) const;
00336 
00349         virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
00350 
00360         virtual void _initParticle(Particle* pParticle) {
00361             // Initialise size incase it's been altered
00362             pParticle->resetDimensions();
00363         }
00364 
00365 
00371         const String &getType(void) const { return mType; }
00372 
00377         virtual void setEnabled(bool enabled);
00378 
00380         virtual bool getEnabled(void) const;
00381 
00389         virtual void setStartTime(Real startTime);
00391         virtual Real getStartTime(void) const;
00392 
00404         virtual void setDuration(Real duration);
00405 
00407         virtual Real getDuration(void) const;
00408 
00420         virtual void setDuration(Real min, Real max);
00422         virtual void setMinDuration(Real min);
00424         virtual void setMaxDuration(Real max);
00426         virtual Real getMinDuration(void) const;
00428         virtual Real getMaxDuration(void) const;
00429 
00439         virtual void setRepeatDelay(Real duration);
00440 
00442         virtual Real getRepeatDelay(void) const;
00443 
00455         virtual void setRepeatDelay(Real min, Real max);
00457         virtual void setMinRepeatDelay(Real min);
00459         virtual void setMaxRepeatDelay(Real max);
00461         virtual Real getMinRepeatDelay(void) const;
00463         virtual Real getMaxRepeatDelay(void) const;
00464 
00465 
00466 
00467     };
00468 
00469 }
00470 
00471 
00472 #endif
00473 

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 Mar 12 14:37:45 2006