Class SixDofSpringJoint

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

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

      public SixDofSpringJoint(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 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, 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 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)
      Return 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)
      Return 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)
      Return 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, 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 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, com.jme3.math.Vector3f pivotInB, com.jme3.math.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
    • 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 SixDofJoint
      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 SixDofJoint
      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 SixDofJoint
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter