Class SixDofJoint

All Implemented Interfaces:
Comparable<NativePhysicsObject>
Direct Known Subclasses:
SixDofSpringJoint

public class SixDofJoint extends Constraint
A 6 degree-of-freedom joint based on Bullet's btGeneric6DofConstraint. Axis rotations are applied in XYZ order.

From the Bullet manual:

For each axis:

  • Lowerlimit = Upperlimit → axis is locked
  • Lowerlimit > Upperlimit → axis is free
  • Lowerlimit < Upperlimit → axis is limited in that range

It is recommended to use the btGeneric6DofSpring2Constraint, it has some improvements over the original btGeneric6Dof(Spring)Constraint.

See Also:
  • Field Details

    • logger2

      public static final Logger logger2
      message logger for this class
  • Constructor Details

    • SixDofJoint

      public SixDofJoint(PhysicsRigidBody rigidBodyB, Vector3f pivotInB, Vector3f pivotInWorld, Matrix3f rotInB, Matrix3f rotInWorld, JointEnd linearReferenceFrame)
      Instantiate a single-ended SixDofJoint.

      To be effective, the joint must be added to the body's PhysicsSpace and the body must be dynamic.

      Parameters:
      rigidBodyB - the body to constrain (not null, alias created)
      pivotInB - the pivot location in B's scaled local coordinates (not null, unaffected)
      pivotInWorld - the pivot location in physics-space coordinates (not null, unaffected)
      rotInB - the orientation of the joint in B's local coordinates (rotation matrix, not null, unaffected)
      rotInWorld - the orientation of the joint in physics-space coordinates (rotation matrix, not null, unaffected)
      linearReferenceFrame - which end to use as the linear reference frame (not null)
    • SixDofJoint

      public SixDofJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Matrix3f rotInA, Matrix3f rotInB, boolean useLinearReferenceFrameA)
      Instantiate a double-ended SixDofJoint.

      To be effective, the joint must be added to the PhysicsSpace of both bodies. Also, the bodies must be distinct and at least one of them must be dynamic.

      Parameters:
      rigidBodyA - the body for the A end (not null, alias created)
      rigidBodyB - the body for the B end (not null, alias created)
      pivotInA - the pivot location in A's scaled local coordinates (not null, unaffected)
      pivotInB - the pivot location in B's scaled local coordinates (not null, unaffected)
      rotInA - the joint orientation in A's local coordinates (rotation matrix, unaffected)
      rotInB - the joint orientation in B's local coordinates (rotation matrix, unaffected)
      useLinearReferenceFrameA - true→use body A, false→use body B
    • SixDofJoint

      public SixDofJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, boolean useLinearReferenceFrameA)
      Instantiate a double-ended SixDofJoint.

      To be effective, the joint must be added to the body's PhysicsSpace and the body must be dynamic.

      Parameters:
      rigidBodyA - the first body to constrain (not null, alias created)
      rigidBodyB - the 2nd body to constrain (not null, alias created)
      pivotInA - the pivot location in A's scaled local coordinates (not null, unaffected)
      pivotInB - the pivot location in B's scaled local coordinates (not null, unaffected)
      useLinearReferenceFrameA - true→use body A, false→use body B
  • Method Details

    • getAngles

      public Vector3f getAngles(Vector3f storeResult)
      Copy the joint's rotation angles.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the rotation angle for each local axis (in radians, either storeResult or a new vector, not null)
    • getAngularLowerLimit

      public Vector3f getAngularLowerLimit(Vector3f storeResult)
      Copy the joint's lower limits for rotation on all 3 axes.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the lower limit for each local axis (in radians, either storeResult or a new vector, not null)
    • getAngularUpperLimit

      public Vector3f getAngularUpperLimit(Vector3f storeResult)
      Copy the joint's upper limits for rotation on all 3 axes.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the upper limit for each local axis (in radians, either storeResult or a new vector, not null)
    • getFrameTransform

      public Transform getFrameTransform(JointEnd end, Transform storeResult)
      Copy the joint's frame transform relative to the specified end.
      Parameters:
      end - which end (not null)
      storeResult - storage for the result (modified if not null)
      Returns:
      the transform of the constraint space relative to the end
    • getLinearLowerLimit

      public Vector3f getLinearLowerLimit(Vector3f storeResult)
      Copy the joint's lower limits for translation on all 3 axes.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the lower limit for each local axis (in radians, either storeResult or a new vector, not null)
    • getLinearUpperLimit

      public Vector3f getLinearUpperLimit(Vector3f storeResult)
      Copy the joint's upper limits for translation on all 3 axes.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the upper limit for each local axis (in radians, either storeResult or a new vector, not null)
    • getPivotOffset

      public Vector3f getPivotOffset(Vector3f storeResult)
      Copy the joint's pivot offset.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the relative pivot position on each local axis (in physics-space units, either storeResult or a new vector, not null)
    • getRotationalLimitMotor

      public RotationalLimitMotor getRotationalLimitMotor(int axisIndex)
      Access the indexed RotationalLimitMotor of this joint, the motor which influences rotation around the indexed axis.
      Parameters:
      axisIndex - the axis index of the desired motor: 0→X, 1→Y, 2→Z
      Returns:
      the pre-existing instance
    • getTranslationalLimitMotor

      public TranslationalLimitMotor getTranslationalLimitMotor()
      Access the TranslationalLimitMotor of this joint, the motor which influences translation on all 3 axes.
      Returns:
      the pre-existing instance
    • setAngularLowerLimit

      public void setAngularLowerLimit(Vector3f limits)
      Alter the joint's lower limits for rotation of all 3 axes.
      Parameters:
      limits - the desired lower limits (in radians, not null, unaffected)
    • setAngularUpperLimit

      public void setAngularUpperLimit(Vector3f limits)
      Alter the joint's upper limits for rotation of all 3 axes.
      Parameters:
      limits - the desired upper limits (in radians, not null, unaffected)
    • setLinearLowerLimit

      public void setLinearLowerLimit(Vector3f vector)
      Alter the joint's lower limits for translation of all 3 axes.
      Parameters:
      vector - the desired lower limits (not null, unaffected)
    • setLinearUpperLimit

      public void setLinearUpperLimit(Vector3f vector)
      Alter the joint's upper limits for translation of all 3 axes.
      Parameters:
      vector - the desired upper limits (not null, unaffected)
    • createJoint

      protected long createJoint(long bodyIdA, long bodyIdB, Vector3f pivotInA, Matrix3f rotInA, Vector3f pivotInB, Matrix3f rotInB, boolean useLinearReferenceFrameA)
      Create a double-ended btGeneric6DofConstraint.
      Parameters:
      bodyIdA - the ID of the body for the A end (not zero)
      bodyIdB - the ID of the body for the B end (not zero)
      pivotInA - the pivot location in A's scaled local coordinates (not null, unaffected)
      rotInA - the orientation of the joint in A's local coordinates (not null, unaffected)
      pivotInB - the pivot location in B's scaled local coordinates (not null, unaffected)
      rotInB - the orientation of the joint in B's local coordinates (not null, unaffected)
      useLinearReferenceFrameA - true→use body A, false→use body B
      Returns:
      the ID of the new joint
    • createJoint1

      protected long createJoint1(long bodyIdB, Vector3f pivotInB, Matrix3f rotInB, boolean useLinearReferenceFrameB)
      Create a single-ended btGeneric6DofConstraint.
      Parameters:
      bodyIdB - the ID of the body for the B end (not zero)
      pivotInB - the pivot location in B's scaled local coordinates (not null, unaffected)
      rotInB - the orientation of the joint in B's local coordinates (not null, unaffected)
      useLinearReferenceFrameB - true→use body A, false→use body B
      Returns:
      the ID of the new joint