Package com.jme3.scene
Class BatchNode
java.lang.Object
com.jme3.scene.Spatial
com.jme3.scene.Node
com.jme3.scene.GeometryGroupNode
com.jme3.scene.BatchNode
- All Implemented Interfaces:
HasLocalTransform
,CloneableSmartAsset
,Collidable
,Savable
,JmeCloneable
,Cloneable
- Direct Known Subclasses:
SimpleBatchNode
BatchNode holds geometries that are a batched version of all the geometries that are in its sub scenegraph.
There is one geometry per different material in the sub tree.
The geometries are directly attached to the node in the scene graph.
Usage is like any other node except you have to call the
batch()
method once all the geometries have been attached to the sub scene graph and their material set
(see todo more automagic for further enhancements)
All the geometries that have been batched are set to not be rendered - Spatial.CullHint
is left intact.
The sub geometries can be transformed as usual, their transforms are used to update the mesh of the geometryBatch.
Sub geoms can be removed but it may be slower than the normal spatial removing
Sub geoms can be added after the batch() method has been called but won't be batched and will just be rendered as normal geometries.
To integrate them in the batch you have to call the batch() method again on the batchNode.
TODO more automagic (batch when needed in the updateLogicalState)
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.scene.Spatial
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
-
Field Summary
Modifier and TypeFieldDescriptionprotected SafeArrayList<BatchNode.Batch>
the list of geometry holding the batched meshesprotected Map<Geometry,
BatchNode.Batch> a map for storing the batches by geometry to quickly access the batch when updatingFields 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
batch()
Batch this batchNode every geometry of the sub scene graph of this node will be batched into a single mesh that will be rendered in one callclone
(boolean cloneMaterials) 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.detachChildAt
(int index) detachChildAt
removes a child at a given index.protected void
doBatch()
Returns the material that is used for the first batch of this BatchNode.protected Matrix4f
final boolean
void
Called bygeom
to specify that it has been unassociated from itsGeometryGroupNode
.void
onMaterialChange
(Geometry geom) void
onMeshChange
(Geometry geom) void
onTransformChange
(Geometry geom) Called bygeom
to specify that its world transform has been changed.void
setMaterial
(Material material) Sets the material to the all the batches of this BatchNode.protected void
setNeedsFullRebatch
(boolean needsFullRebatch) protected void
Methods inherited from class com.jme3.scene.GeometryGroupNode
getGeometryStartIndex, setGeometryStartIndex
Methods inherited from class com.jme3.scene.Node
attachChild, attachChildAt, breadthFirstTraversal, deepClone, depthFirstTraversal, descendantMatches, descendantMatches, descendantMatches, detachAllChildren, detachChild, detachChildNamed, getChild, getChild, getChildIndex, getChildren, getQuantity, getTriangleCount, getVertexCount, hasChild, oldDeepClone, read, setLightListRefresh, setLodLevel, setMatParamOverrideRefresh, setModelBound, setParent, setTransformRefresh, swapChildren, updateGeometricState, updateLogicalState, updateModelBound, updateWorldBound, write
Methods inherited from class com.jme3.scene.Spatial
addControl, addControlAt, addLight, addMatParamOverride, breadthFirstTraversal, center, checkCulling, clearMatParamOverrides, clone, 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, removeFromParent, removeLight, removeMatParamOverride, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setName, setQueueBucket, setRequiresUpdates, setShadowMode, setUserData, toString, updateMatParamOverrides, updateWorldLightList, updateWorldTransforms, worldToLocal
-
Field Details
-
batches
the list of geometry holding the batched meshes -
batchesByGeom
a map for storing the batches by geometry to quickly access the batch when updating
-
-
Constructor Details
-
BatchNode
public BatchNode()Construct a batchNode -
BatchNode
-
-
Method Details
-
onTransformChange
Description copied from class:GeometryGroupNode
Called bygeom
to specify that its world transform has been changed.- Specified by:
onTransformChange
in classGeometryGroupNode
- Parameters:
geom
- The Geometry whose transform changed.
-
onMaterialChange
Description copied from class:GeometryGroupNode
- Specified by:
onMaterialChange
in classGeometryGroupNode
- Parameters:
geom
- The Geometry whose material changed.
-
onMeshChange
Description copied from class:GeometryGroupNode
Called bygeom
to specify that itsmesh
has been changed. This is also called when the geometry'slod level
changes.- Specified by:
onMeshChange
in classGeometryGroupNode
- Parameters:
geom
- The Geometry whose mesh changed.
-
onGeometryUnassociated
Description copied from class:GeometryGroupNode
Called bygeom
to specify that it has been unassociated from itsGeometryGroupNode
. Unassociation occurs when theGeometry
isdetached
from its parentNode
.- Specified by:
onGeometryUnassociated
in classGeometryGroupNode
- Parameters:
geom
- The Geometry which is being unassociated.
-
getTransformMatrix
-
updateSubBatch
-
batch
public void batch()Batch this batchNode every geometry of the sub scene graph of this node will be batched into a single mesh that will be rendered in one call -
doBatch
protected void doBatch() -
detachChildAt
Description copied from class:Node
detachChildAt
removes a child at a given index. That child is returned for saving purposes.- Overrides:
detachChildAt
in classNode
- Parameters:
index
- the index of the child to be removed.- Returns:
- the child at the supplied index.
-
isBatch
-
setMaterial
Sets the material to the all the batches of this BatchNode. Use setMaterial(Material material,int batchIndex) to set a material to a specific batch.- Overrides:
setMaterial
in classNode
- Parameters:
material
- the material to use for this geometry
-
getMaterial
Returns the material that is used for the first batch of this BatchNode.Use getMaterial(Material material,int batchIndex) to get a material from a specific batch.
- Returns:
- the material that is used for the first batch of this BatchNode
- See Also:
-
setNeedsFullRebatch
protected void setNeedsFullRebatch(boolean needsFullRebatch) -
clone
- Overrides:
clone
in classNode
- Parameters:
cloneMaterials
- true to clone materials, false to share them- Returns:
- A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated.
- See Also:
-
cloneFields
Called internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
cloneFields
in interfaceJmeCloneable
- Overrides:
cloneFields
in classNode
- 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.
-
collideWith
Description copied from interface:Collidable
Check collision with another Collidable.- Specified by:
collideWith
in interfaceCollidable
- Overrides:
collideWith
in classNode
- Parameters:
other
- The object to check collision againstresults
- Will contain the list ofCollisionResult
s.- Returns:
- how many collisions were found between this and other
-