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 00132 00133 // NB Method below here are to help out people implementing emitters by providing the 00134 // most commonly used approaches as piecemeal methods 00135 00139 virtual void genEmissionDirection(Vector3& destVector); 00140 00145 virtual void genEmissionVelocity(Vector3& destVector); 00146 00148 virtual Real genEmissionTTL(void); 00149 00151 virtual void genEmissionColour(ColourValue& destColour); 00152 00154 virtual unsigned short genConstantEmissionCount(Real timeElapsed); 00155 00164 void addBaseParameters(void); 00165 00167 void initDurationRepeat(void); 00168 00169 00170 public: 00171 ParticleEmitter(); 00173 virtual ~ParticleEmitter(); 00174 00176 virtual void setPosition(const Vector3& pos); 00177 00179 virtual const Vector3& getPosition(void) const; 00180 00190 virtual void setDirection(const Vector3& direction); 00191 00193 virtual const Vector3& getDirection(void) const; 00194 00205 virtual void setAngle(Real degrees); 00206 00208 virtual Real getAngle(void) const; 00209 00217 virtual void setParticleVelocity(Real speed); 00218 00219 00229 virtual void setParticleVelocity(Real min, Real max); 00231 virtual void setMinParticleVelocity(Real min); 00233 virtual void setMaxParticleVelocity(Real max); 00234 00236 virtual Real getParticleVelocity(void) const; 00237 00239 virtual Real getMinParticleVelocity(void) const; 00240 00242 virtual Real getMaxParticleVelocity(void) const; 00243 00256 virtual void setEmissionRate(Real particlesPerSecond); 00257 00259 virtual Real getEmissionRate(void) const; 00260 00271 virtual void setTimeToLive(Real ttl); 00285 virtual void setTimeToLive(Real minTtl, Real maxTtl); 00286 00288 virtual void setMinTimeToLive(Real min); 00290 virtual void setMaxTimeToLive(Real max); 00291 00293 virtual Real getTimeToLive(void) const; 00294 00296 virtual Real getMinTimeToLive(void) const; 00298 virtual Real getMaxTimeToLive(void) const; 00299 00307 virtual void setColour(const ColourValue& colour); 00317 virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd); 00319 virtual void setColourRangeStart(const ColourValue& colour); 00321 virtual void setColourRangeEnd(const ColourValue& colour); 00323 virtual const ColourValue& getColour(void) const; 00325 virtual const ColourValue& getColourRangeStart(void) const; 00327 virtual const ColourValue& getColourRangeEnd(void) const; 00328 00341 virtual unsigned short _getEmissionCount(Real timeElapsed) = 0; 00342 00352 virtual void _initParticle(Particle* pParticle) { 00353 // Initialise size incase it's been altered 00354 pParticle->resetDimensions(); 00355 } 00356 00357 00363 String getType(void) { return mType; } 00364 00369 virtual void setEnabled(bool enabled); 00370 00372 virtual bool getEnabled(void) const; 00373 00381 virtual void setStartTime(Real startTime); 00383 virtual Real getStartTime(void) const; 00384 00396 virtual void setDuration(Real duration); 00397 00399 virtual Real getDuration(void) const; 00400 00412 virtual void setDuration(Real min, Real max); 00414 virtual void setMinDuration(Real min); 00416 virtual void setMaxDuration(Real max); 00418 virtual Real getMinDuration(void) const; 00420 virtual Real getMaxDuration(void) const; 00421 00431 virtual void setRepeatDelay(Real duration); 00432 00434 virtual Real getRepeatDelay(void) const; 00435 00447 virtual void setRepeatDelay(Real min, Real max); 00449 virtual void setMinRepeatDelay(Real min); 00451 virtual void setMaxRepeatDelay(Real max); 00453 virtual Real getMinRepeatDelay(void) const; 00455 virtual Real getMaxRepeatDelay(void) const; 00456 00457 00458 00459 }; 00460 00461 } 00462 00463 00464 #endif 00465
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:20 2004