Class Anchor

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

public class Anchor extends PhysicsJoint
A PhysicsJoint to join a particular node of a soft body (A) to a rigid body (B), based on Bullet's btSoftBody::Anchor.
  • Field Details

    • logger2

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

    • Anchor

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

      public Anchor(PhysicsSoftBody softBodyA, int nodeIndexA, PhysicsRigidBody rigidBodyB, com.jme3.math.Vector3f pivotInB, boolean allowCollisions)
      Instantiate an anchor with influence=1.
      Parameters:
      softBodyA - the soft body for the A end (not null, alias created)
      nodeIndexA - the index of the node for the A end (≥0, <numNodes)
      rigidBodyB - the rigid body for the B end (not null, alias created)
      pivotInB - the pivot location in B's scaled local coordinates (not null, unaffected)
      allowCollisions - true→allow collisions between the bodies, false→disallow such collisions
  • Method Details

    • copyPivot

      public com.jme3.math.Vector3f copyPivot(com.jme3.math.Vector3f storeResult)
      Copy the location of the connection point in the rigid body at the B end.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a location vector (in B's scaled local coordinates, either storeResult or a new instance)
    • getRigidBody

      public PhysicsRigidBody getRigidBody()
      Access the rigid body at the B end.
      Returns:
      the pre-existing body (not null)
    • getSoftBody

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

      public float influence()
      Return how much influence the anchor has on the bodies.
      Returns:
      the amount (≥0, ≤1, 0→no influence, 1→strong influence)
    • isAllowCollision

      public boolean isAllowCollision()
      Test whether collisions are allowed between the bodies.
      Returns:
      true if collisions are allowed, otherwise false
    • nodeIndex

      public int nodeIndex()
      Return the index of the anchored node in body A.
      Returns:
      the node index (≥0)
    • setInfluence

      public void setInfluence(float amount)
      Alter how much influence the anchor has on the bodies.
      Parameters:
      amount - the degree of influence (≥0, ≤1, 0→no influence, 1→strong influence, default=1)
    • setPivotInB

      public void setPivotInB(com.jme3.math.Vector3f location)
      Alter the pivot location in B's local coordinates.
      Parameters:
      location - the desired location (not null, unaffected)
    • cloneFields

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

      public boolean isEnabled()
      Test whether this Anchor 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