Class PhysicsJoint

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

public abstract class PhysicsJoint extends NativePhysicsObject
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)
    • 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)