|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
gameplay::Node Class Reference

`#include <Node.h>`

Inheritance diagram for gameplay::Node:

List of all members.

## Public Types

enum | Type { NODE = 1, JOINT }

## Public Member Functions

const char * | getTypeName () const
const char * | getId () const
void | setId (const char *id)
virtual Node::Type | getType () const
virtual void | addChild (Node *child)
virtual void | removeChild (Node *child)
virtual void | removeAllChildren ()
Node * | getFirstChild () const
Node * | getNextSibling () const
Node * | getPreviousSibling () const
Node * | getParent () const
unsigned int | getChildCount () const
Node * | getRootNode () const
Node * | findNode (const char *id, bool recursive=true, bool exactMatch=true) const
unsigned int | findNodes (const char *id, std::vector< Node * > &nodes, bool recursive=true, bool exactMatch=true) const
virtual Scene * | getScene () const
void | setTag (const char *name, const char *value="")
const char * | getTag (const char *name) const
bool | hasTag (const char *name) const
void | setEnabled (bool enabled)
bool | isEnabled () const
bool | isEnabledInHierarchy () const
void | update (float elapsedTime)
bool | isStatic () const
virtual const Matrix & | getWorldMatrix () const
const Matrix & | getWorldViewMatrix () const
const Matrix & | getInverseTransposeWorldMatrix () const
const Matrix & | getInverseTransposeWorldViewMatrix () const
const Matrix & | getViewMatrix () const
const Matrix & | getInverseViewMatrix () const
const Matrix & | getProjectionMatrix () const
const Matrix & | getViewProjectionMatrix () const
const Matrix & | getInverseViewProjectionMatrix () const
const Matrix & | getWorldViewProjectionMatrix () const
Vector3 | getTranslationWorld () const
Vector3 | getTranslationView () const
Vector3 | getForwardVectorWorld () const
Vector3 | getForwardVectorView () const
Vector3 | getRightVectorWorld () const
Vector3 | getUpVectorWorld () const
Vector3 | getActiveCameraTranslationWorld () const
Vector3 | getActiveCameraTranslationView () const
Animation * | getAnimation (const char *id=NULL) const
Drawable * | getDrawable () const
void | setDrawable (Drawable *drawable)
Camera * | getCamera () const
void | setCamera (Camera *camera)
Light * | getLight () const
void | setLight (Light *light)
AudioSource * | getAudioSource () const
void | setAudioSource (AudioSource *audio)
PhysicsCollisionObject * | getCollisionObject () const
PhysicsCollisionObject * | setCollisionObject (PhysicsCollisionObject::Type type, const PhysicsCollisionShape::Definition &shape=PhysicsCollisionShape::box(), PhysicsRigidBody::Parameters *rigidBodyParameters=NULL, int group=PHYSICS_COLLISION_GROUP_DEFAULT, int mask=PHYSICS_COLLISION_MASK_DEFAULT)
PhysicsCollisionObject * | setCollisionObject (const char *url)
AIAgent * | getAgent () const
void | setAgent (AIAgent *agent)
Ref * | getUserObject () const
void | setUserObject (Ref *obj)
const BoundingSphere & | getBoundingSphere () const
Node * | clone () const

## Static Public Member Functions

static Node * | create (const char *id=NULL)

## Protected Member Functions

| Node (const char *id)
virtual | ~Node ()
virtual Node * | cloneSingleNode (NodeCloneContext &context) const
Node * | cloneRecursive (NodeCloneContext &context) const
void | cloneInto (Node *node, NodeCloneContext &context) const
void | remove ()
void | transformChanged ()
void | hierarchyChanged ()
void | setBoundsDirty ()

## Protected Attributes

Scene * | _scene
std::string | _id
Node * | _firstChild
Node * | _nextSibling
Node * | _prevSibling
Node * | _parent
unsigned int | _childCount
bool | _enabled
std::map< std::string, std::string > * | _tags
Drawable * | _drawable
Camera * | _camera
Light * | _light
AudioSource * | _audioSource
PhysicsCollisionObject * | _collisionObject
AIAgent * | _agent
Ref * | _userObject
Matrix | _world
BoundingSphere | _bounds
int | _dirtyBits

