Class JoinedBodyControl

java.lang.Object
com.jme3.bullet.control.AbstractPhysicsControl
com.jme3.bullet.control.JoinedBodyControl
All Implemented Interfaces:
PhysicsControl, com.jme3.export.Savable, com.jme3.scene.control.Control, com.jme3.util.clone.JmeCloneable, Cloneable

public class JoinedBodyControl extends AbstractPhysicsControl
A custom PhysicsControl for a dynamic rigid body that can be joined to other bodies. When the Control is removed from a space, all its joints are automatically destroyed.
  • Field Details

    • logger3

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

    • JoinedBodyControl

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

      public JoinedBodyControl(CollisionShape bodyShape, float mass)
      Instantiate an enabled Control in dynamic mode.
      Parameters:
      bodyShape - the desired shape for the rigid body (not null, alias created)
      mass - the desired mass for the rigid body (gt;0)
  • Method Details

    • getRigidBody

      public PhysicsRigidBody getRigidBody()
      Access the rigid body managed by this Control.
      Returns:
      the pre-existing rigid body (not null)
    • isKinematic

      public boolean isKinematic()
      Test whether the body is in kinematic mode.
      Returns:
      true if in kinematic mode, otherwise false (in dynamic mode)
    • setKinematic

      public void setKinematic(boolean newSetting)
      Transition the body from kinematic mode to dynamic mode or vice versa.
      Parameters:
      newSetting - true→set kinematic mode, false→set dynamic mode (default=false)
    • addPhysics

      protected void addPhysics()
      Add all managed physics objects to the PhysicsSpace.
      Specified by:
      addPhysics in class AbstractPhysicsControl
    • cloneFields

      public void cloneFields(com.jme3.util.clone.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 com.jme3.util.clone.JmeCloneable
      Overrides:
      cloneFields in class AbstractPhysicsControl
      Parameters:
      cloner - the Cloner that's cloning this Control (not null, modified)
      original - the instance from which this Control was shallow-cloned (not null, unaffected)
    • createSpatialData

      protected void createSpatialData(com.jme3.scene.Spatial spatial)
      Create spatial-dependent data. Invoked when this Control is added to a Spatial.
      Specified by:
      createSpatialData in class AbstractPhysicsControl
      Parameters:
      spatial - the controlled Spatial (not null, alias created)
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this Control 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 AbstractPhysicsControl
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • removePhysics

      protected void removePhysics()
      Remove all managed physics objects from the PhysicsSpace.
      Specified by:
      removePhysics in class AbstractPhysicsControl
    • removeSpatialData

      protected void removeSpatialData(com.jme3.scene.Spatial spatial)
      Destroy spatial-dependent data. Invoked when this Control is removed from its Spatial.
      Specified by:
      removeSpatialData in class AbstractPhysicsControl
      Parameters:
      spatial - the Spatial to which this Control was added (unused)
    • setPhysicsLocation

      public void setPhysicsLocation(com.jme3.math.Vector3f newLocation)
      Translate the body instantly to the specified location.
      Specified by:
      setPhysicsLocation in class AbstractPhysicsControl
      Parameters:
      newLocation - the desired location (in physics-space coordinates, not null, finite, unaffected)
    • setPhysicsRotation

      protected void setPhysicsRotation(com.jme3.math.Quaternion newOrientation)
      Rotate the body instantly to the specified orientation.
      Specified by:
      setPhysicsRotation in class AbstractPhysicsControl
      Parameters:
      newOrientation - the desired orientation (in physics-space coordinates, not null, not zero, 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.
      Parameters:
      tpf - the time interval between frames (in seconds, ≥0)
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this Control 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 AbstractPhysicsControl
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter