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 SummaryNested 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.SpatialSpatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
- 
Field SummaryFields inherited from class com.jme3.scene.GeometrycachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndexFields inherited from class com.jme3.scene.SpatialbatchHint, 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 SummaryConstructorsConstructorDescriptionInstancedGeometry(String name) Creates instanced geometry with the specified mode and name.
- 
Method SummaryModifier 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.voidDeprecated.voidupdateInstances(Camera cam) protected voidupdateWorldBoundupdates the bounding volume that contains this geometry.voidwrite(JmeExporter exporter) Methods inherited from class com.jme3.scene.GeometryassociateWithGroupNode, 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.SpatialaddControl, 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- 
InstancedGeometrypublic InstancedGeometry()
- 
InstancedGeometryCreates instanced geometry with the specified mode and name.- Parameters:
- name- The name of the spatial.
- See Also:
 
 
- 
- 
Method Details- 
setInstanceCullingFunctionpublic 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.
 
- 
getGlobalUserInstanceDataGlobal 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:
 
- 
setGlobalUserInstanceDataSpecify 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 not- instanced.
 
- 
setTransformUserInstanceDataSpecify camera specific user per-instance data.- Parameters:
- transformInstanceData- The transforms for each instance.
 
- 
getTransformUserInstanceDataReturn user per-instance transform data.- Returns:
- The per-instance transform data.
- See Also:
 
- 
setMaxNumInstancespublic 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
 
- 
getMaxNumInstancespublic int getMaxNumInstances()
- 
getNumVisibleInstancespublic int getNumVisibleInstances()- Returns:
- The number of instances are visible by camera.
 
- 
getNumInstancespublic int getNumInstances()- Returns:
- The number of instances are in this InstancedGeometry
 
- 
isEmptypublic boolean isEmpty()
- 
updateInstancespublic void updateInstances()Deprecated.
- 
updateInstances
- 
deleteInstance
- 
addInstance
- 
updateWorldBoundprotected 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 class- Geometry
- See Also:
 
- 
getGeometries
- 
getAllInstanceData
- 
checkCullingDescription 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 class- Geometry
- Parameters:
- cam- The camera to check against.
- Returns:
- true if inside or intersecting camera frustum (should be rendered), false if outside.
 
- 
collideWithDescription copied from interface:CollidableCheck collision with another Collidable.- Specified by:
- collideWithin interface- Collidable
- Overrides:
- collideWithin 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
 
- 
cloneFieldsCalled internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
- cloneFieldsin interface- JmeCloneable
- Overrides:
- cloneFieldsin 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- Specified by:
- writein interface- Savable
- Overrides:
- writein class- Geometry
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- Geometry
- Throws:
- IOException
 
- 
cleanupprotected void cleanup()Destroy internal buffers.
 
- 
updateInstances(com.jme3.renderer.Camera)