## Detailed Description

Defines a hierarchical structure of objects in 3D transformation spaces.

This object allow you to attach components to a scene such as: Drawable's(Model, Camera, Light, PhysicsCollisionObject, AudioSource, etc.

See also:
  http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-Node

## Member Enumeration Documentation

enum gameplay::Node::Type

Defines the types of nodes.

## Constructor & Destructor Documentation

gameplay::Node::Node | ( | const char * | id | ) | `[protected]`

Constructor.

virtual gameplay::Node::~Node | ( |  | ) | `[protected, virtual]`

Destructor.

## Member Function Documentation

virtual void gameplay::Node::addChild | ( | Node * | child | ) | `[virtual]`

Adds a child node.

Parameters:

  child | The child to add.

Node* gameplay::Node::clone | ( |  | ) | const

Clones the node and all of its child nodes.

Returns:
  A new node.

void gameplay::Node::cloneInto | ( | Node * | node,
|  | NodeCloneContext & | context
| ) |  | const`[protected]`

Copies the data from this node into the given node.

Parameters:

  node | The node to copy the data to.
  context | The clone context.

Node* gameplay::Node::cloneRecursive | ( | NodeCloneContext & | context | ) | const`[protected]`

Recursively clones this node and its children.

Parameters:

  context | The clone context.

Returns:
  The newly created node.

virtual Node* gameplay::Node::cloneSingleNode | ( | NodeCloneContext & | context | ) | const`[protected, virtual]`

Clones a single node and its data but not its children.

Parameters:

  context | The clone context.

Returns:
  Pointer to the newly created node.

Reimplemented in gameplay::Joint.

static Node* gameplay::Node::create | ( | const char * | id = `NULL` | ) | `[static]`

Creates a new node with the specified ID.

Parameters:

  id | The ID for the new node.

Reimplemented in gameplay::Joint.

Node* gameplay::Node::findNode | ( | const char * | id,
|  | bool | recursive = `true`,
|  | bool | exactMatch = `true`
| ) |  | const

Returns the first child node that matches the given ID.

This method checks the specified ID against its immediate child nodes but does not check the ID against itself. If recursive is true, it also traverses the Node's hierarchy with a breadth first search.

Parameters:

  id | The ID of the child to find.
  recursive | True to search recursively all the node's children, false for only direct children.
  exactMatch | true if only nodes whose ID exactly matches the specified ID are returned, or false if nodes that start with the given ID are returned.

Returns:
  The Node found or NULL if not found.

unsigned int gameplay::Node::findNodes | ( | const char * | id,
|  | std::vector< Node * > & | nodes,
|  | bool | recursive = `true`,
|  | bool | exactMatch = `true`
| ) |  | const

Returns all child nodes that match the given ID.

Parameters:

  id | The ID of the node to find.
  nodes | A vector of nodes to be populated with matches.
  recursive | true if a recursive search should be performed, false otherwise.
  exactMatch | true if only nodes whose ID exactly matches the specified ID are returned, or false if nodes that start with the given ID are returned.

Returns:
  The number of matches found.

Vector3 gameplay::Node::getActiveCameraTranslationView | ( |  | ) | const

Returns the view-space translation vector of the currently active camera for this node's scene.

Returns:
  The translation vector of the scene's active camera, in view-space.

Vector3 gameplay::Node::getActiveCameraTranslationWorld | ( |  | ) | const

Returns the translation vector of the currently active camera for this node's scene.

Returns:
  The translation vector of the scene's active camera.

AIAgent* gameplay::Node::getAgent | ( |  | ) | const

Gets the AI agent assigned to this node

Returns:
  The AI agent for this node.

Animation* gameplay::Node::getAnimation | ( | const char * | id = `NULL` | ) | const

