Class HullCollisionShape

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

public class HullCollisionShape extends ConvexShape
A convex-hull collision shape based on Bullet's btConvexHullShape. For a 2-D convex hull, use Convex2dShape.
  • Field Details

    • logger2

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

    • HullCollisionShape

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

      public HullCollisionShape(Collection<com.jme3.math.Vector3f> locations)
      Instantiate a shape based on the specified collection of locations. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      locations - a collection of location vectors on which to base the shape (not null, not empty, unaffected)
    • HullCollisionShape

      public HullCollisionShape(float... coordinates)
      Instantiate a shape based on the specified array of coordinates. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      coordinates - an array of coordinates on which to base the shape (not null, not empty, length a multiple of 3, unaffected)
    • HullCollisionShape

      public HullCollisionShape(FloatBuffer flippedBuffer)
      Instantiate a shape based on a flipped buffer containing coordinates. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      flippedBuffer - the coordinates on which to base the shape (not null, limit>0, limit a multiple of 3, unaffected)
    • HullCollisionShape

      public HullCollisionShape(com.jme3.scene.Mesh... meshes)
      Instantiate a shape based on the specified JME mesh(es). For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      meshes - the mesh(es) on which to base the shape (all non-null, at least one vertex, unaffected)
    • HullCollisionShape

      public HullCollisionShape(jme3utilities.math.RectangularSolid rectangularSolid)
      Instantiate an 8-vertex shape to match the specified rectangular solid.
      Parameters:
      rectangularSolid - the solid on which to base the shape (not null)
    • HullCollisionShape

      public HullCollisionShape(com.jme3.math.Vector3f... locations)
      Instantiate a shape based on the specified array of locations. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      locations - an array of location vectors (in shape coordinates, not null, not empty, unaffected)
    • HullCollisionShape

      public HullCollisionShape(Vhacd4Hull vhacd4Hull)
      Instantiate a shape based on a Vhacd4Hull. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      vhacd4Hull - (not null, unaffected)
    • HullCollisionShape

      public HullCollisionShape(VHACDHull vhacdHull)
      Instantiate a shape based on a VHACDHull. For best performance and stability, the convex hull should have no more than 100 vertices.
      Parameters:
      vhacdHull - (not null, unaffected)
  • Method Details

    • aabbVolume

      public float aabbVolume()
      Calculate a quick upper bound for the unscaled volume of the hull, based on its axis-aligned bounding box.
      Returns:
      the volume (in unscaled shape units cubed, ≥0)
    • copyHullVertices

      public float[] copyHullVertices()
      Copy the unscaled vertex locations of the optimized convex hull.
      Returns:
      a new array (not null)
    • countHullVertices

      public int countHullVertices()
      Count the number of vertices in the optimized convex hull.
      Returns:
      the count (≥0)
    • countMeshVertices

      public int countMeshVertices()
      Count the vertices used to generate the hull.
      Returns:
      the count (>0)
    • getHalfExtents

      public com.jme3.math.Vector3f getHalfExtents(com.jme3.math.Vector3f storeResult)
      Calculate the unscaled half extents of the hull.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the unscaled half extent for each local axis (either storeResult or a new vector, not null, no negative component)
    • split

      public ChildCollisionShape[] split(com.jme3.math.Triangle splittingTriangle)
      Attempt to divide this shape into 2 child shapes.
      Parameters:
      splittingTriangle - to define the splitting plane (in shape coordinates, not null, unaffected)
      Returns:
      a pair of hull-based children, the first child generated by the plane's minus side and the 2nd child generated by its plus side; either child may be null, indicating an empty shape
    • canSplit

      public boolean canSplit()
      Test whether the shape can be split by an arbitrary plane.
      Overrides:
      canSplit in class CollisionShape
      Returns:
      true
    • cloneFields

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

      public float maxRadius()
      Calculate how far this shape extends from its center, including margin.
      Overrides:
      maxRadius in class CollisionShape
      Returns:
      the distance (in physics-space units, ≥0)
    • read

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

      protected void recalculateAabb()
      Recalculate the shape's bounding box if necessary.
      Overrides:
      recalculateAabb in class CollisionShape
    • write

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