Class SixDofSpringJoint

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class SixDofSpringJoint extends SixDofJoint
A 6 degree-of-freedom joint based on Bullet's btGeneric6DofSpringConstraint.

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

    • logger3

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

    • SixDofSpringJoint

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

      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)
    • SixDofSpringJoint

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

      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 orientation of the joint in A's 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
  • Method Details

    • enableSpring

      public void enableSpring(int dofIndex, boolean onOff)
      Enable or disable the spring for the indexed degree of freedom. Enabling a spring also enables the corresponding limit motor. Disabling a spring also disables the corresponding limit motor.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      onOff - true → enable, false → disable (default=false)
    • getDamping

      public float getDamping(int dofIndex)
      Read the damping of the indexed degree of freedom.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      Returns:
      the viscous damping ratio
    • getEquilibriumPoint

      public float getEquilibriumPoint(int dofIndex)
      Read the equilibrium point of the indexed degree of freedom.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      Returns:
      the equilibrium point
    • getStiffness

      public float getStiffness(int dofIndex)
      Read the spring stiffness of the indexed degree of freedom.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      Returns:
      the stiffness
    • isSpringEnabled

      public boolean isSpringEnabled(int dofIndex)
      Test whether the spring for the indexed degree of freedom is enabled.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      Returns:
      true if enabled, otherwise false
    • setDamping

      public void setDamping(int dofIndex, float damping)
      Alter the damping for the indexed degree of freedom.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      damping - the desired viscous damping ratio (0→no damping, 1→critically damped, default=1)
    • setEquilibriumPoint

      public void setEquilibriumPoint()
      Alter the equilibrium points for all degrees of freedom, based on the joint's current location/orientation.
    • setEquilibriumPoint

      public void setEquilibriumPoint(int dofIndex)
      Alter the equilibrium point of the indexed degree of freedom, based on the joint's current location/orientation.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
    • setStiffness

      public void setStiffness(int dofIndex, float stiffness)
      Alter the spring stiffness for the indexed degree of freedom.
      Parameters:
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      stiffness - the desired stiffness (default=0)
    • createJoint

      protected long createJoint(long bodyIdA, long bodyIdB, Vector3f pivotInA, Matrix3f rotInA, Vector3f pivotInB, Matrix3f rotInB, boolean useLinearReferenceFrameA)
      Create a double-ended btGeneric6DofSpringConstraint.
      Overrides:
      createJoint in class SixDofJoint
      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 btGeneric6DofSpringConstraint.
      Overrides:
      createJoint1 in class SixDofJoint
      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