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-2013 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 #include "OgreHeaderPrefix.h"
00039 
00040 
00041 namespace Ogre {
00042 
00043 
00072     class _OgreExport ParticleEmitter : public StringInterface, public Particle
00073     {
00074     protected:
00075 
00076         // Command object for setting / getting parameters
00077         static EmitterCommands::CmdAngle msAngleCmd;
00078         static EmitterCommands::CmdColour msColourCmd;
00079         static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd;
00080         static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd;
00081         static EmitterCommands::CmdDirection msDirectionCmd;
00082         static EmitterCommands::CmdUp msUpCmd;
00083         static EmitterCommands::CmdDirPositionRef msDirPositionRefCmd;
00084         static EmitterCommands::CmdEmissionRate msEmissionRateCmd;
00085         static EmitterCommands::CmdMaxTTL msMaxTTLCmd;
00086         static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd;
00087         static EmitterCommands::CmdMinTTL msMinTTLCmd;
00088         static EmitterCommands::CmdMinVelocity msMinVelocityCmd;
00089         static EmitterCommands::CmdPosition msPositionCmd;
00090         static EmitterCommands::CmdTTL msTTLCmd;
00091         static EmitterCommands::CmdVelocity msVelocityCmd;
00092         static EmitterCommands::CmdDuration msDurationCmd;
00093         static EmitterCommands::CmdMinDuration msMinDurationCmd;
00094         static EmitterCommands::CmdMaxDuration msMaxDurationCmd;
00095         static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd;
00096         static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd;
00097         static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd;
00098         static EmitterCommands::CmdName msNameCmd;
00099         static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd;
00100 
00101 
00103         ParticleSystem* mParent;
00105         Vector3 mPosition;
00107         Real mEmissionRate;
00109         String mType;
00111         Vector3 mDirection;
00113         Vector3 mUp;
00115         bool mUseDirPositionRef;
00116         /* Center position to tell in which direction will particles be emitted according to their position,
00117             useful for explosions & implosions, some emitters (i.e. point emitter) may not need it. */
00118         Vector3 mDirPositionRef;
00120         Radian mAngle;
00122         Real mMinSpeed;
00124         Real mMaxSpeed;
00126         Real mMinTTL;
00128         Real mMaxTTL;
00130         ColourValue mColourRangeStart;
00132         ColourValue mColourRangeEnd;
00133 
00135         bool mEnabled;
00136 
00138         Real mStartTime;
00140         Real mDurationMin;
00142         Real mDurationMax;
00144         Real mDurationRemain;
00145 
00147         Real mRepeatDelayMin;
00148         Real mRepeatDelayMax;
00150         Real mRepeatDelayRemain;
00151 
00152         // Fractions of particles wanted to be emitted last time
00153         Real mRemainder;
00154 
00156         String mName;
00157 
00159         String mEmittedEmitter;
00160 
00161         // If 'true', this emitter is emitted by another emitter.
00162         // NB. That doesn't imply that the emitter itself emits other emitters (that could or could not be the case)
00163         bool mEmitted;
00164 
00165         // NB Method below here are to help out people implementing emitters by providing the
00166         // most commonly used approaches as piecemeal methods
00167 
00171         virtual void genEmissionDirection( const Vector3 &particlePos, Vector3& destVector );
00172 
00177         virtual void genEmissionVelocity(Vector3& destVector);
00178 
00180         virtual Real genEmissionTTL(void);
00181 
00183         virtual void genEmissionColour(ColourValue& destColour);
00184 
00186         virtual unsigned short genConstantEmissionCount(Real timeElapsed);
00187 
00196         void addBaseParameters(void);
00197 
00199         void initDurationRepeat(void);
00200 
00201 
00202     public:
00203         ParticleEmitter(ParticleSystem* psys);
00205         virtual ~ParticleEmitter();
00206 
00208         virtual void setPosition(const Vector3& pos);
00209 
00211         virtual const Vector3& getPosition(void) const;
00212 
00224         virtual void setDirection(const Vector3& direction);
00225 
00227         virtual const Vector3& getDirection(void) const;
00228 
00237         virtual void setUp(const Vector3& up);
00238 
00240         virtual const Vector3& getUp(void) const;
00241 
00255         virtual void setDirPositionReference( const Vector3& position, bool enable );
00256 
00258         virtual const Vector3& getDirPositionReference() const;
00259 
00261         virtual bool getDirPositionReferenceEnabled() const;
00262 
00273         virtual void setAngle(const Radian& angle);
00274 
00276         virtual const Radian& getAngle(void) const;
00277 
00285         virtual void setParticleVelocity(Real speed);
00286 
00287 
00297         virtual void setParticleVelocity(Real min, Real max);
00299         virtual void setMinParticleVelocity(Real min);
00301         virtual void setMaxParticleVelocity(Real max);
00302 
00304         virtual Real getParticleVelocity(void) const;
00305 
00307         virtual Real getMinParticleVelocity(void) const;
00308 
00310         virtual Real getMaxParticleVelocity(void) const;
00311 
00324         virtual void setEmissionRate(Real particlesPerSecond);
00325 
00327         virtual Real getEmissionRate(void) const;
00328 
00339         virtual void setTimeToLive(Real ttl);
00353         virtual void setTimeToLive(Real minTtl, Real maxTtl);
00354 
00356         virtual void setMinTimeToLive(Real min);
00358         virtual void setMaxTimeToLive(Real max);
00359         
00361         virtual Real getTimeToLive(void) const;
00362 
00364         virtual Real getMinTimeToLive(void) const;
00366         virtual Real getMaxTimeToLive(void) const;
00367 
00375         virtual void setColour(const ColourValue& colour);
00385         virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
00387         virtual void setColourRangeStart(const ColourValue& colour);
00389         virtual void setColourRangeEnd(const ColourValue& colour);
00391         virtual const ColourValue& getColour(void) const;
00393         virtual const ColourValue& getColourRangeStart(void) const;
00395         virtual const ColourValue& getColourRangeEnd(void) const;
00396 
00409         virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
00410 
00420         virtual void _initParticle(Particle* pParticle) {
00421             // Initialise size in case it's been altered
00422             pParticle->resetDimensions();
00423         }
00424 
00425 
00431         const String &getType(void) const { return mType; }
00432 
00437         virtual void setEnabled(bool enabled);
00438 
00440         virtual bool getEnabled(void) const;
00441 
00449         virtual void setStartTime(Real startTime);
00451         virtual Real getStartTime(void) const;
00452 
00464         virtual void setDuration(Real duration);
00465 
00467         virtual Real getDuration(void) const;
00468 
00480         virtual void setDuration(Real min, Real max);
00482         virtual void setMinDuration(Real min);
00484         virtual void setMaxDuration(Real max);
00486         virtual Real getMinDuration(void) const;
00488         virtual Real getMaxDuration(void) const;
00489 
00499         virtual void setRepeatDelay(Real duration);
00500 
00502         virtual Real getRepeatDelay(void) const;
00503 
00515         virtual void setRepeatDelay(Real min, Real max);
00517         virtual void setMinRepeatDelay(Real min);
00519         virtual void setMaxRepeatDelay(Real max);
00521         virtual Real getMinRepeatDelay(void) const;
00523         virtual Real getMaxRepeatDelay(void) const;
00524 
00526         const String &getName(void) const;
00527 
00529         virtual void setName(const String& newName);
00530 
00532         const String &getEmittedEmitter(void) const;
00533 
00535         virtual void setEmittedEmitter(const String& emittedEmitter);
00536 
00538         virtual bool isEmitted(void) const;
00539 
00541         virtual void setEmitted(bool emitted);
00542 
00543 
00544     };
00548 }
00549 
00550 #include "OgreHeaderSuffix.h"
00551 
00552 #endif
00553 

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 Mon Jul 27 2020 13:40:44