Class InstancedGeometry

java.lang.Object
com.jme3.scene.Spatial
com.jme3.scene.Geometry
com.jme3.scene.instancing.InstancedGeometry
All Implemented Interfaces:
HasLocalTransform, CloneableSmartAsset, Collidable, Savable, JmeCloneable, Cloneable

public class InstancedGeometry extends Geometry
  • Constructor Details

    • InstancedGeometry

      public InstancedGeometry()
    • InstancedGeometry

      public InstancedGeometry(String name)
      Creates instanced geometry with the specified mode and name.
      Parameters:
      name - The name of the spatial.
      See Also:
  • Method Details

    • setInstanceCullingFunction

      public static void setInstanceCullingFunction(BiFunction<Camera,Geometry,Boolean> instanceCullingFunction)
      Set the function used for culling instances from being rendered. Default is InstancedGeometry.DefaultInstanceCullingFunction.
    • getInstanceCullingFunction

      public static BiFunction<Camera,Geometry,Boolean> getInstanceCullingFunction()
      Returns:
      The instance culling function or null if there isn't any. Default is InstancedGeometry.DefaultInstanceCullingFunction.
    • getGlobalUserInstanceData

      public VertexBuffer[] getGlobalUserInstanceData()
      Global user specified per-instance data. By default set to null, specify an array of VertexBuffers via setGlobalUserInstanceData(com.jme3.scene.VertexBuffer[]).
      Returns:
      global user specified per-instance data.
      See Also:
    • setGlobalUserInstanceData

      public void setGlobalUserInstanceData(VertexBuffer[] globalInstanceData)
      Specify global user per-instance data. By default set to null, specify an array of VertexBuffers that contain per-instance vertex attributes.
      Parameters:
      globalInstanceData - global user per-instance data.
      Throws:
      IllegalArgumentException - If one of the VertexBuffers is not instanced.
    • setTransformUserInstanceData

      public void setTransformUserInstanceData(VertexBuffer transformInstanceData)
      Specify camera specific user per-instance data.
      Parameters:
      transformInstanceData - The transforms for each instance.
    • getTransformUserInstanceData

      public VertexBuffer getTransformUserInstanceData()
      Return user per-instance transform data.
      Returns:
      The per-instance transform data.
      See Also:
    • setMaxNumInstances

      public final void setMaxNumInstances(int maxNumInstances)
      Set the maximum amount of instances that can be rendered by this instanced geometry when mode is set to auto. This re-allocates internal structures and therefore should be called only when necessary.
      Parameters:
      maxNumInstances - The maximum number of instances that can be rendered.
      Throws:
      IllegalStateException - If mode is set to manual.
      IllegalArgumentException - If maxNumInstances is zero or negative
    • getMaxNumInstances

      public int getMaxNumInstances()
    • getNumVisibleInstances

      public int getNumVisibleInstances()
      Returns:
      The number of instances are visible by camera.
    • getNumInstances

      public int getNumInstances()
      Returns:
      The number of instances are in this InstancedGeometry
    • isEmpty

      public boolean isEmpty()
    • updateInstances

      public void updateInstances()
    • deleteInstance

      public void deleteInstance(Geometry geom)
    • addInstance

      public void addInstance(Geometry geometry)
    • updateWorldBound

      protected void updateWorldBound()
      Description copied from class: Geometry
      updateWorldBound updates the bounding volume that contains this geometry. The location of the geometry is based on the location of all this node's parents.
      Overrides:
      updateWorldBound in class Geometry
      See Also:
    • getGeometries

      public Geometry[] getGeometries()
    • getAllInstanceData

      public VertexBuffer[] getAllInstanceData()
    • checkCulling

      public boolean checkCulling(Camera cam)
      Description copied from class: Spatial
      checkCulling checks the spatial with the camera to see if it should be culled.

      This method is called by the renderer. Usually it should not be called directly.

      Overrides:
      checkCulling in class Geometry
      Parameters:
      cam - The camera to check against.
      Returns:
      true if inside or intersecting camera frustum (should be rendered), false if outside.
    • collideWith

      public int collideWith(Collidable other, CollisionResults results)
      Description copied from interface: Collidable
      Check collision with another Collidable.
      Specified by:
      collideWith in interface Collidable
      Overrides:
      collideWith in class Geometry
      Parameters:
      other - The object to check collision against
      results - Will contain the list of CollisionResults.
      Returns:
      how many collisions were found between this and other
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Called internally by com.jme3.util.clone.Cloner. Do not call directly.
      Specified by:
      cloneFields in interface JmeCloneable
      Overrides:
      cloneFields in class Geometry
      Parameters:
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
    • write

      public void write(JmeExporter exporter) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class Geometry
      Throws:
      IOException
    • read

      public void read(JmeImporter importer) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class Geometry
      Throws:
      IOException
    • cleanup

      protected void cleanup()
      Destroy internal buffers.