Class VehicleControl

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

public class VehicleControl extends PhysicsVehicle implements PhysicsControl
A PhysicsControl to link a PhysicsVehicle to a Spatial.
  • Field Details

    • logger4

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

    • VehicleControl

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

      public VehicleControl(CollisionShape shape)
      Instantiate an enabled Control with mass=1 and the specified CollisionShape.
      shape - the desired shape (not null, alias created)
    • VehicleControl

      public VehicleControl(CollisionShape shape, float mass)
      Instantiate an enabled Control with the specified CollisionShape and mass.
      shape - the desired shape (not null, alias created)
      mass - the desired mass (>0)
  • Method Details

    • getSpatial

      public com.jme3.scene.Spatial getSpatial()
      Access the controlled Spatial.
      the Spatial, or null if none
    • isApplyPhysicsLocal

      public boolean isApplyPhysicsLocal()
      Test whether physics-space coordinates should match the spatial's local coordinates.
      true if matching local coordinates, false if matching world coordinates
    • setApplyPhysicsLocal

      public void setApplyPhysicsLocal(boolean applyPhysicsLocal)
      Alter whether physics-space coordinates should match the spatial's local coordinates.
      applyPhysicsLocal - true→match local coordinates, false→match world coordinates (default=false)
    • cloneForSpatial

      public com.jme3.scene.control.Control cloneForSpatial(com.jme3.scene.Spatial spatial)
      Clone this Control for a different Spatial. No longer used as of JME 3.1.
      Specified by:
      cloneForSpatial in interface com.jme3.scene.control.Control
      spatial - (unused)
      UnsupportedOperationException - always
    • getPhysicsSpace

      public PhysicsSpace getPhysicsSpace()
      Access the PhysicsSpace to which the vehicle is (or would be) added.
      Specified by:
      getPhysicsSpace in interface PhysicsControl
      the pre-existing space, or null for none
    • isEnabled

      public boolean isEnabled()
      Test whether this Control is enabled.
      Specified by:
      isEnabled in interface PhysicsControl
      true if enabled, otherwise false
    • render

      public void render(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp)
      Render this Control. Invoked once per ViewPort per frame, provided the Control is added to a scene. Should be invoked only by a subclass or by the RenderManager.
      Specified by:
      render in interface com.jme3.scene.control.Control
      rm - the RenderManager (unused)
      vp - the ViewPort to render (unused)
    • setEnabled

      public void setEnabled(boolean enabled)
      Enable or disable this Control.

      When the Control is disabled, the vehicle is removed from PhysicsSpace. When the Control is enabled again, the vehicle is moved to the current location of the Spatial and then added to the PhysicsSpace.

      Specified by:
      setEnabled in interface PhysicsControl
      enabled - true→enable the Control, false→disable it
    • setPhysicsSpace

      public void setPhysicsSpace(PhysicsSpace newSpace)
      If enabled, add this control's physics object to the specified PhysicsSpace. If not enabled, alter where the object would be added. The object is removed from any other space it's currently in.
      Specified by:
      setPhysicsSpace in interface PhysicsControl
      newSpace - where to add, or null to simply remove
    • setSpatial

      public void setSpatial(com.jme3.scene.Spatial controlledSpatial)
      Alter which Spatial is controlled. Invoked when the Control is added to or removed from a Spatial. Should be invoked only by a subclass or from Spatial. Do not invoke directly from user code.
      Specified by:
      setSpatial in interface com.jme3.scene.control.Control
      controlledSpatial - the Spatial to control (or null)
    • 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 com.jme3.scene.control.Control
      tpf - the time interval between frames (in seconds, ≥0)
    • 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
      cloneFields in class PhysicsVehicle
      cloner - the Cloner that's cloning this Control (not null)
      original - the instance from which this Control was shallow-cloned (not null, unaffected)
    • 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
      read in class PhysicsVehicle
      importer - (not null)
      IOException - from the importer
    • 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
      write in class PhysicsVehicle
      exporter - (not null)
      IOException - from the exporter