Class New6Dof

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

public class New6Dof extends Constraint
A 6 degree-of-freedom Constraint based on Bullet's btGeneric6DofSpring2Constraint.

From the Bullet manual:
This generic constraint can emulate a variety of standard constraints, by configuring each of the 6 degrees of freedom (dof). The first 3 dof axis are linear axis, which represent translation of rigid bodies, and the latter 3 dof axis represent the angular motion. Each axis can be either locked, free or limited.

For each axis:

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

    • logger2

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

    • New6Dof

      public New6Dof(PhysicsRigidBody rigidBodyB, Vector3f pivotInB, Vector3f pivotInWorld, Matrix3f rotInB, Matrix3f rotInWorld, RotationOrder rotationOrder)
      Instantiate a single-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked.

      To be effective, the constraint 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 constraint in B's local coordinates (rotation matrix, not null, unaffected)
      rotInWorld - the orientation of the constraint in physics-space coordinates (rotation matrix, not null, unaffected)
      rotationOrder - the order in which to apply axis rotations (not null)
    • New6Dof

      public New6Dof(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInA, Vector3f pivotInB, Matrix3f rotInA, Matrix3f rotInB, RotationOrder rotationOrder)
      Instantiate a double-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked.

      To be effective, the constraint 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 constraint in A's local coordinates (not null, unaffected)
      rotInB - the orientation of the constraint in B's local coordinates (not null, unaffected)
      rotationOrder - the order in which to apply axis rotations (not null)
  • Method Details

    • calculatedBasisA

      public Matrix3f calculatedBasisA(Matrix3f storeResult)
      Calculate the pivot orientation of the A end.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the orientation (a rotation matrix in physics-space coordinates, either storeResult or a new matrix, not null)
    • calculatedBasisB

      public Matrix3f calculatedBasisB(Matrix3f storeResult)
      Calculate the pivot orientation of the B end.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the orientation (a rotation matrix in physics-space coordinates, either storeResult or a new matrix, not null)
    • calculatedOriginA

      public Vector3f calculatedOriginA(Vector3f storeResult)
      Calculate the pivot location of the A end (native field: m_calculatedTransformA.m_origin).
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a location vector (in physics-space coordinates, either storeResult or a new vector, not null)
    • calculatedOriginB

      public Vector3f calculatedOriginB(Vector3f storeResult)
      Calculate the pivot location of the B end (native field: m_calculatedTransformB.m_origin).
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a location vector (in physics-space coordinates, either storeResult or a new vector, not null)
    • checkRotationOrder

      public boolean checkRotationOrder()
      Compare Bullet's rotation order to the JVM copy.
      Returns:
      true if rotation orders are identical, otherwise false
    • enableSpring

      public void enableSpring(int dofIndex, boolean onOff)
      Enable or disable the spring 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)
      onOff - true → enable, false → disable (default=false)
    • get

      public float get(MotorParam parameter, int dofIndex)
      Return the specified parameter of the indexed degree of freedom.
      Parameters:
      parameter - which parameter (not null)
      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 parameter value
    • getAngles

      public Vector3f getAngles(Vector3f storeResult)
      Calculate the constraint's rotation angles (native field: m_calculatedAxisAngleDiff).
      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)
    • getAxis

      public Vector3f getAxis(int axisIndex, Vector3f storeResult)
      Calculate the indexed axis of the Constraint (native field: m_calculatedAxis).
      Parameters:
      axisIndex - the axis index of the desired motor: 0→X, 1→Y, 2→Z
      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)
    • getFrameTransform

      public Transform getFrameTransform(JointEnd end, Transform storeResult)
      Copy the constraint's frame transform relative to the specified end (native fields: m_frameInA, m_frameInB).
      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
    • getPivotOffset

      public Vector3f getPivotOffset(Vector3f storeResult)
      Copy the constraint's pivot offset (native field: m_calculatedLinearDiff).
      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)
    • getRotationMatrix

      public Matrix3f getRotationMatrix(JointEnd end, Matrix3f storeResult)
      Copy the orientation of the constraint in the specified end's coordinate system.
      Parameters:
      end - which end (not null)
      storeResult - storage for the result (modified if not null)
      Returns:
      a rotation matrix (either storeResult or a new instance)
      See Also:
    • getRotationMotor

      public RotationMotor getRotationMotor(int axisIndex)
      Access the indexed RotationMotor of this constraint, 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
    • getRotationOrder

      public RotationOrder getRotationOrder()
      Return the order in which axis rotations are applied (native field: m_rotateOrder).
      Returns:
      an enum value (not null)
    • getTranslationMotor

      public TranslationMotor getTranslationMotor()
      Access the TranslationMotor of this Constraint, the motor which influences translation on all 3 axes.
      Returns:
      the pre-existing instance
    • isMotorEnabled

      public boolean isMotorEnabled(int dofIndex)
      Test whether the motor is enabled 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)
      Returns:
      true if enabled, otherwise false
    • isServoEnabled

      public boolean isServoEnabled(int dofIndex)
      Test whether the servo is enabled 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)
      Returns:
      true if enabled, otherwise false
    • isSpringEnabled

      public boolean isSpringEnabled(int dofIndex)
      Test whether the spring is enabled 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)
      Returns:
      true if enabled, otherwise false
    • newInstance

      public static New6Dof newInstance(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f pivotInWorld, Quaternion rotInWorld, RotationOrder rotationOrder)
      Instantiate a double-ended New6Dof constraint with all rotation DOFs free and all translation DOFs locked at zero. The pivot calculations assume all DOFs are initially at zero.

      To be effective, the Constraint 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)
      pivotInWorld - the pivot location (in physics-space coordinates, not null, unaffected)
      rotInWorld - the orientation of the constraint (in physics-space coordinates, not null, not zero, unaffected)
      rotationOrder - the order in which to apply axis rotations (not null)
      Returns:
      a new instance, not in any PhysicsSpace
    • set

      public void set(MotorParam parameter, int dofIndex, float value)
      Alter the specified parameter for the indexed degree of freedom.
      Parameters:
      parameter - which parameter (not null)
      dofIndex - which degree of freedom (0→X translation, 1→Y translation, 2→Z translation, 3→X rotation, 4→Y rotation, 5→Z rotation)
      value - the desired parameter value
    • setDamping

      public void setDamping(int dofIndex, float damping, boolean limitIfNeeded)
      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)
      limitIfNeeded - true→automatically limit damping to prevent the spring from blowing up
    • setEquilibriumPoint

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

      public void setEquilibriumPoint(int dofIndex)
      Alter the equilibrium point of the indexed degree of freedom, based on the constraint'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)
    • setEquilibriumPoint

      public void setEquilibriumPoint(int dofIndex, float value)
      Alter 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)
      value - the desired equilibrium point
    • setRotationOrder

      public void setRotationOrder(RotationOrder rotationOrder)
      Alter the order in which to apply axis rotations.
      Parameters:
      rotationOrder - the desired order (not null)
    • setStiffness

      public void setStiffness(int dofIndex, float stiffness, boolean limitIfNeeded)
      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)
      limitIfNeeded - true→automatically limit stiffness to prevent the spring from moving too widely
    • setPivotInA

      public void setPivotInA(Vector3f location)
      Alter the pivot location in A's scaled local coordinates.
      Overrides:
      setPivotInA in class Constraint
      Parameters:
      location - the desired location (not null, unaffected)
    • setPivotInB

      public void setPivotInB(Vector3f location)
      Alter the pivot location in B's scaled local coordinates.
      Overrides:
      setPivotInB in class Constraint
      Parameters:
      location - the desired location (not null, unaffected)