Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-2006 Torus Knot Software Ltd
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 You may alternatively use this source under the terms of a specific version of
00025 the OGRE Unrestricted License provided you have obtained such a license from
00026 Torus Knot Software Ltd.
00027 -----------------------------------------------------------------------------
00028 */
00029 #ifndef __ParticleEmitter_H__
00030 #define __ParticleEmitter_H__
00031 
00032 #include "OgrePrerequisites.h"
00033 #include "OgreString.h"
00034 #include "OgreVector3.h"
00035 #include "OgreColourValue.h"
00036 #include "OgreStringInterface.h"
00037 #include "OgreParticleEmitterCommands.h"
00038 #include "OgreParticle.h"
00039 
00040 
00041 namespace Ogre {
00042 
00043 
00066     class _OgreExport ParticleEmitter : public StringInterface, public Particle
00067     {
00068     protected:
00069 
00070         // Command object for setting / getting parameters
00071         static EmitterCommands::CmdAngle msAngleCmd;
00072         static EmitterCommands::CmdColour msColourCmd;
00073         static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd;
00074         static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd;
00075         static EmitterCommands::CmdDirection msDirectionCmd;
00076         static EmitterCommands::CmdEmissionRate msEmissionRateCmd;
00077         static EmitterCommands::CmdMaxTTL msMaxTTLCmd;
00078         static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd;
00079         static EmitterCommands::CmdMinTTL msMinTTLCmd;
00080         static EmitterCommands::CmdMinVelocity msMinVelocityCmd;
00081         static EmitterCommands::CmdPosition msPositionCmd;
00082         static EmitterCommands::CmdTTL msTTLCmd;
00083         static EmitterCommands::CmdVelocity msVelocityCmd;
00084         static EmitterCommands::CmdDuration msDurationCmd;
00085         static EmitterCommands::CmdMinDuration msMinDurationCmd;
00086         static EmitterCommands::CmdMaxDuration msMaxDurationCmd;
00087         static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd;
00088         static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd;
00089         static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd;
00090         static EmitterCommands::CmdName msNameCmd;
00091         static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd;
00092 
00093 
00095         ParticleSystem* mParent;
00097         Vector3 mPosition;
00099         Real mEmissionRate;
00101         String mType;
00103         Vector3 mDirection;
00104         // Notional up vector, just used to speed up generation of variant directions
00105         Vector3 mUp;
00107         Radian mAngle;
00109         Real mMinSpeed;
00111         Real mMaxSpeed;
00113         Real mMinTTL;
00115         Real mMaxTTL;
00117         ColourValue mColourRangeStart;
00119         ColourValue mColourRangeEnd;
00120 
00122         bool mEnabled;
00123 
00125         Real mStartTime;
00127         Real mDurationMin;
00129         Real mDurationMax;
00131         Real mDurationRemain;
00132 
00134         Real mRepeatDelayMin;
00135         Real mRepeatDelayMax;
00137         Real mRepeatDelayRemain;
00138 
00139         // Fractions of particles wanted to be emitted last time
00140         Real mRemainder;
00141 
00143         String mName;
00144 
00146         String mEmittedEmitter;
00147 
00148         // If 'true', this emitter is emitted by another emitter.
00149         // NB. That doesn´t imply that the emitter itself emits other emitters (that could or could not be the case)
00150         bool mEmitted;
00151 
00152         // NB Method below here are to help out people implementing emitters by providing the
00153         // most commonly used approaches as piecemeal methods
00154 
00158         virtual void genEmissionDirection(Vector3& destVector);
00159 
00164         virtual void genEmissionVelocity(Vector3& destVector);
00165 
00167         virtual Real genEmissionTTL(void);
00168 
00170         virtual void genEmissionColour(ColourValue& destColour);
00171 
00173         virtual unsigned short genConstantEmissionCount(Real timeElapsed);
00174 
00183         void addBaseParameters(void);
00184 
00186         void initDurationRepeat(void);
00187 
00188 
00189     public:
00190         ParticleEmitter(ParticleSystem* psys);
00192         virtual ~ParticleEmitter();
00193 
00195         virtual void setPosition(const Vector3& pos);
00196 
00198         virtual const Vector3& getPosition(void) const;
00199 
00209         virtual void setDirection(const Vector3& direction);
00210 
00212         virtual const Vector3& getDirection(void) const;
00213 
00224         virtual void setAngle(const Radian& angle);
00225 #ifndef OGRE_FORCE_ANGLE_TYPES
00226         inline void setAngle(Real angle) {
00227             setAngle ( Angle(angle) );
00228         }
00229 #endif//OGRE_FORCE_ANGLE_TYPES
00230 
00232         virtual const Radian& getAngle(void) const;
00233 
00241         virtual void setParticleVelocity(Real speed);
00242 
00243 
00253         virtual void setParticleVelocity(Real min, Real max);
00255         virtual void setMinParticleVelocity(Real min);
00257         virtual void setMaxParticleVelocity(Real max);
00258 
00260         virtual Real getParticleVelocity(void) const;
00261 
00263         virtual Real getMinParticleVelocity(void) const;
00264 
00266         virtual Real getMaxParticleVelocity(void) const;
00267 
00280         virtual void setEmissionRate(Real particlesPerSecond);
00281 
00283         virtual Real getEmissionRate(void) const;
00284 
00295         virtual void setTimeToLive(Real ttl);
00309         virtual void setTimeToLive(Real minTtl, Real maxTtl);
00310 
00312         virtual void setMinTimeToLive(Real min);
00314         virtual void setMaxTimeToLive(Real max);
00315         
00317         virtual Real getTimeToLive(void) const;
00318 
00320         virtual Real getMinTimeToLive(void) const;
00322         virtual Real getMaxTimeToLive(void) const;
00323 
00331         virtual void setColour(const ColourValue& colour);
00341         virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
00343         virtual void setColourRangeStart(const ColourValue& colour);
00345         virtual void setColourRangeEnd(const ColourValue& colour);
00347         virtual const ColourValue& getColour(void) const;
00349         virtual const ColourValue& getColourRangeStart(void) const;
00351         virtual const ColourValue& getColourRangeEnd(void) const;
00352 
00365         virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
00366 
00376         virtual void _initParticle(Particle* pParticle) {
00377             // Initialise size incase it's been altered
00378             pParticle->resetDimensions();
00379         }
00380 
00381 
00387         const String &getType(void) const { return mType; }
00388 
00393         virtual void setEnabled(bool enabled);
00394 
00396         virtual bool getEnabled(void) const;
00397 
00405         virtual void setStartTime(Real startTime);
00407         virtual Real getStartTime(void) const;
00408 
00420         virtual void setDuration(Real duration);
00421 
00423         virtual Real getDuration(void) const;
00424 
00436         virtual void setDuration(Real min, Real max);
00438         virtual void setMinDuration(Real min);
00440         virtual void setMaxDuration(Real max);
00442         virtual Real getMinDuration(void) const;
00444         virtual Real getMaxDuration(void) const;
00445 
00455         virtual void setRepeatDelay(Real duration);
00456 
00458         virtual Real getRepeatDelay(void) const;
00459 
00471         virtual void setRepeatDelay(Real min, Real max);
00473         virtual void setMinRepeatDelay(Real min);
00475         virtual void setMaxRepeatDelay(Real max);
00477         virtual Real getMinRepeatDelay(void) const;
00479         virtual Real getMaxRepeatDelay(void) const;
00480 
00482         const String &getName(void) const;
00483 
00485         virtual void setName(const String& newName);
00486 
00488         const String &getEmittedEmitter(void) const;
00489 
00491         virtual void setEmittedEmitter(const String& emittedEmitter);
00492 
00494         virtual bool isEmitted(void) const;
00495 
00497         virtual void setEmitted(bool emitted);
00498 
00499 
00500     };
00501 
00502 }
00503 
00504 
00505 #endif
00506 

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 Thu Mar 6 09:46:26 2008