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-2012 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::CmdUp msUpCmd;
00082         static EmitterCommands::CmdEmissionRate msEmissionRateCmd;
00083         static EmitterCommands::CmdMaxTTL msMaxTTLCmd;
00084         static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd;
00085         static EmitterCommands::CmdMinTTL msMinTTLCmd;
00086         static EmitterCommands::CmdMinVelocity msMinVelocityCmd;
00087         static EmitterCommands::CmdPosition msPositionCmd;
00088         static EmitterCommands::CmdTTL msTTLCmd;
00089         static EmitterCommands::CmdVelocity msVelocityCmd;
00090         static EmitterCommands::CmdDuration msDurationCmd;
00091         static EmitterCommands::CmdMinDuration msMinDurationCmd;
00092         static EmitterCommands::CmdMaxDuration msMaxDurationCmd;
00093         static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd;
00094         static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd;
00095         static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd;
00096         static EmitterCommands::CmdName msNameCmd;
00097         static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd;
00098 
00099 
00101         ParticleSystem* mParent;
00103         Vector3 mPosition;
00105         Real mEmissionRate;
00107         String mType;
00109         Vector3 mDirection;
00110         // Notional up vector, used to speed up generation of variant directions, and also to orient some emitters.
00111         Vector3 mUp;
00113         Radian mAngle;
00115         Real mMinSpeed;
00117         Real mMaxSpeed;
00119         Real mMinTTL;
00121         Real mMaxTTL;
00123         ColourValue mColourRangeStart;
00125         ColourValue mColourRangeEnd;
00126 
00128         bool mEnabled;
00129 
00131         Real mStartTime;
00133         Real mDurationMin;
00135         Real mDurationMax;
00137         Real mDurationRemain;
00138 
00140         Real mRepeatDelayMin;
00141         Real mRepeatDelayMax;
00143         Real mRepeatDelayRemain;
00144 
00145         // Fractions of particles wanted to be emitted last time
00146         Real mRemainder;
00147 
00149         String mName;
00150 
00152         String mEmittedEmitter;
00153 
00154         // If 'true', this emitter is emitted by another emitter.
00155         // NB. That doesn't imply that the emitter itself emits other emitters (that could or could not be the case)
00156         bool mEmitted;
00157 
00158         // NB Method below here are to help out people implementing emitters by providing the
00159         // most commonly used approaches as piecemeal methods
00160 
00164         virtual void genEmissionDirection(Vector3& destVector);
00165 
00170         virtual void genEmissionVelocity(Vector3& destVector);
00171 
00173         virtual Real genEmissionTTL(void);
00174 
00176         virtual void genEmissionColour(ColourValue& destColour);
00177 
00179         virtual unsigned short genConstantEmissionCount(Real timeElapsed);
00180 
00189         void addBaseParameters(void);
00190 
00192         void initDurationRepeat(void);
00193 
00194 
00195     public:
00196         ParticleEmitter(ParticleSystem* psys);
00198         virtual ~ParticleEmitter();
00199 
00201         virtual void setPosition(const Vector3& pos);
00202 
00204         virtual const Vector3& getPosition(void) const;
00205 
00217         virtual void setDirection(const Vector3& direction);
00218 
00220         virtual const Vector3& getDirection(void) const;
00221 
00230         virtual void setUp(const Vector3& up);
00231 
00233         virtual const Vector3& getUp(void) const;
00234 
00245         virtual void setAngle(const Radian& angle);
00246 
00248         virtual const Radian& getAngle(void) const;
00249 
00257         virtual void setParticleVelocity(Real speed);
00258 
00259 
00269         virtual void setParticleVelocity(Real min, Real max);
00271         virtual void setMinParticleVelocity(Real min);
00273         virtual void setMaxParticleVelocity(Real max);
00274 
00276         virtual Real getParticleVelocity(void) const;
00277 
00279         virtual Real getMinParticleVelocity(void) const;
00280 
00282         virtual Real getMaxParticleVelocity(void) const;
00283 
00296         virtual void setEmissionRate(Real particlesPerSecond);
00297 
00299         virtual Real getEmissionRate(void) const;
00300 
00311         virtual void setTimeToLive(Real ttl);
00325         virtual void setTimeToLive(Real minTtl, Real maxTtl);
00326 
00328         virtual void setMinTimeToLive(Real min);
00330         virtual void setMaxTimeToLive(Real max);
00331         
00333         virtual Real getTimeToLive(void) const;
00334 
00336         virtual Real getMinTimeToLive(void) const;
00338         virtual Real getMaxTimeToLive(void) const;
00339 
00347         virtual void setColour(const ColourValue& colour);
00357         virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
00359         virtual void setColourRangeStart(const ColourValue& colour);
00361         virtual void setColourRangeEnd(const ColourValue& colour);
00363         virtual const ColourValue& getColour(void) const;
00365         virtual const ColourValue& getColourRangeStart(void) const;
00367         virtual const ColourValue& getColourRangeEnd(void) const;
00368 
00381         virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
00382 
00392         virtual void _initParticle(Particle* pParticle) {
00393             // Initialise size in case it's been altered
00394             pParticle->resetDimensions();
00395         }
00396 
00397 
00403         const String &getType(void) const { return mType; }
00404 
00409         virtual void setEnabled(bool enabled);
00410 
00412         virtual bool getEnabled(void) const;
00413 
00421         virtual void setStartTime(Real startTime);
00423         virtual Real getStartTime(void) const;
00424 
00436         virtual void setDuration(Real duration);
00437 
00439         virtual Real getDuration(void) const;
00440 
00452         virtual void setDuration(Real min, Real max);
00454         virtual void setMinDuration(Real min);
00456         virtual void setMaxDuration(Real max);
00458         virtual Real getMinDuration(void) const;
00460         virtual Real getMaxDuration(void) const;
00461 
00471         virtual void setRepeatDelay(Real duration);
00472 
00474         virtual Real getRepeatDelay(void) const;
00475 
00487         virtual void setRepeatDelay(Real min, Real max);
00489         virtual void setMinRepeatDelay(Real min);
00491         virtual void setMaxRepeatDelay(Real max);
00493         virtual Real getMinRepeatDelay(void) const;
00495         virtual Real getMaxRepeatDelay(void) const;
00496 
00498         const String &getName(void) const;
00499 
00501         virtual void setName(const String& newName);
00502 
00504         const String &getEmittedEmitter(void) const;
00505 
00507         virtual void setEmittedEmitter(const String& emittedEmitter);
00508 
00510         virtual bool isEmitted(void) const;
00511 
00513         virtual void setEmitted(bool emitted);
00514 
00515 
00516     };
00520 }
00521 
00522 
00523 #endif
00524 

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:25 2012