Spinning Topp Logo BlackTopp Studios
inc
worldproxy.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 _worldproxy_h
41 #define _worldproxy_h
42 
43 #include "transformableobject.h"
44 
45 namespace Mezzanine
46 {
47  class WorldObject;
48  class WorldManager;
49  ///////////////////////////////////////////////////////////////////////////////
50  /// @brief This is the base class for proxy objects belonging to the various 3D subsystems.
51  /// @details
52  ///////////////////////////////////////
54  {
55  protected:
56  /// @internal
57  /// @brief Pointer to the Object this proxy belongs to.
59  /// @internal
60  /// @brief The unique ID assigned to the type of proxy an instance is.
62 
63  /// @internal
64  /// @brief Implementation method for serializing additional sets of data.
65  /// @param SelfRoot The root node containing all the serialized data for this instance.
66  virtual void ProtoSerializeImpl(XML::Node& SelfRoot) const;
67  /// @internal
68  /// @brief Implementation method for deseriailizing additional sets of data.
69  /// @param SelfRoot An XML::Node containing the data to populate this class with.
70  virtual void ProtoDeSerializeImpl(const XML::Node& SelfRoot);
71  public:
72  /// @brief Blank constructor.
73  WorldProxy();
74  /// @brief Normal/ID constructor.
75  /// @param ID The unique ID assigned to the type of proxy an instance is.
76  WorldProxy(const UInt32 ID);
77  /// @brief Class destructor.
78  virtual ~WorldProxy();
79 
80  ///////////////////////////////////////////////////////////////////////////////
81  // Utility
82 
83  /// @brief Accessor for the type of proxy.
84  /// @return Returns enum value for the type of proxy this object is.
85  virtual Mezzanine::ProxyType GetProxyType() const = 0;
86  /// @brief Performs all the necessary task to ensure this object is connected to it's respective world and ready for use.
87  virtual void AddToWorld() = 0;
88  /// @brief Unhooks this proxy from it's respective world.
89  virtual void RemoveFromWorld() = 0;
90  /// @brief Gets whether or not this object is inside of it's world.
91  /// @return Returns true if this proxy is inserted in it's respective subsystems world.
92  virtual Boole IsInWorld() const = 0;
93 
94  /// @brief Gets a pointer to the parent object controlling this proxy.
95  /// @return Returns a pointer to the WorldObject controlling this proxy, or NULL if this proxy isn't bound to a WorldObject.
96  virtual WorldObject* GetParentObject() const;
97  /// @brief Gets the unique ID of this proxy.
98  /// @remarks Proxy IDs are only unique to their family of proxies belonging to a specific subsystem. Across subsystems IDs can be reused.
99  /// @return Returns a UInt32 containing the unique ID for this proxy.
100  virtual UInt32 GetProxyID() const;
101  /// @brief Gets a pointer to this proxies creator.
102  /// @return Returns a pointer to the WorldManager that created this WorldProxy.
103  virtual WorldManager* GetCreator() const = 0;
104 
105  ///////////////////////////////////////////////////////////////////////////////
106  // Transform Methods
107 
108  /// @copydoc TransformableObject::SetLocation(const Vector3&)
109  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
110  virtual void SetLocation(const Vector3& Loc) = 0;
111  /// @copydoc TransformableObject::SetLocation(const Real, const Real, const Real)
112  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
113  virtual void SetLocation(const Real X, const Real Y, const Real Z) = 0;
114  /// @copydoc TransformableObject::GetLocation() const
115  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
116  virtual Vector3 GetLocation() const = 0;
117  /// @copydoc TransformableObject::SetOrientation(const Quaternion&)
118  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
119  virtual void SetOrientation(const Quaternion& Ori) = 0;
120  /// @copydoc TransformableObject::SetOrientation(const Real, const Real, const Real, const Real)
121  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
122  virtual void SetOrientation(const Real X, const Real Y, const Real Z, const Real W) = 0;
123  /// @copydoc TransformableObject::GetOrientation() const
124  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
125  virtual Quaternion GetOrientation() const = 0;
126  /// @copydoc TransformableObject::SetScale(const Vector3&)
127  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
128  virtual void SetScale(const Vector3& Sc) = 0;
129  /// @copydoc TransformableObject::SetScale(const Real, const Real, const Real)
130  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
131  virtual void SetScale(const Real X, const Real Y, const Real Z) = 0;
132  /// @copydoc TransformableObject::GetScale() const
133  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
134  virtual Vector3 GetScale() const = 0;
135 
136  /// @copydoc TransformableObject::Translate(const Vector3&)
137  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
138  virtual void Translate(const Vector3& Trans) = 0;
139  /// @copydoc TransformableObject::Translate(const Real, const Real, const Real)
140  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
141  virtual void Translate(const Real X, const Real Y, const Real Z) = 0;
142  /// @copydoc TransformableObject::Yaw(const Real)
143  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
144  virtual void Yaw(const Real Angle) = 0;
145  /// @copydoc TransformableObject::Pitch(const Real)
146  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
147  virtual void Pitch(const Real Angle) = 0;
148  /// @copydoc TransformableObject::Roll(const Real)
149  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
150  virtual void Roll(const Real Angle) = 0;
151  /// @copydoc TransformableObject::Rotate(const Vector3&, const Real)
152  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
153  virtual void Rotate(const Vector3& Axis, const Real Angle) = 0;
154  /// @copydoc TransformableObject::Rotate(const Quaternion&)
155  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
156  virtual void Rotate(const Quaternion& Rotation) = 0;
157  /// @copydoc TransformableObject::Scale(const Vector3&)
158  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
159  virtual void Scale(const Vector3& Scale) = 0;
160  /// @copydoc TransformableObject::Scale(const Real, const Real, const Real)
161  /// @warning Calling this method directly can de-sync a WorldObject. Do NOT do this unless you know exactly what you are doing.
162  virtual void Scale(const Real X, const Real Y, const Real Z) = 0;
163 
164  ///////////////////////////////////////////////////////////////////////////////
165  // Serialization
166 
167  /// @brief Convert this class to an XML::Node ready for serialization.
168  /// @param ParentNode The point in the XML hierarchy that all this renderable should be appended to.
169  virtual void ProtoSerialize(XML::Node& ParentNode) const;
170  /// @brief Convert the properties of this class to an XML::Node ready for serialization.
171  /// @param SelfRoot The root node containing all the serialized data for this instance.
172  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
173 
174  /// @brief Take the data stored in an XML Node and overwrite this object with it.
175  /// @param SelfRoot An XML::Node containing the data to populate this class with.
176  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
177  /// @brief Take the data stored in an XML Node and overwrite the properties of this object with it.
178  /// @param SelfRoot An XML::Node containing the data to populate this class with.
179  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
180 
181  /// @brief Gets the most derived serializable name of this WorldProxy.
182  /// @note When creating a new WorldProxy class verify this method has a valid return for it in order for serialization to work properly.
183  /// @return Returns the name of the XML tag from the most derived class of "this".
184  virtual String GetDerivedSerializableName() const;
185  /// @brief Get the name of the the XML tag the proxy class will leave behind as its instances are serialized.
186  /// @return A string containing the name of this class.
187  static String GetSerializableName();
188 
189  ///////////////////////////////////////////////////////////////////////////////
190  // Internal Methods
191 
192  /// @internal
193  /// @brief Binds this proxy to a WorldObject.
194  /// @param NewParent A pointer to the WorldObject taking possession of this proxy.
195  void _Bind(WorldObject* NewParent);
196  };//WorldProxy
197 }//Mezzanine
198 
199 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
This is an interface for all 3D objects that can have their full transforms manipulated.
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
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
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
WorldObject * ParentObject
Pointer to the Object this proxy belongs to.
Definition: worldproxy.h:58
This is the base class for all managers that belong to a single world instance.
Definition: worldmanager.h:55
UInt32 ProxyID
The unique ID assigned to the type of proxy an instance is.
Definition: worldproxy.h:61
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...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
This is used to store information about rotation in 3d space.
Definition: quaternion.h:68
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159