public class InstancedGeometry extends Geometry
Modifier and Type | Class and Description |
---|---|
static class |
InstancedGeometry.DefaultInstanceCullingFunction
By default, it checks if geometry is in camera frustum and culls it
if it is outside camera view.
|
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
cachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndex
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localOverrides, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_CHILD_LIGHTLIST, RF_LIGHTLIST, RF_MATPARAM_OVERRIDE, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldOverrides, worldTransform
Constructor and Description |
---|
InstancedGeometry() |
InstancedGeometry(java.lang.String name)
Creates instanced geometry with the specified mode and name.
|
Modifier and Type | Method and Description |
---|---|
void |
addInstance(Geometry geometry) |
boolean |
checkCulling(Camera cam)
checkCulling checks the spatial with the camera to see if it
should be culled. |
protected void |
cleanup()
Destroy internal buffers.
|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Called internally by com.jme3.util.clone.Cloner.
|
int |
collideWith(Collidable other,
CollisionResults results)
Check collision with another Collidable.
|
void |
deleteInstance(Geometry geom) |
VertexBuffer[] |
getAllInstanceData() |
Geometry[] |
getGeometries() |
VertexBuffer[] |
getGlobalUserInstanceData()
Global user specified per-instance data.
|
static java.util.function.BiFunction<Camera,Geometry,java.lang.Boolean> |
getInstanceCullingFunction() |
int |
getMaxNumInstances() |
int |
getNumInstances() |
int |
getNumVisibleInstances() |
VertexBuffer |
getTransformUserInstanceData()
Return user per-instance transform data.
|
boolean |
isEmpty() |
void |
read(JmeImporter importer) |
void |
setGlobalUserInstanceData(VertexBuffer[] globalInstanceData)
Specify global user per-instance data.
|
static void |
setInstanceCullingFunction(java.util.function.BiFunction<Camera,Geometry,java.lang.Boolean> instanceCullingFunction)
Set the function used for culling instances from being rendered.
|
void |
setMaxNumInstances(int maxNumInstances)
Set the maximum amount of instances that can be rendered by this
instanced geometry when mode is set to auto.
|
void |
setTransformUserInstanceData(VertexBuffer transformInstanceData)
Specify camera specific user per-instance data.
|
void |
updateInstances() |
protected void |
updateWorldBound()
updateWorldBound updates the bounding volume that contains
this geometry. |
void |
write(JmeExporter exporter) |
associateWithGroupNode, breadthFirstTraversal, clone, clone, computeWorldMatrix, deepClone, depthFirstTraversal, getFallbackMorphTarget, getLodLevel, getMaterial, getMesh, getModelBound, getMorphState, getMorphState, getNbSimultaneousGPUMorph, getTriangleCount, getVertexCount, getWorldMatrix, isBatched, isDirtyMorph, isGrouped, isIgnoreTransform, oldDeepClone, removeFromParent, setDirtyMorph, setFallbackMorphTarget, setIgnoreTransform, setLodLevel, setMaterial, setMesh, setModelBound, setMorphState, setMorphState, setNbSimultaneousGPUMorph, setParent, unassociateFromGroupNode, updateModelBound, updateWorldLightList, updateWorldTransforms
addControl, addControlAt, addLight, addMatParamOverride, breadthFirstTraversal, center, clearMatParamOverrides, depthFirstTraversal, forceRefresh, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalMatParamOverrides, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldMatParamOverrides, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, jmeClone, localToWorld, lookAt, matches, move, move, oldClone, removeControl, removeControl, removeLight, removeMatParamOverride, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLightListRefresh, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setMatParamOverrideRefresh, setName, setQueueBucket, setRequiresUpdates, setShadowMode, setTransformRefresh, setUserData, toString, updateGeometricState, updateLogicalState, updateMatParamOverrides, worldToLocal
public InstancedGeometry()
public InstancedGeometry(java.lang.String name)
name
- The name of the spatial.Spatial(java.lang.String)
public static void setInstanceCullingFunction(java.util.function.BiFunction<Camera,Geometry,java.lang.Boolean> instanceCullingFunction)
InstancedGeometry.DefaultInstanceCullingFunction
.public static java.util.function.BiFunction<Camera,Geometry,java.lang.Boolean> getInstanceCullingFunction()
InstancedGeometry.DefaultInstanceCullingFunction
.public VertexBuffer[] getGlobalUserInstanceData()
null
, specify an array of VertexBuffers
via setGlobalUserInstanceData(com.jme3.scene.VertexBuffer[])
.setGlobalUserInstanceData(com.jme3.scene.VertexBuffer[])
public void setGlobalUserInstanceData(VertexBuffer[] globalInstanceData)
null
, specify an array of VertexBuffers
that contain per-instance vertex attributes.globalInstanceData
- global user per-instance data.java.lang.IllegalArgumentException
- If one of the VertexBuffers is not
instanced
.public void setTransformUserInstanceData(VertexBuffer transformInstanceData)
transformInstanceData
- The transforms for each instance.public VertexBuffer getTransformUserInstanceData()
setTransformUserInstanceData(com.jme3.scene.VertexBuffer)
public final void setMaxNumInstances(int maxNumInstances)
maxNumInstances
- The maximum number of instances that can be
rendered.java.lang.IllegalStateException
- If mode is set to manual.java.lang.IllegalArgumentException
- If maxNumInstances is zero or negativepublic int getMaxNumInstances()
public int getNumVisibleInstances()
public int getNumInstances()
InstancedGeometry
public boolean isEmpty()
public void updateInstances()
public void deleteInstance(Geometry geom)
public void addInstance(Geometry geometry)
protected void updateWorldBound()
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.updateWorldBound
in class Geometry
Spatial.updateWorldBound()
public Geometry[] getGeometries()
public VertexBuffer[] getAllInstanceData()
public boolean checkCulling(Camera cam)
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.
checkCulling
in class Geometry
cam
- The camera to check against.public int collideWith(Collidable other, CollisionResults results)
Collidable
collideWith
in interface Collidable
collideWith
in class Geometry
other
- The object to check collision againstresults
- Will contain the list of CollisionResult
s.public void cloneFields(Cloner cloner, java.lang.Object original)
cloneFields
in interface JmeCloneable
cloneFields
in class Geometry
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.public void write(JmeExporter exporter) throws java.io.IOException
public void read(JmeImporter importer) throws java.io.IOException
protected void cleanup()