Documentation

Classes

Class SceneNode

The base class for scene nodes, a node in the hierarchical 3d scene rendering graph.

Class Overview
SceneNode()
A scene node is a node in the hierarchical scene graph. Every scene node may have children, which are also scene nodes. Children move relative to their parent's position. If the parent of a node is not visible, its children won't be visible either. In this way, it is for example easily possible to attach a light to a moving car, or to place a walking character on a moving platform on a moving ship.

Concrete implementations are for example: CameraSceneNode, BillboardSceneNode, PathSceneNode, MeshSceneNode, SkyBoxSceneNode.

Field Summary
Field Attributes Field Name and Description
 
Id
Defines the id of the scene node, completely freely usable by the user.
 
Defines the name of the scene node, completely freely usable by the user.
 
Pos
Position of the scene node, relative to its parent.
 
Rot
Rotation of the scene node, relative to its parent, in degrees.
 
Scale of the scene node, relative to its parent, in degrees.
 
An optional TriangleSelector, giving access to the collision geometry of this scene node.
 
Defines whether the node should be visible (if all of its parents are visible).
Method Summary
Method Attributes Method Name and Description
 
Adds a scene node animator to the list of animators manipulating this scene node.
 
Adds a child to this scene node.
 
createClone(newparent)
Creates a clone of this scene node and its children.
 
Gets the absolute position of the node in world coordinates.
 
Returns the absolute transformation matrix of the node, also known as world matrix.
 
Returns the first scene node Animator attached to this scene node with the specified type.
 
Returns an array of Animators which are animating this scene node.
 
Get the axis aligned, not transformed bounding box of this node.
 
Returns the material based on the zero based index i.
 
Get amount of materials used by this scene node.
 
Returns the parent scene node of this scene node.
 
Returns the relative transformation of the scene node.
 
Returns the bounding box of this scene node, transformed with the absolute transformation of this scene node.
 
Returns the type string of the scene node.
 
init()
Initializes the scene node, can be called by scene nodes derived from this class.
 
OnAnimate(scene, current)
OnAnimate() is called just before rendering the whole scene.
 
This method is called just before the rendering process of the whole scene.
 
Removes an animator from this scene node.
 
Removes a child from this scene node.
 
render(renderer)
Renders the node.
 
Updates the absolute position based on the relative and the parents position.
Field Detail
{Number} Id
Defines the id of the scene node, completely freely usable by the user.

{String} Name
Defines the name of the scene node, completely freely usable by the user.

{Vect3d} Pos
Position of the scene node, relative to its parent. If you want the position in world coordinates, use getAbsolutePosition(). If you change this value, be sure to call updateAbsolutePosition() afterwards to make the change be reflected immediately.

{Vect3d} Rot
Rotation of the scene node, relative to its parent, in degrees. Note that this is the relative rotation of the node. If you want the absolute rotation, use getAbsoluteTransformation().getRotation() If you change this value, be sure to call updateAbsolutePosition() afterwards to make the change be reflected immediately.

{Vect3d} Scale
Scale of the scene node, relative to its parent, in degrees. Default is (1,1,1) This is the scale of this node relative to its parent. If you want the absolute scale, use getAbsoluteTransformation().getScale() If you change this value, be sure to call updateAbsolutePosition() afterwards to make the change be reflected immediately.

{TriangleSelector} Selector
An optional TriangleSelector, giving access to the collision geometry of this scene node.

{Boolean} Visible
Defines whether the node should be visible (if all of its parents are visible). This is only an option set by the user, but has nothing to do with geometry culling.
Method Detail
addAnimator(a)
Adds a scene node animator to the list of animators manipulating this scene node.
Parameters:
a
{Animator} the new animator to add.

addChild(n)
Adds a child to this scene node. If the scene node already has a parent it is first removed from the other parent.
Parameters:
n
{SceneNode} the child scene node to add.

{SceneNode} createClone(newparent)
Creates a clone of this scene node and its children.
Parameters:
newparent
{SceneNode} The new parent of the cloned scene node.
Returns:
{SceneNode} the cloned version of this scene node

