MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
point2pointconstraint.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 _physicspoint2pointconstraint_h
41 #define _physicspoint2pointconstraint_h
42 
43 #include "Physics/constraint.h"
44 
45 class btPoint2PointConstraint;
46 
47 namespace Mezzanine
48 {
49  namespace Physics
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @class Point2PointConstraint
53  /// @brief Tries to make a point relative to each of two actors match in 3d space, without regard to rotation.
54  /// @details This will translate (push around) the actors to attempt to get the offsets to match up in 3d space.
55  /// The actors can freely rotate about their relative offsets.
56  ///////////////////////////////////////
58  {
59  protected:
60  /// @brief Bullet constraint that this class encapsulates.
61  btPoint2PointConstraint* Point2Point;
62  public:
63  ////////////////////////////////////////////////////////////////////////////////
64  // Point2PointConstraint Construction and Destruction
65 
66  /// @brief Double body constructor. Binds the two bodies.
67  /// @param ProxyA The first proxy to apply this constraint to.
68  /// @param ProxyB The second proxy to apply this constraint to.
69  /// @param PivotA The location in ProxyA's local space to apply the constraint to.
70  /// @param PivotB The location in ProxyB's local space to apply the constraint to.
71  Point2PointConstraint(RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& PivotA, const Vector3& PivotB);
72  /// @brief Single body constructor. Binds the body to world space.
73  /// @param ProxyA The proxy to apply this constraint to.
74  /// @param PivotA The position relative to ProxyA's center of gravity to "Pin" to the world.
75  Point2PointConstraint(RigidProxy* ProxyA, const Vector3& PivotA);
76  /// @brief Class destructor.
77  virtual ~Point2PointConstraint();
78 
79  ////////////////////////////////////////////////////////////////////////////////
80  // Point2PointConstraint Position and Orientation
81 
82  /// @brief Set offset of the first proxy.
83  /// @param PivotA The offset as a Vector3 relative to the center of mass of ProxyA.
84  virtual void SetPivotALocation(const Vector3& PivotA);
85  /// @brief Set offset of the second proxy.
86  /// @param PivotB The offset as a Vector3 relative to the center of mass of ProxyB.
87  virtual void SetPivotBLocation(const Vector3& PivotB);
88  /// @brief Get offset of the first proxy.
89  /// @return The offset as a Vector3 relative to the center of mass of ProxyA.
90  virtual Vector3 GetPivotALocation() const;
91  /// @brief Get offset of the second proxy.
92  /// @return The offset as a Vector3 relative to the center of mass of ProxyB.
93  virtual Vector3 GetPivotBLocation() const;
94 
95  ////////////////////////////////////////////////////////////////////////////////
96  // Point2PointConstraint Specific Physics Settings
97 
98  /// @brief Set the current impulse clamping on the constraint
99  /// @param Clamping This is a value that the constraint solver can use to adjust accumlated values when solving the constraint.
100  virtual void SetImpulseClamping(Real Clamping);
101  /// @brief get the current impulse clamping value
102  /// @return A real with the Clamping
103  virtual Real GetImpulseClamping() const;
104  /// @brief Set a resistive force against the constraint, not too dissimilar to from hinge friction or Air resistance
105  /// @param Damping A real with the desired values
106  virtual void SetDamping(Real Damping);
107  /// @brief Get the current Damping
108  /// @return A Real with the Damping value.
109  virtual Real GetDamping() const;
110  /// @brief This may be a scalar for how strongly Angular momentum affects linear momemtum
111  /// @todo Research this more carefully
112  /// @details This function is a tightly wrapped bullet 3d function. No real documentation for it exists, from its responsibility/location in Bullet3d and
113  /// a basic understanding of torque ( see http://en.wikipedia.org/wiki/Torque ) It is highly likely that it is a value to adjust how torque affects momentum.
114  virtual void SetTAU(Real TAU);
115  /// @brief Retrieve the Tau Setting
116  /// @return The Tau value as a Real
117  virtual Real GetTAU() const;
118 
119  /// @copydoc Constraint::ValidParamOnAxis(int) const
120  virtual Constraint::ParamList ValidParamOnAxis(int Axis) const;
121  /// @copydoc Constraint::ValidLinearAxis() const
122  virtual Constraint::AxisList ValidLinearAxis() const;
123  /// @copydoc Constraint::ValidAngularAxis() const
124  virtual Constraint::AxisList ValidAngularAxis() const;
125  /// @copydoc Constraint::ValidAngularAxis(ConstraintParam,int) const
126  virtual bool HasParamBeenSet(ConstraintParam Param, int Axis) const;
127 
128  /// @copydoc Constraint::GetConstraintBase() const
129  virtual btTypedConstraint* GetConstraintBase() const;
130 
131  ///////////////////////////////////////////////////////////////////////////////
132  // Serialization
133 
134  /// @brief Convert this class to an XML::Node ready for serialization
135  /// @param CurrentRoot The point in the XML hierarchy that all this vectorw should be appended to.
136  virtual void ProtoSerialize(XML::Node& CurrentRoot) const;
137  /// @brief Take the data stored in an XML and overwrite this instance of this object with it
138  /// @param OneNode and XML::Node containing the data.
139  /// @warning A precondition of using this is that all of the actors intended for use must already be Deserialized.
140  virtual void ProtoDeSerialize(const XML::Node& OneNode);
141  /// @brief Get the name of the the XML tag this class will leave behind as its instances are serialized.
142  /// @return A string containing "Point2PointConstraint"
143  static String SerializableName();
144  };//Point2PointConstraint
145  }//Physics
146 }//Mezzanine
147 
148 ///////////////////////////////////////////////////////////////////////////////
149 // Class External << Operators for streaming or assignment
150 
151 /// @copydoc operator << (std::ostream& stream, const Mezzanine::Physics::Constraint& x)
152 std::ostream& MEZZ_LIB operator << (std::ostream& stream, const Mezzanine::Physics::Point2PointConstraint& x);
153 /// @copydoc operator >> (std::istream& stream, Mezzanine::Physics::Constraint& x)
154 std::istream& MEZZ_LIB operator >> (std::istream& stream, Mezzanine::Physics::Point2PointConstraint& x);
155 /// @copydoc operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::Physics::Constraint& x)
156 void operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::Physics::Point2PointConstraint& x);
157 
158 #endif