## Documentation

- Overview
- Website
- Tutorials
- Class Index

## Classes

- _global_
- CL3D
- CL3D.AnimatedMeshSceneNode
- CL3D.Animator
- CL3D.AnimatorAnimateTexture
- CL3D.AnimatorCameraFPS
- CL3D.AnimatorCameraModelViewer
- CL3D.AnimatorCollisionResponse
- CL3D.AnimatorFlyCircle
- CL3D.AnimatorFlyStraight
- CL3D.AnimatorFollowPath
- CL3D.AnimatorOnClick
- CL3D.AnimatorOnProximity
- CL3D.AnimatorRotation
- CL3D.BillboardSceneNode
- CL3D.BoundingBoxTriangleSelector
- CL3D.Box3d
- CL3D.CameraSceneNode
- CL3D.ColorF
- CL3D.CopperCubeVariable
- CL3D.CopperLicht
- CL3D.CubeSceneNode
- CL3D.HotspotSceneNode
- CL3D.Light
- CL3D.LightSceneNode
- CL3D.Line3d
- CL3D.Material
- CL3D.Matrix4
- CL3D.Mesh
- CL3D.MeshBuffer
- CL3D.MeshSceneNode
- CL3D.MeshTriangleSelector
- CL3D.MetaTriangleSelector
- CL3D.Mobile2DInputSceneNode
- CL3D.OctTreeTriangleSelector
- CL3D.Overlay2DSceneNode
- CL3D.ParticleSystemSceneNode
- CL3D.PathSceneNode
- CL3D.Plane3d
- CL3D.Quaternion
- CL3D.Renderer
- CL3D.Scene
- CL3D.SceneNode
- CL3D.SkyBoxSceneNode
- CL3D.SoundSceneNode
- CL3D.TerrainSceneNode
- CL3D.Texture
- CL3D.TextureManager
- CL3D.Triangle3d
- CL3D.TriangleSelector
- CL3D.Vect2d
- CL3D.Vect3d
- CL3D.Vertex3D
- CL3D.WaterSurfaceSceneNode

CopperLicht API Documentation

# Class CL3D.SceneNode

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

Class Overview
CL3D.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: CL3D.CameraSceneNode, CL3D.BillboardSceneNode, CL3D.PathSceneNode, CL3D.MeshSceneNode, CL3D.SkyBoxSceneNode.

Field Summary
Field Attributes | Field Name and Description
--- | ---
| Id Defines the id of the scene node, completely freely usable by the user.
| Name 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 Scale of the scene node, relative to its parent, in degrees.
| Selector An optional TriangleSelector, giving access to the collision geometry of this scene node.
| Visible Defines whether the node should be visible (if all of its parents are visible).

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addAnimator(a) Adds a scene node animator to the list of animators manipulating this scene node.
| addChild(n) Adds a child to this scene node.
| createClone(newparent, oldNodeId, newNodeId) Creates a clone of this scene node and its children.
| getAbsolutePosition() Gets the absolute position of the node in world coordinates.
| getAbsoluteTransformation() Returns the absolute transformation matrix of the node, also known as world matrix.
| getAnimatorOfType(type) Returns the first Animator attached to this scene node with the specified type.
| getAnimators() Returns an array of Animators which are animating this scene node.
| getBoundingBox() Get the axis aligned, not transformed bounding box of this node.
| getChildren() Returns an array with all child scene nodes of this node
| getMaterial(i) Returns the material based on the zero based index i.
| getMaterialCount() Get amount of materials used by this scene node.
| getParent() Returns the parent scene node of this scene node.
| getRelativeTransformation() Returns the relative transformation of the scene node.
| getTransformedBoundingBox() Returns the bounding box of this scene node, transformed with the absolute transformation of this scene node.
| getType() Returns the type string of the scene node.
| init() Initializes the scene node, can be called by scene nodes derived from this class.
| isActuallyVisible() Returns if the scene node and all its parents are actually visible.
| OnAnimate(scene, current) OnAnimate() is called just before rendering the whole scene.
| OnRegisterSceneNode(scene) This method is called just before the rendering process of the whole scene.
| removeAnimator(a) Removes an animator from this scene node.
| removeChild(n) Removes a child from this scene node.
| render(renderer) Renders the node.
| updateAbsolutePosition() 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:
{CL3D.Animator} a
  the new CL3D.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:
{CL3D.SceneNode} n
  the child scene node to add.

{CL3D.SceneNode} createClone(newparent, oldNodeId, newNodeId)
Creates a clone of this scene node and its children.

Parameters:
{CL3D.SceneNode} newparent
  The new parent of the cloned scene node.
oldNodeId
newNodeId

Returns:
  {CL3D.SceneNode} the cloned version of this scene node

{CL3D.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:
  {CL3D.Vect3d} the absolute position

{CL3D.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:
  {CL3D.Matrix4} the absolute matrix

{CL3D.Animator} getAnimatorOfType(type)
Returns the first 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:
  {CL3D.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.

{CL3D.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:
  {CL3D.Box3d} Bounding box of this scene node.

{Array} getChildren()
Returns an array with all child scene nodes of this node

Returns:
  {Array}

{CL3D.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:
  {CL3D.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.

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

Returns:
  {CL3D.SceneNode}

{CL3D.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:
  {CL3D.Matrix4} the relative transformation

{CL3D.Box3d} getTransformedBoundingBox()
Returns the bounding box of this scene node, transformed with the absolute transformation of this scene node.

Returns:
  {CL3D.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.

{boolean} isActuallyVisible()
Returns if the scene node and all its parents are actually visible. For a quicker way, simply check the Visible property of this class. This method Checks the flags for this node and all its parents and maybe a bit slower.

Returns:
  {boolean} if the scene node and all its parents are visible

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:
{CL3D.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, CL3D.Scene.RENDER_MODE_DEFAULT);

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

Parameters:
{CL3D.Scene} scene
  the current scene

removeAnimator(a)
Removes an animator from this scene node.

Parameters:
{CL3D.Animator} a
  the new CL3D.Animator to remove.

removeChild(n)
Removes a child from this scene node.

Parameters:
{CL3D.SceneNode} n
  the child scene node to remove.

render(renderer)
Renders the node. Override to implement rendering your own scene node.

Parameters:
{CL3D.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.

© 2011-2018 N.Gebhardt, Ambiera
Documentation generated by JsDoc Toolkit