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
Nested ClassesModifier and TypeClassDescriptionstatic classBy 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, startIndexFields 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
ConstructorsConstructorDescriptionInstancedGeometry(String name) Creates instanced geometry with the specified mode and name. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInstance(Geometry geometry) booleancheckCulling(Camera cam) checkCullingchecks the spatial with the camera to see if it should be culled.protected voidcleanup()Destroy internal buffers.voidcloneFields(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.intcollideWith(Collidable other, CollisionResults results) Check collision with another Collidable.voiddeleteInstance(Geometry geom) Geometry[]Global user specified per-instance data.static BiFunction<Camera,Geometry, Boolean> intintintReturn user per-instance transform data.booleanisEmpty()voidread(JmeImporter importer) voidsetGlobalUserInstanceData(VertexBuffer[] globalInstanceData) Specify global user per-instance data.static voidsetInstanceCullingFunction(BiFunction<Camera, Geometry, Boolean> instanceCullingFunction) Set the function used for culling instances from being rendered.final voidsetMaxNumInstances(int maxNumInstances) Set the maximum amount of instances that can be rendered by this instanced geometry when mode is set to auto.voidsetTransformUserInstanceData(VertexBuffer transformInstanceData) Specify camera specific user per-instance data.voidprotected voidupdateWorldBoundupdates the bounding volume that contains this geometry.voidwrite(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, updateWorldTransformsMethods 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:GeometryupdateWorldBoundupdates the bounding volume that contains this geometry. The location of the geometry is based on the location of all this node's parents.- Overrides:
updateWorldBoundin classGeometry- See Also:
-
getGeometries
-
getAllInstanceData
-
checkCulling
Description copied from class:SpatialcheckCullingchecks 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:
checkCullingin 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:CollidableCheck collision with another Collidable.- Specified by:
collideWithin interfaceCollidable- Overrides:
collideWithin classGeometry- Parameters:
other- The object to check collision againstresults- Will contain the list ofCollisionResults.- 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:
cloneFieldsin interfaceJmeCloneable- Overrides:
cloneFieldsin 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:
writein interfaceSavable- Overrides:
writein classGeometry- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classGeometry- Throws:
IOException
-
cleanup
protected void cleanup()Destroy internal buffers.
-