public class BatchNode extends GeometryGroupNode
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)
Modifier and Type | Class and Description |
---|---|
protected class |
BatchNode.Batch |
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
Modifier and Type | Field and Description |
---|---|
protected SafeArrayList<BatchNode.Batch> |
batches
the list of geometry holding the batched meshes
|
protected java.util.Map<Geometry,BatchNode.Batch> |
batchesByGeom
a map for storing the batches by geometry to quickly access the batch when updating
|
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 |
---|
BatchNode()
Construct a batchNode
|
BatchNode(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
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
|
Node |
clone(boolean cloneMaterials) |
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.
|
Spatial |
detachChildAt(int index)
detachChildAt removes a child at a given index. |
protected void |
doBatch() |
Material |
getMaterial()
Returns the material that is used for the first batch of this BatchNode.
|
protected Matrix4f |
getTransformMatrix(Geometry g) |
boolean |
isBatch(Spatial s) |
void |
onGeometryUnassociated(Geometry geom)
Called by
geom to specify that it
has been unassociated from its GeometryGroupNode . |
void |
onMaterialChange(Geometry geom)
|
void |
onMeshChange(Geometry geom)
|
void |
onTransformChange(Geometry geom)
Called by
geom 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 |
updateSubBatch(Geometry bg) |
getGeometryStartIndex, setGeometryStartIndex
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
addControl, 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
protected SafeArrayList<BatchNode.Batch> batches
protected java.util.Map<Geometry,BatchNode.Batch> batchesByGeom
public BatchNode()
public BatchNode(java.lang.String name)
public void onTransformChange(Geometry geom)
GeometryGroupNode
geom
to specify that its world transform
has been changed.onTransformChange
in class GeometryGroupNode
geom
- The Geometry whose transform changed.public void onMaterialChange(Geometry geom)
GeometryGroupNode
onMaterialChange
in class GeometryGroupNode
geom
- The Geometry whose material changed.public void onMeshChange(Geometry geom)
GeometryGroupNode
geom
to specify that its
mesh
has been changed.
This is also called when the geometry's
lod level
changes.onMeshChange
in class GeometryGroupNode
geom
- The Geometry whose mesh changed.public void onGeometryUnassociated(Geometry geom)
GeometryGroupNode
geom
to specify that it
has been unassociated from its GeometryGroupNode
.
Unassociation occurs when the Geometry
is
detached
from its parent
Node
.onGeometryUnassociated
in class GeometryGroupNode
geom
- The Geometry which is being unassociated.protected void updateSubBatch(Geometry bg)
public void batch()
protected void doBatch()
public Spatial detachChildAt(int index)
Node
detachChildAt
removes a child at a given index. That child
is returned for saving purposes.detachChildAt
in class Node
index
- the index of the child to be removed.public final boolean isBatch(Spatial s)
public void setMaterial(Material material)
setMaterial
in class Node
material
- the material to use for this geometrypublic Material getMaterial()
Use getMaterial(Material material,int batchIndex) to get a material from a specific batch.
setMaterial(com.jme3.material.Material)
protected void setNeedsFullRebatch(boolean needsFullRebatch)
public Node clone(boolean cloneMaterials)
clone
in class Node
cloneMaterials
- true to clone materials, false to share themMesh.cloneForAnim()
public void cloneFields(Cloner cloner, java.lang.Object original)
cloneFields
in interface JmeCloneable
cloneFields
in class Node
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 int collideWith(Collidable other, CollisionResults results)
Collidable
collideWith
in interface Collidable
collideWith
in class Node
other
- The object to check collision againstresults
- Will contain the list of CollisionResult
s.