OgreParticleSystem.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 __ParticleSystem_H__
29 #define __ParticleSystem_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreVector3.h"
34 #include "OgreString.h"
35 #include "OgreParticleIterator.h"
36 #include "OgreStringInterface.h"
37 #include "OgreMovableObject.h"
38 #include "OgreRadixSort.h"
39 #include "OgreController.h"
41 #include "OgreHeaderPrefix.h"
42 
43 
44 namespace Ogre {
45 
68  {
69  public:
70 
73  {
74  public:
75  String doGet(const void* target) const;
76  void doSet(void* target, const String& val);
77  };
80  {
81  public:
82  String doGet(const void* target) const;
83  void doSet(void* target, const String& val);
84  };
87  {
88  public:
89  String doGet(const void* target) const;
90  void doSet(void* target, const String& val);
91  };
94  {
95  public:
96  String doGet(const void* target) const;
97  void doSet(void* target, const String& val);
98  };
101  {
102  public:
103  String doGet(const void* target) const;
104  void doSet(void* target, const String& val);
105  };
108  {
109  public:
110  String doGet(const void* target) const;
111  void doSet(void* target, const String& val);
112  };
115  {
116  public:
117  String doGet(const void* target) const;
118  void doSet(void* target, const String& val);
119  };
121  class CmdSorted : public ParamCommand
122  {
123  public:
124  String doGet(const void* target) const;
125  void doSet(void* target, const String& val);
126  };
129  {
130  public:
131  String doGet(const void* target) const;
132  void doSet(void* target, const String& val);
133  };
136  {
137  public:
138  String doGet(const void* target) const;
139  void doSet(void* target, const String& val);
140  };
143  {
144  public:
145  String doGet(const void* target) const;
146  void doSet(void* target, const String& val);
147  };
148 
150  ParticleSystem();
156  ParticleSystem(const String& name, const String& resourceGroupName);
157 
158  virtual ~ParticleSystem();
159 
169  void setRenderer(const String& typeName);
170 
172  ParticleSystemRenderer* getRenderer(void) const;
174  const String& getRendererName(void) const;
175 
185  ParticleEmitter* addEmitter(const String& emitterType);
186 
196  ParticleEmitter* getEmitter(unsigned short index) const;
197 
199  unsigned short getNumEmitters(void) const;
200 
209  void removeEmitter(unsigned short index);
210 
212  void removeAllEmitters(void);
213 
214 
224  ParticleAffector* addAffector(const String& affectorType);
225 
235  ParticleAffector* getAffector(unsigned short index) const;
236 
238  unsigned short getNumAffectors(void) const;
239 
248  void removeAffector(unsigned short index);
249 
251  void removeAllAffectors(void);
252 
255  void clear();
256 
264  size_t getNumParticles(void) const;
265 
277  Particle* createParticle(void);
278 
288  Particle* createEmitterParticle(const String& emitterName);
289 
296  Particle* getParticle(size_t index);
297 
302  size_t getParticleQuota(void) const;
303 
315  void setParticleQuota(size_t quota);
316 
321  size_t getEmittedEmitterQuota(void) const;
322 
328  void setEmittedEmitterQuota(size_t quota);
329 
335  ParticleSystem& operator=(const ParticleSystem& rhs);
336 
343  void _update(Real timeElapsed);
344 
351  ParticleIterator _getIterator(void);
352 
357  virtual void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
358 
362  virtual const String& getMaterialName(void) const;
363 
368  virtual void _notifyCurrentCamera(Camera* cam);
369 
374  void _notifyAttached(Node* parent, bool isTagPoint = false);
375 
380  virtual const AxisAlignedBox& getBoundingBox(void) const { return mAABB; }
381 
386  virtual Real getBoundingRadius(void) const { return mBoundingRadius; }
387 
392  virtual void _updateRenderQueue(RenderQueue* queue);
393 
395  void visitRenderables(Renderable::Visitor* visitor,
396  bool debugRenderables = false);
397 
410  void fastForward(Real time, Real interval = 0.1);
411 
420  void setSpeedFactor(Real speedFactor) { mSpeedFactor = speedFactor; }
421 
424  Real getSpeedFactor(void) const { return mSpeedFactor; }
425 
441  void setIterationInterval(Real iterationInterval);
442 
445  Real getIterationInterval(void) const { return mIterationInterval; }
446 
449  static void setDefaultIterationInterval(Real iterationInterval) { msDefaultIterationInterval = iterationInterval; }
450 
453  static Real getDefaultIterationInterval(void) { return msDefaultIterationInterval; }
454 
469  void setNonVisibleUpdateTimeout(Real timeout);
473  Real getNonVisibleUpdateTimeout(void) const { return mNonvisibleTimeout; }
474 
478  { msDefaultNonvisibleTimeout = timeout; }
479 
482  static Real getDefaultNonVisibleUpdateTimeout(void) { return msDefaultNonvisibleTimeout; }
483 
485  const String& getMovableType(void) const;
486 
489  virtual void _notifyParticleResized(void);
490 
493  virtual void _notifyParticleRotated(void);
494 
505  virtual void setDefaultDimensions(Real width, Real height);
506 
508  virtual void setDefaultWidth(Real width);
510  virtual Real getDefaultWidth(void) const;
512  virtual void setDefaultHeight(Real height);
514  virtual Real getDefaultHeight(void) const;
516  virtual bool getCullIndividually(void) const;
537  virtual void setCullIndividually(bool cullIndividual);
539  virtual const String& getResourceGroupName(void) const { return mResourceGroupName; }
546  const String& getOrigin(void) const { return mOrigin; }
548  void _notifyOrigin(const String& origin) { mOrigin = origin; }
549 
551  void setRenderQueueGroup(uint8 queueID);
553  void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
554 
561  void setSortingEnabled(bool enabled) { mSorted = enabled; }
563  bool getSortingEnabled(void) const { return mSorted; }
564 
574  void setBounds(const AxisAlignedBox& aabb);
575 
592  void setBoundsAutoUpdated(bool autoUpdate, Real stopIn = 0.0f);
593 
603  void setKeepParticlesInLocalSpace(bool keepLocal);
604 
608  bool getKeepParticlesInLocalSpace(void) const { return mLocalSpace; }
609 
623  void _updateBounds(void);
624 
634  void setEmitting(bool v);
635 
641  bool getEmitting() const;
642 
644  uint32 getTypeFlags(void) const;
645  protected:
646 
659 
660 
666 
669 
689  bool mSorted;
699  unsigned long mLastVisibleFrame;
706 
710 
713  {
716 
717  SortByDirectionFunctor(const Vector3& dir);
718  float operator()(Particle* p) const;
719  };
720 
723  {
726 
727  SortByDistanceFunctor(const Vector3& pos);
728  float operator()(Particle* p) const;
729  };
730 
732 
742  ActiveParticleList mActiveParticles;
743 
753  FreeParticleList mFreeParticles;
754 
759  ParticlePool mParticlePool;
760 
766 
775  EmittedEmitterPool mEmittedEmitterPool;
776 
781  FreeEmittedEmitterMap mFreeEmittedEmitters;
782 
788  ActiveEmittedEmitterList mActiveEmittedEmitters;
789 
792 
794  ParticleEmitterList mEmitters;
796  ParticleAffectorList mAffectors;
797 
800 
803 
806 
808  size_t mPoolSize;
809 
812 
815 
820 
822  void _expire(Real timeElapsed);
823 
825  void _triggerEmitters(Real timeElapsed);
826 
829  void _executeTriggerEmitters(ParticleEmitter* emitter, unsigned requested, Real timeElapsed);
830 
832  void _applyMotion(Real timeElapsed);
833 
835  void _triggerAffectors(Real timeElapsed);
836 
838  void _sortParticles(Camera* cam);
839 
841  void increasePool(size_t size);
842 
850  void increaseEmittedEmitterPool(size_t size);
851 
853  void initParameters(void);
854 
856  void configureRenderer(void);
857 
859  void createVisualParticles(size_t poolstart, size_t poolend);
861  void destroyVisualParticles(size_t poolstart, size_t poolend);
862 
868  void initialiseEmittedEmitters(void);
869 
873  void initialiseEmittedEmitterPool(void);
874 
876  void addFreeEmittedEmitters(void);
877 
879  void removeAllEmittedEmitters(void);
880 
884  FreeEmittedEmitterList* findFreeEmittedEmitter (const String& name);
885 
891  void removeFromActiveEmittedEmitters (ParticleEmitter* emitter);
892 
897  void addActiveEmittedEmittersToFreeList (void);
898 
907  void _notifyReorganiseEmittedEmitterData (void);
908  };
912 }
913 
914 #include "OgreHeaderSuffix.h"
915 
916 #endif
void _notifyOrigin(const String &origin)
Notify this particle system of it's origin.
bool mSorted
Particles sorted according to camera?
Real mNonvisibleTimeout
Update timeout when nonvisible (0 for no timeout)
Real mTimeSinceLastVisible
Amount of time non-visible so far.
Real mDefaultHeight
Default height of each particle.
Command object for particle_height (see ParamCommand).
virtual const AxisAlignedBox & getBoundingBox(void) const
Overridden from MovableObject.
map< String, EmittedEmitterList >::type EmittedEmitterPool
bool mEmittedEmitterPoolInitialised
Indication whether the emitted emitter pool (= pool with particle emitters that are emitted) is initi...
MaterialPtr mMaterial
Pointer to the material to use.
Real getSpeedFactor(void) const
Gets the &#39;speed factor&#39; on this particle system.
static CmdRenderer msRendererCmd
#define _OgreExport
Definition: OgrePlatform.h:257
static CmdCull msCullCmd
Command objects.
bool mLocalSpace
Particles in local space?
Abstract class defining a movable object in a scene.
Real mSpeedFactor
Speed factor.
static CmdIterationInterval msIterationIntervalCmd
bool mIsEmitting
Used to control if the particle system should emit particles or not.
size_t mEmittedEmitterPoolSize
The number of emitted emitters in the pool.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
void setSpeedFactor(Real speedFactor)
Sets a &#39;speed factor&#39; on this particle system, which means it scales the elapsed real time which has ...
float Real
Software floating point type.
static CmdWidth msWidthCmd
bool getSortingEnabled(void) const
Gets whether particles are sorted relative to the camera.
Class to manage the scene object rendering queue.
vector< ParticleEmitter * >::type ParticleEmitterList
Real mIterationInterval
Iteration interval.
Abstract class defining the interface to be implemented by particle affectors.
static Real getDefaultNonVisibleUpdateTimeout(void)
Get the default nonvisible timeout for all ParticleSystem instances.
virtual const String & getResourceGroupName(void) const
Return the resource group to be used to load dependent resources.
void setSortingEnabled(bool enabled)
Set whether or not particles are sorted according to the camera.
ParticleSystemRenderer * mRenderer
The renderer used to render this particle system.
Command object for local space (see ParamCommand).
virtual Real getBoundingRadius(void) const
Overridden from MovableObject.
Command object for cull_each (see ParamCommand).
size_t mPoolSize
The number of particles in the pool.
static CmdNonvisibleTimeout msNonvisibleTimeoutCmd
static void setDefaultNonVisibleUpdateTimeout(Real timeout)
Set the default nonvisible timeout for all ParticleSystem instances.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
vector< ParticleEmitter * >::type EmittedEmitterList
static CmdEmittedEmitterQuota msEmittedEmitterQuotaCmd
static Real getDefaultIterationInterval(void)
Get the default iteration interval for all ParticleSystem instances.
Real mDefaultWidth
Default width of each particle.
AxisAlignedBox mWorldAABB
World AABB, only used to compare world-space positions to calc bounds.
#define _OgrePrivate
Definition: OgrePlatform.h:258
Abstract class defining the interface required to be implemented by classes which provide rendering c...
ParticlePool mParticlePool
Pool of particle instances for use and reuse in the active particle list.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:64
vector< ParticleAffector * >::type ParticleAffectorList
static CmdLocalSpace msLocalSpaceCmd
static RadixSort< ActiveParticleList, Particle *, float > mRadixSorter
static Real msDefaultNonvisibleTimeout
Default nonvisible update timeout.
Command object for quota (see ParamCommand).
unsigned char uint8
Definition: OgrePlatform.h:361
Controller< Real > * mTimeController
Controller for time update.
FreeParticleList mFreeParticles
Free particle queue.
FreeEmittedEmitterMap mFreeEmittedEmitters
Free emitted emitter list.
Class defining the common interface which classes can use to present a reflection-style, self-defining parameter set to callers.
ActiveEmittedEmitterList mActiveEmittedEmitters
Active emitted emitter list.
Command object for material (see ParamCommand).
String mRendererType
The name of the type of renderer used to render this system.
unsigned long mLastVisibleFrame
Last frame in which known to be visible.
_StringBase String
ParticleAffectorList mAffectors
List of particle affectors, ie modifiers of particles.
static CmdHeight msHeightCmd
Convenience class to make it easy to step through all particles in a ParticleSystem.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
vector< Particle * >::type ParticlePool
Class for performing a radix sort (fast comparison-less sort based on byte value) on various standard...
Definition: OgreRadixSort.h:88
Class representing a single particle instance.
Definition: OgreParticle.h:61
unsigned int uint32
Definition: OgrePlatform.h:359
Command object for renderer (see ParamCommand).
Real getIterationInterval(void) const
Gets a &#39;iteration interval&#39; on this particle system.
Command object for sorting (see ParamCommand).
Abstract class defining the interface to be implemented by particle emitters.
Real getNonVisibleUpdateTimeout(void) const
Gets when the particle system should stop updating after it hasn&#39;t been visible for a while...
static Real msDefaultIterationInterval
Default iteration interval.
static CmdSorted msSortedCmd
const String & getOrigin(void) const
Get the origin of this particle system, e.g.
bool mIterationIntervalSet
Iteration interval set? Otherwise track default.
list< Particle * >::type FreeParticleList
Command object for particle_width (see ParamCommand).
ActiveParticleList mActiveParticles
Active particle list.
bool getKeepParticlesInLocalSpace(void) const
Gets whether particles (and any affector effects) remain relative to the node the particle system is ...
static void setDefaultIterationInterval(Real iterationInterval)
Set the default iteration interval for all ParticleSystem instances.
static CmdMaterial msMaterialCmd
String mOrigin
Optional origin of this particle system (eg script name)
map< String, FreeEmittedEmitterList >::type FreeEmittedEmitterMap
String mMaterialName
Name of the material to use.
bool mNonvisibleTimeoutSet
Update timeout when nonvisible set? Otherwise track default.
String mResourceGroupName
Name of the resource group to use to load materials.
Class defining particle system based special effects.
unsigned short ushort
Abstract class which is command object which gets/sets parameters.
list< Particle * >::type ActiveParticleList
A 3D box aligned with the x/y/z axes.
Command object for iteration interval(see ParamCommand).
list< ParticleEmitter * >::type ActiveEmittedEmitterList
bool mCullIndividual
Do we cull each particle individually?
ParticleEmitterList mEmitters
List of particle emitters, ie sources of particles.
static CmdQuota msQuotaCmd
list< ParticleEmitter * >::type FreeEmittedEmitterList
EmittedEmitterPool mEmittedEmitterPool
Pool of emitted emitters for use and reuse in the active emitted emitter list.
Command object for emittedEmitterQuota (see ParamCommand).
Command object for nonvisible timeout (see ParamCommand).
bool mIsRendererConfigured
Have we set the material etc on the renderer?

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