Class CompoundMesh

java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.infos.CompoundMesh
All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, Comparable<NativePhysicsObject>

public class CompoundMesh extends NativePhysicsObject implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
A scalable mesh that combines multiple indexed meshes. Based on Bullet's btTriangleIndexVertexArray.
  • Field Details

    • logger

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

    • CompoundMesh

      public CompoundMesh()
      Instantiate an empty mesh.
    • CompoundMesh

      public CompoundMesh(CompoundMesh original)
      Copy an existing mesh.
      Parameters:
      original - the mesh to copy (not null, unaffected)
    • CompoundMesh

      public CompoundMesh(CompoundMesh base, com.jme3.math.Vector3f offset)
      Instantiate a mesh by applying an offset to an existing mesh.
      Parameters:
      base - the mesh to use as a base (not null, unaffected)
      offset - the offset to add to the scaled vertex positions (not null, unaffected)
    • CompoundMesh

      public CompoundMesh(com.jme3.scene.Mesh... jmeMeshes)
      Instantiate a mesh based on the specified JME mesh(es).
      Parameters:
      jmeMeshes - the JME mesh(es) (all non-null, modes=Triangles/TriangleStrip/TriangleFan, unaffected)
  • Method Details

    • add

      public final void add(IndexedMesh submesh)
      Add a submesh to this mesh.
      Parameters:
      submesh - (not null, alias created)
    • countSubmeshes

      public int countSubmeshes()
      Count how many submeshes are in this mesh.
      Returns:
      the count (≥0)
    • 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)
    • getScale

      public com.jme3.math.Vector3f getScale(com.jme3.math.Vector3f storeResult)
      Copy the scale factors.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the scale factor for each local axis (either storeResult or a new vector, not null)
    • getSubmesh

      public IndexedMesh getSubmesh(int index)
      Access the specified submesh.
      Parameters:
      index - the index of the desired submesh (in the order the submeshes were added, ≥0)
      Returns:
      the pre-existing instance (not null)
    • maxMin

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

      public void setScale(com.jme3.math.Vector3f scale)
      Alter the scale factors.
      Parameters:
      scale - the desired scale factor for each local axis (not null, no negative component, unaffected, default=(1,1,1))
    • split

      public CompoundMesh[] split(com.jme3.math.Triangle scaledTriangle)
      Attempt to divide this mesh into 2 meshes.
      Parameters:
      scaledTriangle - to define the splitting plane (in scaled coordinates, 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
    • cloneFields

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

      public CompoundMesh jmeClone()
      Create a shallow clone for the JME cloner.
      Specified by:
      jmeClone in interface com.jme3.util.clone.JmeCloneable
      Returns:
      a new instance
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this mesh from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this mesh to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter