MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gearconstraint.h
1 // © Copyright 2010 - 2014 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  /// @headerfile gearconstraint.h
54  /// @brief This is a constraint that duplicate the angular motion of one object to another, adjusted by the provided ratio.
55  /// @details
56  ///////////////////////////////////////
58  {
59  protected:
60  /// @brief Bullet constraint that this class encapsulates.
61  btGearConstraint* Gear;
62  public:
63  /// @brief Double body constructor. Binds the two bodies.
64  /// @param ProxyA The first proxy to apply this constraint to.
65  /// @param ProxyB The second proxy to apply this constraint to.
66  /// @param PivotA The axis in ProxyA's local space to apply the constraint to.
67  /// @param PivotB The axis in ProxyB's local space to apply the constraint to.
68  /// @param Ratio The amount the rotation from ProxyA that shall be used to be applied to ProxyB.
69  GearConstraint(RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& AxisA, const Vector3& AxisB, const Real Ratio);
70  /// @brief Class destructor.
71  virtual ~GearConstraint();
72 
73  ///////////////////////////////////////////////////////////////////////////////
74  // Axis configuration
75 
76  /// @brief Sets the axis in ActorA's local space which will translate to ActorB.
77  /// @param Axis A vector3 expressing the axis on ActorA this constraint will be applied to.
78  virtual void SetAxisA(const Vector3& Axis);
79  /// @brief Sets the axis in ActorB's local space which will be manipulated.
80  /// @param Axis A vector3 expressing the axis on ActorB this constraint will be applied to.
81  virtual void SetAxisB(const Vector3& Axis);
82  /// @brief Gets the axis in ActorA's local space which will translate to ActorB.
83  /// @return Returns a vector3 expressing the axis on ActorA this constraint is being applied to.
84  virtual Vector3 GetAxisA() const;
85  /// @brief Gets the axis in ActorB's local space which will be manipulated.
86  /// @return Returns a vector3 expressing the axis on ActorB this constraint is being applied to.
87  virtual Vector3 GetAxisB() const;
88 
89  ///////////////////////////////////////////////////////////////////////////////
90  // Ratio Configuration
91 
92  /// @brief Sets the ratio at which ActorA's rotation will be applied to ActorB.
93  /// @param Ratio The ratio at which rotations on ActorA's specified axis will be transfered to ActorB's specified axis.
94  virtual void SetRotationRatio(const Real Ratio);
95  /// @brief Gets the ratio at which ActorA's rotation will be applied to ActorB.
96  /// @return Returns a Real representing the ratio at which rotations on ActorA's specified axis is being transfered to ActorB's specified axis.
97  virtual Real GetRotationRatio() const;
98 
99  ///////////////////////////////////////////////////////////////////////////////
100  // Parameter Configuration
101 
102  /// @copydoc Constraint::ValidParamOnAxis(int) const
103  virtual Constraint::ParamList ValidParamOnAxis(int Axis) const;
104  /// @copydoc Constraint::ValidLinearAxis() const
105  virtual Constraint::AxisList ValidLinearAxis() const;
106  /// @copydoc Constraint::ValidAngularAxis() const
107  virtual Constraint::AxisList ValidAngularAxis() const;
108  /// @copydoc Constraint::ValidAngularAxis(ConstraintParam,int) const
109  virtual bool HasParamBeenSet(ConstraintParam Param, int Axis) const;
110 
111  ///////////////////////////////////////////////////////////////////////////////
112  // Serialization
113 
114  /// @brief Convert this class to an XML::Node ready for serialization
115  /// @param CurrentRoot The point in the XML hierarchy that all this vectorw should be appended to.
116  virtual void ProtoSerialize(XML::Node& CurrentRoot) const;
117  /// @brief Take the data stored in an XML and overwrite this instance of this object with it
118  /// @param OneNode and XML::Node containing the data.
119  /// @warning A precondition of using this is that all of the actors intended for use must already be Deserialized.
120  virtual void ProtoDeSerialize(const XML::Node& OneNode);
121  /// @brief Get the name of the the XML tag this class will leave behind as its instances are serialized.
122  /// @return A string containing "Point2PointConstraint"
123  static String SerializableName();
124 
125  ///////////////////////////////////////////////////////////////////////////////
126  // Internal Methods
127 
128  /// @copydoc Constraint::GetConstraintBase() const
129  virtual btTypedConstraint* GetConstraintBase() const;
130  };//GearConstraint
131  }//Physics
132 }//Mezzanine
133 
134 #endif