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 00227 virtual const Radian& getAngle(void) const; 00228 00236 virtual void setParticleVelocity(Real speed); 00237 00238 00248 virtual void setParticleVelocity(Real min, Real max); 00250 virtual void setMinParticleVelocity(Real min); 00252 virtual void setMaxParticleVelocity(Real max); 00253 00255 virtual Real getParticleVelocity(void) const; 00256 00258 virtual Real getMinParticleVelocity(void) const; 00259 00261 virtual Real getMaxParticleVelocity(void) const; 00262 00275 virtual void setEmissionRate(Real particlesPerSecond); 00276 00278 virtual Real getEmissionRate(void) const; 00279 00290 virtual void setTimeToLive(Real ttl); 00304 virtual void setTimeToLive(Real minTtl, Real maxTtl); 00305 00307 virtual void setMinTimeToLive(Real min); 00309 virtual void setMaxTimeToLive(Real max); 00310 00312 virtual Real getTimeToLive(void) const; 00313 00315 virtual Real getMinTimeToLive(void) const; 00317 virtual Real getMaxTimeToLive(void) const; 00318 00326 virtual void setColour(const ColourValue& colour); 00336 virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd); 00338 virtual void setColourRangeStart(const ColourValue& colour); 00340 virtual void setColourRangeEnd(const ColourValue& colour); 00342 virtual const ColourValue& getColour(void) const; 00344 virtual const ColourValue& getColourRangeStart(void) const; 00346 virtual const ColourValue& getColourRangeEnd(void) const; 00347 00360 virtual unsigned short _getEmissionCount(Real timeElapsed) = 0; 00361 00371 virtual void _initParticle(Particle* pParticle) { 00372 // Initialise size in case it's been altered 00373 pParticle->resetDimensions(); 00374 } 00375 00376 00382 const String &getType(void) const { return mType; } 00383 00388 virtual void setEnabled(bool enabled); 00389 00391 virtual bool getEnabled(void) const; 00392 00400 virtual void setStartTime(Real startTime); 00402 virtual Real getStartTime(void) const; 00403 00415 virtual void setDuration(Real duration); 00416 00418 virtual Real getDuration(void) const; 00419 00431 virtual void setDuration(Real min, Real max); 00433 virtual void setMinDuration(Real min); 00435 virtual void setMaxDuration(Real max); 00437 virtual Real getMinDuration(void) const; 00439 virtual Real getMaxDuration(void) const; 00440 00450 virtual void setRepeatDelay(Real duration); 00451 00453 virtual Real getRepeatDelay(void) const; 00454 00466 virtual void setRepeatDelay(Real min, Real max); 00468 virtual void setMinRepeatDelay(Real min); 00470 virtual void setMaxRepeatDelay(Real max); 00472 virtual Real getMinRepeatDelay(void) const; 00474 virtual Real getMaxRepeatDelay(void) const; 00475 00477 const String &getName(void) const; 00478 00480 virtual void setName(const String& newName); 00481 00483 const String &getEmittedEmitter(void) const; 00484 00486 virtual void setEmittedEmitter(const String& emittedEmitter); 00487 00489 virtual bool isEmitted(void) const; 00490 00492 virtual void setEmitted(bool emitted); 00493 00494 00495 }; 00496 00497 } 00498 00499 00500 #endif 00501
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:24 2009