OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreParticleEmitter.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __ParticleEmitter_H__
29 #define __ParticleEmitter_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreVector3.h"
33 #include "OgreColourValue.h"
34 #include "OgreStringInterface.h"
36 #include "OgreParticle.h"
37 #include "OgreHeaderPrefix.h"
38 
39 
40 namespace Ogre {
41 
42 
72  {
73  protected:
74 
75  // Command object for setting / getting parameters
99 
100 
115  /* Center position to tell in which direction will particles be emitted according to their position,
116  useful for explosions & implosions, some emitters (i.e. point emitter) may not need it. */
132 
134  bool mEnabled;
135 
144 
150 
151  // Fractions of particles wanted to be emitted last time
153 
156 
159 
160  // If 'true', this emitter is emitted by another emitter.
161  // NB. That doesn't imply that the emitter itself emits other emitters (that could or could not be the case)
162  bool mEmitted;
163 
164  // NB Method below here are to help out people implementing emitters by providing the
165  // most commonly used approaches as piecemeal methods
166 
170  virtual void genEmissionDirection( const Vector3 &particlePos, Vector3& destVector );
171 
176  virtual void genEmissionVelocity(Vector3& destVector);
177 
179  virtual Real genEmissionTTL(void);
180 
182  virtual void genEmissionColour(ColourValue& destColour);
183 
185  virtual unsigned short genConstantEmissionCount(Real timeElapsed);
186 
195  void addBaseParameters(void);
196 
198  void initDurationRepeat(void);
199 
200 
201  public:
204  virtual ~ParticleEmitter();
205 
207  virtual void setPosition(const Vector3& pos);
208 
210  virtual const Vector3& getPosition(void) const;
211 
223  virtual void setDirection(const Vector3& direction);
224 
226  virtual const Vector3& getDirection(void) const;
227 
236  virtual void setUp(const Vector3& up);
237 
239  virtual const Vector3& getUp(void) const;
240 
254  virtual void setDirPositionReference( const Vector3& position, bool enable );
255 
257  virtual const Vector3& getDirPositionReference() const;
258 
260  virtual bool getDirPositionReferenceEnabled() const;
261 
272  virtual void setAngle(const Radian& angle);
273 
275  virtual const Radian& getAngle(void) const;
276 
284  virtual void setParticleVelocity(Real speed);
285 
286 
296  virtual void setParticleVelocity(Real min, Real max);
298  virtual void setMinParticleVelocity(Real min);
300  virtual void setMaxParticleVelocity(Real max);
301 
303  virtual Real getParticleVelocity(void) const;
304 
306  virtual Real getMinParticleVelocity(void) const;
307 
309  virtual Real getMaxParticleVelocity(void) const;
310 
323  virtual void setEmissionRate(Real particlesPerSecond);
324 
326  virtual Real getEmissionRate(void) const;
327 
338  virtual void setTimeToLive(Real ttl);
352  virtual void setTimeToLive(Real minTtl, Real maxTtl);
353 
355  virtual void setMinTimeToLive(Real min);
357  virtual void setMaxTimeToLive(Real max);
358 
360  virtual Real getTimeToLive(void) const;
361 
363  virtual Real getMinTimeToLive(void) const;
365  virtual Real getMaxTimeToLive(void) const;
366 
374  virtual void setColour(const ColourValue& colour);
384  virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
386  virtual void setColourRangeStart(const ColourValue& colour);
388  virtual void setColourRangeEnd(const ColourValue& colour);
390  virtual const ColourValue& getColour(void) const;
392  virtual const ColourValue& getColourRangeStart(void) const;
394  virtual const ColourValue& getColourRangeEnd(void) const;
395 
408  virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
409 
419  virtual void _initParticle(Particle* pParticle) {
420  // Initialise size in case it's been altered
421  pParticle->resetDimensions();
422  }
423 
424 
430  const String &getType(void) const { return mType; }
431 
436  virtual void setEnabled(bool enabled);
437 
439  virtual bool getEnabled(void) const;
440 
448  virtual void setStartTime(Real startTime);
450  virtual Real getStartTime(void) const;
451 
463  virtual void setDuration(Real duration);
464 
466  virtual Real getDuration(void) const;
467 
479  virtual void setDuration(Real min, Real max);
481  virtual void setMinDuration(Real min);
483  virtual void setMaxDuration(Real max);
485  virtual Real getMinDuration(void) const;
487  virtual Real getMaxDuration(void) const;
488 
498  virtual void setRepeatDelay(Real duration);
499 
501  virtual Real getRepeatDelay(void) const;
502 
514  virtual void setRepeatDelay(Real min, Real max);
516  virtual void setMinRepeatDelay(Real min);
518  virtual void setMaxRepeatDelay(Real max);
520  virtual Real getMinRepeatDelay(void) const;
522  virtual Real getMaxRepeatDelay(void) const;
523 
525  const String &getName(void) const;
526 
528  virtual void setName(const String& newName);
529 
531  const String &getEmittedEmitter(void) const;
532 
534  virtual void setEmittedEmitter(const String& emittedEmitter);
535 
537  virtual bool isEmitted(void) const;
538 
540  virtual void setEmitted(bool emitted);
541 
542 
543  };
547 }
548 
549 #include "OgreHeaderSuffix.h"
550 
551 #endif
552 
Command object for particle emitter - see ParamCommand.
virtual void _initParticle(Particle *pParticle)
Initialises a particle based on the emitter's approach and parameters.
Command object for particle emitter - see ParamCommand.
Class defining particle system based special effects.
float Real
Software floating point type.
Real mDurationMin
Minimum length of time emitter will run for (0 = forever)
#define _OgreExport
Definition: OgrePlatform.h:255
static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd
static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd
Real mDurationRemain
Current duration remainder.
Real mDurationMax
Maximum length of time the emitter will run for (0 = forever)
const float & max(const float &a, const float &b)
Definition: OgreCommon.h:851
Command object for particle emitter - see ParamCommand.
Real mMinSpeed
Min speed of particles.
Command object for particle emitter - see ParamCommand.
Class representing colour.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdDuration msDurationCmd
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdTTL msTTLCmd
Real mMaxSpeed
Max speed of particles.
static EmitterCommands::CmdUp msUpCmd
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdColour msColourCmd
ColourValue mColourRangeEnd
Initial colour of particles (range end)
Command object for particle emitter - see ParamCommand.
Command object for ParticleEmitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd
Command object for particle emitter - see ParamCommand.
ParticleSystem * mParent
Parent particle system.
static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdAngle msAngleCmd
static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd
Radian mAngle
Angle around direction which particles may be emitted, internally radians but angleunits for interfac...
static EmitterCommands::CmdEmissionRate msEmissionRateCmd
static EmitterCommands::CmdMaxDuration msMaxDurationCmd
Command object for particle emitter - see ParamCommand.
String mEmittedEmitter
The name of the emitter to be emitted (optional)
Class defining the common interface which classes can use to present a reflection-style, self-defining parameter set to callers.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdMinTTL msMinTTLCmd
bool mUseDirPositionRef
When true, mDirPositionRef is used instead of mDirection to generate particles.
Real mRepeatDelayRemain
Repeat delay left.
static EmitterCommands::CmdVelocity msVelocityCmd
String mType
Name of the type of emitter, MUST be initialised by subclasses.
Real mMaxTTL
Initial time-to-live of particles (max)
Class representing a single particle instance.
Definition: OgreParticle.h:60
void resetDimensions(void)
Utility method to reset this particle.
static EmitterCommands::CmdMinVelocity msMinVelocityCmd
bool mEnabled
Whether this emitter is currently enabled (defaults to true)
static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd
String mName
The name of the emitter. The name is optional unless it is used as an emitter that is emitted itself...
const float & min(const float &a, const float &b)
Definition: OgreCommon.h:846
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdDirection msDirectionCmd
ColourValue mColourRangeStart
Initial colour of particles (range start)
Command object for particle emitter - see ParamCommand.
Abstract class defining the interface to be implemented by particle emitters.
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
Command object for particle emitter - see ParamCommand.
Real mEmissionRate
Rate in particles per second at which this emitter wishes to emit particles.
static EmitterCommands::CmdMinDuration msMinDurationCmd
Vector3 mPosition
Position relative to the center of the ParticleSystem.
static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd
Command object for particle emitter - see ParamCommand.
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:49
static EmitterCommands::CmdDirPositionRef msDirPositionRefCmd
static EmitterCommands::CmdMaxTTL msMaxTTLCmd
Vector3 mUp
Notional up vector, used to speed up generation of variant directions, and also to orient some emitte...
_StringBase String
Definition: OgreCommon.h:53
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdName msNameCmd
Vector3 mDirection
Base direction of the emitter, may not be used by some emitters.
Real mRepeatDelayMin
Time between each repeat.
Real mStartTime
Start time (in seconds from start of first call to ParticleSystem to update)
const String & getType(void) const
Returns the name of the type of emitter.
Real mMinTTL
Initial time-to-live of particles (min)
static EmitterCommands::CmdPosition msPositionCmd