Spinning Topp Logo BlackTopp Studios
inc
hinge2constraint.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 _physicshinge2constraint_h
41 #define _physicshinge2constraint_h
42 
43 #include "Physics/generic6dofspringconstraint.h"
44 
45 #ifndef SWIG
46 class btHinge2Constraint;
47 
48 namespace Mezzanine
49 {
50  namespace Physics
51  {
52  ///////////////////////////////////////////////////////////////////////////////
53  /// @class Hinge2Constraint
54  /// @brief This is a convience class that will configure a 6DoF spring constraint with 2 angular and 1 linear (with a spring) axes of freedom such that it can behave like a wheel and axel.
55  /// @details Simulating a Wheel and Axel is the primary use for this constraint. The 2 angular axes that it gives you are the axis for rotating the child object around the parents axis
56  /// (aka turning the wheel), and the child rotating around it's own local axis (aka spinning the wheel for motion). The linear axis acts as suspension (which is where the spring comes in).
57  /// @n @n
58  /// In a normal vehicle use case, Axis1 would be the vertical axis of the main body. Axis2 would be the X axis of the main body, assuming it is pointed along the Z axis.
59  ///////////////////////////////////////
61  {
62  protected:
63  /// @copydoc TypedConstraint::_GetConstraintBase() const
64  virtual btHinge2Constraint* Hinge2() const;
65 
66  /// @copydoc DualTransformConstraint::CreateConstraint(RigidProxy*, RigidProxy*, const Transform&, const Transform&)
67  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Transform& TransA, const Transform& TransB);
68  /// @internal
69  /// @brief Conveniece method used primarily for serialization to create an internal constraint.
70  /// @param RigidA A pointer to the first proxy that will be constrained.
71  /// @param RigidB A pointer to the second proxy that will be constrained.
72  /// @param Anchor The point in world cocrdinates where the "axel" and "suspension" meet.
73  /// @param Axis1 The axis on which the child object should rotate about the parent object(aka turning). Must be orthogonal to Axis2.
74  /// @param Axis2 The axis on which the child object will rotate on it's own(aka spinning).
75  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Vector3& Anchor, const Vector3& Axis1, const Vector3& Axis2);
76  public:
77  /// @brief Convenience constructor.
78  /// @remarks All axes passed in should be in world coordinates.
79  /// @param ID The unique identifier assigned to this constraint.
80  /// @param ProxyA A pointer to the first proxy that will be constrained.
81  /// @param ProxyB A pointer to the second proxy that will be constrained.
82  /// @param Anchor The point in world cocrdinates where the "axel" and "suspension" meet.
83  /// @param Axis1 The axis on which the child object should rotate about the parent object(aka turning). Must be orthogonal to Axis2.
84  /// @param Axis2 The axis on which the child object will rotate on it's own(aka spinning).
85  /// @param Creator A pointer to the manager that created this constraint.
86  Hinge2Constraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& Anchor, const Vector3& Axis1, const Vector3& Axis2, PhysicsManager* Creator);
87  /// @brief Dual-Transform constructor.
88  /// @param ID The unique identifier assigned to this constraint.
89  /// @param ProxyA A pointer to the first proxy that will be constrained.
90  /// @param ProxyB A pointer to the second proxy that will be constrained.
91  /// @param TransA The offset and rotation from ProxyAs center of gravity to get to match an offset from ProxyB.
92  /// @param TransB The offset and rotation from ProxyBs center of gravity.
93  /// @param Creator A pointer to the manager that created this constraint.
94  Hinge2Constraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Transform& TransA, const Transform& TransB, PhysicsManager* Creator);
95  /// @brief XML constructor.
96  /// @param SelfRoot An XML::Node containing the data to populate this class with.
97  /// @param Creator A pointer to the manager that created this constraint.
98  Hinge2Constraint(const XML::Node& SelfRoot, PhysicsManager* Creator);
99  /// @brief Class destructor.
100  virtual ~Hinge2Constraint();
101 
102  ///////////////////////////////////////////////////////////////////////////////
103  // Limits
104 
105  /// @brief Convenience method for setting the maximum allowed turning angle.
106  /// @param AngelMax The maximum angle the child object is allowed to rotated around the parent (max turning angle).
107  virtual void SetUpperLimit(const Real AngelMax);
108  /// @brief Convenience method for setting the minimum allowed turning angle.
109  /// @param AngelMin The minimum angle the child object is allowed to rotated around the parent (min turning angle).
110  virtual void SetLowerLimit(const Real AngelMin);
111 
112  ///////////////////////////////////////////////////////////////////////////////
113  // Serialization
114 
115  /// @copydoc Constraint::GetDerivedSerializableName() const
116  virtual String GetDerivedSerializableName() const;
117  /// @brief Get the name of the the XML tag the class will leave behind as its instances are serialized.
118  /// @return A string containing the name of this class.
119  static String GetSerializableName();
120  };//Hinge2Constraint
121  }//Physics
122 }//Mezzanine
123 #endif
124 
125 
126 #endif
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 convience class that will configure a 6DoF spring constraint with 2 angular and 1 linear (w...
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
Creates a constraint as configurable as the 6Dof constraint, but has added support for spring motion...
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159