Class SoftPhysicsJoint

All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, Comparable<NativePhysicsObject>
Direct Known Subclasses:
SoftAngularJoint, SoftLinearJoint

public abstract class SoftPhysicsJoint extends PhysicsJoint
The abstract base class for joining a PhysicsSoftBody to another body, based on Bullet's btSoftBody::Joint. A SoftPhysicsJoint can be soft-soft or soft-rigid:
  • a soft-soft joint joins particular clusters of 2 distinct soft bodies
  • a soft-rigid joint joins a particular cluster of a soft body to a rigid body
Subclasses include SoftLinearJoint and SoftAngularJoint.

To join a particular *node* of a soft body to a rigid body, use an Anchor instead.

  • Field Details

    • logger2

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

    • SoftPhysicsJoint

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

      protected SoftPhysicsJoint(PhysicsSoftBody softBodyA, int clusterIndexA, PhysicsRigidBody rigidBodyB)
      Instantiate a SoftPhysicsJoint to join a soft-body cluster and a rigid body.

      To be fully effective, the joint must be added to the PhysicsSoftSpace of both bodies.

      Parameters:
      softBodyA - the soft body for the A end (not null, alias created)
      clusterIndexA - the index of the cluster for the A end (≥0)
      rigidBodyB - the rigid body for the B end (not null, alias created)
    • SoftPhysicsJoint

      protected SoftPhysicsJoint(PhysicsSoftBody softBodyA, int clusterIndexA, PhysicsSoftBody softBodyB, int clusterIndexB)
      Instantiate a SoftPhysicsJoint to join 2 soft bodies.

      To be effective, the joint must be added to the PhysicsSoftSpace of both bodies. Also, the bodies must be distinct.

      Parameters:
      softBodyA - the body for the A end (not null, alias created)
      clusterIndexA - the index of the cluster for the A end (≥0)
      softBodyB - the body for the B end (not null, alias created)
      clusterIndexB - the index of the cluster for the B end (≥0)
  • Method Details

    • checkParameters

      public boolean checkParameters()
      Compare Bullet parameters against their local copies.
      Returns:
      true if the local copies are accurate, otherwise false
    • clusterIndexA

      public int clusterIndexA()
      Read the index of the cluster for the A end.
      Returns:
      the index (≥0)
    • clusterIndexB

      public int clusterIndexB()
      Read the index of the cluster for the B end.
      Returns:
      the index (≥0) or -1 for a soft-rigid joint
    • getCFM

      public float getCFM()
      Read the constraint force mixing coefficient (aka CFM).

      From the Bullet documentation:

      • If CFM=0 then the constraint will be hard.
      • If CFM is set to a positive value, it will be possible to violate the constraint by "pushing on it" (for example, for contact constraints by forcing the two contacting objects together). In other words the constraint will be soft, and the softness will increase as CFM increases.
      Returns:
      the coefficient value (≥0)
    • getERP

      public float getERP()
      Read the error-reduction parameter (aka ERP).

      From the Bullet documentation:

      The ERP specifies what proportion of the joint error will be fixed during the next simulation step.

      • If ERP=0 then no correcting force is applied and the bodies will eventually drift apart as the simulation proceeds.
      • If ERP=1 then the simulation will attempt to fix all joint error during the next simulation step. However, setting ERP=1 is not recommended, as the joint error will not be completely fixed due to various internal approximations.
      Values between 0.1 and 0.8 are recommended.
      Returns:
      the parameter value (≥0, ≤1, default=1)
    • getSoftBodyA

      public PhysicsSoftBody getSoftBodyA()
      Access the soft body at the A end.
      Returns:
      the pre-existing soft body (not null)
    • getSoftBodyB

      public PhysicsSoftBody getSoftBodyB()
      Access the soft body at the B end.
      Returns:
      the pre-existing soft body, or null for a soft-rigid joint
    • getSplit

      public float getSplit()
      Return the split.
      Returns:
      the split value
    • isSoftRigid

      public boolean isSoftRigid()
      Test whether this joint is a soft-rigid joint.
      Returns:
      true if soft-rigid, otherwise false
    • isSoftSoft

      public boolean isSoftSoft()
      Test whether this joint is a soft-soft joint.
      Returns:
      true if soft-soft, otherwise false
    • setCFM

      public void setCFM(float cfm)
      Set the constraint force mixing coefficient (aka CFM).

      From the Bullet documentation:

      • If CFM=0 then the constraint will be hard.
      • If CFM is set to a positive value, it will be possible to violate the constraint by "pushing on it" (for example, for contact constraints by forcing the two contacting objects together). In other words the constraint will be soft, and the softness will increase as CFM increases.

      Setting CFM to a negative value can cause instability.

      Parameters:
      cfm - the desired coefficient value (≥0, default=1)
    • setERP

      public void setERP(float erp)
      Set the error-reduction parameter (aka ERP).

      From the Bullet documentation:

      The ERP specifies what proportion of the joint error will be fixed during the next simulation step.

      • If ERP=0 then no correcting force is applied and the bodies will eventually drift apart as the simulation proceeds.
      • If ERP=1 then the simulation will attempt to fix all joint error during the next simulation step. However, setting ERP=1 is not recommended, as the joint error will not be completely fixed due to various internal approximations.
      Values between 0.1 and 0.8 are recommended.
      Parameters:
      erp - the desired parameter value (≥0, ≤1, default=1)
    • setSplit

      public void setSplit(float split)
      Alter the split.
      Parameters:
      split - the desired split value (default=1)
    • finalizeNative

      protected static void finalizeNative(long jointId)
      Finalize the btTypedConstraint.
      Parameters:
      jointId - identifier of the btSoftBody::Joint (not zero)
    • isEnabled

      public boolean isEnabled()
      Test whether this joint is enabled.
      Specified by:
      isEnabled in class PhysicsJoint
      Returns:
      true
    • 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 PhysicsJoint
      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 PhysicsJoint
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter