|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jme.scene.Spatial
com.jme.scene.Node
public class Node
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 Summary |
|---|
| Nested classes/interfaces inherited from class com.jme.scene.Spatial |
|---|
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode |
| Field Summary | |
|---|---|
protected java.util.List<Spatial> |
children
This node's children. |
| Fields inherited from class com.jme.scene.Spatial |
|---|
collisionBits, cullHint, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder |
| Constructor Summary | |
|---|---|
Node()
Default constructor. |
|
Node(java.lang.String name)
Constructor instantiates a new Node with a default empty
list for containing children. |
|
| Method Summary | |
|---|---|
protected void |
applyRenderState(java.util.Stack<? extends RenderState>[] states)
Applies the stack of render states to each child by calling updateRenderState(states) on each child. |
int |
attachChild(Spatial child)
attachChild attaches a child to this node. |
int |
attachChildAt(Spatial child,
int index)
attachChildAt attaches a child to this node at an index. |
void |
childChange(Geometry geometry,
int index1,
int index2)
|
java.util.List<Spatial> |
descendantMatches(java.lang.Class<? extends Spatial> spatialSubclass)
Convenience wrapper. |
java.util.List<Spatial> |
descendantMatches(java.lang.Class<? extends Spatial> spatialSubclass,
java.lang.String nameRegex)
Returns flat list of Spatials implementing the specified class AND with name matching the specified pattern. |
java.util.List<Spatial> |
descendantMatches(java.lang.String nameRegex)
Convenience wrapper. |
void |
detachAllChildren()
detachAllChildren removes all children attached to this
node. |
int |
detachChild(Spatial child)
detachChild removes a given child from the node's list. |
Spatial |
detachChildAt(int index)
detachChildAt removes a child at a given index. |
int |
detachChildNamed(java.lang.String childName)
detachChild removes a given child from the node's list. |
void |
draw(Renderer r)
draw calls the onDraw method for each child maintained by
this node. |
void |
findCollisions(Spatial scene,
CollisionResults results,
int requiredOnBits)
checks this spatial against a second spatial, any collisions are stored in the results object. |
void |
findPick(Ray toTest,
PickResults results,
int requiredOnBits)
Tests a ray against this spatial, and stores the results in the result object. |
Spatial |
getChild(int i)
getChild returns a child at a given index. |
Spatial |
getChild(java.lang.String name)
getChild returns the first child found with exactly the
given name (case sensitive.) |
int |
getChildIndex(Spatial sp)
|
java.util.List<Spatial> |
getChildren()
Returns all children to this node. |
int |
getQuantity()
getQuantity returns the number of children this node
maintains. |
int |
getTriangleCount()
getTriangleCount returns the number of triangles contained
in all sub-branches of this node that contain geometry. |
int |
getVertexCount()
getVertexCount returns the number of vertices contained
in all sub-branches of this node that contain geometry. |
boolean |
hasChild(Spatial spat)
determines if the provided Spatial is contained in the children list of this node. |
boolean |
hasCollision(Spatial scene,
boolean checkTriangles,
int requiredOnBits)
Checks this spatial against a second spatial for collisions. |
void |
lockBounds()
Calling this method tells the scenegraph that it is not necessary to update bounds from this point in the scenegraph on down to the leaves. |
void |
lockMeshes(Renderer r)
Flags this spatial and those below it that any meshes in the specified scenegraph location or lower will not have changes in vertex, texcoord, normal or color data. |
void |
lockShadows()
Calling this method tells the scenegraph that it is not necessary to update Shadow volumes that may be associated with this Spatial. |
void |
lockTransforms()
Flags this spatial and those below it in the scenegraph to not recalculate world transforms such as translation, rotation and scale on every update. |
void |
read(JMEImporter e)
|
void |
setModelBound(BoundingVolume modelBound)
setModelBound sets the bounding object for this Spatial. |
void |
sortLights()
|
void |
swapChildren(int index1,
int index2)
|
void |
unlockBounds()
Flags this spatial and those below it to allow for bounds updating (the default). |
void |
unlockMeshes(Renderer r)
Flags this spatial and those below it to allow for mesh updating (the default). |
void |
unlockShadows()
Flags this spatial and those below it to allow for shadow volume updates (the default). |
void |
unlockTransforms()
Flags this spatial and those below it to allow for transform updating (the default). |
void |
updateModelBound()
updateBound recalculates the bounding object for this
Spatial. |
void |
updateWorldBound()
updateWorldBound merges the bounds of all the children
maintained by this node. |
void |
updateWorldData(float time)
updateWorldData updates all the children maintained by
this node. |
void |
updateWorldVectors(boolean recurse)
If not locked, updates worldscale, worldrotation and worldtranslation |
void |
write(JMEExporter e)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.jme.util.export.Savable |
|---|
getClassTag |
| Field Detail |
|---|
protected java.util.List<Spatial> children
| Constructor Detail |
|---|
public Node()
public Node(java.lang.String name)
Node with a default empty
list for containing children.
name - the name of the scene element. This is required for
identification and comparision purposes.| Method Detail |
|---|
public int getQuantity()
getQuantity returns the number of children this node
maintains.
public int getTriangleCount()
getTriangleCount returns the number of triangles contained
in all sub-branches of this node that contain geometry.
getTriangleCount in class Spatialpublic int getVertexCount()
getVertexCount returns the number of vertices contained
in all sub-branches of this node that contain geometry.
getVertexCount in class Spatialpublic int attachChild(Spatial child)
attachChild attaches a child to this node. This node
becomes the child's parent. The current number of children maintained is
returned.
child - the child to attach to this node.
public int attachChildAt(Spatial child,
int index)
attachChildAt attaches a child to this node at an index. This node
becomes the child's parent. The current number of children maintained is
returned.
child - the child to attach to this node.
public int detachChild(Spatial child)
detachChild removes a given child from the node's list.
This child will no longer be maintained.
child - the child to remove.
public int detachChildNamed(java.lang.String childName)
detachChild removes 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.
childName - the child to remove.
public Spatial detachChildAt(int index)
detachChildAt removes a child at a given index. That child
is returned for saving purposes.
index - the index of the child to be removed.
public void detachAllChildren()
detachAllChildren removes all children attached to this
node.
public int getChildIndex(Spatial sp)
public void swapChildren(int index1,
int index2)
public Spatial getChild(int i)
getChild returns a child at a given index.
i - the index to retrieve the child from.
public Spatial getChild(java.lang.String name)
getChild returns the first child found with exactly the
given name (case sensitive.)
name - the name of the child to retrieve. If null, we'll return null.
public boolean hasChild(Spatial spat)
spat - the child object to look for.
public void updateWorldData(float time)
updateWorldData updates all the children maintained by
this node.
updateWorldData in class Spatialtime - the frame time.public void updateWorldVectors(boolean recurse)
Spatial
updateWorldVectors in class Spatialrecurse - usually false when updating the tree. Set to true when you
just want to update the world transforms for a branch without
updating geometric state.public void lockBounds()
Spatial
lockBounds in class SpatialSpatial.unlockBounds()public void lockShadows()
Spatial
lockShadows in class SpatialSpatial.unlockShadows()public void lockTransforms()
Spatial
lockTransforms in class SpatialSpatial.unlockTransforms()public void lockMeshes(Renderer r)
Spatial
lockMeshes in class Spatialr - A renderer to lock against.Spatial.unlockMeshes(Renderer)public void unlockBounds()
Spatial
unlockBounds in class SpatialSpatial.lockBounds()public void unlockShadows()
Spatial
unlockShadows in class SpatialSpatial.lockShadows()public void unlockTransforms()
Spatial
unlockTransforms in class SpatialSpatial.lockTransforms()public void unlockMeshes(Renderer r)
Spatial
unlockMeshes in class Spatialr - The renderer used to lock against.Spatial.lockMeshes(Renderer)public void draw(Renderer r)
draw calls the onDraw method for each child maintained by
this node.
draw in class Spatialr - the renderer to draw to.Spatial.draw(com.jme.renderer.Renderer)protected void applyRenderState(java.util.Stack<? extends RenderState>[] states)
applyRenderState in class Spatialstates - The Stack[] of render states to apply to each child.public void sortLights()
sortLights in class Spatialpublic void updateWorldBound()
updateWorldBound merges the bounds of all the children
maintained by this node. This will allow for faster culling operations.
updateWorldBound in class SpatialSpatial.updateWorldBound()
public void findCollisions(Spatial scene,
CollisionResults results,
int requiredOnBits)
Spatial
findCollisions in class Spatialscene - the scene to test against.results - the results of the collisions.requiredOnBits - considered a collision only if these bits are 'on'
in both 'this' and the 'scene' spatial.
public boolean hasCollision(Spatial scene,
boolean checkTriangles,
int requiredOnBits)
Spatial
hasCollision in class Spatialscene - the scene to test against.checkTriangles - check for collisions on triangle accuracy levelrequiredOnBits - considered a collision only if these bits are 'on'
in both 'this' and the 'scene' spatial.
public void findPick(Ray toTest,
PickResults results,
int requiredOnBits)
Spatial
findPick in class SpatialtoTest - ray to test picking againstresults - the results of the pickingrequiredOnBits - considered a collision only if these bits are 'on'
in 'this' spatial.public java.util.List<Spatial> getChildren()
public void childChange(Geometry geometry,
int index1,
int index2)
public void write(JMEExporter e)
throws java.io.IOException
write in interface Savablewrite in class Spatialjava.io.IOException
public void read(JMEImporter e)
throws java.io.IOException
read in interface Savableread in class Spatialjava.io.IOExceptionpublic void setModelBound(BoundingVolume modelBound)
SpatialsetModelBound sets the bounding object for this Spatial.
setModelBound in class SpatialmodelBound - the bounding object for this spatial.public void updateModelBound()
SpatialupdateBound recalculates the bounding object for this
Spatial.
updateModelBound in class Spatial
public java.util.List<Spatial> descendantMatches(java.lang.Class<? extends Spatial> spatialSubclass,
java.lang.String nameRegex)
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).
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.
Pattern,
Spatial.matches(Class extends Spatial>, String)public java.util.List<Spatial> descendantMatches(java.lang.Class<? extends Spatial> spatialSubclass)
descendantMatches(Class extends Spatial>, String)public java.util.List<Spatial> descendantMatches(java.lang.String nameRegex)
descendantMatches(Class extends Spatial>, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||