overview wiki api reference download
 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:
gameplay::Transform gameplay::Ref gameplay::AnimationTarget gameplay::ScriptTarget gameplay::Joint

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 ()
NodegetFirstChild () const
NodegetNextSibling () const
NodegetPreviousSibling () const
NodegetParent () const
unsigned int getChildCount () const
NodegetRootNode () const
NodefindNode (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 ScenegetScene () 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 MatrixgetWorldMatrix () const
const MatrixgetWorldViewMatrix () const
const MatrixgetInverseTransposeWorldMatrix () const
const MatrixgetInverseTransposeWorldViewMatrix () const
const MatrixgetViewMatrix () const
const MatrixgetInverseViewMatrix () const
const MatrixgetProjectionMatrix () const
const MatrixgetViewProjectionMatrix () const
const MatrixgetInverseViewProjectionMatrix () const
const MatrixgetWorldViewProjectionMatrix () 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
AnimationgetAnimation (const char *id=NULL) const
DrawablegetDrawable () const
void setDrawable (Drawable *drawable)
CameragetCamera () const
void setCamera (Camera *camera)
LightgetLight () const
void setLight (Light *light)
AudioSourcegetAudioSource () const
void setAudioSource (AudioSource *audio)
PhysicsCollisionObjectgetCollisionObject () const
PhysicsCollisionObjectsetCollisionObject (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)
PhysicsCollisionObjectsetCollisionObject (const char *url)
AIAgentgetAgent () const
void setAgent (AIAgent *agent)
RefgetUserObject () const
void setUserObject (Ref *obj)
const BoundingSpheregetBoundingSphere () const
Nodeclone () const

Static Public Member Functions

static Nodecreate (const char *id=NULL)

Protected Member Functions

 Node (const char *id)
virtual ~Node ()
virtual NodecloneSingleNode (NodeCloneContext &context) const
NodecloneRecursive (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

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:
childThe child to add.

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:
nodeThe node to copy the data to.
contextThe clone context.
Node* gameplay::Node::cloneRecursive ( NodeCloneContext context) const [protected]

Recursively clones this node and its children.

Parameters:
contextThe 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:
contextThe 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:
idThe 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:
idThe ID of the child to find.
recursiveTrue to search recursively all the node's children, false for only direct children.
exactMatchtrue 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:
idThe ID of the node to find.
nodesA vector of nodes to be populated with matches.
recursivetrue if a recursive search should be performed, false otherwise.
exactMatchtrue 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.

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.

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

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

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:
idThe 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.

Gets the audio source attached to this node.

Returns:
The audio source attached to this node.

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.

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.

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.

Gets the drawable object attached to this node.

Returns:
The drawable component attached to this node.

Returns the first child for this node.

Returns:
The first child.

Returns the forward vector of the Node in view space.

Returns:
The forward vector in view space.

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.

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.

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.

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

Returns:
The inverse view matrix of this node.

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.

Get the light attached to this node.

Returns:
The light attached to this node.

Returns the first sibling of this node.

Returns:
The first sibling.

Returns the parent of this node.

Returns:
The parent.

Returns the previous sibling to this node.

Returns:
The previous sibling.

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

Returns:
The projection matrix of this node.

Returns the right vector of the Node in world space.

Returns:
The right vector in world space.

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:
nameName of the tag to return.
Returns:
The value of the given tag, or NULL if the tag is not set.

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

Returns:
The view space translation vector.

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.

Returns the up vector of the Node in world space.

Returns:
The up vector in world space.

Gets the user object assigned to this node.

Returns:
The user object assigned object to this node.

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

Returns:
The view matrix of this node.

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.

Gets the world view matrix corresponding to this node.

Returns:
The world view matrix of this node.

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:
nameName 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.

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:
childThe child to remove.
void gameplay::Node::setAgent ( AIAgent agent)

Sets the AI agent for this node.

Parameters:
agentThe AI agent to set.

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:
audioThe 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:
cameraThe 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:
typeThe type of the collision object to set; to disable the physics collision object, pass PhysicsCollisionObject::NONE.
shapeDefinition 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().
rigidBodyParametersIf 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.
groupGroup identifier of the object for collision filtering.
maskBitmask to filter groups of objects to collide with this one.

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:
urlThe 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:
drawableThe new drawable component. May be NULL.
void gameplay::Node::setEnabled ( bool  enabled)

Sets if the node is enabled in the scene.

Parameters:
enabledif the node is enabled in the scene.
void gameplay::Node::setId ( const char *  id)

Sets the identifier for the node.

Parameters:
idThe 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:
lightThe 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:
nameName of the tag to set.
valueOptional value of the tag (empty string by default).

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

Parameters:
objThe 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:
elapsedTimeElapsed time in milliseconds.

Member Data Documentation

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

The AI agent component attached to this node.

The audio source component attached to this node.

The bounding sphere for this node.

The camera component attached to this node.

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

The number of child nodes.

The collision object component attached to this node.

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

The dirty bits used for optimization.

The drawble component attached to this node.

bool gameplay::Node::_enabled [protected]

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

The nodes first child.

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

The nodes id.

The light component attached to this node.

The nodes next sibiling.

The nodes parent.

The nodes previous sibiling.

The scene this node is attached to.

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

Tags assigned to this node.

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