Class SimplexCollisionShape

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

public class SimplexCollisionShape extends ConvexShape
A simple point, line-segment, triangle, or tetrahedron collision shape based on Bullet's btBU_Simplex1to4. These shapes cannot be scaled.
  • Field Details

    • logger2

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

    • SimplexCollisionShape

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

      public SimplexCollisionShape(com.jme3.math.Vector3f location)
      Instantiate a point shape based on the specified location.
      Parameters:
      location - the location of the point (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(com.jme3.math.Vector3f point1, com.jme3.math.Vector3f point2)
      Instantiate a line-segment shape based on the specified endpoints.
      Parameters:
      point1 - the location of first endpoint (in shape coordinates, not null, unaffected)
      point2 - the location of 2nd endpoint (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(com.jme3.math.Vector3f vertex1, com.jme3.math.Vector3f vertex2, com.jme3.math.Vector3f vertex3)
      Instantiate a triangular shape based on the specified vertices.
      Parameters:
      vertex1 - the location of first vertex (in shape coordinates, not null, unaffected)
      vertex2 - the location of 2nd vertex (in shape coordinates, not null, unaffected)
      vertex3 - the location of 3rd vertex (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(com.jme3.math.Vector3f vertex1, com.jme3.math.Vector3f vertex2, com.jme3.math.Vector3f vertex3, com.jme3.math.Vector3f vertex4)
      Instantiate a tetrahedral shape based on the specified vertices.
      Parameters:
      vertex1 - the location of first vertex (in shape coordinates, not null, unaffected)
      vertex2 - the location of 2nd vertex (in shape coordinates, not null, unaffected)
      vertex3 - the location of 3rd vertex (in shape coordinates, not null, unaffected)
      vertex4 - the location of 4th vertex (in shape coordinates, not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(com.jme3.math.AbstractTriangle triangle)
      Instantiate a triangular shape based on the specified AbstractTriangle.
      Parameters:
      triangle - the triangle (not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(FloatBuffer buffer, int startPosition, int endPosition)
      Instantiate a simplex shape based on the specified FloatBuffer range.
      Parameters:
      buffer - the buffer that contains the vertex locations (not null, unaffected)
      startPosition - the buffer position at which the vertex locations start (≥0, ≤endPosition-3)
      endPosition - the buffer position at which the vertex locations end (≥startPosition+3, ≤capacity)
    • SimplexCollisionShape

      public SimplexCollisionShape(com.jme3.math.LineSegment segment)
      Instantiate a line-segment shape based on the specified LineSegment.
      Parameters:
      segment - the segment (not null, unaffected)
    • SimplexCollisionShape

      public SimplexCollisionShape(com.jme3.math.Vector3f[] vertices)
      Instantiate a simplex shape based on the specified array.
      Parameters:
      vertices - an array of vertex locations (not null, not empty, unaffected)
  • Method Details

    • copyVertex

      public com.jme3.math.Vector3f copyVertex(int index, com.jme3.math.Vector3f storeResult)
      Copy the indexed vertex.
      Parameters:
      index - (≥0, <4)
      storeResult - storage for the result (modified if not null)
      Returns:
      the location of the vertex (either storeResult or a new instance)
    • copyVertices

      public float[] copyVertices()
      Copy the unscaled vertex locations.
      Returns:
      a new array (not null)
    • countMeshVertices

      public int countMeshVertices()
      Count the points used to generate the simplex.
      Returns:
      the count (≥1, ≤4)
    • getHalfExtents

      public com.jme3.math.Vector3f getHalfExtents(com.jme3.math.Vector3f storeResult)
      Calculate the unscaled half extents of the simplex.
      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)
    • unscaledVolume

      public float unscaledVolume()
      Calculate the unscaled volume of the simplex.
      Returns:
      the volume (in shape units cubed, ≥0)
    • canScale

      public boolean canScale(com.jme3.math.Vector3f scale)
      Test whether the specified scale factors can be applied to the shape. For simplex shapes, scaling must be unity.
      Overrides:
      canScale in class CollisionShape
      Parameters:
      scale - the desired scale factor for each local axis (may be null, unaffected)
      Returns:
      true if applicable, otherwise false
    • 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 the shape extends from its origin, 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
    • toHullShape

      public HullCollisionShape toHullShape()
      Approximate this shape with a HullCollisionShape.
      Overrides:
      toHullShape in class ConvexShape
      Returns:
      a new shape
    • 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