Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Mezzanine::Physics::Constraint Class Referenceabstract

This is the base class for all constraints supported. More...

#include <constraint.h>

+ Inheritance diagram for Mezzanine::Physics::Constraint:
+ Collaboration diagram for Mezzanine::Physics::Constraint:

Public Types

typedef std::vector< int > AxisList
 Used to Store lists of Int Axis for return types. More...
 
typedef std::vector< ConstraintParamParamList
 Used to Store lists of param for return types.
 

Public Member Functions

virtual ~Constraint ()
 Class destructor.
 
virtual btTypedConstraint * _GetConstraintBase () const =0
 Get the Bullet constraint that this class encapsulates. More...
 
virtual void EnableConstraint (const Boole Enable)
 Enables or disables this constraint. More...
 
virtual Boole GetAllowCollisions () const
 Gets whether or not collisions can/will occur between the two constrained bodies. More...
 
virtual UInt32 GetConstraintID () const
 Gets the unique ID of this constraint. More...
 
virtual String GetDerivedSerializableName () const =0
 Gets the most derived serializable name of this Constraint. More...
 
virtual Real GetParam (ConstraintParam Param, int Axis=-1) const
 Gets value of constraint parameters. More...
 
virtual RigidProxyGetProxyA () const
 Gets the first Proxy this constraint applies to. More...
 
virtual RigidProxyGetProxyB () const
 Gets the second Proxy this constraint applies to. More...
 
virtual AxisList GetValidAngularAxes () const =0
 Get A list sorted (low to high) of all axis that operate Angularly (that lock sliding/translation) More...
 
virtual AxisList GetValidAxes () const
 Get a sorted (low to high) list of All Valid Axis. More...
 
virtual AxisList GetValidLinearAxes () const =0
 Get a sorted (low to high) list of all axis that operate linearly (that lock sliding/translation) More...
 
virtual ParamList GetValidParams () const
 Get A sorted (low to high) list of Parameters that are valid on all Axis. More...
 
virtual ParamList GetValidParamsOnAxis (int Axis) const =0
 Get a sorted (low to high) list of Parameters that are valid on this Axis. More...
 
virtual Boole HasParamBeenSet (ConstraintParam Param, int Axis) const =0
 Has the given Param on the Given Axis been set yet. More...
 
virtual Boole IsConstraintEnabled () const
 Gets whether or not this constraint is enabled. More...
 
virtual Boole IsParamValidOnAxis (ConstraintParam Param, int Axis) const
 Is a certain Parameter valid on a certain axis. More...
 
virtual void ProtoDeSerialize (const XML::Node &SelfRoot)
 Take the data stored in an XML Node and overwrite this object with it. More...
 
virtual void ProtoDeSerializeGlobalOverrides (const XML::Node &SelfRoot)
 Take the data stored in an XML Node and overwrite the global overrides of this object with it. More...
 
virtual void ProtoDeSerializeInitData (const XML::Node &SelfRoot)=0
 Take the data stored in an XML Node and initializes a new internal object with it. More...
 
virtual void ProtoDeSerializeProperties (const XML::Node &SelfRoot)
 Take the data stored in an XML Node and overwrite the properties of this object with it. More...
 
virtual void ProtoSerialize (XML::Node &ParentNode) const
 Convert this class to an XML::Node ready for serialization. More...
 
virtual void ProtoSerializeGlobalOverrides (XML::Node &SelfRoot) const
 Convert the global overrides of this class to an XML::Node ready for serialization. More...
 
virtual void ProtoSerializeInitData (XML::Node &SelfRoot) const =0
 Convert the data needed to initialize this class to an XML::Node ready for serialization. More...
 
virtual void ProtoSerializeProperties (XML::Node &SelfRoot) const
 Convert the properties of this class to an XML::Node ready for serialization. More...
 
virtual void SetAllowCollisions (const Boole Allow)
 Sets whether collisions between the two constrained bodies should occur. More...
 
virtual void SetParam (ConstraintParam Param, Real Value, int Axis=-1)
 Provides override of constraint parameters. More...
 

Static Public Member Functions

static String GetSerializableName ()
 Get the name of the the XML tag the class will leave behind as its instances are serialized. More...
 

Protected Member Functions

 Constraint (const UInt32 ID, PhysicsManager *Creator)
 Zero body constructor. More...
 
 Constraint (const UInt32 ID, RigidProxy *Prox1, PhysicsManager *Creator)
 Single body constructor. More...
 
 Constraint (const UInt32 ID, RigidProxy *Prox1, RigidProxy *Prox2, PhysicsManager *Creator)
 Dual body constructor. More...
 

