Class DacLinks

All Implemented Interfaces:
PhysicsControl, PhysicsTickListener, Savable, Control, JmeCloneable, Cloneable
Direct Known Subclasses:
DynamicAnimControl

public class DacLinks extends DacConfiguration implements PhysicsTickListener
Access a DynamicAnimControl at the PhysicsLink level once it's been added to a Spatial.

This class is shared between JBullet and Native Bullet.

  • Field Details

    • logger3

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

    • findBone

      public Joint findBone(String boneName)
      Access the named bone.

      Allowed only when the control IS added to a spatial.

      Parameters:
      boneName - the name of the skeleton bone to access
      Returns:
      the pre-existing instance, or null if not found
    • findBoneLink

      public BoneLink findBoneLink(String boneName)
      Access the BoneLink for the named bone. Returns null if bone is not linked, or if the control is not added to a spatial.
      Parameters:
      boneName - the name of the bone (not null, not empty)
      Returns:
      the pre-existing BoneLink, or null if not found
    • findLink

      public PhysicsLink findLink(String linkName)
      Access the named link. Returns null if the name is invalid, or if the control is not added to a spatial.
      Parameters:
      linkName - the name of the link (not null, not empty)
      Returns:
      the pre-existing link, or null if not found
    • getSkeleton

      public Armature getSkeleton()
      Access the skeleton. Returns null if the control is not added to a spatial.
      Returns:
      the pre-existing skeleton, or null
    • getTorsoLink

      public TorsoLink getTorsoLink()
      Access the TorsoLink. Returns null if the control is not added to a spatial.
      Returns:
      the pre-existing TorsoLink, or null
    • isReady

      public boolean isReady()
      Test whether this control is ready for dynamic mode.
      Returns:
      true if ready, otherwise false
    • listLinks

      public <T extends PhysicsLink> List<T> listLinks(Class<T> linkType)
      Enumerate all physics links of the specified type managed by this control.
      Type Parameters:
      T - subclass of PhysicsLink
      Parameters:
      linkType - the subclass of PhysicsLink to search for (not null)
      Returns:
      a new array of links (not null, not empty)
    • listRigidBodies

      public PhysicsRigidBody[] listRigidBodies()
      Enumerate all rigid bodies managed by this control.

      Allowed only when the control IS added to a spatial.

      Returns:
      a new array of pre-existing rigid bodies (not null, not empty)
    • rebuild

      public void rebuild()
      Rebuild the ragdoll. This is useful if you applied scale to the model after it was initialized.

      Allowed only when the control IS added to a spatial.

    • setMass

      public void setMass(PhysicsLink link, float mass)
      Alter the mass of the specified link.
      Parameters:
      link - the link to modify (not null)
      mass - the desired mass (>0)
    • verifyReadyForDynamicMode

      public void verifyReadyForDynamicMode(String desiredAction)
      Verify that this control is ready for dynamic mode, which implies that it is added to a Spatial.
      Parameters:
      desiredAction - (not null, not empty)
    • getBoneLinks

      protected List<BoneLink> getBoneLinks()
      Access the list of bone links in a pre-order, depth-first traversal of the link hierarchy.
      Returns:
      the pre-existing list (not null)
    • verifyAddedToSpatial

      protected void verifyAddedToSpatial(String desiredAction)
      Verify that this control is added to a Spatial.
      Parameters:
      desiredAction - (not null, not empty)
    • addPhysics

      protected void addPhysics(PhysicsSpace space)
      Add all managed physics objects to the PhysicsSpace.
      Specified by:
      addPhysics in class AbstractPhysicsControl
      Parameters:
      space - which physics space to add to (not null)
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Callback from Cloner to convert this shallow-cloned control into a deep-cloned one, using the specified cloner and original to resolve copied fields.
      Specified by:
      cloneFields in interface JmeCloneable
      Overrides:
      cloneFields in class DacConfiguration
      Parameters:
      cloner - the cloner that's cloning this control (not null, modified)
      original - the control from which this control was shallow-cloned (not null, unaffected)
    • createSpatialData

      protected void createSpatialData(Spatial spatial)
      Create spatial-dependent data. Invoked each time the control is added to a spatial. Also invoked by rebuild().
      Specified by:
      createSpatialData in class AbstractPhysicsControl
      Parameters:
      spatial - the controlled spatial (not null)
    • jmeClone

      public DacLinks jmeClone()
      Create a shallow clone for the JME cloner.
      Specified by:
      jmeClone in interface JmeCloneable
      Overrides:
      jmeClone in class DacConfiguration
      Returns:
      a new instance
    • mass

      public float mass(String boneName)
      Read the mass of the named bone/torso.
      Overrides:
      mass in class DacConfiguration
      Parameters:
      boneName - the name of the bone/torso (not null)
      Returns:
      the mass (>0) or NaN if undetermined
    • read

      public void read(JmeImporter im) throws IOException
      De-serialize this control, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Overrides:
      read in class DacConfiguration
      Parameters:
      im - importer (not null)
      Throws:
      IOException - from importer
    • removePhysics

      protected void removePhysics(PhysicsSpace space)
      Remove all managed physics objects from the PhysicsSpace.
      Specified by:
      removePhysics in class AbstractPhysicsControl
      Parameters:
      space - which physics space to remove from (not null)
    • removeSpatialData

      protected void removeSpatialData(Spatial spat)
      Remove spatial-dependent data. Invoked each time this control is rebuilt or removed from a spatial.
      Specified by:
      removeSpatialData in class AbstractPhysicsControl
      Parameters:
      spat - the previously controlled spatial (unused)
    • setDamping

      public void setDamping(float dampingRatio)
      Alter the viscous damping ratio for all rigid bodies, including new ones.
      Overrides:
      setDamping in class DacConfiguration
      Parameters:
      dampingRatio - the desired damping ratio (non-negative, 0→no damping, 1→critically damped, default=0.6)
    • setGravity

      public void setGravity(Vector3f gravity)
      Alter this control's gravitational acceleration for Ragdoll mode.
      Overrides:
      setGravity in class DacConfiguration
      Parameters:
      gravity - the desired acceleration vector (in physics-space coordinates, not null, unaffected, default=0,-9.8,0)
    • setJointLimits

      public void setJointLimits(String boneName, RangeOfMotion rom)
      Alter the range of motion of the joint connecting the named BoneLink to its parent in the link hierarchy.
      Overrides:
      setJointLimits in class DacConfiguration
      Parameters:
      boneName - the name of the BoneLink (not null, not empty)
      rom - the desired range of motion (not null)
    • setMass

      public void setMass(String boneName, float mass)
      Alter the mass of the named bone/torso.
      Overrides:
      setMass in class DacConfiguration
      Parameters:
      boneName - the name of the bone, or torsoName (not null)
      mass - the desired mass (>0)
    • setPhysicsLocation

      protected void setPhysicsLocation(Vector3f vec)
      Translate the torso to the specified location.
      Specified by:
      setPhysicsLocation in class AbstractPhysicsControl
      Parameters:
      vec - desired location (not null, unaffected)
    • setPhysicsRotation

      protected void setPhysicsRotation(Quaternion quat)
      Rotate the torso to the specified orientation.
      Specified by:
      setPhysicsRotation in class AbstractPhysicsControl
      Parameters:
      quat - desired orientation (not null, unaffected)
    • update

      public void update(float tpf)
      Update this control. Invoked once per frame during the logical-state update, provided the control is added to a scene. Do not invoke directly from user code.
      Specified by:
      update in interface Control
      Overrides:
      update in class AbstractPhysicsControl
      Parameters:
      tpf - the time interval between frames (in seconds, ≥0)
    • write

      public void write(JmeExporter ex) throws IOException
      Serialize this control, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Overrides:
      write in class DacConfiguration
      Parameters:
      ex - exporter (not null)
      Throws:
      IOException - from exporter
    • physicsTick

      public void physicsTick(PhysicsSpace space, float timeStep)
      Callback from Bullet, invoked just after the physics has been stepped. Used to re-activate any deactivated rigid bodies.
      Specified by:
      physicsTick in interface PhysicsTickListener
      Parameters:
      space - the space that was just stepped (not null)
      timeStep - the time per physics step (in seconds, ≥0)
    • prePhysicsTick

      public void prePhysicsTick(PhysicsSpace space, float timeStep)
      Callback from Bullet, invoked just before the physics is stepped. A good time to clear/apply forces.
      Specified by:
      prePhysicsTick in interface PhysicsTickListener
      Parameters:
      space - the space that is about to be stepped (not null)
      timeStep - the time per physics step (in seconds, ≥0)