59 lines
2.6 KiB
Java

package org.atriaSoft.ephysics.constraint;
/**
* This structure is used to gather the information needed to create a fixed
* joint. This structure will be used to create the actual fixed joint.
*/
struct FixedJointInfo extends JointInfo {
public :
Vector3f anchorPointWorldSpace; //!< Anchor point (in world-space coordinates)
/**
* @breif Contructor
* @param rigidBody1 The first body of the joint
* @param rigidBody2 The second body of the joint
* @param initAnchorPointWorldSpace The initial anchor point of the joint in world-space coordinates
*/
FixedJointInfo(RigidBody* rigidBody1,
RigidBody* rigidBody2,
Vector3f initAnchorPointWorldSpace):
JointInfo(rigidBody1, rigidBody2, FIXEDJOINT),
this.anchorPointWorldSpace(initAnchorPointWorldSpace){
}
};
/**
* @breif It represents a fixed joint that is used to forbid any translation or rotation
* between two bodies.
*/
class FixedJoint extends Joint {
private:
static float BETA; //!< Beta value for the bias factor of position correction
Vector3f localAnchorPointBody1; //!< Anchor point of body 1 (in local-space coordinates of body 1)
Vector3f localAnchorPointBody2; //!< Anchor point of body 2 (in local-space coordinates of body 2)
Vector3f r1World; //!< Vector from center of body 2 to anchor point in world-space
Vector3f r2World; //!< Vector from center of body 2 to anchor point in world-space
Matrix3f i1; //!< Inertia tensor of body 1 (in world-space coordinates)
Matrix3f i2; //!< Inertia tensor of body 2 (in world-space coordinates)
Vector3f impulseTranslation; //!< Accumulated impulse for the 3 translation raints
Vector3f impulseRotation; //!< Accumulate impulse for the 3 rotation raints
Matrix3f inverseMassMatrixTranslation; //!< Inverse mass matrix K=JM^-1J^-t of the 3 translation raints (3x3 matrix)
Matrix3f inverseMassMatrixRotation; //!< Inverse mass matrix K=JM^-1J^-t of the 3 rotation raints (3x3 matrix)
Vector3f biasTranslation; //!< Bias vector for the 3 translation raints
Vector3f biasRotation; //!< Bias vector for the 3 rotation raints
Quaternion initOrientationDifferenceInv; //!< Inverse of the initial orientation difference between the two bodies
long getSizeInBytes() {
return sizeof(FixedJoint);
}
void initBeforeSolve( ConstraintSolverData raintSolverData) ;
void warmstart( ConstraintSolverData raintSolverData) ;
void solveVelocityConstraint( ConstraintSolverData raintSolverData) ;
void solvePositionConstraint( ConstraintSolverData raintSolverData) ;
public:
/// Constructor
FixedJoint( FixedJointInfo jointInfo);
};
}