Class IndexedMesh

java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.IndexedMesh
All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class IndexedMesh extends NativePhysicsObject
An indexed triangle mesh based on Bullet's btIndexedMesh. Immutable.
  • Field Details

    • logger

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

    • IndexedMesh

      public IndexedMesh(Vector3f[] positionArray, int[] indexArray)
      Instantiate an IndexedMesh based on the specified positions and indices.
      Parameters:
      positionArray - (not null, unaffected)
      indexArray - (not null, unaffected, length a multiple of 3)
    • IndexedMesh

      public IndexedMesh(FloatBuffer buffer)
      Instantiate an IndexedMesh based on the specified vertex positions. An index will be assigned to each distinct position.
      Parameters:
      buffer - the vertex positions of a non-indexed triangle mesh (not null, flipped, limit a multiple of 9, unaffected)
    • IndexedMesh

      public IndexedMesh(FloatBuffer positionBuffer, IntBuffer indexBuffer)
      Instantiate an IndexedMesh based on the specified positions and indices.
      Parameters:
      positionBuffer - (not null, not flipped, length a multiple of 3, alias created)
      indexBuffer - (not null, not flipped, length a multiple of 3, alias created)
    • IndexedMesh

      public IndexedMesh(CollisionShape shape, int meshResolution)
      Instantiate a IndexedMesh to visualize the specified collision shape.
      Parameters:
      shape - shape to visualize (not null, not compound, unaffected)
      meshResolution - 0→low, 1→high for convex shapes, 2→high for all shapes
  • Method Details

    • copyIndices

      public IntBuffer copyIndices()
      Copy the triangle indices.
      Returns:
      a new, direct, unflipped buffer
    • copyTriangle

      public void copyTriangle(int triangleIndex, Triangle destination)
      Copy the vertex positions of the specified triangle.
      Parameters:
      triangleIndex - the index of the source triangle (≥0)
      destination - storage for the result (not null, modified)
    • copyTriangles

      public FloatBuffer copyTriangles()
      Copy the unindexed triangle vertices to a new buffer.
      Returns:
      a new, direct, unflipped buffer
    • copyVertexPositions

      public FloatBuffer copyVertexPositions()
      Copy the vertex positions to a new buffer.
      Returns:
      a new, direct, unflipped buffer
    • countTriangles

      public int countTriangles()
      Count how many triangles are in this mesh.
      Returns:
      the count (≥0)
    • countVertices

      public int countVertices()
      Count how many vertices are in this mesh.
      Returns:
      the count (≥0)
    • maxDistance

      public float maxDistance(Transform meshToWorld)
      Calculate how far the mesh extends from some origin.
      Parameters:
      meshToWorld - the transform to apply to vertex locations (not null, unaffected)
      Returns:
      the maximum length of the transformed vectors (≥0)
    • maxMin

      public void maxMin(Vector3f storeMaxima, Vector3f storeMinima)
      Find the maximum and minimum coordinates for each axis among the vertices in this mesh.
      Parameters:
      storeMaxima - storage for the maxima (not null, modified)
      storeMinima - storage for the minima (not null, modified)
    • split

      public IndexedMesh[] split(Plane splittingPlane)
      Attempt to divide this mesh into 2 meshes.
      Parameters:
      splittingPlane - the splitting plane (not null, unaffected)
      Returns:
      a pair of meshes, the first mesh generated by the plane's minus side and the 2nd mesh generated by its plus side; either mesh may be null, indicating an empty mesh
    • surfaceArea

      public float surfaceArea()
      Calculate the (one-sided) surface area of the mesh.
      Returns:
      the area (in square mesh units, ≥0)
    • volumeConvex

      public float volumeConvex()
      Calculate volume of the mesh, assuming it's both closed and convex.
      Returns:
      the volume (in cubic mesh units, ≥0)