OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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 "OgreString.h"
33 #include "OgreVector3.h"
34 #include "OgreColourValue.h"
35 #include "OgreStringInterface.h"
37 #include "OgreParticle.h"
38 
39 
40 namespace Ogre {
41 
42 
72  {
73  protected:
74 
75  // Command object for setting / getting parameters
97 
98 
109  // Notional up vector, just used to speed up generation of variant directions
125 
127  bool mEnabled;
128 
137 
143 
144  // Fractions of particles wanted to be emitted last time
146 
149 
152 
153  // If 'true', this emitter is emitted by another emitter.
154  // NB. That doesn´t imply that the emitter itself emits other emitters (that could or could not be the case)
155  bool mEmitted;
156 
157  // NB Method below here are to help out people implementing emitters by providing the
158  // most commonly used approaches as piecemeal methods
159 
163  virtual void genEmissionDirection(Vector3& destVector);
164 
169  virtual void genEmissionVelocity(Vector3& destVector);
170 
172  virtual Real genEmissionTTL(void);
173 
175  virtual void genEmissionColour(ColourValue& destColour);
176 
178  virtual unsigned short genConstantEmissionCount(Real timeElapsed);
179 
188  void addBaseParameters(void);
189 
191  void initDurationRepeat(void);
192 
193 
194  public:
197  virtual ~ParticleEmitter();
198 
200  virtual void setPosition(const Vector3& pos);
201 
203  virtual const Vector3& getPosition(void) const;
204 
214  virtual void setDirection(const Vector3& direction);
215 
217  virtual const Vector3& getDirection(void) const;
218 
229  virtual void setAngle(const Radian& angle);
230 
232  virtual const Radian& getAngle(void) const;
233 
241  virtual void setParticleVelocity(Real speed);
242 
243 
253  virtual void setParticleVelocity(Real min, Real max);
255  virtual void setMinParticleVelocity(Real min);
257  virtual void setMaxParticleVelocity(Real max);
258 
260  virtual Real getParticleVelocity(void) const;
261 
263  virtual Real getMinParticleVelocity(void) const;
264 
266  virtual Real getMaxParticleVelocity(void) const;
267 
280  virtual void setEmissionRate(Real particlesPerSecond);
281 
283  virtual Real getEmissionRate(void) const;
284 
295  virtual void setTimeToLive(Real ttl);
309  virtual void setTimeToLive(Real minTtl, Real maxTtl);
310 
312  virtual void setMinTimeToLive(Real min);
314  virtual void setMaxTimeToLive(Real max);
315 
317  virtual Real getTimeToLive(void) const;
318 
320  virtual Real getMinTimeToLive(void) const;
322  virtual Real getMaxTimeToLive(void) const;
323 
331  virtual void setColour(const ColourValue& colour);
341  virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
343  virtual void setColourRangeStart(const ColourValue& colour);
345  virtual void setColourRangeEnd(const ColourValue& colour);
347  virtual const ColourValue& getColour(void) const;
349  virtual const ColourValue& getColourRangeStart(void) const;
351  virtual const ColourValue& getColourRangeEnd(void) const;
352 
365  virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
366 
376  virtual void _initParticle(Particle* pParticle) {
377  // Initialise size in case it's been altered
378  pParticle->resetDimensions();
379  }
380 
381 
387  const String &getType(void) const { return mType; }
388 
393  virtual void setEnabled(bool enabled);
394 
396  virtual bool getEnabled(void) const;
397 
405  virtual void setStartTime(Real startTime);
407  virtual Real getStartTime(void) const;
408 
420  virtual void setDuration(Real duration);
421 
423  virtual Real getDuration(void) const;
424 
436  virtual void setDuration(Real min, Real max);
438  virtual void setMinDuration(Real min);
440  virtual void setMaxDuration(Real max);
442  virtual Real getMinDuration(void) const;
444  virtual Real getMaxDuration(void) const;
445 
455  virtual void setRepeatDelay(Real duration);
456 
458  virtual Real getRepeatDelay(void) const;
459 
471  virtual void setRepeatDelay(Real min, Real max);
473  virtual void setMinRepeatDelay(Real min);
475  virtual void setMaxRepeatDelay(Real max);
477  virtual Real getMinRepeatDelay(void) const;
479  virtual Real getMaxRepeatDelay(void) const;
480 
482  const String &getName(void) const;
483 
485  virtual void setName(const String& newName);
486 
488  const String &getEmittedEmitter(void) const;
489 
491  virtual void setEmittedEmitter(const String& emittedEmitter);
492 
494  virtual bool isEmitted(void) const;
495 
497  virtual void setEmitted(bool emitted);
498 
499 
500  };
504 }
505 
506 
507 #endif
508 
Command object for particle emitter - see ParamCommand.
virtual void _initParticle(Particle *pParticle)
Initialises a particle based on the emitter's approach and parameters.
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:203
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)
Command object for particle emitter - see ParamCommand.
Real mMinSpeed
Min speed of particles.
Command object for particle emitter - see ParamCommand.
Class representing colour.
static EmitterCommands::CmdDuration msDurationCmd
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdTTL msTTLCmd
Real mMaxSpeed
Max speed of particles.
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
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...
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:51
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:46
static EmitterCommands::CmdMaxTTL msMaxTTLCmd
_StringBase String
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