Gets the first animation in the node hierarchy with the specified ID.

Parameters:

  id | The ID of the animation to get. Returns the first animation if ID is NULL.

Returns:
  The first animation with the specified ID.

Reimplemented from gameplay::AnimationTarget.

AudioSource* gameplay::Node::getAudioSource | ( |  | ) | const

Gets the audio source attached to this node.

Returns:
  The audio source attached to this node.

const BoundingSphere& gameplay::Node::getBoundingSphere | ( |  | ) | const

Returns the bounding sphere for the Node, in world space.

The bounding sphere for a node represents the area, in world space, that the node contains. This includes the space occupied by any child nodes as well as the space occupied by any data inside the node (such as models).

Bounding spheres for nodes are rough approximations of the data contained within a node and they are intended for visibility testing or first-pass intersection testing only. They are not appropriate for accurate collision detection since they most often do not tightly contain a node's content.

A node that does not occupy any space will return a bounding sphere with a center point equal to the node translation and a radius of zero.

Returns:
  The world-space bounding sphere for the node.

Camera* gameplay::Node::getCamera | ( |  | ) | const

Gets the camera attached to this node.

Returns:
  Gets the camera attached to this node.

unsigned int gameplay::Node::getChildCount | ( |  | ) | const

Returns the number of direct children of this item.

Returns:
  The number of children.

PhysicsCollisionObject* gameplay::Node::getCollisionObject | ( |  | ) | const

Returns the pointer to this node's physics collision object.

The type of the returned collision object can be queried using the PhysicsCollisionObject::getType() method.

Returns:
  The pointer to this node's physics collision object.

Drawable* gameplay::Node::getDrawable | ( |  | ) | const

Gets the drawable object attached to this node.

Returns:
  The drawable component attached to this node.

Node* gameplay::Node::getFirstChild | ( |  | ) | const

Returns the first child for this node.

Returns:
  The first child.

Vector3 gameplay::Node::getForwardVectorView | ( |  | ) | const

Returns the forward vector of the Node in view space.

Returns:
  The forward vector in view space.

Vector3 gameplay::Node::getForwardVectorWorld | ( |  | ) | const

Returns the forward vector of the Node in world space.

Returns:
  The forward vector in world space.

const char* gameplay::Node::getId | ( |  | ) | const

Gets the identifier for the node.

Returns:
  The node identifier.

const Matrix& gameplay::Node::getInverseTransposeWorldMatrix | ( |  | ) | const

Gets the inverse transpose world matrix corresponding to this node.

This matrix is typically used to transform normal vectors into world space.

Returns:
  The inverse world matrix of this node.

const Matrix& gameplay::Node::getInverseTransposeWorldViewMatrix | ( |  | ) | const

Gets the inverse transpose world view matrix corresponding to this node.

This matrix is typically used to transform normal vectors into view space.

Returns:
  The inverse world view matrix of this node.

const Matrix& gameplay::Node::getInverseViewMatrix | ( |  | ) | const

Gets the inverse view matrix corresponding to this node based on the scene's active camera.

Returns:
  The inverse view matrix of this node.

const Matrix& gameplay::Node::getInverseViewProjectionMatrix | ( |  | ) | const

Gets the inverse view * projection matrix corresponding to this node based on the scene's active camera.

Returns:
  The inverse view * projection matrix of this node.

Light* gameplay::Node::getLight | ( |  | ) | const

Get the light attached to this node.

Returns:
  The light attached to this node.

Node* gameplay::Node::getNextSibling | ( |  | ) | const

Returns the first sibling of this node.

Returns:
  The first sibling.

Node* gameplay::Node::getParent | ( |  | ) | const

Returns the parent of this node.

Returns:
  The parent.

Node* gameplay::Node::getPreviousSibling | ( |  | ) | const

Returns the previous sibling to this node.

Returns:
  The previous sibling.

const Matrix& gameplay::Node::getProjectionMatrix | ( |  | ) | const

Gets the projection matrix corresponding to this node based on the scene's active camera.

