Class SixDofJoint

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

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

      public SixDofJoint(PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, com.jme3.math.Vector3f pivotInWorld, com.jme3.math.Matrix3f rotInB, com.jme3.math.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, com.jme3.math.Vector3f pivotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.Matrix3f rotInA, com.jme3.math.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, com.jme3.math.Vector3f pivotInA, com.jme3.math.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 com.jme3.math.Vector3f getAngles(com.jme3.math.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 com.jme3.math.Vector3f getAngularLowerLimit(com.jme3.math.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 com.jme3.math.Vector3f getAngularUpperLimit(com.jme3.math.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 com.jme3.math.Transform getFrameTransform(JointEnd end, com.jme3.math.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 com.jme3.math.Vector3f getLinearLowerLimit(com.jme3.math.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 com.jme3.math.Vector3f getLinearUpperLimit(com.jme3.math.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 com.jme3.math.Vector3f getPivotOffset(com.jme3.math.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(com.jme3.math.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(com.jme3.math.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(com.jme3.math.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(com.jme3.math.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, com.jme3.math.Vector3f pivotInA, com.jme3.math.Matrix3f rotInA, com.jme3.math.Vector3f pivotInB, com.jme3.math.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, com.jme3.math.Vector3f pivotInB, com.jme3.math.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
    • cloneFields

      public void cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
      Callback from Cloner to convert this shallow-cloned joint 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 joint (not null)
      original - the instance from which this joint was shallow-cloned (not null, unaffected)
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this joint 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 joint 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