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 
743 
754 
760 
766 
776 
782 
789 
792 
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

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 Wed Oct 23 2013 06:57:24