Returns:
  The projection matrix of this node.

Vector3 gameplay::Node::getRightVectorWorld | ( |  | ) | const

Returns the right vector of the Node in world space.

Returns:
  The right vector in world space.

Node* gameplay::Node::getRootNode | ( |  | ) | const

Gets the top level node in this node's parent hierarchy.

virtual Scene* gameplay::Node::getScene | ( |  | ) | const`[virtual]`

Gets the scene this node is currenlty within.

Returns:
  The scene.

Reimplemented in gameplay::Joint.

const char* gameplay::Node::getTag | ( | const char * | name | ) | const

Returns the value of the custom tag with the given name.

Parameters:

  name | Name of the tag to return.

Returns:
  The value of the given tag, or NULL if the tag is not set.

Vector3 gameplay::Node::getTranslationView | ( |  | ) | const

Gets the translation vector (or position) of this Node in view space.

Returns:
  The view space translation vector.

Vector3 gameplay::Node::getTranslationWorld | ( |  | ) | const

Gets the translation vector (or position) of this Node in world space.

Returns:
  The world translation vector.

virtual Node::Type gameplay::Node::getType | ( |  | ) | const`[virtual]`

Returns the type of the node.

Reimplemented in gameplay::Joint.

const char* gameplay::Node::getTypeName | ( |  | ) | const`[virtual]`

Extends ScriptTarget::getTypeName() to return the type name of this class.

Returns:
  The type name of this class: "Node"

See also:
  ScriptTarget::getTypeName()

Reimplemented from gameplay::Transform.

Vector3 gameplay::Node::getUpVectorWorld | ( |  | ) | const

Returns the up vector of the Node in world space.

Returns:
  The up vector in world space.

Ref* gameplay::Node::getUserObject | ( |  | ) | const

Gets the user object assigned to this node.

Returns:
  The user object assigned object to this node.

const Matrix& gameplay::Node::getViewMatrix | ( |  | ) | const

Gets the view matrix corresponding to this node based on the scene's active camera.

Returns:
  The view matrix of this node.

const Matrix& gameplay::Node::getViewProjectionMatrix | ( |  | ) | const

Gets the view * projection matrix corresponding to this node based on the scene's active camera.

Returns:
  The view * projection matrix of this node.

virtual const Matrix& gameplay::Node::getWorldMatrix | ( |  | ) | const`[virtual]`

Gets the world matrix corresponding to this node.

Returns:
  The world matrix of this node.

const Matrix& gameplay::Node::getWorldViewMatrix | ( |  | ) | const

Gets the world view matrix corresponding to this node.

Returns:
  The world view matrix of this node.

const Matrix& gameplay::Node::getWorldViewProjectionMatrix | ( |  | ) | const

Gets the world * view * projection matrix corresponding to this node based on the scene's active camera.

Returns:
  The world * view * projection matrix of this node.

bool gameplay::Node::hasTag | ( | const char * | name | ) | const

Determines if a custom tag with the specified name is set.

Parameters:

  name | Name of the tag to query.

Returns:
  true if the tag is set, false otherwise.

void gameplay::Node::hierarchyChanged | ( |  | ) | `[protected]`

Called when this Node's hierarchy changes.

bool gameplay::Node::isEnabled | ( |  | ) | const

Gets if the node is enabled in the scene.

Returns:
  if the node is enabled in the scene.

bool gameplay::Node::isEnabledInHierarchy | ( |  | ) | const

Gets if the node inherently enabled.

Returns:
  if components attached on this node should be running.

bool gameplay::Node::isStatic | ( |  | ) | const`[virtual]`

Returns whether the transformation of this node is static.

Nodes that have static rigid bodies attached to them are considered static.

Returns:
  True if the transformation of this Node is static, false otherwise.

See also:
  Transform::isStatic()

Reimplemented from gameplay::Transform.

void gameplay::Node::remove | ( |  | ) | `[protected]`

Removes this node from its parent.