Protected Attributes

Boole AllowCollisions
 Whether or not collisions will be allowed to occure between the constrained bodies. More...
 
UInt32 ConstraintID
 The unique ID used to identify this constraint. More...
 
Boole Enabled
 Whether or not the constraint is currently taking effect. More...
 
PhysicsManagerManager
 This is a pointer to the physics manager that created and owns this constraint. More...
 
RigidProxyProxA
 The first Collidable this constraint applies to. More...
 
RigidProxyProxB
 The second Collidable this constraint applies to. More...
 

Friends

class PhysicsManager
 

Detailed Description

This is the base class for all constraints supported.

This class provides the basis for all the other constraints. This is also a virtual class and provides no constraint properties of it's own, thus shouldn't/can't be called on manually.

Any class implementing a this must implement at least these functions to create a minimally functiontal constraint:

It is advisable to re-implement a few more functions as well, these all have implementation writtens in terms of of the function that must be implemented, but the genericity of them may impede performance.

Definition at line 116 of file constraint.h.

Member Typedef Documentation

typedef std::vector<int> Mezzanine::Physics::Constraint::AxisList

Used to Store lists of Int Axis for return types.

In general Axis will come in groups of three, such as 0,1,2, or 0,1,2,3,4,5 which could represent X,Y, and Z or multiple grousp of X,Y, and Z. These Axis can represent Linear/Translation or Angular/Rotation information. Some Constraints support values that affect all constraints, this is usually represented a -1.

Definition at line 124 of file constraint.h.

Constructor & Destructor Documentation

Mezzanine::Physics::Constraint::Constraint ( const UInt32  ID,
PhysicsManager Creator 
)
protected

Zero body constructor.

Remarks
This should only ever be used for XML deserialization.
Parameters
IDThe unique identifier assigned to this constraint.
CreatorA pointer to the manager that created this constraint.
Mezzanine::Physics::Constraint::Constraint ( const UInt32  ID,
RigidProxy Prox1,
PhysicsManager Creator 
)
protected

Single body constructor.

Parameters
IDThe unique identifier assigned to this constraint.
Prox1A pointer to the first/only proxy that will be constrained.
CreatorA pointer to the manager that created this constraint.
Mezzanine::Physics::Constraint::Constraint ( const UInt32  ID,
RigidProxy Prox1,
RigidProxy Prox2,
PhysicsManager Creator 
)
protected

Dual body constructor.

Parameters
IDThe unique identifier assigned to this constraint.
Prox1A pointer to the first proxy that will be constrained.
Prox2A pointer to the second proxy that will be constrained.
CreatorA pointer to the manager that created this constraint.

Member Function Documentation

virtual btTypedConstraint* Mezzanine::Physics::Constraint::_GetConstraintBase ( ) const
pure virtual

Get the Bullet constraint that this class encapsulates.

Returns
A pointer to the btTypedConstraint that stores the underlying constraint.

Implemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual void Mezzanine::Physics::Constraint::EnableConstraint ( const Boole  Enable)
virtual

Enables or disables this constraint.

Parameters
EnableWhether or not to make this constraint take effect.
virtual Boole Mezzanine::Physics::Constraint::GetAllowCollisions ( ) const
virtual

Gets whether or not collisions can/will occur between the two constrained bodies.

Returns
Returns true if collisions are enabled between both bodies of this constraint, false otherwise.
virtual UInt32 Mezzanine::Physics::Constraint::GetConstraintID ( ) const
virtual

Gets the unique ID of this constraint.

Returns
Returns a UInt32 representing the unique ID of this constraint among all other constraints in it's parent manager.
virtual String Mezzanine::Physics::Constraint::GetDerivedSerializableName ( ) const
pure virtual

Gets the most derived serializable name of this Constraint.

Note
When creating a new Constraint class verify this method has a valid return for it in order for serialization to work properly.
Returns
Returns the name of the XML tag from the most derived class of "this".

Implemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::Generic6DofSpringConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, Mezzanine::Physics::GearConstraint, Mezzanine::Physics::UniversalConstraint, and Mezzanine::Physics::Hinge2Constraint.

virtual Real Mezzanine::Physics::Constraint::GetParam ( ConstraintParam  Param,
int  Axis = -1 
) const
virtual

Gets value of constraint parameters.

See SetParam() for clarification. Gets information on constraint parameters.

Parameters
Para,Theparameter to get information for.
AxisOptional axis.
Returns
Returns the value for the requested parameter.
virtual RigidProxy* Mezzanine::Physics::Constraint::GetProxyA ( ) const
virtual