{Vect3d} getAbsolutePosition()
Gets the absolute position of the node in world coordinates. If you want the position of the node relative to its parent, use Pos instead, this is much faster as well. Note: If local changes to the position, scale or rotation have been made to this scene node in this frame, call updateAbsolutePosition() to ensure this position is up to date.
Returns:
{Vect3d} the absolute position

{Matrix4} getAbsoluteTransformation()
Returns the absolute transformation matrix of the node, also known as world matrix. Note: If local changes to the position, scale or rotation have been made to this scene node in this frame, call updateAbsolutePosition() to ensure this transformation is up to date.
Returns:
{Matrix4} the absolute matrix

{Animator} getAnimatorOfType(type)
Returns the first scene node Animator attached to this scene node with the specified type.
Parameters:
type
is a string with the type returned by Animator.getType(). A possible value is for example 'camerafps'. See the concreate animator implementations for type strings.
Returns:
{Animator} The animator if found, or null if not.

{Array} getAnimators()
Returns an array of Animators which are animating this scene node.
Returns:
{Array} Bounding box of this scene node.

{Box3D} getBoundingBox()
Get the axis aligned, not transformed bounding box of this node. This means that if this node is an animated 3d character, moving in a room, the bounding box will always be around the origin. To get the box in real world coordinates, just transform it with the matrix you receive with getAbsoluteTransformation() or simply use getTransformedBoundingBox(), which does the same.
Returns:
{Box3D} Bounding box of this scene node.

{Material} getMaterial(i)
Returns the material based on the zero based index i. To get the amount of materials used by this scene node, use getMaterialCount(). This function is needed for inserting the node into the scene hierarchy at an optimal position for minimizing renderstate changes, but can also be used to directly modify the material of a scene node.
Parameters:
i
Returns:
{Material} the material with the specified index or null.

{Number} getMaterialCount()
Get amount of materials used by this scene node.
Returns:
{Number} the amount of materials.

{SceneNode} getParent()
Returns the parent scene node of this scene node.
Returns:
{SceneNode}

{Matrix4} getRelativeTransformation()
Returns the relative transformation of the scene node. The relative transformation is stored internally as 3 vectors: translation, rotation and scale. To get the relative transformation matrix, it is calculated from these values.
Returns:
{Matrix4} the relative transformation

{Box3d} getTransformedBoundingBox()
Returns the bounding box of this scene node, transformed with the absolute transformation of this scene node.
Returns:
{Box3d} The axis aligned, transformed and animated absolute bounding box of this node.

{String} getType()
Returns the type string of the scene node. For example 'camera' if this is a camera, or 'mesh' if it is a mesh scene node.
Returns:
{String} type name of the scene node.

init()
Initializes the scene node, can be called by scene nodes derived from this class.

OnAnimate(scene, current)
OnAnimate() is called just before rendering the whole scene. Nodes may calculate or store animations here, and may do other useful things, depending on what they are. Also, OnAnimate() should be called for all child scene nodes here. This method will be called once per frame, independent of whether the scene node is visible or not.
Parameters:
{Scene} scene
the current scene
{Number} current
time in milliseconds

OnRegisterSceneNode(scene)
This method is called just before the rendering process of the whole scene. Nodes may register themselves in the rendering pipeline during this call, precalculate the geometry which should be renderered, and prevent their children from being able to register themselves if they are clipped by simply not calling their OnRegisterSceneNode method. If you are implementing your own scene node, you should overwrite this method with an implementation code looking like this:
if (this.Visible)
{
 // register for rendering
 scene.registerNodeForRendering(this, Scene.RENDER_MODE_DEFAULT);

 // call base class to register childs (if needed)
	SceneNode.prototype.OnRegisterSceneNode.call(this, scene); 
}
Parameters:
scene
the current scene

removeAnimator(a)
Removes an animator from this scene node.
Parameters:
a
{Animator} the new animator to remove.

removeChild(n)
Removes a child from this scene node.
Parameters:
n
{SceneNode} the child scene node to remove.

render(renderer)
Renders the node. Override to implement rendering your own scene node.
Parameters:
renderer
{Renderer} the currently used renderer.

updateAbsolutePosition()
Updates the absolute position based on the relative and the parents position. Note: This does not recursively update the parents absolute positions, so if you have a deeper hierarchy you might want to update the parents first.

© 2010 N.Gebhardt, Ambiera
Documentation generated by JsDoc Toolkit