virtual void gameplay::Node::removeAllChildren | ( |  | ) | `[virtual]`

Removes all child nodes.

virtual void gameplay::Node::removeChild | ( | Node * | child | ) | `[virtual]`

Removes a child node.

Parameters:

  child | The child to remove.

void gameplay::Node::setAgent | ( | AIAgent * | agent | ) |

Sets the AI agent for this node.

Parameters:

  agent | The AI agent to set.

void gameplay::Node::setAudioSource | ( | AudioSource * | audio | ) |

Attaches an audio source to this node.

This will increase the reference count of the new audio source and decrease the reference count of the old audio source.

Parameters:

  audio | The new audio source. May be NULL.

void gameplay::Node::setBoundsDirty | ( |  | ) | `[protected]`

Marks the bounding volume of the node as dirty.

void gameplay::Node::setCamera | ( | Camera * | camera | ) |

Attaches a camera to this node.

This will increase the reference count of the new camera and decrease the reference count of the old camera.

Parameters:

  camera | The new camera. May be NULL.

PhysicsCollisionObject* gameplay::Node::setCollisionObject | ( | PhysicsCollisionObject::Type | type,
|  | const PhysicsCollisionShape::Definition & | shape = `PhysicsCollisionShape::box()`,
|  | PhysicsRigidBody::Parameters * | rigidBodyParameters = `NULL`,
|  | int | group = `PHYSICS_COLLISION_GROUP_DEFAULT`,
|  | int | mask = `PHYSICS_COLLISION_MASK_DEFAULT`
| ) |  |

Sets (or disables) the physics collision object for this node.

The supported collision object types include rigid bodies, ghost objects, characters, vehicles, and vehicle wheels.

Rigid bodies are used to represent most physical objects in a game. The important feature of rigid bodies is that they can be simulated by the physics system as other rigid bodies or collision objects collide with them. To support this physics simulation, rigid bodies require additional parameters, such as mass, friction and restitution to define their physical features. These parameters can be passed into the 'rigidBodyParameters' parameter.

Vehicles consist of a rigid body with wheels. The rigid body parameters can be passed-in via the 'rigidBodyParameters' parameter, and wheels can be added to the vehicle.

Ghost objects are a simple type of collision object that are not simulated. By default they pass through other objects in the scene without affecting them. Ghost objects do receive collision events however, which makes them useful for representing non-simulated entities in a game that still require collision events, such as volumetric triggers, power-ups, etc.

Characters are an extension of ghost objects which provide a number of additional features for animating and moving characters within a game. Characters are represented as ghost objects instead of rigid bodies to allow more direct control over character movement, since attempting to model a physics character with a simulated rigid body usually results in unresponsive and unpredictable character movement. Unlike normal ghost objects, characters to react to other characters and rigid bodies in the world. Characters react to gravity and collide (and respond) with rigid bodies to allow them to walk on the ground, slide along walls and walk up/down slopes and stairs.

Parameters:

  type | The type of the collision object to set; to disable the physics collision object, pass PhysicsCollisionObject::NONE.
  shape | Definition of a physics collision shape to be used for this collision object. Use the static shape methods on the PhysicsCollisionShape class to specify a shape definition, such as PhysicsCollisionShape::box().
  rigidBodyParameters | If type is PhysicsCollisionObject::RIGID_BODY or PhysicsCollisionObject::VEHICLE, this must point to a valid rigid body parameters object containing information about the rigid body; otherwise, this parameter may be NULL.
  group | Group identifier of the object for collision filtering.
  mask | Bitmask to filter groups of objects to collide with this one.

PhysicsCollisionObject* gameplay::Node::setCollisionObject | ( | const char * | url | ) |

Sets the physics collision object for this node using the data from the Properties object defined at the specified URL, where the URL is of the format "<file-path>.<extension>#<namespace-id>/<namespace-id>/.../<namespace-id>" (and "#<namespace-id>/<namespace-id>/.../<namespace-id>" is optional).

