Class New6Dof

All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, 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

      protected New6Dof()
      No-argument constructor needed by SavableClassUtil.
    • New6Dof

      public New6Dof(PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Vector3f pivotInWorld, com.jme3.math.Matrix3f rotInB, com.jme3.math.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, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInA, com.jme3.math.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 com.jme3.math.Matrix3f calculatedBasisA(com.jme3.math.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 com.jme3.math.Matrix3f calculatedBasisB(com.jme3.math.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 com.jme3.math.Vector3f calculatedOriginA(com.jme3.math.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 com.jme3.math.Vector3f calculatedOriginB(com.jme3.math.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 com.jme3.math.Vector3f getAngles(com.jme3.math.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 com.jme3.math.Vector3f getAxis(int axisIndex, com.jme3.math.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 com.jme3.math.Transform getFrameTransform(JointEnd end, com.jme3.math.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 com.jme3.math.Vector3f getPivotOffset(com.jme3.math.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 com.jme3.math.Matrix3f getRotationMatrix(JointEnd end, com.jme3.math.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, com.jme3.math.Vector3f pivotInWorld, com.jme3.math.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
    • cloneFields

      public void cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
      Callback from Cloner to convert this shallow-cloned constraint into a deep-cloned one, using the specified Cloner and original to resolve copied fields.
      Specified by:
      cloneFields in interface com.jme3.util.clone.JmeCloneable
      Overrides:
      cloneFields in class Constraint
      Parameters:
      cloner - the Cloner that's cloning this constraint (not null)
      original - the instance from which this constraint was shallow-cloned (not null, unaffected)
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this Constraint from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Overrides:
      read in class Constraint
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this Constraint to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Overrides:
      write in class Constraint
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter