Spinning Topp Logo BlackTopp Studios
inc
universalconstraint.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 _physicsuniversalconstraint_h
41 #define _physicsuniversalconstraint_h
42 
43 #include "Physics/generic6dofconstraint.h"
44 
45 class btUniversalConstraint;
46 
47 namespace Mezzanine
48 {
49  namespace Physics
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @class UniversalConstraint
53  /// @brief This is a constraint for sharing the rotation of one object along an angular axis with another.
54  /// @details The UniversalConstriant shares some similarities with the Gear and Hinge2 constraints, but it is distinct in the nuance of
55  /// it's behaviors. @n
56  /// With the Gear constraint you can set a ratio on which the amount of rotation that is transferred from the parent
57  /// object to it's child. With the UniversalConstraint the amount of rotation is evenly matched. @n
58  /// With the Hinge2 constraint the axes provided must always be orthogonal and rotations along those axis aren't really related. The
59  /// child can spin about it's own axis without really disrupting the parent whatsoever. With the Universal constraint you must define
60  /// two axes, one on the parent and one on the child, however those axes must be perpendicular to the axis you wish to rotate the object
61  /// around. @n
62  /// After the constraint is constructed the constraint will attempt to keep the axes provided at 90 degrees apart, forcing the parent
63  /// or child to rotate as needed to maintain that angular distance.
65  {
66  protected:
67  /// @copydoc TypedConstraint::_GetConstraintBase() const
68  virtual btUniversalConstraint* Universal() const;
69 
70  /// @copydoc DualTransformConstraint::CreateConstraint(RigidProxy*, RigidProxy*, const Transform&, const Transform&)
71  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Transform& TransA, const Transform& TransB);
72  /// @internal
73  /// @brief Conveniece method used primarily for serialization to create an internal constraint.
74  /// @param RigidA A pointer to the first proxy that will be constrained.
75  /// @param RigidB A pointer to the second proxy that will be constrained.
76  /// @param Anchor The central point around both Axis1 and Axis 2 will connect and spin.
77  /// @param Axis1 An axis perpendicular to the axis you wish to have the ProxyA spin.
78  /// @param Axis2 An axis perpendicular to the axis you wish to have the ProxyB spin.
79  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Vector3& Anchor, const Vector3& Axis1, const Vector3& Axis2);
80  public:
81  /// @brief Convenience axis constructor.
82  /// @remarks All axes passed in should be in world coordinates.
83  /// @param ID The unique identifier assigned to this constraint.
84  /// @param ProxyA A pointer to the first proxy that will be constrained.
85  /// @param ProxyB A pointer to the second proxy that will be constrained.
86  /// @param Anchor The central point around both Axis1 and Axis 2 will connect and spin.
87  /// @param Axis1 An axis perpendicular to the axis you wish to have the ProxyA spin.
88  /// @param Axis2 An axis perpendicular to the axis you wish to have the ProxyB spin.
89  /// @param Creator A pointer to the manager that created this constraint.
90  UniversalConstraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& Anchor, const Vector3& Axis1, const Vector3& Axis2, PhysicsManager* Creator);
91  /// @brief Class constructor.
92  /// @param ID The unique identifier assigned to this constraint.
93  /// @param ProxyA A pointer to the first proxy that will be constrained.
94  /// @param ProxyB A pointer to the second proxy that will be constrained.
95  /// @param TransA The offset and rotation from ProxyAs center of gravity to get to match an offset from ProxyB.
96  /// @param TransB The offset and rotation from ProxyBs center of gravity.
97  /// @param Creator A pointer to the manager that created this constraint.
98  UniversalConstraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Transform& TransA, const Transform& TransB, PhysicsManager* Creator);
99  /// @brief XML constructor.
100  /// @param SelfRoot An XML::Node containing the data to populate this class with.
101  /// @param Creator A pointer to the manager that created this constraint.
102  UniversalConstraint(const XML::Node& SelfRoot, PhysicsManager* Creator);
103  /// @brief Class destructor.
104  virtual ~UniversalConstraint();
105 
106  ///////////////////////////////////////////////////////////////////////////////
107  // Limits
108 
109  /// @brief Sets the maximum angular limits of this constraint.
110  /// @param Ang1Max The maximum angle allowed on Axis1.
111  /// @param Ang2Max The maximum angle allowed on Axis2.
112  virtual void SetUpperLimit(const Real Ang1Max, const Real Ang2Max);
113  /// @brief Sets the minimum angular limits of this constraint.
114  /// @param Ang1Min The minimum angle allowed on Axis1.
115  /// @param Ang2Min The minimum angle allowed on Axis2.
116  virtual void SetLowerLimit(const Real Ang1Min, const Real Ang2Min);
117 
118  ///////////////////////////////////////////////////////////////////////////////
119  // Serialization
120 
121  /// @copydoc Constraint::GetDerivedSerializableName() const
122  virtual String GetDerivedSerializableName() const;
123  /// @brief Get the name of the the XML tag the class will leave behind as its instances are serialized.
124  /// @return A string containing the name of this class.
125  static String GetSerializableName();
126  };//UniversalConstraint
127  }//Physics
128 }//Mezzanine
129 
130 #endif
Create simple but specific limits on any axis of movement or rotation.
This is a constraint for sharing the rotation of one object along an angular axis with another...
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
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
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159