Gets the first Proxy this constraint applies to.

Returns
Returns a pointer to the first Proxy this constraint applies to.
virtual RigidProxy* Mezzanine::Physics::Constraint::GetProxyB ( ) const
virtual

Gets the second Proxy this constraint applies to.

Returns
Returns a pointer to the second Proxy this constraint applies to.
static String Mezzanine::Physics::Constraint::GetSerializableName ( )
static

Get the name of the the XML tag the class will leave behind as its instances are serialized.

Returns
A string containing the name of this class.
virtual AxisList Mezzanine::Physics::Constraint::GetValidAngularAxes ( ) const
pure virtual

Get A list sorted (low to high) of all axis that operate Angularly (that lock sliding/translation)

Warning
Odd behaviors, maybe even undefined behavior can happen if This returns a matching Axis to a Linear Axis. Any given axis should only be one or the other
Returns
An Axislist with the Axis this constraint Angularly supports.

Implemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual AxisList Mezzanine::Physics::Constraint::GetValidAxes ( ) const
virtual

Get a sorted (low to high) list of All Valid Axis.

This is implemented using ValidLinearAxis and ValidAngularAxis, Derived versions of this class may wish to make a more specialized implementation of this method that doesn't have the overhead of passing around 3 vectors by value.

Returns
An Axislist with all the Axis this constraint supports.
virtual AxisList Mezzanine::Physics::Constraint::GetValidLinearAxes ( ) const
pure virtual

Get a sorted (low to high) list of all axis that operate linearly (that lock sliding/translation)

Warning
Odd behaviors, maybe even undefined behavior can happen if This returns a matching Axis to a Linear Axis. Any given axis should only be one or the other
Returns
An Axislist with the Axis this constraint linearly supports.

Implemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual ParamList Mezzanine::Physics::Constraint::GetValidParams ( ) const
virtual

Get A sorted (low to high) list of Parameters that are valid on all Axis.

This is implemented using ValidAxis and ValidParamOnAxis, Derived versions of this class may wish to make a more specialized implementation of this method that doesn't have the overhead of passing around many vectors by value and executing slow loops. Most likely all of these constraint Parameter and axis functions could be replaced with some fairly simple switch statements and statically coded values that are specific to the kind of constraint.

Returns
A Paramlist with the parameters valid on all axis.
virtual ParamList Mezzanine::Physics::Constraint::GetValidParamsOnAxis ( int  Axis) const
pure virtual

Get a sorted (low to high) list of Parameters that are valid on this Axis.

Parameters returned from this will work on the given axis even if they are not valid on any other axis. There is no guarantee that the Parameters will be uniquely stored per an axis. There is no guarantee that changing one parameter will not change another.

Parameters
Axisthe Axis to check.
Returns
A Paramlist with all the valid parameters for this axis.

Implemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual Boole Mezzanine::Physics::Constraint::HasParamBeenSet ( ConstraintParam  Param,
int  Axis 
) const
pure virtual

Has the given Param on the Given Axis been set yet.

Parameters
ParamThe parameter to Check
AxisThe Axis on which to check the param

This will probably have to implement the same logic aas what is in the respective get/setparam function of each constraint http://bulletphysics.com/Bullet/BulletFull/classbtTypedConstraint.html#a11f44dd743b59bc05e25d500456e2559

Returns
True if it has been set, false if it has.

Implemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual Boole Mezzanine::Physics::Constraint::IsConstraintEnabled ( ) const
virtual

Gets whether or not this constraint is enabled.

Returns
Returns true if this constraint is currently enabled, false otherwise.
virtual Boole Mezzanine::Physics::Constraint::IsParamValidOnAxis ( ConstraintParam  Param,
int  Axis 
) const
virtual

Is a certain Parameter valid on a certain axis.

Parameters
ParamThe Parameter to Check
AxisThe Axis to Check

This is implemented using ValidParamOnAxis, Derived versions of this class may wish to make a more specialized implementation of this method.

Returns
True if Param is valid on Axis, and Axis is valid. If anything is invalid this returns false.
virtual void Mezzanine::Physics::Constraint::ProtoDeSerialize ( const XML::Node SelfRoot)
virtual

Take the data stored in an XML Node and overwrite this object with it.

Parameters
SelfRootAn XML::Node containing the data to populate this class with.
virtual void Mezzanine::Physics::Constraint::ProtoDeSerializeGlobalOverrides ( const XML::Node SelfRoot)
virtual

