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-2013 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 #include "OgreHeaderPrefix.h"
39 
40 
41 namespace Ogre {
42 
43 
73  {
74  protected:
75 
76  // Command object for setting / getting parameters
100 
101 
116  /* Center position to tell in which direction will particles be emitted according to their position,
117  useful for explosions & implosions, some emitters (i.e. point emitter) may not need it. */
133 
135  bool mEnabled;
136 
145 
151 
152  // Fractions of particles wanted to be emitted last time
154 
157 
160 
161  // If 'true', this emitter is emitted by another emitter.
162  // NB. That doesn't imply that the emitter itself emits other emitters (that could or could not be the case)
163  bool mEmitted;
164 
165  // NB Method below here are to help out people implementing emitters by providing the
166  // most commonly used approaches as piecemeal methods
167 
171  virtual void genEmissionDirection( const Vector3 &particlePos, Vector3& destVector );
172 
177  virtual void genEmissionVelocity(Vector3& destVector);
178 
180  virtual Real genEmissionTTL(void);
181 
183  virtual void genEmissionColour(ColourValue& destColour);
184 
186  virtual unsigned short genConstantEmissionCount(Real timeElapsed);
187 
196  void addBaseParameters(void);
197 
199  void initDurationRepeat(void);
200 
201 
202  public:
205  virtual ~ParticleEmitter();
206 
208  virtual void setPosition(const Vector3& pos);
209 
211  virtual const Vector3& getPosition(void) const;
212 
224  virtual void setDirection(const Vector3& direction);
225 
227  virtual const Vector3& getDirection(void) const;
228 
237  virtual void setUp(const Vector3& up);
238 
240  virtual const Vector3& getUp(void) const;
241 
255  virtual void setDirPositionReference( const Vector3& position, bool enable );
256 
258  virtual const Vector3& getDirPositionReference() const;
259 
261  virtual bool getDirPositionReferenceEnabled() const;
262 
273  virtual void setAngle(const Radian& angle);
274 
276  virtual const Radian& getAngle(void) const;
277 
285  virtual void setParticleVelocity(Real speed);
286 
287 
297  virtual void setParticleVelocity(Real min, Real max);
299  virtual void setMinParticleVelocity(Real min);
301  virtual void setMaxParticleVelocity(Real max);
302 
304  virtual Real getParticleVelocity(void) const;
305 
307  virtual Real getMinParticleVelocity(void) const;
308 
310  virtual Real getMaxParticleVelocity(void) const;
311 
324  virtual void setEmissionRate(Real particlesPerSecond);
325 
327  virtual Real getEmissionRate(void) const;
328 
339  virtual void setTimeToLive(Real ttl);
353  virtual void setTimeToLive(Real minTtl, Real maxTtl);
354 
356  virtual void setMinTimeToLive(Real min);
358  virtual void setMaxTimeToLive(Real max);
359 
361  virtual Real getTimeToLive(void) const;
362 
364  virtual Real getMinTimeToLive(void) const;
366  virtual Real getMaxTimeToLive(void) const;
367 
375  virtual void setColour(const ColourValue& colour);
385  virtual void setColour(const ColourValue& colourStart, const ColourValue& colourEnd);
387  virtual void setColourRangeStart(const ColourValue& colour);
389  virtual void setColourRangeEnd(const ColourValue& colour);
391  virtual const ColourValue& getColour(void) const;
393  virtual const ColourValue& getColourRangeStart(void) const;
395  virtual const ColourValue& getColourRangeEnd(void) const;
396 
409  virtual unsigned short _getEmissionCount(Real timeElapsed) = 0;
410 
420  virtual void _initParticle(Particle* pParticle) {
421  // Initialise size in case it's been altered
422  pParticle->resetDimensions();
423  }
424 
425 
431  const String &getType(void) const { return mType; }
432 
437  virtual void setEnabled(bool enabled);
438 
440  virtual bool getEnabled(void) const;
441 
449  virtual void setStartTime(Real startTime);
451  virtual Real getStartTime(void) const;
452 
464  virtual void setDuration(Real duration);
465 
467  virtual Real getDuration(void) const;
468 
480  virtual void setDuration(Real min, Real max);
482  virtual void setMinDuration(Real min);
484  virtual void setMaxDuration(Real max);
486  virtual Real getMinDuration(void) const;
488  virtual Real getMaxDuration(void) const;
489 
499  virtual void setRepeatDelay(Real duration);
500 
502  virtual Real getRepeatDelay(void) const;
503 
515  virtual void setRepeatDelay(Real min, Real max);
517  virtual void setMinRepeatDelay(Real min);
519  virtual void setMaxRepeatDelay(Real max);
521  virtual Real getMinRepeatDelay(void) const;
523  virtual Real getMaxRepeatDelay(void) const;
524 
526  const String &getName(void) const;
527 
529  virtual void setName(const String& newName);
530 
532  const String &getEmittedEmitter(void) const;
533 
535  virtual void setEmittedEmitter(const String& emittedEmitter);
536 
538  virtual bool isEmitted(void) const;
539 
541  virtual void setEmitted(bool emitted);
542 
543 
544  };
548 }
549 
550 #include "OgreHeaderSuffix.h"
551 
552 #endif
553 
static EmitterCommands::CmdMaxDuration msMaxDurationCmd
static EmitterCommands::CmdDuration msDurationCmd
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdMinTTL msMinTTLCmd
Command object for particle emitter - see ParamCommand.
#define _OgreExport
Definition: OgrePlatform.h:257
static EmitterCommands::CmdColour msColourCmd
Command object for particle emitter - see ParamCommand.
ColourValue mColourRangeEnd
Initial colour of particles (range end)
static EmitterCommands::CmdTTL msTTLCmd
Real mMaxTTL
Initial time-to-live of particles (max)
static EmitterCommands::CmdDirection msDirectionCmd
String mName
The name of the emitter. The name is optional unless it is used as an emitter that is emitted itself...
Class representing colour.
float Real
Software floating point type.
static EmitterCommands::CmdMaxRepeatDelay msMaxRepeatDelayCmd
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
const String & getType(void) const
Returns the name of the type of emitter.
static EmitterCommands::CmdMinDuration msMinDurationCmd
Real mDurationMax
Maximum length of time the emitter will run for (0 = forever)
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Radian mAngle
Angle around direction which particles may be emitted, internally radians but angleunits for interfac...
static EmitterCommands::CmdMaxTTL msMaxTTLCmd
static EmitterCommands::CmdRepeatDelay msRepeatDelayCmd
Real mStartTime
Start time (in seconds from start of first call to ParticleSystem to update)
Vector3 mPosition
Position relative to the center of the ParticleSystem.
static EmitterCommands::CmdMaxVelocity msMaxVelocityCmd
Real mMinTTL
Initial time-to-live of particles (min)
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
static EmitterCommands::CmdPosition msPositionCmd
static EmitterCommands::CmdMinVelocity msMinVelocityCmd
static EmitterCommands::CmdAngle msAngleCmd
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdColourRangeStart msColourRangeStartCmd
static EmitterCommands::CmdColourRangeEnd msColourRangeEndCmd
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
static EmitterCommands::CmdMinRepeatDelay msMinRepeatDelayCmd
static EmitterCommands::CmdEmissionRate msEmissionRateCmd
Class defining the common interface which classes can use to present a reflection-style, self-defining parameter set to callers.
void resetDimensions(void)
Utility method to reset this particle.
Command object for particle emitter - see ParamCommand.
_StringBase String
bool mEnabled
Whether this emitter is currently enabled (defaults to true)
Vector3 mDirection
Base direction of the emitter, may not be used by some emitters.
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Real mDurationRemain
Current duration remainder.
virtual void _initParticle(Particle *pParticle)
Initialises a particle based on the emitter's approach and parameters.
Command object for particle emitter - see ParamCommand.
Class representing a single particle instance.
Definition: OgreParticle.h:61
ParticleSystem * mParent
Parent particle system.
Command object for particle emitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Real mRepeatDelayMin
Time between each repeat.
Abstract class defining the interface to be implemented by particle emitters.
static EmitterCommands::CmdUp msUpCmd
Command object for particle emitter - see ParamCommand.
bool mUseDirPositionRef
When true, mDirPositionRef is used instead of mDirection to generate particles.
static EmitterCommands::CmdVelocity msVelocityCmd
ColourValue mColourRangeStart
Initial colour of particles (range start)
Real mEmissionRate
Rate in particles per second at which this emitter wishes to emit particles.
Command object for particle emitter - see ParamCommand.
Real mRepeatDelayRemain
Repeat delay left.
static EmitterCommands::CmdDirPositionRef msDirPositionRefCmd
Class defining particle system based special effects.
String mType
Name of the type of emitter, MUST be initialised by subclasses.
static EmitterCommands::CmdEmittedEmitter msEmittedEmitterCmd
String mEmittedEmitter
The name of the emitter to be emitted (optional)
Command object for particle emitter - see ParamCommand.
Real mMinSpeed
Min speed of particles.
static EmitterCommands::CmdName msNameCmd
Command object for ParticleEmitter - see ParamCommand.
Command object for particle emitter - see ParamCommand.
Real mMaxSpeed
Max speed of particles.
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
Vector3 mUp
Notional up vector, used to speed up generation of variant directions, and also to orient some emitte...
Real mDurationMin
Minimum length of time emitter will run for (0 = forever)

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.