Class PhysicsJoint

java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.joints.PhysicsJoint
All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, Comparable<NativePhysicsObject>
Direct Known Subclasses:
Anchor, Constraint, SoftPhysicsJoint

public abstract class PhysicsJoint extends NativePhysicsObject implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
The abstract base class for physics joints based on Bullet's btTypedConstraint, btSoftBody::Anchor, or btSoftBody::Joint.
  • Field Details

    • logger

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

    • PhysicsJoint

      protected PhysicsJoint()
      Instantiate a PhysicsJoint.

      This no-arg constructor was made explicit to avoid javadoc warnings from JDK 18+.

  • Method Details

    • countEnds

      public int countEnds()
      Count how many ends this joint has.
      Returns:
      1 if single-ended, 2 if double-ended
    • destroy

      public void destroy()
      Remove this joint from the joint lists of both ends.
    • findEnd

      public JointEnd findEnd(PhysicsBody body)
      Test whether the specified body is an end of this joint.
      Parameters:
      body - the body to find (not null, unaffected)
      Returns:
      the enum value if found, otherwise null
    • findOtherBody

      public PhysicsBody findOtherBody(PhysicsBody body)
      Access the remaining body of this joint.
      Parameters:
      body - (not null, unaffected)
      Returns:
      the body at the other end (null if not found or the joint is single-ended)
    • getBody

      public PhysicsBody getBody(JointEnd end)
      Access the body at the specified end of this joint.
      Parameters:
      end - which end of the joint to access (not null)
      Returns:
      the pre-existing body, or null if none
    • getBodyA

      public PhysicsBody getBodyA()
      Access the body at the joint's "A" end.
      Returns:
      the pre-existing body, or null if none
    • getBodyB

      public PhysicsBody getBodyB()
      Access the body at the joint's "B" end.
      Returns:
      the pre-existing body, or null if none
    • getPhysicsSpace

      public PhysicsSpace getPhysicsSpace()
      Access the PhysicsSpace where this joint is added.
      Returns:
      the pre-existing instance, or null if none
    • isEnabled

      public abstract boolean isEnabled()
      Test whether this joint is enabled.
      Returns:
      true if enabled, otherwise false
    • setPhysicsSpace

      public void setPhysicsSpace(PhysicsSpace physicsSpace)
      Alter which PhysicsSpace this joint is added to. Do not invoke directly! The field is updated automatically when added/removed.
      Parameters:
      physicsSpace - (may be null)
    • setBodyA

      protected final void setBodyA(PhysicsBody body)
      Specify the body at the joint's "A" end.
      Parameters:
      body - the desired body (not null, alias created)
    • setBodyB

      protected final void setBodyB(PhysicsBody body)
      Specify the body at the joint's "B" end.
      Parameters:
      body - the desired body (not null, alias created)
    • cloneFields

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

      public PhysicsJoint jmeClone()
      Create a shallow clone for the JME cloner.
      Specified by:
      jmeClone in interface com.jme3.util.clone.JmeCloneable
      Returns:
      a new instance
    • 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
      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
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter
    • setNativeId

      protected void setNativeId(long jointId)
      Initialize the native ID.
      Overrides:
      setNativeId in class NativePhysicsObject
      Parameters:
      jointId - the native identifier of the btTypedConstraint, btSoftBody::Anchor, or btSoftBody::Joint (not zero)
    • toString

      public String toString()
      Represent this joint as a String.
      Overrides:
      toString in class NativePhysicsObject
      Returns:
      a descriptive string of text (not null, not empty)