Spinning Topp Logo BlackTopp Studios
inc
gearconstraint.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 _physicsgearconstraint_h
41 #define _physicsgearconstraint_h
42 
43 #include "Physics/constraint.h"
44 
45 class btGearConstraint;
46 
47 namespace Mezzanine
48 {
49  namespace Physics
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @class GearConstraint
53  /// @brief This is a constraint that duplicate the angular motion of one object to another, adjusted by the provided ratio.
54  /// @details
55  ///////////////////////////////////////
57  {
58  protected:
59  /// @internal
60  /// @brief Bullet constraint that this class encapsulates.
61  btGearConstraint* Gear;
62 
63  /// @internal
64  /// @brief Creates the internal constraint.
65  /// @remarks This methods exists primarily as a convenience for serialization, and shouldn't be called unless it is known to be safe.
66  /// @param RigidA A pointer to the first Proxy to be constrained.
67  /// @param RigidB A pointer to the second Proxy to be constrained.
68  /// @param AxisA The offset to place the constraint in the first proxys local space.
69  /// @param AxisB The offset to place the constraint in the second proxys local space.
70  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Vector3& AxisA, const Vector3& AxisB);
71  /// @internal
72  /// @brief Destroys the internal constraint.
73  /// @remarks This methods exists primarily as a convenience for serialization, and shouldn't be called unless it is known to be safe.
74  virtual void DestroyConstraint();
75  public:
76  /// @brief Double body constructor. Binds the two bodies.
77  /// @param ID The unique identifier assigned to this constraint.
78  /// @param ProxyA The first proxy to apply this constraint to.
79  /// @param ProxyB The second proxy to apply this constraint to.
80  /// @param PivotA The axis in ProxyA's local space to apply the constraint to.
81  /// @param PivotB The axis in ProxyB's local space to apply the constraint to.
82  /// @param Creator A pointer to the manager that created this constraint.
83  GearConstraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& AxisA, const Vector3& AxisB, PhysicsManager* Creator);
84  /// @brief Double body constructor. Binds the two bodies.
85  /// @param ID The unique identifier assigned to this constraint.
86  /// @param ProxyA The first proxy to apply this constraint to.
87  /// @param ProxyB The second proxy to apply this constraint to.
88  /// @param PivotA The axis in ProxyA's local space to apply the constraint to.
89  /// @param PivotB The axis in ProxyB's local space to apply the constraint to.
90  /// @param Ratio The amount the rotation from ProxyA that shall be used to be applied to ProxyB.
91  /// @param Creator A pointer to the manager that created this constraint.
92  GearConstraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& AxisA, const Vector3& AxisB, const Real Ratio, PhysicsManager* Creator);
93  /// @brief XML constructor.
94  /// @param SelfRoot An XML::Node containing the data to populate this class with.
95  /// @param Creator A pointer to the manager that created this constraint.
96  GearConstraint(const XML::Node& SelfRoot, PhysicsManager* Creator);
97  /// @brief Class destructor.
98  virtual ~GearConstraint();
99 
100  ///////////////////////////////////////////////////////////////////////////////
101  // Axis configuration
102 
103  /// @brief Sets the axis in ActorA's local space which will translate to ActorB.
104  /// @param Axis A vector3 expressing the axis on ActorA this constraint will be applied to.
105  virtual void SetAxisA(const Vector3& Axis);
106  /// @brief Sets the axis in ActorB's local space which will be manipulated.
107  /// @param Axis A vector3 expressing the axis on ActorB this constraint will be applied to.
108  virtual void SetAxisB(const Vector3& Axis);
109  /// @brief Gets the axis in ActorA's local space which will translate to ActorB.
110  /// @return Returns a vector3 expressing the axis on ActorA this constraint is being applied to.
111  virtual Vector3 GetAxisA() const;
112  /// @brief Gets the axis in ActorB's local space which will be manipulated.
113  /// @return Returns a vector3 expressing the axis on ActorB this constraint is being applied to.
114  virtual Vector3 GetAxisB() const;
115 
116  ///////////////////////////////////////////////////////////////////////////////
117  // Ratio Configuration
118 
119  /// @brief Sets the ratio at which ActorA's rotation will be applied to ActorB.
120  /// @param Ratio The ratio at which rotations on ActorA's specified axis will be transfered to ActorB's specified axis.
121  virtual void SetRotationRatio(const Real Ratio);
122  /// @brief Gets the ratio at which ActorA's rotation will be applied to ActorB.
123  /// @return Returns a Real representing the ratio at which rotations on ActorA's specified axis is being transfered to ActorB's specified axis.
124  virtual Real GetRotationRatio() const;
125 
126  ///////////////////////////////////////////////////////////////////////////////
127  // Parameter Configuration
128 
129  /// @copydoc Constraint::GetValidParamsOnAxis(int) const
130  virtual Constraint::ParamList GetValidParamsOnAxis(int Axis) const;
131  /// @copydoc Constraint::GetValidLinearAxes() const
132  virtual Constraint::AxisList GetValidLinearAxes() const;
133  /// @copydoc Constraint::GetValidAngularAxes() const
134  virtual Constraint::AxisList GetValidAngularAxes() const;
135  /// @copydoc Constraint::ValidAngularAxis(ConstraintParam,int) const
136  virtual Boole HasParamBeenSet(ConstraintParam Param, int Axis) const;
137 
138  ///////////////////////////////////////////////////////////////////////////////
139  // Serialization
140 
141  /// @copydoc Constraint::ProtoSerializeInitData(XML::Node&) const
142  virtual void ProtoSerializeInitData(XML::Node& SelfRoot) const;
143  /// @copydoc Constraint::ProtoSerializeProperties(XML::Node&) const
144  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
145 
146  /// @copydoc Constraint::ProtoDeSerializeInitData(const XML::Node&)
147  virtual void ProtoDeSerializeInitData(const XML::Node& SelfRoot);
148  /// @copydoc Constraint::ProtoDeSerializeProperties(const XML::Node&)
149  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
150 
151  /// @copydoc Constraint::GetDerivedSerializableName() const
152  virtual String GetDerivedSerializableName() const;
153  /// @brief Get the name of the the XML tag the class will leave behind as its instances are serialized.
154  /// @return A string containing the name of this class.
155  static String GetSerializableName();
156 
157  ///////////////////////////////////////////////////////////////////////////////
158  // Internal Methods
159 
160  /// @copydoc Constraint::_GetConstraintBase() const
161  virtual btTypedConstraint* _GetConstraintBase() const;
162  };//GearConstraint
163  }//Physics
164 }//Mezzanine
165 
166 #endif
std::vector< int > AxisList
Used to Store lists of Int Axis for return types.
Definition: constraint.h:124
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
This is the base class for all constraints supported.
Definition: constraint.h:116
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
btGearConstraint * Gear
Bullet constraint that this class encapsulates.
ConstraintParam
Used by constraints for setting some parameters.
Definition: constraint.h:61
This is a proxy from which rigid body proxys are handled.
Definition: rigidproxy.h:102
std::vector< ConstraintParam > ParamList
Used to Store lists of param for return types.
Definition: constraint.h:120
This is simply a place for storing all the Physics Related functions.
This is a constraint that duplicate the angular motion of one object to another, adjusted by the prov...
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