Parameters:

  url | The URL pointing to the Properties object defining the physics collision object.

void gameplay::Node::setDrawable | ( | Drawable * | drawable | ) |

Set the drawable object to be attached to this node

This is typically a Model, ParticleEmiiter, Form, Terrrain, Sprite, TileSet or Text.

This will increase the reference count of the new drawble and decrease the reference count of the old drawable.

Parameters:

  drawable | The new drawable component. May be NULL.

void gameplay::Node::setEnabled | ( | bool | enabled | ) |

Sets if the node is enabled in the scene.

Parameters:

  enabled | if the node is enabled in the scene.

void gameplay::Node::setId | ( | const char * | id | ) |

Sets the identifier for the node.

Parameters:

  id | The identifier to set for the node.

void gameplay::Node::setLight | ( | Light * | light | ) |

Attaches a light to this node.

This will increase the reference count of the new light and decrease the reference count of the old light.

Parameters:

  light | The new light. May be NULL.

void gameplay::Node::setTag | ( | const char * | name,
|  | const char * | value = `""`
| ) |  |

Sets a tag on this Node.

tags can be used for a variety of purposes within a game. For example, a tag called "transparent" can be added to nodes, to indicate which nodes in a scene are transparent. This tag can then be read during rendering to sort transparent and opaque objects for correct drawing order.

Setting a tag to NULL removes the tag from the Node.

Parameters:

  name | Name of the tag to set.
  value | Optional value of the tag (empty string by default).

void gameplay::Node::setUserObject | ( | Ref * | obj | ) |

Sets a user object to be assigned object to this node.

Parameters:

  obj | The user object assigned object to this node.

void gameplay::Node::transformChanged | ( |  | ) | `[protected, virtual]`

Called when this Node's transform changes.

Reimplemented from gameplay::Transform.

Reimplemented in gameplay::Joint.

void gameplay::Node::update | ( | float | elapsedTime | ) |

Called to update the state of this Node.

This method is called by Scene::update(float) to update the state of all active nodes in a scene. A Node is considered active if Node::isActive() returns true.

If any scripts are attached to the node, their update event will be fired.

Parameters:

  elapsedTime | Elapsed time in milliseconds.

## Member Data Documentation

AIAgent* gameplay::Node::_agent `[mutable, protected]`

The AI agent component attached to this node.

AudioSource* gameplay::Node::_audioSource `[protected]`

The audio source component attached to this node.

BoundingSphere gameplay::Node::_bounds `[mutable, protected]`

The bounding sphere for this node.

Camera* gameplay::Node::_camera `[protected]`

The camera component attached to this node.

unsigned int gameplay::Node::_childCount `[protected]`

The number of child nodes.

PhysicsCollisionObject* gameplay::Node::_collisionObject `[protected]`

The collision object component attached to this node.

int gameplay::Node::_dirtyBits `[mutable, protected]`

The dirty bits used for optimization.

Drawable* gameplay::Node::_drawable `[protected]`

The drawble component attached to this node.

bool gameplay::Node::_enabled `[protected]`

If this node is enabled. Maybe different if parent is enabled/disabled.

Node* gameplay::Node::_firstChild `[protected]`

The nodes first child.

std::string gameplay::Node::_id `[protected]`

The nodes id.

Light* gameplay::Node::_light `[protected]`

The light component attached to this node.

Node* gameplay::Node::_nextSibling `[protected]`

The nodes next sibiling.

Node* gameplay::Node::_parent `[protected]`

The nodes parent.

Node* gameplay::Node::_prevSibling `[protected]`

The nodes previous sibiling.

Scene* gameplay::Node::_scene `[protected]`

The scene this node is attached to.

std::map<std::string, std::string>* gameplay::Node::_tags `[protected]`

Tags assigned to this node.

Ref* gameplay::Node::_userObject `[protected]`

The user object component attached to this node.

Matrix gameplay::Node::_world `[mutable, protected]`

The world matrix for this node.

All Classes Functions Variables Typedefs Enumerations Enumerator