Package com.jme3.scene
Class Node
java.lang.Object
com.jme3.scene.Spatial
com.jme3.scene.Node
- All Implemented Interfaces:
- HasLocalTransform,- CloneableSmartAsset,- Collidable,- Savable,- JmeCloneable,- Cloneable
- Direct Known Subclasses:
- ArmatureDebugger,- ArmatureNode,- AssetLinkNode,- AudioNode,- BitmapText,- CameraNode,- GeometryGroupNode,- LightNode,- SkeletonDebugger,- StatsView,- TerrainQuad
Node defines an internal node of a scene graph. The internal
 node maintains a collection of children and handles merging said children
 into a single bound to allow for very fast culling of multiple nodes. Node
 allows for any number of children to be attached.- 
Nested Class SummaryNested classes/interfaces inherited from class com.jme3.scene.SpatialSpatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
- 
Field SummaryFieldsFields 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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintattachChild(Spatial child) attachChildattaches a child to this node.intattachChildAt(Spatial child, int index) attachChildAtattaches a child to this node at an index.protected voidbreadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) clone(boolean cloneMaterials) voidcloneFields(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.intcollideWith(Collidable other, CollisionResults results) Check collision with another Collidable.voiddepthFirstTraversal(SceneGraphVisitor visitor, Spatial.DFSMode mode) Visit each scene graph element ordered by DFS.descendantMatches(Class<T> spatialSubclass) Convenience wrapper.descendantMatches(Class<T> spatialSubclass, String nameRegex) Returns flat list of Spatials implementing the specified class AND with name matching the specified pattern.descendantMatches(String nameRegex) Convenience wrapper.voiddetachAllChildrenremoves all children attached to this node.intdetachChild(Spatial child) detachChildremoves a given child from the node's list.detachChildAt(int index) detachChildAtremoves a child at a given index.intdetachChildNamed(String childName) detachChildremoves a given child from the node's list.getChild(int i) getChildreturns a child at a given index.getChildreturns the first child found with exactly the given name (case-sensitive).intgetChildIndex(Spatial sp) getChildIndexreturns the index of the given spatial in this node's list of children.Returns all children to this node.intgetQuantityreturns the number of children this node maintains.intgetTriangleCountreturns the number of triangles contained in all sub-branches of this node that contain geometry.intgetVertexCountreturns the number of vertices contained in all sub-branches of this node that contain geometry.booleandetermines if the provided Spatial is contained in the children list of this node.voidread(JmeImporter importer) protected voidvoidsetLodLevel(int lod) Sets the level of detail to use when rendering this Spatial, this call propagates to all geometries under this Spatial.voidsetMaterial(Material mat) Applies the given material to the Spatial, this will propagate the material down to the geometries in the scene graph.protected voidvoidsetModelBound(BoundingVolume modelBound) setModelBoundsets the bounding object for this Spatial.protected voidCalled byattachChild(Spatial)anddetachChild(Spatial)- don't call directly.protected voidIndicate that the transform of this spatial has changed and that a refresh is required.voidswapChildren(int index1, int index2) More efficient than e.g.voidupdateGeometricStateupdates the light list, computes the world transforms, and computes the world bounds for this Spatial.voidupdateLogicalState(float tpf) updateLogicalStatecalls theupdate()method for all controls attached to this Spatial.voidupdateModelBoundrecalculates the bounding object for this Spatial.protected voidShould be overridden by Node and Geometry.voidwrite(JmeExporter e) Methods inherited from class com.jme3.scene.SpatialaddControl, 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- 
childrenThis node's children.
 
- 
- 
Constructor Details- 
Nodepublic Node()Instantiate aNodewith no name, no parent, and no children.
- 
NodeConstructor instantiates a newNodewith a default empty list for containing children.- Parameters:
- name- the name of the scene element
 
 
- 
- 
Method Details- 
getQuantitypublic int getQuantity()getQuantityreturns the number of children this node maintains.- Returns:
- the number of children this node maintains.
 
- 
setTransformRefreshprotected void setTransformRefresh()Description copied from class:SpatialIndicate that the transform of this spatial has changed and that a refresh is required.- Overrides:
- setTransformRefreshin class- Spatial
 
- 
setLightListRefreshprotected void setLightListRefresh()- Overrides:
- setLightListRefreshin class- Spatial
 
- 
setMatParamOverrideRefreshprotected void setMatParamOverrideRefresh()- Overrides:
- setMatParamOverrideRefreshin class- Spatial
 
- 
updateWorldBoundprotected void updateWorldBound()Description copied from class:SpatialShould be overridden by Node and Geometry.- Overrides:
- updateWorldBoundin class- Spatial
 
- 
setParentDescription copied from class:SpatialCalled byattachChild(Spatial)anddetachChild(Spatial)- don't call directly.setParentsets the parent of this node.
- 
updateLogicalStatepublic void updateLogicalState(float tpf) Description copied from class:SpatialupdateLogicalStatecalls theupdate()method for all controls attached to this Spatial.- Overrides:
- updateLogicalStatein class- Spatial
- Parameters:
- tpf- Time per frame.
- See Also:
 
- 
updateGeometricStatepublic void updateGeometricState()Description copied from class:SpatialupdateGeometricStateupdates the light list, computes the world transforms, and computes the world bounds for this Spatial. Calling this when the Spatial is attached to a node will cause undefined results. User code should only call this method on Spatials having no parent.- Overrides:
- updateGeometricStatein class- Spatial
- See Also:
 
- 
getTriangleCountpublic int getTriangleCount()getTriangleCountreturns the number of triangles contained in all sub-branches of this node that contain geometry.- Specified by:
- getTriangleCountin class- Spatial
- Returns:
- the triangle count of this branch.
 
- 
getVertexCountpublic int getVertexCount()getVertexCountreturns the number of vertices contained in all sub-branches of this node that contain geometry.- Specified by:
- getVertexCountin class- Spatial
- Returns:
- the vertex count of this branch.
 
- 
attachChildattachChildattaches a child to this node. This node becomes the child's parent. The current number of children maintained is returned.
 If the child already had a parent it is detached from that former parent.- Parameters:
- child- the child to attach to this node.
- Returns:
- the number of children maintained by this node.
- Throws:
- IllegalArgumentException- if child is null.
 
- 
attachChildAtattachChildAtattaches a child to this node at an index. This node becomes the child's parent. The current number of children maintained is returned.
 If the child already had a parent it is detached from that former parent.- Parameters:
- child- the child to attach to this node.
- index- the position where the child should be attached
- Returns:
- the number of children maintained by this node.
- Throws:
- IllegalArgumentException- if child is null or this
 
- 
detachChilddetachChildremoves a given child from the node's list. This child will no longer be maintained.- Parameters:
- child- the child to remove (not null)
- Returns:
- the index the child was at. -1 if the child was not in the list.
 
- 
detachChildNameddetachChildremoves a given child from the node's list. This child will no longer be maintained. Only the first child with a matching name is removed.- Parameters:
- childName- the child to remove (not null)
- Returns:
- the index the child was at. -1 if the child was not in the list.
 
- 
detachChildAtdetachChildAtremoves a child at a given index. That child is returned for saving purposes.- Parameters:
- index- the index of the child to be removed.
- Returns:
- the child at the supplied index.
 
- 
detachAllChildrenpublic void detachAllChildren()detachAllChildrenremoves all children attached to this node.
- 
getChildIndexgetChildIndexreturns the index of the given spatial in this node's list of children.- Parameters:
- sp- The spatial to look up
- Returns:
- The index of the spatial in the node's children, or -1 if the spatial is not attached to this node
 
- 
swapChildrenpublic void swapChildren(int index1, int index2) More efficient than e.g. detaching and attaching, as no updates are needed.- Parameters:
- index1- The index of the first child to swap
- index2- The index of the second child to swap
 
- 
getChildgetChildreturns a child at a given index.- Parameters:
- i- the index to retrieve the child from.
- Returns:
- the child at a specified index.
 
- 
getChildgetChildreturns the first child found with exactly the given name (case-sensitive). This method does a depth-first recursive search of all descendants of this node, it will return the first spatial found with a matching name.- Parameters:
- name- the name of the child to retrieve. If null, we'll return null.
- Returns:
- the child if found, or null.
 
- 
hasChilddetermines if the provided Spatial is contained in the children list of this node.- Parameters:
- spat- the child object to look for.
- Returns:
- true if the object is contained, false otherwise.
 
- 
getChildrenReturns all children to this node. Note that modifying that given list is not allowed.- Returns:
- a list containing all children to this node
 
- 
setMaterialDescription copied from class:SpatialApplies the given material to the Spatial, this will propagate the material down to the geometries in the scene graph.- Overrides:
- setMaterialin class- Spatial
- Parameters:
- mat- The material to set.
 
- 
setLodLevelpublic void setLodLevel(int lod) Description copied from class:SpatialSets the level of detail to use when rendering this Spatial, this call propagates to all geometries under this Spatial.- Overrides:
- setLodLevelin class- Spatial
- Parameters:
- lod- The lod level to set.
 
- 
collideWithDescription copied from interface:CollidableCheck collision with another Collidable.- 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
 
- 
descendantMatchesReturns flat list of Spatials implementing the specified class AND with name matching the specified pattern.Note that we are matching the pattern, therefore the pattern must match the entire pattern (i.e. it behaves as if it is sandwiched between "^" and "$"). You can set regex modes, like case insensitivity, by using the (?X) or (?X:Y) constructs. By design, it is always safe to code loops like: for (Spatial spatial : node.descendantMatches(AClass.class, "regex"))"Descendants" does not include self, per the definition of the word. To test for descendants AND self, you must do a node.matches(aClass, aRegex)+node.descendantMatches(aClass, aRegex).- Type Parameters:
- T- the type of Spatial returned
- Parameters:
- spatialSubclass- Subclass which matching Spatials must implement. Null causes all Spatials to qualify.
- nameRegex- Regular expression to match Spatial name against. Null causes all Names to qualify.
- Returns:
- Non-null, but possibly 0-element, list of matching Spatials (also Instances extending Spatials).
- See Also:
 
- 
descendantMatchesConvenience wrapper.- Type Parameters:
- T- the type of Spatial returned
- Parameters:
- spatialSubclass- the type of Spatial returned, or null for all spatials
- Returns:
- a new list of pre-existing spatials (may be empty)
- See Also:
 
- 
descendantMatchesConvenience wrapper.- Type Parameters:
- T- the type of Spatial returned
- Parameters:
- nameRegex- regular expression to match Spatial names against, or null for all spatials
- Returns:
- a new list of pre-existing spatials (may be empty)
- See Also:
 
- 
clone- Overrides:
- clonein class- Spatial
- 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:
 
- 
deepClone
- 
oldDeepClone
- 
cloneFieldsCalled internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
- cloneFieldsin interface- JmeCloneable
- Overrides:
- cloneFieldsin class- Spatial
- 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- Spatial
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- Spatial
- Throws:
- IOException
 
- 
setModelBoundDescription copied from class:SpatialsetModelBoundsets the bounding object for this Spatial.- Specified by:
- setModelBoundin class- Spatial
- Parameters:
- modelBound- the bounding object for this spatial.
 
- 
updateModelBoundpublic void updateModelBound()Description copied from class:SpatialupdateModelBoundrecalculates the bounding object for this Spatial.- Specified by:
- updateModelBoundin class- Spatial
 
- 
depthFirstTraversalDescription copied from class:SpatialVisit each scene graph element ordered by DFS. There are two modes: pre order and post order.- Specified by:
- depthFirstTraversalin class- Spatial
- Parameters:
- visitor- the action to take for each visited Spatial
- mode- the traversal mode: pre order or post order
 
- 
breadthFirstTraversal- Specified by:
- breadthFirstTraversalin class- Spatial
 
 
-