Spinning Topp Logo BlackTopp Studios
inc
areaeffect.h
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 _areaeffect_h
41 #define _areaeffect_h
42 
43 #include "worldobject.h"
44 #include "colourvalue.h"
45 
46 namespace Mezzanine
47 {
48  namespace Graphics
49  {
50  class EntityProxy;
51  class ParticleSystemProxy;
52  }
53  namespace Physics
54  {
55  class GhostProxy;
56  class CollisionShape;
57  }
58  ///////////////////////////////////////////////////////////////////////////////
59  /// @brief This class is used to define area's in the world that have unique effects.
60  /// @details Common uses for this class are for gravity fields, and explosions. But can be made to do more. @n
61  /// Note: This is a base class intended to be derived from. This class cannot be created itself. To make an
62  /// AreaEffect class that does what you want it to, simple inherit from this class with an AE class of your own,
63  /// and define the ApplyEffect() function to do what you want your effect to do.
64  ///////////////////////////////////////
66  {
67  public:
68  /// @brief Basic container type for Object storage by this class.
69  typedef std::vector< WorldObject* > ObjectContainer;
70  /// @brief Iterator type for Object instances stored by this class.
71  typedef ObjectContainer::iterator ObjectIterator;
72  /// @brief Const Iterator type for Object instances stored by this class.
73  typedef ObjectContainer::const_iterator ConstObjectIterator;
74  protected:
75  /// @internal
76  /// @brief Container for actors within the field area.
77  ObjectContainer OverlappingObjects;
78  /// @internal
79  /// @brief Container of actors that have been added since last frame.
80  ObjectContainer AddedObjects;
81  /// @internal
82  /// @brief Container of actors that have been removed since last frame.
83  ObjectContainer RemovedObjects;
84  /// @internal
85  /// @brief Container of proxies that representing this AE field.
86  ProxyContainer AEProxies;
87  /// @internal
88  /// @brief A pointer to the ghost powering this AE field.
90 
91  /// @internal
92  /// @brief Common constructor method for AreaEffect base class.
93  /// @param Shape A pointer to the collision shape that will be applied to this object.
94  virtual void CreateAreaEffect(Physics::CollisionShape* Shape);
95  /// @internal
96  /// @brief Common destructor method for AreaEffect base class.
97  virtual void DestroyAreaEffect();
98  public:
99  /// @brief Blank constructor.
100  /// @param TheWorld A pointer to the world this object belongs to.
101  AreaEffect(World* TheWorld);
102  /// @brief Class constructor.
103  /// @param Name The name to be given to this object.
104  /// @param TheWorld A pointer to the world this object belongs to.
105  AreaEffect(const String& Name, World* TheWorld);
106  /// @brief Class constructor.
107  /// @param Name The name to be given to this object.
108  /// @param Shape A pointer to the collision shape that will be applied to this object.
109  /// @param TheWorld A pointer to the world this object belongs to.
110  AreaEffect(const String& Name, Physics::CollisionShape* Shape, World* TheWorld);
111  /// @brief Class destructor.
112  virtual ~AreaEffect();
113 
114  ///////////////////////////////////////////////////////////////////////////////
115  // Utility
116 
117  /// @copydoc Mezzanine::WorldObject::GetType() const
118  virtual WorldObjectType GetType() const;
119 
120  /// @brief Gets a pointer to the physics portion of this AreaEffect.
121  /// @return Returns a pointer to the Ghost proxy representing the physics portion of this AreaEffect.
122  virtual Physics::GhostProxy* GetGhostProxy() const;
123 
124  /// @brief Defines and applies the effect of the field.
125  /// @details When inheriting this class, this function is what defines the effect the field has. @n
126  /// This function will be called on by the physics manager and shouldn't be called manually.
127  virtual void ApplyEffect() = 0;
128 
129  /// @copydoc Mezzanine::WorldObject::IsInWorld() const
130  virtual Boole IsInWorld() const;
131 
132  /// @copydoc Mezzanine::WorldObject::IsStatic() const
133  virtual Boole IsStatic() const;
134  /// @copydoc Mezzanine::WorldObject::IsKinematic() const
135  virtual Boole IsKinematic() const;
136 
137  /// @copydoc Mezzanine::WorldObject::GetProxies(ProxyContainer&)
138  virtual void GetProxies(ProxyContainer& Proxies);
139  /// @copydoc Mezzanine::WorldObject::GetProxies(const UInt32, ProxyContainer&)
140  virtual void GetProxies(const UInt32 Types, ProxyContainer& Proxies);
141 
142  ///////////////////////////////////////////////////////////////////////////////
143  // Working with the World
144 
145  /// @copydoc Mezzanine::WorldObject::AddToWorld()
146  virtual void AddToWorld();
147  /// @copydoc Mezzanine::WorldObject::RemoveFromWorld()
148  virtual void RemoveFromWorld();
149 
150  ///////////////////////////////////////////////////////////////////////////////
151  // Overlapping Object Management
152 
153  /// @brief Gets the number of objects currently overlapping with this AE.
154  /// @return Returns the number of objects inside this AE.
155  UInt32 GetNumOverlappingObjects() const;
156  /// @brief Gets the number of objects added to this AE since the last update.
157  /// @note Updates are usually once per frame, but can be manipulated to be more or less frequent.
158  /// @return Returns the number of new objects overlapping with this AE.
159  UInt32 GetNumAddedObjects() const;
160  /// @brief Gets the number of objects removed from this AE since the last update.
161  /// @note Updates are usually once per frame, but can be manipulated to be more or less frequent.
162  /// @return Returns the number of objects that were found to no longer be overlapping during the last update.
163  UInt32 GetNumRemovedObjects() const;
164  /// @brief Gets the list of objects within this field.
165  /// @return Returns the list of objects contained within this field.
166  ObjectContainer& GetOverlappingObjects();
167  /// @brief Gets the list of objects that have been added to the list since the last simulation step.
168  /// @return Returns the vector storing all the objects that have been added to the list since the last simulation step.
169  ObjectContainer& GetAddedObjects();
170  /// @brief Gets the list of objects that have been removed from the list since the last simulation step.
171  /// @return Returns the vector storing all the objects that have been removed from the list since the last simulation step.
172  ObjectContainer& GetRemovedObjects();
173 
174  ///////////////////////////////////////////////////////////////////////////////
175  // AreaEffect Properties
176 
177  ///////////////////////////////////////////////////////////////////////////////
178  // Transform Methods
179 
180  /// @copydoc TransformableObject::SetLocation(const Vector3&)
181  virtual void SetLocation(const Vector3& Loc);
182  /// @copydoc TransformableObject::SetLocation(const Real, const Real, const Real)
183  virtual void SetLocation(const Real X, const Real Y, const Real Z);
184  /// @copydoc TransformableObject::GetLocation() const
185  virtual Vector3 GetLocation() const;
186  /// @copydoc TransformableObject::SetOrientation(const Quaternion&)
187  virtual void SetOrientation(const Quaternion& Ori);
188  /// @copydoc TransformableObject::SetOrientation(const Real, const Real, const Real, const Real)
189  virtual void SetOrientation(const Real X, const Real Y, const Real Z, const Real W);
190  /// @copydoc TransformableObject::GetOrientation() const
191  virtual Quaternion GetOrientation() const;
192  /// @copydoc TransformableObject::SetScale(const Vector3&)
193  virtual void SetScale(const Vector3& Sc);
194  /// @copydoc TransformableObject::SetScale(const Real, const Real, const Real)
195  virtual void SetScale(const Real X, const Real Y, const Real Z);
196  /// @copydoc TransformableObject::GetScale() const
197  virtual Vector3 GetScale() const;
198 
199  /// @copydoc TransformableObject::Translate(const Vector3&)
200  virtual void Translate(const Vector3& Trans);
201  /// @copydoc TransformableObject::Translate(const Real, const Real, const Real)
202  virtual void Translate(const Real X, const Real Y, const Real Z);
203  /// @copydoc TransformableObject::Yaw(const Real)
204  virtual void Yaw(const Real Angle);
205  /// @copydoc TransformableObject::Pitch(const Real)
206  virtual void Pitch(const Real Angle);
207  /// @copydoc TransformableObject::Roll(const Real)
208  virtual void Roll(const Real Angle);
209  /// @copydoc TransformableObject::Rotate(const Vector3&, const Real)
210  virtual void Rotate(const Vector3& Axis, const Real Angle);
211  /// @copydoc TransformableObject::Rotate(const Quaternion&)
212  virtual void Rotate(const Quaternion& Rotation);
213  /// @copydoc TransformableObject::Scale(const Vector3&)
214  virtual void Scale(const Vector3& Scale);
215  /// @copydoc TransformableObject::Scale(const Real, const Real, const Real)
216  virtual void Scale(const Real X, const Real Y, const Real Z);
217 
218  ///////////////////////////////////////////////////////////////////////////////
219  // Serialization
220 
221  /// @copydoc Mezzanine::WorldObject::ProtoSerializeProperties(XML::Node& SelfRoot) const
222  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
223  /// @copydoc Mezzanine::WorldObject::ProtoSerializeProxies(XML::Node&) const
224  virtual void ProtoSerializeProxies(XML::Node& SelfRoot) const;
225 
226  /// @copydoc Mezzanine::WorldObject::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
227  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
228  /// @copydoc Mezzanine::WorldObject::ProtoDeSerializeProxies(const XML::Node&)
229  virtual void ProtoDeSerializeProxies(const XML::Node& SelfRoot);
230 
231  /// @copydoc Mezzanine::WorldObject::GetDerivedSerializableName() const
232  virtual String GetDerivedSerializableName() const;
233  /// @copydoc Mezzanine::WorldObject::GetSerializableName()
234  static String GetSerializableName();
235 
236  ///////////////////////////////////////////////////////////////////////////////
237  // Internal Methods
238 
239  /// @copydoc Mezzanine::WorldObject::_Update()
240  virtual void _Update();
241  /// @copydoc Mezzanine::WorldObject::_NotifyProxyDestroyed(WorldProxy*)
242  virtual void _NotifyProxyDestroyed(WorldProxy* ToBeDestroyed);
243  };//AreaEffect
244 
245  ///////////////////////////////////////////////////////////////////////////////
246  /// @brief A base factory type for the creation of AreaEffect objects.
247  /// @details
248  ///////////////////////////////////////
250  {
251  public:
252  /// @brief Class constructor.
254  /// @brief Class destructor.
255  virtual ~AreaEffectFactory() { }
256 
257  /// @brief Gets the name of the AreaEffect that is created by this factory.
258  /// @return Returns the typename of the AreaEffect created by this factory.
259  virtual String GetTypeName() const = 0;
260 
261  /// @brief Creates a AreaEffect of the type represented by this factory.
262  /// @param Name The name to be given to this object.
263  /// @param TheWorld A pointer to the world this object belongs to.
264  /// @param Params A NameValuePairList containing the params to be applied during construction.
265  /// @return Returns a pointer to the AreaEffect created.
266  virtual AreaEffect* CreateAreaEffect(const String& Name, World* TheWorld, const NameValuePairMap& Params) = 0;
267  /// @brief Creates a AreaEffect from XML.
268  /// @param XMLNode The node of the xml document to construct from.
269  /// @param TheWorld A pointer to the world this object belongs to.
270  /// @return Returns a pointer to the AreaEffect created.
271  virtual AreaEffect* CreateAreaEffect(const XML::Node& XMLNode, World* TheWorld) = 0;
272  /// @brief Destroys a AreaEffect created by this factory.
273  /// @param ToBeDestroyed A pointer to the AreaEffect to be destroyed.
274  virtual void DestroyAreaEffect(AreaEffect* ToBeDestroyed) = 0;
275  };//AreaEffectFactory
276 }//Mezzanine
277 
278 #endif
This is the base class for all collision shapes.
ObjectContainer AddedObjects
Container of actors that have been added since last frame.
Definition: areaeffect.h:80
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
std::vector< WorldObject * > ObjectContainer
Basic container type for Object storage by this class.
Definition: areaeffect.h:69
ProxyContainer AEProxies
Container of proxies that representing this AE field.
Definition: areaeffect.h:86
This is the proxy object for ghost objects with no contact response.
Definition: ghostproxy.h:55
ObjectContainer::iterator ObjectIterator
Iterator type for Object instances stored by this class.
Definition: areaeffect.h:71
ObjectContainer OverlappingObjects
Container for actors within the field area.
Definition: areaeffect.h:77
This is the proxy class for placing and manipulating a mesh in the scene.
Definition: entityproxy.h:62
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
This is the base class from which classes that are insertable into the physical world.
Definition: worldobject.h:60
This class is used to define area's in the world that have unique effects.
Definition: areaeffect.h:65
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is the base class for proxy objects belonging to the various 3D subsystems.
Definition: worldproxy.h:53
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
A base factory type for the creation of AreaEffect objects.
Definition: areaeffect.h:249
Physics::GhostProxy * Ghost
A pointer to the ghost powering this AE field.
Definition: areaeffect.h:89
AreaEffectFactory()
Class constructor.
Definition: areaeffect.h:253
ObjectContainer::const_iterator ConstObjectIterator
Const Iterator type for Object instances stored by this class.
Definition: areaeffect.h:73
virtual ~AreaEffectFactory()
Class destructor.
Definition: areaeffect.h:255
This is the proxy class for placing and manipulating particles in the scene.
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
WorldObjectType
Used by various classes to help identify what class an object is.
Definition: enumerations.h:147
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
This class represents a world for objects to interact within.
Definition: world.h:74
This is used to store information about rotation in 3d space.
Definition: quaternion.h:68
ObjectContainer RemovedObjects
Container of actors that have been removed since last frame.
Definition: areaeffect.h:83
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