Class PhysicsGhostObject

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

public class PhysicsGhostObject extends PhysicsCollisionObject
A collision object for intangibles, based on Bullet's btPairCachingGhostObject. This is useful for creating a character controller, collision sensors/triggers, explosions etc.

Overlap detection skips the narrow-phase collision-detection algorithm and relies entirely on the broad-phase algorithm, which is AABB plus a margin of about 0.06 world units. Precise collision detection is still available via PhysicsSpace.addCollisionListener().

From Bullet manual:
btGhostObject is a special btCollisionObject, useful for fast localized collision queries.

  • Field Details

    • logger2

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

    • PhysicsGhostObject

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

      public PhysicsGhostObject(CollisionShape shape)
      Instantiate a ghost object with the specified CollisionShape. The new object is not added to any CollisionSpace.
      Parameters:
      shape - the desired shape (not null, alias created)
  • Method Details

    • getOverlapping

      public PhysicsCollisionObject getOverlapping(int index)
      Access an overlapping collision object by its position in the list. Important: getOverlappingObjects() must be invoked first!
      Parameters:
      index - which list position (≥0, <count)
      Returns:
      the pre-existing object
    • getOverlappingCount

      public int getOverlappingCount()
      Count how many collision objects this object overlaps.
      Returns:
      the count (≥0)
    • getOverlappingObjects

      public List<PhysicsCollisionObject> getOverlappingObjects()
      Update and access a list of overlapping objects.
      Returns:
      an internal list which may get reused (not null)
    • setPhysicsLocation

      public void setPhysicsLocation(com.jme3.math.Vector3f location)
      Directly alter the location of the ghost's center.
      Parameters:
      location - the desired location (in physics-space coordinates, not null, finite, unaffected)
    • setPhysicsLocationDp

      public void setPhysicsLocationDp(com.simsilica.mathd.Vec3d location)
      Directly alter the location of the ghost's center.
      Parameters:
      location - the desired location (in physics-space coordinates, not null, unaffected)
    • setPhysicsRotation

      public void setPhysicsRotation(com.jme3.math.Matrix3f orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation matrix in physics-space coordinates, not null, unaffected)
    • setPhysicsRotation

      public void setPhysicsRotation(com.jme3.math.Quaternion orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation quaternion in physics-space coordinates, not null, not zero, unaffected)
    • setPhysicsRotationDp

      public void setPhysicsRotationDp(com.simsilica.mathd.Matrix3d orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation matrix in physics-space coordinates, not null, unaffected)
    • setPhysicsRotationDp

      public void setPhysicsRotationDp(com.simsilica.mathd.Quatd orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation quaternion in physics-space coordinates, not null, unaffected)
    • cloneFields

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

      public void setCollisionShape(CollisionShape collisionShape)
      Apply the specified CollisionShape to this object. Note that the object should not be in any CollisionSpace while changing shape; the object gets rebuilt on the physics side.
      Overrides:
      setCollisionShape in class PhysicsCollisionObject
      Parameters:
      collisionShape - the shape to apply (not null, alias created)
    • read

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

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