Node

See Javadoc

Definition

The Node is an internal node within the scene graph, this is opposed to Geometry which represents leaf nodes. As such, Nodes maintain links to children. These children are Spatials and, therefore, can be other Nodes or Geometry.

Child Management

The Node class can maintain an arbitrary number of children (dependant on memory, of course), that is managed internally via a list. Each child combines their BoundingVolume to merge into a single bounding that is used for the Node.

Adding and Removing Child Nodes

Adding and removing children are managed through a number of methods. attachChild takes a Spatial as an argument. It will add that Spatial to the Node's children list and set the Spatial's parent reference to the Node. Removal of children can be done in a number of ways. detachAllChildren will remove all children the Node maintains. detachChild will remove a specific Spatial suppied. detachChildAt will remove a child at a given index in the children list. detachChildNamed will remove a child with a given name.

  • Tip: It is important to take care with detachChildNamed, in that you should make sure that all Spatials have a unique name. This method will remove the first found Spatial with the supplied name.

Getting Child Nodes

Obtaining children is done using the two getChild methods. One takes an index, where this represents the index of the desired child in the children list, while the other takes the name of the Spatial to obtain.

  • Tip: Again, the same note, make sure the name of a Spatial is unique for this call to be accurate.

You can also call getChildren to obtain the list of all children. getQuantity will supply the number of children the Node is maintaining. Lastly, a convience method exists for determining if a Node is maintaining a specific Spatial, hasChild will supply a boolean about if the Spatial is in the list or not.

Performance

Since a Node uses an ArrayList to keep track of its children, care should be taken when adding/removing Nodes, or searching for Nodes by name or reference. The current implementation runs in linear time on average for these operations, while accessing children by index runs in constant time.

Drawing

When rendering the Node, the list of children is iterated through calling each child's onDraw method. No other operations are preformed.

Collision and Picking Implementation

During a call for collision and picking checks: hasCollsions, findCollisions, findPick, Node checks to see if its bounding volume intersects with the testing Spatial, if so, it passes the checks down its children.


/var/www/wiki/data/pages/nodes.txt · Last modified: 2009/07/28 18:44 (external edit)  
Recent changes · Show pagesource · Login

Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

subscribe to jME latest jme headlines


site design by bleedcrimson designs © 2008