MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
particlesystemproxy.h
Go to the documentation of this file.
1 // © Copyright 2010 - 2014 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.
86  /// @internal
87  /// @brief Vector of affectors in use by this particle effect.
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.
100  Boolean Paused;
101 
102  /// @internal
103  /// @brief Constructs this particle system from a pre-made particle script.
104  /// @param Name The name of this particle effect.
105  /// @param Template Name of the particle script to be used in creating this particle effect.
106  virtual void CreateParticleSystem(const String& Template);
107  /// @internal
108  /// @brief Destroys the particle system providing this class with it's functionality.
109  virtual void DestroyParticleSystem();
110  /// @internal
111  /// @brief Generates a name for this ParticleSystem to placate the internal system.
112  /// @note This will no longer be necessary in after the switch to Ogre 2.0.
113  /// @return Returns a string containing the auto-generated name of this particle.
114  static String GenerateName();
115  public:
116  /// @todo Create a non-template constructor so people can make particle effects entirely from c++.
117 
118  /// @brief Template constructor.
119  /// @param Template Name of the particle script to be used in creating this particle effect.
120  /// @param Creator A pointer to the manager that created this proxy.
121  ParticleSystemProxy(const String& Template, SceneManager* Creator);
122  /// @brief XML constructor.
123  /// @param SelfRoot An XML::Node containing the data to populate this class with.
124  /// @param Creator A pointer to the manager that created this proxy.
125  ParticleSystemProxy(const XML::Node& SelfRoot, SceneManager* Creator);
126  /// @brief Class destructor.
127  virtual ~ParticleSystemProxy();
128 
129  ///////////////////////////////////////////////////////////////////////////////
130  // Utility
131 
132  /// @copydoc WorldProxy::GetProxyType() const
133  virtual Mezzanine::ProxyType GetProxyType() const;
134 
135  /// @brief Gets the name of this particle effect.
136  /// @note This method will be removed in the Ogre 2.0 switch.
137  /// @return Returns a const reference to a string containing the name of this particle system proxy.
138  const String& GetName() const;
139  /// @brief Gets the name of the template this particle effect is based on.
140  /// @return Returns a const reference to a string containing the name of the template this particle system proxy is based on.
141  const String& GetTemplate() const;
142 
143  /// @brief Pauses this proxy, preventing it from emitting, moving, or removing any particles.
144  /// @param Pause Will pauae the proxy if running and Pause is true, otherwise it will resume the proxy if paused and Pause is false.
145  void PauseParticleSystem(bool Pause);
146  /// @brief Gets whether or not this particle system is currently paused.
147  /// @return Returns true if this particle system is paused, false otherwise.
148  Boolean IsParticleSystemPaused() const;
149 
150  /// @brief Sets a custom parameter of a particle effect.
151  /// @remarks The params available to change depends on the internal particle system used.
152  /// You should check your particle script where possible to ensure particles you are
153  /// changing are the type you expect.
154  /// @param Name The name of the parameter to alter.
155  /// @param Value The new value to set for the named parameter.
156  void SetCustomParam(const String& Name, const String& Value);
157  /// @brief Gets a custom parameter of a particle effect.
158  /// @remarks The params available to change depends on the internal particle system used.
159  /// You should check your particle script where possible to ensure the particle has the
160  /// param you are looking for.
161  /// @param Name The name of the parameter to fetch.
162  String GetCustomParam(const String& Name) const;
163 
164  ///////////////////////////////////////////////////////////////////////////////
165  // Emitters
166 
167  /// @brief Gets the Emitter at the specified index.
168  /// @param Index The index of the Emitter to get.
169  /// @return Returns a pointer to the Emitter at the specified index.
170  ParticleEmitter* GetEmitter(const UInt16 Index) const;
171  /// @brief Gets the number of Emitters in use by this particle effect.
172  /// @return Returns a UInt16 representing the number of Emitters in this particle effect.
173  UInt16 GetNumEmitters() const;
174  /// @brief Destroy's an Emitter in use by this particle effect.
175  /// @param Index The index to destroy.
176  void DestroyEmitter(const UInt16 Index);
177  /// @brief Destroy's all Emitters in use by this particle effect.
178  void DestroyAllEmitters();
179 
180  ///////////////////////////////////////////////////////////////////////////////
181  // Affectors
182 
183  /// @brief Gets the Affector at the specified index.
184  /// @param Index The index of the Affector to get.
185  /// @return Returns a pointer to the Affector at the specified index.
186  ParticleAffector* GetAffector(const UInt16 Index) const;
187  /// @brief Gets the number of Affectors in use by this particle effect.
188  /// @return Returns a UInt16 representing the number of Affectors in this particle effect.
189  UInt16 GetNumAffectors() const;
190  /// @brief Destroy's an Affector in use by this particle effect.
191  /// @param Index The index to destroy.
192  void DestroyAffector(const UInt16 Index);
193  /// @brief Destroy's all Affectors in use by this particle effect.
194  void DestroyAllAffectors();
195 
196  ///////////////////////////////////////////////////////////////////////////////
197  // ParticleSystem Properties
198 
199  /// @brief Sets the factor at which time progresses for this ParticleEffect.
200  /// @param Factor The factor at which time progresses. Valid values range from 0.0 to 1.0.
201  /// @note If the ParticleEffect is paused, this will set the value to resume with when the ParticleEffect is unpaused.
202  void SetSpeedFactor(const Real Factor);
203  /// @brief Gets the Factor at which this ParticleEffect is currently progressing.
204  /// @return Returns a Real representing the factor at which the ParticleEffect is currently progressing.
205  /// @note If the ParticleEffect is paused, this will return what the speed would be if it were unpaused.
206  Real GetSpeedFactor() const;
207 
208  ///////////////////////////////////////////////////////////////////////////////
209  // Serialization
210 
211  /// @copydoc WorldProxy::ProtoSerialize(XML::Node&) const
212  virtual void ProtoSerialize(XML::Node& ParentNode) const;
213  /// @brief Convert the template name of this class to an XML::Node ready for serialization.
214  /// @param SelfRoot The root node containing all the serialized data for this instance.
215  virtual void ProtoSerializeTemplate(XML::Node& SelfRoot) const;
216  /// @brief Convert the custom altered parameters of this class to an XML::Node ready for serialization.
217  /// @param SelfRoot The root node containing all the serialized data for this instance.
218  virtual void ProtoSerializeCustomParameters(XML::Node& SelfRoot) const;
219  /// @brief Convert the emitters of this class to an XML::Node ready for serialization.
220  /// @param SelfRoot The root node containing all the serialized data for this instance.
221  virtual void ProtoSerializeEmitters(XML::Node& SelfRoot) const;
222  /// @brief Convert the affectors of this class to an XML::Node ready for serialization.
223  /// @param SelfRoot The root node containing all the serialized data for this instance.
224  virtual void ProtoSerializeAffectors(XML::Node& SelfRoot) const;
225  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
226  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
227 
228  /// @copydoc WorldProxy::ProtoDeSerialize(const XML::Node&)
229  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
230  /// @brief Take the data stored in an XML Node and overwrite the template name of this object with it.
231  /// @param SelfRoot An XML::Node containing the data to populate this class with.
232  virtual void ProtoDeSerializeTemplate(const XML::Node& SelfRoot);
233  /// @brief Take the data stored in an XML Node and overwrite the custom altered parameters of this object with it.
234  /// @param SelfRoot An XML::Node containing the data to populate this class with.
235  virtual void ProtoDeSerializeCustomParameters(const XML::Node& SelfRoot);
236  /// @brief Take the data stored in an XML Node and overwrite the emitters of this object with it.
237  /// @param SelfRoot An XML::Node containing the data to populate this class with.
238  virtual void ProtoDeSerializeEmitters(const XML::Node& SelfRoot);
239  /// @brief Take the data stored in an XML Node and overwrite the affectors of this object with it.
240  /// @param SelfRoot An XML::Node containing the data to populate this class with.
241  virtual void ProtoDeSerializeAffectors(const XML::Node& SelfRoot);
242  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
243  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
244 
245  /// @copydoc WorldProxy::GetDerivedSerializableName() const
246  virtual String GetDerivedSerializableName() const;
247  /// @copydoc WorldProxy::GetSerializableName()
248  static String GetSerializableName();
249 
250  ///////////////////////////////////////////////////////////////////////////////
251  // Internal Methods
252 
253  /// @internal
254  /// @brief Accessor for the internal particle system.
255  /// @return Returns a pointer to the internal particle system this proxy is based on.
256  virtual Ogre::ParticleSystem* _GetGraphicsObject() const;
257  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
258  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
259  };//ParticleSystemProxy
260  }//Graphics
261 }//Mezzanine
262 
263 #endif