Take the data stored in an XML Node and overwrite the global overrides of this object with it.

Warning
Internally there is no way to unset a global variable. If you are calling this method without first called "ProtoDeSerializeInitData" then you will have the previous global overrides in effect as well.
Parameters
SelfRootAn XML::Node containing the data to populate this class with.
virtual void Mezzanine::Physics::Constraint::ProtoDeSerializeInitData ( const XML::Node SelfRoot)
pure virtual

Take the data stored in an XML Node and initializes a new internal object with it.

Parameters
SelfRootAn XML::Node containing the data to populate this class with.

Implemented in Mezzanine::Physics::Point2PointConstraint, Mezzanine::Physics::GearConstraint, and Mezzanine::Physics::DualTransformConstraint.

virtual void Mezzanine::Physics::Constraint::ProtoDeSerializeProperties ( const XML::Node SelfRoot)
virtual

Take the data stored in an XML Node and overwrite the properties of this object with it.

Parameters
SelfRootAn XML::Node containing the data to populate this class with.

Reimplemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::Generic6DofSpringConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual void Mezzanine::Physics::Constraint::ProtoSerialize ( XML::Node ParentNode) const
virtual

Convert this class to an XML::Node ready for serialization.

Parameters
ParentNodeThe point in the XML hierarchy that all this renderable should be appended to.
virtual void Mezzanine::Physics::Constraint::ProtoSerializeGlobalOverrides ( XML::Node SelfRoot) const
virtual

Convert the global overrides of this class to an XML::Node ready for serialization.

Parameters
SelfRootThe root node containing all the serialized data for this instance.
virtual void Mezzanine::Physics::Constraint::ProtoSerializeInitData ( XML::Node SelfRoot) const
pure virtual

Convert the data needed to initialize this class to an XML::Node ready for serialization.

Parameters
SelfRootThe root node containing all the serialized data for this instance.

Implemented in Mezzanine::Physics::Point2PointConstraint, Mezzanine::Physics::DualTransformConstraint, and Mezzanine::Physics::GearConstraint.

virtual void Mezzanine::Physics::Constraint::ProtoSerializeProperties ( XML::Node SelfRoot) const
virtual

Convert the properties of this class to an XML::Node ready for serialization.

Parameters
SelfRootThe root node containing all the serialized data for this instance.

Reimplemented in Mezzanine::Physics::Generic6DofConstraint, Mezzanine::Physics::SliderConstraint, Mezzanine::Physics::HingeConstraint, Mezzanine::Physics::Generic6DofSpringConstraint, Mezzanine::Physics::ConeTwistConstraint, Mezzanine::Physics::Point2PointConstraint, and Mezzanine::Physics::GearConstraint.

virtual void Mezzanine::Physics::Constraint::SetAllowCollisions ( const Boole  Allow)
virtual

Sets whether collisions between the two constrained bodies should occur.

Note
If this is set while the constraint is enabled, it will have to be disabled and then re-enabled to take effect.
Parameters
AllowWhether or not collisions will be allowed to occure between the constrained bodies.
virtual void Mezzanine::Physics::Constraint::SetParam ( ConstraintParam  Param,
Real  Value,
int  Axis = -1 
)
virtual

Provides override of constraint parameters.

Parameters such as ERP(Error Reduction Parameter) and CFM(Constraint Force Mixing) can be altered with this function. Optionally provide axis.

Parameters
ParamThe parameter to override.
ValueThe new value for the parameter.
AxisOptional axis.

Member Data Documentation

Boole Mezzanine::Physics::Constraint::AllowCollisions
protected

Whether or not collisions will be allowed to occure between the constrained bodies.

Definition at line 142 of file constraint.h.

UInt32 Mezzanine::Physics::Constraint::ConstraintID
protected

The unique ID used to identify this constraint.

Definition at line 139 of file constraint.h.

Boole Mezzanine::Physics::Constraint::Enabled
protected

Whether or not the constraint is currently taking effect.

Definition at line 145 of file constraint.h.

PhysicsManager* Mezzanine::Physics::Constraint::Manager
protected

This is a pointer to the physics manager that created and owns this constraint.

Definition at line 136 of file constraint.h.

RigidProxy* Mezzanine::Physics::Constraint::ProxA
protected

The first Collidable this constraint applies to.

Definition at line 130 of file constraint.h.

RigidProxy* Mezzanine::Physics::Constraint::ProxB
protected

The second Collidable this constraint applies to.

Definition at line 133 of file constraint.h.


The documentation for this class was generated from the following file: