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-2011 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __ParticleEmitter_H__ 00029 #define __ParticleEmitter_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 #include "OgreString.h" 00033 #include "OgreVector3.h" 00034 #include "OgreColourValue.h" 00035 #include "OgreStringInterface.h" 00036 #include "OgreParticleEmitterCommands.h" 00037 #include "OgreParticle.h" 00038 00039 00040 namespace Ogre { 00041 00042 00071 class _OgreExport ParticleEmitter : public StringInterface, public Particle 00072 { 00073 protected: 00074 00075 // Command object for setting / getting parameters 00076 static EmitterCommands::CmdAngle msAngleCmd; 00077 static EmitterCommands::CmdColour msColourCmd; 00078 static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd; 00079 static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd; 00080 static EmitterCommands::CmdDirection msDirectionCmd; 00081 static EmitterCommands::CmdEmissionRate msEmissionRateCmd; 00082 static EmitterCommands::CmdMaxTTL msMaxTTLCmd; 00083 static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd; 00084 static EmitterCommands::CmdMinTTL msMinTTLCmd; 00085 static EmitterCommands::CmdMinVelocity msMinVelocityCmd; 00086 static EmitterCommands::CmdPosition msPositionCmd; 00087 static EmitterCommands::CmdTTL msTTLCmd; 00088 static EmitterCommands::CmdVelocity msVelocityCmd; 00089 static EmitterCommands::CmdDuration msDurationCmd; 00090 static EmitterCommands::CmdMinDuration msMinDurationCmd; 00091 static EmitterCommands::CmdMaxDuration msMaxDurationCmd; 00092 static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd; 00093 static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd; 00094 static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd; 00095 static EmitterCommands::CmdName msNameCmd; 00096 static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd; 00097 00098 00100 ParticleSystem* mParent; 00102 Vector3 mPosition; 00104 Real mEmissionRate; 00106 String mType; 00108 Vector3 mDirection; 00109 // Notional up vector, just used to speed up generation of variant directions 00110 Vector3 mUp; 00112 Radian mAngle; 00114 Real mMinSpeed; 00116 Real mMaxSpeed; 00118 Real mMinTTL; 00120 Real mMaxTTL; 00122 ColourValue mColourRangeStart; 00124 ColourValue mColourRangeEnd; 00125 00127 bool mEnabled; 00128 00130 Real mStartTime; 00132 Real mDurationMin; 00134 Real mDurationMax; 00136 Real mDurationRemain; 00137 00139 Real mRepeatDelayMin; 00140 Real mRepeatDelayMax; 00142 Real mRepeatDelayRemain; 00143 00144 // Fractions of particles wanted to be emitted last time 00145 Real mRemainder; 00146 00148 String mName; 00149 00151 String mEmittedEmitter; 00152 00153 // If 'true', this emitter is emitted by another emitter. 00154 // NB. That doesn´t imply that the emitter itself emits other emitters (that could or could not be the case) 00155 bool mEmitted; 00156 00157 // NB Method below here are to help out people implementing emitters by providing the 00158 // most commonly used approaches as piecemeal methods 00159 00163 virtual void genEmissionDirection(Vector3& destVector); 00164 00169 virtual void genEmissionVelocity(Vector3& destVector); 00170 00172 virtual Real genEmissionTTL(void); 00173 00175 virtual void genEmissionColour(ColourValue& destColour); 00176 00178 virtual unsigned short genConstantEmissionCount(Real timeElapsed); 00179 00188 void addBaseParameters(void); 00189 00191 void initDurationRepeat(void); 00192 00193 00194 public: 00195 ParticleEmitter(ParticleSystem* psys); 00197 virtual ~ParticleEmitter(); 00198 00200 virtual void setPosition(const Vector3& pos); 00201 00203 virtual const Vector3& getPosition(void) const; 00204 00214 virtual void setDirection(const Vector3& direction); 00215 00217 virtual const Vector3& getDirection(void) const; 00218 00229 virtual void setAngle(const Radian& angle); 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 in case 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 }; 00504 } 00505 00506 00507 #endif 00508
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sat Jan 14 2012 18:40:43