Package com.jme3.scene.instancing
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
By default, it checks if geometry is in camera frustum and culls it if it is outside camera view.Nested classes/interfaces inherited from class com.jme3.scene.Spatial
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
-
Field Summary
Fields inherited from class com.jme3.scene.Geometry
cachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndex
Fields inherited from class com.jme3.scene.Spatial
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 Summary
ConstructorDescriptionInstancedGeometry
(String name) Creates instanced geometry with the specified mode and name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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, 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) Geometry[]
Global user specified per-instance data.static BiFunction<Camera,
Geometry, Boolean> int
int
int
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
(BiFunction<Camera, Geometry, Boolean> instanceCullingFunction) Set the function used for culling instances from being rendered.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.void
setTransformUserInstanceData
(VertexBuffer transformInstanceData) Specify camera specific user per-instance data.void
protected void
updateWorldBound
updates the bounding volume that contains this geometry.void
write
(JmeExporter exporter) Methods inherited from class com.jme3.scene.Geometry
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
Methods inherited from class com.jme3.scene.Spatial
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
-
Constructor Details
-
InstancedGeometry
public InstancedGeometry() -
InstancedGeometry
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 isInstancedGeometry.DefaultInstanceCullingFunction
. -
getInstanceCullingFunction
- Returns:
- The instance culling function or null if there isn't any.
Default is
InstancedGeometry.DefaultInstanceCullingFunction
.
-
getGlobalUserInstanceData
Global user specified per-instance data. By default set tonull
, specify an array of VertexBuffers viasetGlobalUserInstanceData(com.jme3.scene.VertexBuffer[])
.- Returns:
- global user specified per-instance data.
- See Also:
-
setGlobalUserInstanceData
Specify global user per-instance data. By default set tonull
, 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 notinstanced
.
-
setTransformUserInstanceData
Specify camera specific user per-instance data.- Parameters:
transformInstanceData
- The transforms for each instance.
-
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
-
addInstance
-
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 classGeometry
- See Also:
-
getGeometries
-
getAllInstanceData
-
checkCulling
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 classGeometry
- Parameters:
cam
- The camera to check against.- Returns:
- true if inside or intersecting camera frustum (should be rendered), false if outside.
-
collideWith
Description copied from interface:Collidable
Check collision with another Collidable.- Specified by:
collideWith
in interfaceCollidable
- Overrides:
collideWith
in classGeometry
- Parameters:
other
- The object to check collision againstresults
- Will contain the list ofCollisionResult
s.- Returns:
- how many collisions were found between this and other
-
cloneFields
Called internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
cloneFields
in interfaceJmeCloneable
- Overrides:
cloneFields
in classGeometry
- 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
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classGeometry
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classGeometry
- Throws:
IOException
-
cleanup
protected void cleanup()Destroy internal buffers.
-