Class NewHinge

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

public class NewHinge extends New6Dof
A 3 degree-of-freedom Constraint that mimics ODE's Hinge2 joint, such as might be used to model one of the front wheels on a motor vehicle.

Rotation is enabled only for the Z and X axes, with limits on Z-axis rotation. The X axis rotates freely. Translation is enabled only for the Z axis, with a suspension spring.

Inspired by Bullet's btHinge2Constraint.

  • Field Details

    • logger3

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

    • NewHinge

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

      public NewHinge(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f anchor, com.jme3.math.Vector3f axis1, com.jme3.math.Vector3f axis2)
      Instantiate a double-ended constraint.

      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)
      anchor - initial anchor location for the constraint frame (in physics-space coordinates, not null, unaffected)
      axis1 - initial Z-axis direction for the constraint frame (in physics-space coordinates, not null, not zero, unaffected)
      axis2 - initial X-axis direction for the constraint frame (in physics-space coordinates, not null, not zero, unaffected)
  • Method Details

    • getAnchor

      public com.jme3.math.Vector3f getAnchor(com.jme3.math.Vector3f storeResult)
      Determine the anchor location for body A.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the location (either storeResult or a new vector, not null)
    • getAnchor2

      public com.jme3.math.Vector3f getAnchor2(com.jme3.math.Vector3f storeResult)
      Determine the anchor location for body B.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the location (either storeResult or a new vector, not null)
    • getAngle1

      public float getAngle1()
      Determine the rotation angle for axis1.
      Returns:
      the rotation angle (in radians)
    • getAngle2

      public float getAngle2()
      Determine the rotation angle for axis2.
      Returns:
      the rotation angle (in radians)
    • getAxis1

      public com.jme3.math.Vector3f getAxis1(com.jme3.math.Vector3f storeResult)
      Determine the direction of axis1.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a direction vector (either storeResult or a new vector, not null)
    • getAxis2

      public com.jme3.math.Vector3f getAxis2(com.jme3.math.Vector3f storeResult)
      Determine the direction of axis2.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a direction vector (either storeResult or a new vector, not null)
    • setLowerLimit

      public final void setLowerLimit(float angle1Min)
      Alter the lower limit for axis1 rotation.
      Parameters:
      angle1Min - the desired angle (in radians)
    • setUpperLimit

      public final void setUpperLimit(float angle1Max)
      Alter the upper limit for axis1 rotation.
      Parameters:
      angle1Max - the desired angle (in radians)
    • 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 New6Dof
      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 New6Dof
      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 New6Dof
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter