Spinning Topp Logo BlackTopp Studios
inc
particlesystemproxy.h
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _graphicsparticlesystemproxy_h
41 #define _graphicsparticlesystemproxy_h
42 
43 /// @file
44 /// @brief This file contains the declaration for the World proxy wrapping particle functionality.
45 
47 
48 namespace Ogre
49 {
50  class ParticleSystem;
51 }
52 
53 namespace Mezzanine
54 {
55  namespace Graphics
56  {
57  class ParticleEmitter;
58  class ParticleAffector;
59  ///////////////////////////////////////////////////////////////////////////////
60  /// @brief This is the proxy class for placing and manipulating particles in the scene.
61  /// @details
62  ///////////////////////////////////////
64  {
65  public:
66  /// @brief Basic container type for ParticleEmitter storage by this class.
67  typedef std::vector<ParticleEmitter*> EmitterContainer;
68  /// @brief Iterator type for ParticleEmitter instances stored by this class.
69  typedef EmitterContainer::iterator EmitterIterator;
70  /// @brief Const Iterator type for ParticleEmitter instances stored by this class.
71  typedef EmitterContainer::const_iterator ConstEmitterIterator;
72  /// @brief Basic container type for ParticleAffector storage by this class.
73  typedef std::vector<ParticleAffector*> AffectorContainer;
74  /// @brief Iterator type for ParticleAffector instances stored by this class.
75  typedef AffectorContainer::iterator AffectorIterator;
76  /// @brief Const Iterator type for ParticleAffector instances stored by this class.
77  typedef AffectorContainer::const_iterator ConstAffectorIterator;
78  protected:
79  /// @internal
80  /// @brief A cache containing all of the custom altered parameters of this particle system.
81  /// @note Once we have a proper wrapper for particle systems (or our own implementation) this no longer needs to exist.
83  /// @internal
84  /// @brief Vector of emitters in use by this particle effect.
85  EmitterContainer Emitters;
86  /// @internal
87  /// @brief Vector of affectors in use by this particle effect.
88  AffectorContainer Affectors;
89  /// @internal
90  /// @brief Stores the template, primarily for serialization.
92  /// @internal
93  /// @brief Pointer to the ogre ParticleSystem from which this proxy gets it's functionality.
94  Ogre::ParticleSystem* GraphicsParticleSystem;
95  /// @internal
96  /// @brief Stores the current speed factor of this particle system for when it gets paused.
98  /// @internal
99  /// @brief Stores whether or not updates to this particle system are paused.
101 
102  /// @copydoc WorldProxy::ProtoSerializeImpl(XML::Node&) const
103  virtual void ProtoSerializeImpl(XML::Node& SelfRoot) const;
104  /// @copydoc WorldProxy::ProtoDeSerializeImpl(const XML::Node&)
105  virtual void ProtoDeSerializeImpl(const XML::Node& SelfRoot);
106  /// @internal
107  /// @brief Constructs this particle system from a pre-made particle script.
108  /// @param Name The name of this particle effect.
109  /// @param Template Name of the particle script to be used in creating this particle effect.
110  virtual void CreateParticleSystem(const String& Template);
111  /// @internal
112  /// @brief Destroys the particle system providing this class with it's functionality.
113  virtual void DestroyParticleSystem();
114  /// @internal
115  /// @brief Generates a name for this ParticleSystem to placate the internal system.
116  /// @note This will no longer be necessary in after the switch to Ogre 2.0.
117  /// @return Returns a string containing the auto-generated name of this particle.
118  static String GenerateName();
119  public:
120  /// @todo Create a non-template constructor so people can make particle effects entirely from c++.
121 
122  /// @brief Template constructor.
123  /// @param ID The unique ID assigned to this ParticleSystemProxy.
124  /// @param Template Name of the particle script to be used in creating this particle effect.
125  /// @param Creator A pointer to the manager that created this proxy.
126  ParticleSystemProxy(const UInt32 ID, const String& Template, SceneManager* Creator);
127  /// @brief XML constructor.
128  /// @param SelfRoot An XML::Node containing the data to populate this class with.
129  /// @param Creator A pointer to the manager that created this proxy.
130  ParticleSystemProxy(const XML::Node& SelfRoot, SceneManager* Creator);
131  /// @brief Class destructor.
132  virtual ~ParticleSystemProxy();
133 
134  ///////////////////////////////////////////////////////////////////////////////
135  // Utility
136 
137  /// @copydoc WorldProxy::GetProxyType() const
138  virtual Mezzanine::ProxyType GetProxyType() const;
139 
140  /// @brief Gets the name of this particle effect.
141  /// @note This method will be removed in the Ogre 2.0 switch.
142  /// @return Returns a const reference to a string containing the name of this particle system proxy.
143  const String& GetName() const;
144  /// @brief Gets the name of the template this particle effect is based on.
145  /// @return Returns a const reference to a string containing the name of the template this particle system proxy is based on.
146  const String& GetTemplate() const;
147 
148  /// @brief Pauses this proxy, preventing it from emitting, moving, or removing any particles.
149  /// @param Pause Will pauae the proxy if running and Pause is true, otherwise it will resume the proxy if paused and Pause is false.
150  void PauseParticleSystem(Boole Pause);
151  /// @brief Gets whether or not this particle system is currently paused.
152  /// @return Returns true if this particle system is paused, false otherwise.
153  Boole IsParticleSystemPaused() const;
154 
155  /// @brief Sets a custom parameter of a particle effect.
156  /// @remarks The params available to change depends on the internal particle system used.
157  /// You should check your particle script where possible to ensure particles you are
158  /// changing are the type you expect.
159  /// @param Name The name of the parameter to alter.
160  /// @param Value The new value to set for the named parameter.
161  void SetCustomParam(const String& Name, const String& Value);
162  /// @brief Gets a custom parameter of a particle effect.
163  /// @remarks The params available to change depends on the internal particle system used.
164  /// You should check your particle script where possible to ensure the particle has the
165  /// param you are looking for.
166  /// @param Name The name of the parameter to fetch.
167  String GetCustomParam(const String& Name) const;
168 
169  ///////////////////////////////////////////////////////////////////////////////
170  // Emitters
171 
172  /// @brief Gets the Emitter at the specified index.
173  /// @param Index The index of the Emitter to get.
174  /// @return Returns a pointer to the Emitter at the specified index.
175  ParticleEmitter* GetEmitter(const UInt16 Index) const;
176  /// @brief Gets the number of Emitters in use by this particle effect.
177  /// @return Returns a UInt16 representing the number of Emitters in this particle effect.
178  UInt16 GetNumEmitters() const;
179  /// @brief Destroy's an Emitter in use by this particle effect.
180  /// @param Index The index to destroy.
181  void DestroyEmitter(const UInt16 Index);
182  /// @brief Destroy's all Emitters in use by this particle effect.
183  void DestroyAllEmitters();
184 
185  ///////////////////////////////////////////////////////////////////////////////
186  // Affectors
187 
188  /// @brief Gets the Affector at the specified index.
189  /// @param Index The index of the Affector to get.
190  /// @return Returns a pointer to the Affector at the specified index.
191  ParticleAffector* GetAffector(const UInt16 Index) const;
192  /// @brief Gets the number of Affectors in use by this particle effect.
193  /// @return Returns a UInt16 representing the number of Affectors in this particle effect.
194  UInt16 GetNumAffectors() const;
195  /// @brief Destroy's an Affector in use by this particle effect.
196  /// @param Index The index to destroy.
197  void DestroyAffector(const UInt16 Index);
198  /// @brief Destroy's all Affectors in use by this particle effect.
199  void DestroyAllAffectors();
200 
201  ///////////////////////////////////////////////////////////////////////////////
202  // ParticleSystem Properties
203 
204  /// @brief Sets the factor at which time progresses for this ParticleEffect.
205  /// @param Factor The factor at which time progresses. Valid values range from 0.0 to 1.0.
206  /// @note If the ParticleEffect is paused, this will set the value to resume with when the ParticleEffect is unpaused.
207  void SetSpeedFactor(const Real Factor);
208  /// @brief Gets the Factor at which this ParticleEffect is currently progressing.
209  /// @return Returns a Real representing the factor at which the ParticleEffect is currently progressing.
210  /// @note If the ParticleEffect is paused, this will return what the speed would be if it were unpaused.
211  Real GetSpeedFactor() const;
212 
213  ///////////////////////////////////////////////////////////////////////////////
214  // Serialization
215 
216  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
217  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
218  /// @brief Convert the template name of this class to an XML::Node ready for serialization.
219  /// @param SelfRoot The root node containing all the serialized data for this instance.
220  virtual void ProtoSerializeTemplate(XML::Node& SelfRoot) const;
221  /// @brief Convert the custom altered parameters of this class to an XML::Node ready for serialization.
222  /// @param SelfRoot The root node containing all the serialized data for this instance.
223  virtual void ProtoSerializeCustomParameters(XML::Node& SelfRoot) const;
224  /// @brief Convert the emitters of this class to an XML::Node ready for serialization.
225  /// @param SelfRoot The root node containing all the serialized data for this instance.
226  virtual void ProtoSerializeEmitters(XML::Node& SelfRoot) const;
227  /// @brief Convert the affectors of this class to an XML::Node ready for serialization.
228  /// @param SelfRoot The root node containing all the serialized data for this instance.
229  virtual void ProtoSerializeAffectors(XML::Node& SelfRoot) const;
230 
231  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
232  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
233  /// @brief Take the data stored in an XML Node and overwrite the template name of this object with it.
234  /// @param SelfRoot An XML::Node containing the data to populate this class with.
235  virtual void ProtoDeSerializeTemplate(const XML::Node& SelfRoot);
236  /// @brief Take the data stored in an XML Node and overwrite the custom altered parameters of this object with it.
237  /// @param SelfRoot An XML::Node containing the data to populate this class with.
238  virtual void ProtoDeSerializeCustomParameters(const XML::Node& SelfRoot);
239  /// @brief Take the data stored in an XML Node and overwrite the emitters of this object with it.
240  /// @param SelfRoot An XML::Node containing the data to populate this class with.
241  virtual void ProtoDeSerializeEmitters(const XML::Node& SelfRoot);
242  /// @brief Take the data stored in an XML Node and overwrite the affectors of this object with it.
243  /// @param SelfRoot An XML::Node containing the data to populate this class with.
244  virtual void ProtoDeSerializeAffectors(const XML::Node& SelfRoot);
245 
246  /// @copydoc WorldProxy::GetDerivedSerializableName() const
247  virtual String GetDerivedSerializableName() const;
248  /// @copydoc WorldProxy::GetSerializableName()
249  static String GetSerializableName();
250 
251  ///////////////////////////////////////////////////////////////////////////////
252  // Internal Methods
253 
254  /// @internal
255  /// @brief Accessor for the internal particle system.
256  /// @return Returns a pointer to the internal particle system this proxy is based on.
257  virtual Ogre::ParticleSystem* _GetGraphicsObject() const;
258  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
259  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
260  };//ParticleSystemProxy
261  }//Graphics
262 }//Mezzanine
263 
264 #endif
AffectorContainer::iterator AffectorIterator
Iterator type for ParticleAffector instances stored by this class.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
This class contains utilities and functions to allow the manipulation of the Graphical scene...
Definition: scenemanager.h:85
AffectorContainer::const_iterator ConstAffectorIterator
Const Iterator type for ParticleAffector instances stored by this class.
This file contains the declaration for the base class from which graphics proxies inherit...
Boole Paused
Stores whether or not updates to this particle system are paused.
This is the base proxy class for world proxies wrapping functionality of the graphics subsystem...
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
std::vector< ParticleAffector * > AffectorContainer
Basic container type for ParticleAffector storage by this class.
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
Real SpeedFactor
Stores the current speed factor of this particle system for when it gets paused.
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
ProxyType
Used by all World proxies to describe what their derived types are.
Definition: enumerations.h:91
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
String Template
Stores the template, primarily for serialization.
EmitterContainer::iterator EmitterIterator
Iterator type for ParticleEmitter instances stored by this class.
EmitterContainer::const_iterator ConstEmitterIterator
Const Iterator type for ParticleEmitter instances stored by this class.
std::vector< ParticleEmitter * > EmitterContainer
Basic container type for ParticleEmitter storage by this class.
NameValuePairMap CustomSystemParameters
A cache containing all of the custom altered parameters of this particle system.
This is the proxy class for placing and manipulating particles in the scene.
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
This class defines how particles of a given particle effect spawn.
Ogre::ParticleSystem * GraphicsParticleSystem
Pointer to the ogre ParticleSystem from which this proxy gets it's functionality. ...
AffectorContainer Affectors
Vector of affectors in use by this particle effect.
This class defines how particles of a given particle effect behave during their lifetime.
EmitterContainer Emitters
Vector of emitters in use by this particle effect.
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:209
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159