Spinning Topp Logo BlackTopp Studios
inc
dualtransformconstraint.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 _physicsdualtransformconstraint_h
41 #define _physicsdualtransformconstraint_h
42 
43 #include "Physics/constraint.h"
44 
45 namespace Mezzanine
46 {
47  namespace Physics
48  {
49  ///////////////////////////////////////////////////////////////////////////////
50  /// @brief All constraints that track rotation and location of the Pivot relative to each Actor inherit from this.
51  /// @details Since not all contraints provide tracking for the Actor Transform (location/rotation of the pivot)
52  /// we subdivided the constraints to unify the interface of those that could be unified. This stores nothing, but
53  /// provides uniform access to the transform and rotation functions. \n \n
54  /// Any deriving class must implement every thing from TypedConstraint and the four set/get Transform function. It
55  /// is expected that more derived classes will implement the Set/Get Pivot/Rotation Function in a more efficient
56  /// Manner if a more efficient way exists. The non-transform get/set function are implmented in terms of the
57  /// get/set transform function extra copies of values and extra reading/writing may occur if the compiler weakly
58  /// optimizes. Of course, implementing more functions could slow down the software if it no longer fits in CPU
59  /// caches. As always benchmark if this is something that may be critically slowing you down.
60  ///////////////////////////////////////////////////////////////////////////////
62  {
63  protected:
64  /// @internal
65  /// @brief Creates the internal constraint.
66  /// @remarks This methods exists primarily as a convenience for serialization, and shouldn't be called unless it is known to be safe.
67  /// @param RigidA A pointer to the first Proxy to be constrained.
68  /// @param RigidB A pointer to the second Proxy to be constrained.
69  /// @param TransA The offset to place the constraint in the first proxys local space.
70  /// @param TransB The offset to place the constraint in the second proxys local space.
71  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Transform& TransA, const Transform& TransB) = 0;
72  /// @internal
73  /// @brief Destroys the internal constraint.
74  /// @remarks This methods exists primarily as a convenience for serialization, and shouldn't be called unless it is known to be safe.
75  virtual void DestroyConstraint() = 0;
76 
77  /// @internal
78  /// @brief Single body inheritance constructor.
79  /// @param ID The unique identifier assigned to this constraint.
80  /// @param Prox1 A pointer to the first/only proxy that will be constrained.
81  /// @param Creator A pointer to the manager that created this constraint.
82  DualTransformConstraint(const UInt32 ID, RigidProxy* Prox1, PhysicsManager* Creator);
83  /// @internal
84  /// @brief Dual body inheritance constructor.
85  /// @param ID The unique identifier assigned to this constraint.
86  /// @param Prox1 A pointer to the first proxy that will be constrained.
87  /// @param Prox2 A pointer to the second proxy that will be constrained.
88  /// @param Creator A pointer to the manager that created this constraint.
89  DualTransformConstraint(const UInt32 ID, RigidProxy* Prox1, RigidProxy* Prox2, PhysicsManager* Creator);
90  public:
91  /// @brief Class destructor.
92  virtual ~DualTransformConstraint();
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Transform Methods
96 
97  /// @brief Sets the Position and Rotation for the first and second body using a Transform.
98  /// @param TransA The new position and rotation for ProxyA.
99  /// @param TransB The new position and rotation for ProxyB.
100  virtual void SetPivotTransforms(const Transform& TransA, const Transform& TransB);
101  /// @brief Sets the Position and Rotation for the first body using a Transform.
102  /// @param TransA The new position and rotation.
103  virtual void SetPivotATransform(const Transform& TransA) = 0;
104  /// @brief Sets the Position and Rotation for the second body using a Transform.
105  /// @param TransB The new position and rotation.
106  virtual void SetPivotBTransform(const Transform& TransB) = 0;
107  /// @brief Gets the current Rotation and Location of ProxyA.
108  /// @return This returns a Mezzanine::Transform.
109  virtual Transform GetPivotATransform() const = 0;
110  /// @brief Gets the current Rotation and Location of ProxyB.
111  /// @return This returns a Mezzanine::Transform.
112  virtual Transform GetPivotBTransform() const = 0;
113 
114  /// @brief Sets The relative location of the pivot from ProxA's Center of gravity.
115  /// @param Location The New value for PivotA.
116  virtual void SetPivotALocation(const Vector3& Location);
117  /// @brief Sets The relative location of the pivot from ProxB's Center of gravity.
118  /// @param Location The New value for PivotB.
119  virtual void SetPivotBLocation(const Vector3& Location);
120  /// @brief Gets the location of the pivot relative to ProxA's Center of gravity.
121  /// @return A Vector3 with the pivot location.
122  virtual Vector3 GetPivotALocation() const;
123  /// @brief Gets the location of the pivot relative to ProxB's Center of gravity.
124  /// @return A Vector3 with the pivot location.
125  virtual Vector3 GetPivotBLocation() const;
126 
127  /// @brief Sets The relative rotation of ProxA.
128  /// @param Rotation The new rotation amount for ProxA.
129  virtual void SetPivotARotation(const Quaternion& Rotation);
130  /// @brief Sets The relative rotation of ProxB.
131  /// @param otation The new rotation amount for ProxB.
132  virtual void SetPivotBRotation(const Quaternion& Rotation);
133  /// @brief Gets the relative rotation for ProxA.
134  /// @return A Quaternion that has the rotation.
135  virtual Quaternion GetPivotARotation() const;
136  /// @brief Gets the relative rotation for ProxB.
137  /// @return A Quaternion that has the rotation.
138  virtual Quaternion GetPivotBRotation() const;
139 
140  ///////////////////////////////////////////////////////////////////////////////
141  // Serialization
142 
143  /// @copydoc Constraint::ProtoSerializeInitData(XML::Node&) const
144  virtual void ProtoSerializeInitData(XML::Node& SelfRoot) const;
145  /// @copydoc Constraint::ProtoDeSerializeInitData(const XML::Node&)
146  virtual void ProtoDeSerializeInitData(const XML::Node& SelfRoot);
147 
148  /// @brief Get the name of the the XML tag the class will leave behind as its instances are serialized.
149  /// @return A string containing the name of this class.
150  static String GetSerializableName();
151  };//DualTransformConstraint
152  }//Physics
153 }//Mezzanine
154 
155 #endif
All constraints that track rotation and location of the Pivot relative to each Actor inherit from thi...
This is the base class for all constraints supported.
Definition: constraint.h:116
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This is a proxy from which rigid body proxys are handled.
Definition: rigidproxy.h:102
Stores information about relative location and rotation in 3d space.
Definition: transform.h:62
This is simply a place for storing all the Physics Related functions.
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