Class GearJoint

All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, Comparable<NativePhysicsObject>

public class GearJoint extends Constraint
A joint that couples the angular velocities of two bodies, based on Bullet's btGearConstraint.

From the Bullet manual:

The btGearConstraint will couple the angular velocity for two bodies around given local axis and ratio.

  • Field Details

    • logger2

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

    • GearJoint

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

      public GearJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f axisInA, com.jme3.math.Vector3f axisInB)
      Instantiate a double-ended GearJoint with a 1:1 ratio.

      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)
      axisInA - the A body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
      axisInB - the B body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
    • GearJoint

      public GearJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f axisInA, com.jme3.math.Vector3f axisInB, float ratio)
      Instantiate a double-ended GearJoint with the specified gear ratio.

      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)
      axisInA - the A body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
      axisInB - the B body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
      ratio - the number of revolutions the A body should make for each revolution of the B body
  • Method Details

    • getAxisA

      public com.jme3.math.Vector3f getAxisA(com.jme3.math.Vector3f storeResult)
      Copy A body's axis of rotation.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the A body's axis of rotation in its local coordinates (either storeResult or new vector)
    • getAxisB

      public com.jme3.math.Vector3f getAxisB(com.jme3.math.Vector3f storeResult)
      Copy the B body's axis of rotation.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the B body's axis of rotation in its local coordinates (either storeResult or new vector)
    • getRatio

      public float getRatio()
      Get the gear ratio.
      Returns:
      the number of revolutions the A body makes for each revolution of the B body
    • setAxisA

      public void setAxisA(com.jme3.math.Vector3f axisInA)
      Alter the A body's axis of rotation.
      Parameters:
      axisInA - the desired axis in local coordinates (unit vector, not null, unaffected)
    • setAxisB

      public void setAxisB(com.jme3.math.Vector3f axisInB)
      Alter the B body's axis of rotation.
      Parameters:
      axisInB - the axisInB axis in local coordinates (unit vector, not null, unaffected)
    • setRatio

      public void setRatio(float ratio)
      Alter the joint's gear ratio.
      Parameters:
      ratio - the number of revolutions the A body should make for each revolution of the B body (default=1)
    • 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