Spinning Topp Logo BlackTopp Studios
inc
point2pointconstraint.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 _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  /// @internal
61  /// @brief The internal constraint that this class encapsulates.
62  btPoint2PointConstraint* Point2Point;
63 
64  /// @internal
65  /// @brief Creates the internal constraint.
66  /// @remarks This methods exists primarily as a convenience for serialization, and shouldn't be called unless it is known to be safe.
67  /// @param RigidA A pointer to the first Proxy to be constrained.
68  /// @param RigidB A pointer to the second Proxy to be constrained.
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  virtual void CreateConstraint(RigidProxy* RigidA, RigidProxy* RigidB, const Vector3& PivotA, const Vector3& PivotB);
72  /// @internal
73  /// @brief Destroys the internal constraint.
74  /// @remarks This methods exists primarily as a convenience for serialization, and shouldn't be called unless it is known to be safe.
75  virtual void DestroyConstraint();
76  public:
77  /// @brief Double body constructor. Binds the two bodies.
78  /// @param ID The unique identifier assigned to this constraint.
79  /// @param ProxyA The first proxy to apply this constraint to.
80  /// @param ProxyB The second proxy to apply this constraint to.
81  /// @param PivotA The location in ProxyA's local space to apply the constraint to.
82  /// @param PivotB The location in ProxyB's local space to apply the constraint to.
83  /// @param Creator A pointer to the manager that created this constraint.
84  Point2PointConstraint(const UInt32 ID, RigidProxy* ProxyA, RigidProxy* ProxyB, const Vector3& PivotA, const Vector3& PivotB, PhysicsManager* Creator);
85  /// @brief Single body constructor. Binds the body to world space.
86  /// @param ID The unique identifier assigned to this constraint.
87  /// @param ProxyA The proxy to apply this constraint to.
88  /// @param PivotA The position relative to ProxyA's center of gravity to "Pin" to the world.
89  /// @param Creator A pointer to the manager that created this constraint.
90  Point2PointConstraint(const UInt32 ID, RigidProxy* ProxyA, const Vector3& PivotA, PhysicsManager* Creator);
91  /// @brief XML constructor.
92  /// @param SelfRoot An XML::Node containing the data to populate this class with.
93  /// @param Creator A pointer to the manager that created this constraint.
94  Point2PointConstraint(const XML::Node& SelfRoot, PhysicsManager* Creator);
95  /// @brief Class destructor.
96  virtual ~Point2PointConstraint();
97 
98  ////////////////////////////////////////////////////////////////////////////////
99  // Position and Orientation
100 
101  /// @brief Set offset of the first proxy.
102  /// @param PivotA The offset as a Vector3 relative to the center of mass of ProxyA.
103  virtual void SetPivotA(const Vector3& PivotA);
104  /// @brief Set offset of the second proxy.
105  /// @param PivotB The offset as a Vector3 relative to the center of mass of ProxyB.
106  virtual void SetPivotB(const Vector3& PivotB);
107  /// @brief Get offset of the first proxy.
108  /// @return The offset as a Vector3 relative to the center of mass of ProxyA.
109  virtual Vector3 GetPivotA() const;
110  /// @brief Get offset of the second proxy.
111  /// @return The offset as a Vector3 relative to the center of mass of ProxyB.
112  virtual Vector3 GetPivotB() const;
113 
114  ////////////////////////////////////////////////////////////////////////////////
115  // Specific Physics Settings
116 
117  /// @brief Set the current impulse clamping on the constraint.
118  /// @param Clamping This is a value that the constraint solver can use to adjust accumlated values when solving the constraint.
119  virtual void SetImpulseClamping(const Real Clamping);
120  /// @brief get the current impulse clamping value.
121  /// @return A real with the Clamping.
122  virtual Real GetImpulseClamping() const;
123  /// @brief Set a resistive force against the constraint, not too dissimilar to from hinge friction or Air resistance.
124  /// @param Damping A real with the desired values.
125  virtual void SetDamping(const Real Damping);
126  /// @brief Get the current Damping.
127  /// @return A Real with the Damping value.
128  virtual Real GetDamping() const;
129  /// @brief This may be a scalar for how strongly Angular momentum affects linear momemtum.
130  /// @todo Research this more carefully.
131  /// @details This function is a tightly wrapped bullet 3d function. No real documentation for it exists, from its responsibility/location in Bullet3d and
132  /// 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.
133  virtual void SetTAU(const Real TAU);
134  /// @brief Retrieve the Tau Setting.
135  /// @return The Tau value as a Real.
136  virtual Real GetTAU() const;
137 
138  ///////////////////////////////////////////////////////////////////////////////
139  // Parameter Configuration
140 
141  /// @copydoc Constraint::GetValidParamsOnAxis(int) const
142  virtual Constraint::ParamList GetValidParamsOnAxis(int Axis) const;
143  /// @copydoc Constraint::GetValidLinearAxes() const
144  virtual Constraint::AxisList GetValidLinearAxes() const;
145  /// @copydoc Constraint::GetValidAngularAxes() const
146  virtual Constraint::AxisList GetValidAngularAxes() const;
147  /// @copydoc Constraint::ValidAngularAxis(ConstraintParam,int) const
148  virtual Boole HasParamBeenSet(ConstraintParam Param, int Axis) const;
149 
150  ///////////////////////////////////////////////////////////////////////////////
151  // Serialization
152 
153  /// @copydoc Constraint::ProtoSerializeInitData(XML::Node&) const
154  virtual void ProtoSerializeInitData(XML::Node& SelfRoot) const;
155  /// @copydoc Constraint::ProtoSerializeProperties(XML::Node&) const
156  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
157 
158  /// @copydoc Constraint::ProtoDeSerializeInitData(const XML::Node&)
159  virtual void ProtoDeSerializeInitData(const XML::Node& SelfRoot);
160  /// @copydoc Constraint::ProtoDeSerializeProperties(const XML::Node&)
161  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
162 
163  /// @copydoc Constraint::GetDerivedSerializableName() const
164  virtual String GetDerivedSerializableName() const;
165  /// @brief Get the name of the the XML tag the class will leave behind as its instances are serialized.
166  /// @return A string containing the name of this class.
167  static String GetSerializableName();
168 
169  ///////////////////////////////////////////////////////////////////////////////
170  // Internal
171 
172  /// @copydoc Constraint::_GetConstraintBase() const
173  virtual btTypedConstraint* _GetConstraintBase() const;
174  };//Point2PointConstraint
175  }//Physics
176 }//Mezzanine
177 
178 ///////////////////////////////////////////////////////////////////////////////
179 // Class External << Operators for streaming or assignment
180 
181 #ifndef SWIG
182 /// @copydoc operator << (std::ostream& stream, const Mezzanine::Physics::Constraint& x)
183 std::ostream& MEZZ_LIB operator << (std::ostream& stream, const Mezzanine::Physics::Point2PointConstraint& x);
184 /// @copydoc operator >> (std::istream& stream, Mezzanine::Physics::Constraint& x)
185 std::istream& MEZZ_LIB operator >> (std::istream& stream, Mezzanine::Physics::Point2PointConstraint& x);
186 /// @copydoc operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::Physics::Constraint& x)
188 #endif
189 
190 #endif
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
Definition: interpolator.h:433
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
Tries to make a point relative to each of two actors match in 3d space, without regard to rotation...
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
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.
btPoint2PointConstraint * Point2Point
The internal constraint that this class encapsulates.
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::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
Definition: interpolator.h:448
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159