Drag[en]gine Game Engine
1.21
|
Collider Constraint. More...
#include <deColliderConstraint.h>
Public Types | |
enum | eDegreesOfFreedom { edofLinearX , edofLinearY , edofLinearZ , edofAngularX , edofAngularY , edofAngularZ } |
Degrees of freedom. More... | |
Public Member Functions | |
Constructors and Destructors | |
deColliderConstraint () | |
Create new collider constraint. More... | |
deColliderConstraint (const deColliderConstraint &constraint) | |
Create new collider constraint as a copy of another constraint. More... | |
virtual | ~deColliderConstraint () |
Clean up collider constraint. More... | |
Management | |
deCollider * | GetTargetCollider () const |
Target collider or NULL to constraint to the world. More... | |
void | SetTargetCollider (deCollider *collider) |
Set target collider or NULL to constraint to the world. More... | |
const decString & | GetTargetBone () const |
Name of the target bone. More... | |
void | SetTargetBone (const char *bone) |
Set name of the target bone. More... | |
const decVector & | GetPosition1 () const |
Position of the reference coordinate system. More... | |
void | SetPosition1 (const decVector &position) |
Set position of the reference coordinate system. More... | |
const decQuaternion & | GetOrientation1 () const |
Orientation of the reference coordinate system. More... | |
void | SetOrientation1 (const decQuaternion &orientation) |
Set orientation of the reference coordinate system. More... | |
const decVector & | GetPosition2 () const |
Position of the reference coordinate system. More... | |
void | SetPosition2 (const decVector &position) |
Set position of the reference coordinate system. More... | |
const decQuaternion & | GetOrientation2 () const |
Orientation of the reference coordinate system. More... | |
void | SetOrientation2 (const decQuaternion &orientation) |
Set orientation of the reference coordinate system. More... | |
deColliderConstraintDof & | GetDof (eDegreesOfFreedom dof) |
Retrieves a degree of freedom. More... | |
const deColliderConstraintDof & | GetDof (eDegreesOfFreedom dof) const |
deColliderConstraintDof & | GetDofLinearX () |
X-axis linear degree of freedom. More... | |
const deColliderConstraintDof & | GetDofLinearX () const |
deColliderConstraintDof & | GetDofLinearY () |
Y-axis linear degree of freedom. More... | |
const deColliderConstraintDof & | GetDofLinearY () const |
deColliderConstraintDof & | GetDofLinearZ () |
Z-axis linear degree of freedom. More... | |
const deColliderConstraintDof & | GetDofLinearZ () const |
deColliderConstraintDof & | GetDofAngularX () |
X-axis angular degree of freedom. More... | |
const deColliderConstraintDof & | GetDofAngularX () const |
deColliderConstraintDof & | GetDofAngularY () |
Y-axis angular degree of freedom. More... | |
const deColliderConstraintDof & | GetDofAngularY () const |
deColliderConstraintDof & | GetDofAngularZ () |
Z-axis angular degree of freedom. More... | |
const deColliderConstraintDof & | GetDofAngularZ () const |
float | GetLinearDamping () const |
Linear damping. More... | |
void | SetLinearDamping (float damping) |
Set linear damping. More... | |
float | GetAngularDamping () const |
Angular damping. More... | |
void | SetAngularDamping (float damping) |
Set angular damping. More... | |
float | GetSpringDamping () const |
Spring damping. More... | |
void | SetSpringDamping (float damping) |
Set spring damping. More... | |
void | LockAll () |
Locks all degrees of freedom. More... | |
void | SetToBallJoint () |
Locks all linear degrees of freedom and sets all angular degrees of freedom free. More... | |
void | SetToHingeJoint (eDegreesOfFreedom degreeOfFreedom, float lowerLimit, float upperLimit) |
Set upper and lower limit for angular degree of freedom and locks all others (hinge joint). More... | |
void | SetToPistonJoint (eDegreesOfFreedom degreeOfFreedom, float lowerLimit, float upperLimit) |
Set upper and lower limit for linear degree of freem and locks all others. More... | |
void | SetSpringLinear1D (eDegreesOfFreedom degreeOfFreedom, float stiffness, float damping, float bendStiffness) |
Set a one-dimensional linear spring with bending properties. More... | |
bool | GetIsRope () const |
Determines if this constraint is a rope. More... | |
void | SetIsRope (bool isRope) |
Sets if this constraint is a rope. More... | |
float | GetBreakingThreshold () const |
Breaking impulse threshold or 0 if disabled. More... | |
void | SetBreakingThreshold (float impulseThreshold) |
Set breaking impulse threshold or 0 to disable. More... | |
int | GetBone () const |
Bone index or -1 if constraint the entire collider. More... | |
void | SetBone (int bone) |
Set bone index or -1 if constraint the entire collider. More... | |
Operators | |
deColliderConstraint & | operator= (const deColliderConstraint &constraint) |
Set constraint with parameters from another constraint. More... | |
Collider Constraint.
Defines a constraint for a collider. Constraints can be used for colliders attached or colliders itself. If used on an attachement the attached collider is constraint to the parent collider. If used on a collider it is constraint to the static world. Constraints are defined in a generic way as a 6-Dof ( degreees of freedom ) type constraint. Two coordinate systems are defined for the two constraint partners. Each degree of freedom can be either locked, limited or free. If limited the upper and lower limit can be set. There are three linear and three angular degrees of freedom. The linear degrees of freedom allow the constraint partner to move translational relative to a given major axis whereas the angular degrees of freedom allow rotation about a major axis.
A degree of freedom is considered locked if the upper and lower limit are equal. It is considered free if the upper limit is smaller than the lower limit. In all other cases the degree of freedom is limited.
By default all degrees of freedom are locked.
In addition each degree of freedom can be turned into a spring type degree of freedom. A degree of freedom can be limited or free while being a spring or not. The spring is defined using the constants found in Hooke's Law therefore F=-k*x . The stiffness sprint constant equals to the k constant defining the percentage of the distance stretched away from the equilibrium position applied as force. Hence k is given as [N/m]. The spring damping determines the amount of energy lost over time. A stiffness of 0 disables spring behavior for a given degree of freedom.
A constraint can also be defined as a rope. If the constraint is a rope no collision shape is required on the affected colliders as the constraint itself becomes a rope shape.
A constraint can be set to break if an impulse larger than a threshold value affects the constraint object along a degree of freedom. The physics module is responsible to translate these settings into a useful simulation configuration and can vary. By default a degree of freedom does not break.
deColliderConstraint::deColliderConstraint | ( | ) |
Create new collider constraint.
deColliderConstraint::deColliderConstraint | ( | const deColliderConstraint & | constraint | ) |
Create new collider constraint as a copy of another constraint.
|
virtual |
Clean up collider constraint.
|
inline |
Angular damping.
|
inline |
Bone index or -1 if constraint the entire collider.
|
inline |
Breaking impulse threshold or 0 if disabled.
deColliderConstraintDof& deColliderConstraint::GetDof | ( | eDegreesOfFreedom | dof | ) |
Retrieves a degree of freedom.
const deColliderConstraintDof& deColliderConstraint::GetDof | ( | eDegreesOfFreedom | dof | ) | const |
|
inline |
X-axis angular degree of freedom.
|
inline |
|
inline |
Y-axis angular degree of freedom.
|
inline |
|
inline |
Z-axis angular degree of freedom.
|
inline |
|
inline |
X-axis linear degree of freedom.
|
inline |
|
inline |
Y-axis linear degree of freedom.
|
inline |
|
inline |
Z-axis linear degree of freedom.
|
inline |
|
inline |
Determines if this constraint is a rope.
|
inline |
Linear damping.
|
inline |
Orientation of the reference coordinate system.
|
inline |
Orientation of the reference coordinate system.
|
inline |
Position of the reference coordinate system.
|
inline |
Position of the reference coordinate system.
|
inline |
Spring damping.
|
inline |
Name of the target bone.
|
inline |
Target collider or NULL to constraint to the world.
void deColliderConstraint::LockAll | ( | ) |
Locks all degrees of freedom.
deColliderConstraint& deColliderConstraint::operator= | ( | const deColliderConstraint & | constraint | ) |
Set constraint with parameters from another constraint.
void deColliderConstraint::SetAngularDamping | ( | float | damping | ) |
Set angular damping.
void deColliderConstraint::SetBone | ( | int | bone | ) |
Set bone index or -1 if constraint the entire collider.
void deColliderConstraint::SetBreakingThreshold | ( | float | impulseThreshold | ) |
Set breaking impulse threshold or 0 to disable.
void deColliderConstraint::SetIsRope | ( | bool | isRope | ) |
Sets if this constraint is a rope.
void deColliderConstraint::SetLinearDamping | ( | float | damping | ) |
Set linear damping.
void deColliderConstraint::SetOrientation1 | ( | const decQuaternion & | orientation | ) |
Set orientation of the reference coordinate system.
void deColliderConstraint::SetOrientation2 | ( | const decQuaternion & | orientation | ) |
Set orientation of the reference coordinate system.
void deColliderConstraint::SetPosition1 | ( | const decVector & | position | ) |
Set position of the reference coordinate system.
void deColliderConstraint::SetPosition2 | ( | const decVector & | position | ) |
Set position of the reference coordinate system.
void deColliderConstraint::SetSpringDamping | ( | float | damping | ) |
Set spring damping.
void deColliderConstraint::SetSpringLinear1D | ( | eDegreesOfFreedom | degreeOfFreedom, |
float | stiffness, | ||
float | damping, | ||
float | bendStiffness | ||
) |
Set a one-dimensional linear spring with bending properties.
The given linear degree of freedom is set free with the given spring stiffness and damping. All other linear degrees of freedom are set free to with the given bending stiffness and damping. All angular degrees of freedom are locked.
void deColliderConstraint::SetTargetBone | ( | const char * | bone | ) |
Set name of the target bone.
void deColliderConstraint::SetTargetCollider | ( | deCollider * | collider | ) |
Set target collider or NULL to constraint to the world.
void deColliderConstraint::SetToBallJoint | ( | ) |
Locks all linear degrees of freedom and sets all angular degrees of freedom free.
void deColliderConstraint::SetToHingeJoint | ( | eDegreesOfFreedom | degreeOfFreedom, |
float | lowerLimit, | ||
float | upperLimit | ||
) |
Set upper and lower limit for angular degree of freedom and locks all others (hinge joint).
void deColliderConstraint::SetToPistonJoint | ( | eDegreesOfFreedom | degreeOfFreedom, |
float | lowerLimit, | ||
float | upperLimit | ||
) |
Set upper and lower limit for linear degree of freem and locks all others.