overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions
gameplay::Scene Class Reference

#include <Scene.h>

Inheritance diagram for gameplay::Scene:
gameplay::Ref

List of all members.

Public Member Functions

const char * getId () const
void setId (const char *id)
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
NodeaddNode (const char *id=NULL)
void addNode (Node *node)
void removeNode (Node *node)
void removeAllNodes ()
unsigned int getNodeCount () const
NodegetFirstNode () const
CameragetActiveCamera ()
void setActiveCamera (Camera *camera)
void bindAudioListenerToCamera (bool bind)
const Vector3getAmbientColor () const
void setAmbientColor (float red, float green, float blue)
void update (float elapsedTime)
template<class T >
void visit (T *instance, bool(T::*visitMethod)(Node *))
template<class T , class C >
void visit (T *instance, bool(T::*visitMethod)(Node *, C), C cookie)
void visit (const char *visitMethod)
NodegetNext ()
void reset ()

Static Public Member Functions

static Scenecreate (const char *id=NULL)
static Sceneload (const char *filePath)
static ScenegetScene (const char *id=NULL)

Detailed Description

Defines the root container for a hierarchy of Node objects.

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

Member Function Documentation

Node* gameplay::Scene::addNode ( const char *  id = NULL)

Creates and adds a new node to the scene.

Parameters:
idAn optional node ID.
Returns:
The new node.
void gameplay::Scene::addNode ( Node node)

Adds the specified node to the scene.

Parameters:
nodeThe node to be added to the scene.

Sets the audio listener to transform along with the active camera if set to true. If you have a 2D game that doesn't require it, then set to false. This is on by default for the scene.

Parameters:
bindtrue if you want to the audio listener to follow the active camera's transform.
static Scene* gameplay::Scene::create ( const char *  id = NULL) [static]

Creates a new empty scene.

Parameters:
idID of the new scene, or NULL to use an empty string for the ID (default).
Returns:
The newly created empty scene.
Node* gameplay::Scene::findNode ( const char *  id,
bool  recursive = true,
bool  exactMatch = true 
) const

Returns the first node in the scene that matches the given ID.

Parameters:
idThe ID of the node to find.
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 first node found that matches the given ID.
unsigned int gameplay::Scene::findNodes ( const char *  id,
std::vector< Node * > &  nodes,
bool  recursive = true,
bool  exactMatch = true 
) const

Returns all nodes in the scene that match the given ID.

Parameters:
idThe ID of the node to find.
nodesVector of nodes to be populated with matches.
recursivetrue if a recursive search should be performed, false otherwise.
exactMatchtrue if only nodes who's 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.

Gets the active camera for the scene.

Returns:
The active camera for the scene.
See also:
VisibleSet::getActiveCamera

Returns the ambient color of the scene.

The default ambient light color is black (0,0,0).

This value can be bound to materials using the SCENE_LIGHT_AMBIENT_COLOR auto binding.

Returns:
The scene's ambient color.

Returns the first node in the scene.

Returns:
The first node in the scene.
const char* gameplay::Scene::getId ( ) const

Gets the identifier for the scene.

Returns:
The scene identifier.
See also:
VisibleSet::getNext
unsigned int gameplay::Scene::getNodeCount ( ) const

Returns the number of nodes at the root level of the scene.

Returns:
The node count.
static Scene* gameplay::Scene::getScene ( const char *  id = NULL) [static]

Gets a currently active scene.

If id is an NULL, the first active scene is returned.

Parameters:
idID of the scene to retrieve, or NULL to retrieve the first active scene.
Returns:
The scene that matches the specified ID, or NULL if no matching scene could be found.
static Scene* gameplay::Scene::load ( const char *  filePath) [static]

Loads a scene from the given '.scene' or '.gpb' file.

Parameters:
filePathThe path to the '.scene' or '.gpb' file to load from.
Returns:
The loaded scene or NULL if the scene could not be loaded from the given file.

Removes all nodes from the scene.

Removes the specified node from the scene.

Parameters:
nodeThe node to remove.
See also:
VisibleSet::reset

Sets the active camera on the scene.

Parameters:
cameraThe active camera to be set on the scene.
void gameplay::Scene::setAmbientColor ( float  red,
float  green,
float  blue 
)

Sets the ambient color of the scene.

Parameters:
redThe red channel between 0.0 and 1.0.
greenThe green channel between 0.0 and 1.0.
blueThe blue channel between 0.0 and 1.0.
See also:
getAmbientColor()
void gameplay::Scene::setId ( const char *  id)

Sets the identifier for the scene.

Parameters:
idThe identifier to set for the scene.
void gameplay::Scene::update ( float  elapsedTime)

Updates all active nodes in the scene.

This method is recursively calls the Node::update(float) method on all nodes that are active within the scene. A Node is considered active if Node::isActive() returns true.

Parameters:
elapsedTimeElapsed time in milliseconds.
template<class T >
void gameplay::Scene::visit ( T *  instance,
bool(T::*)(Node *)  visitMethod 
)

Visits each node in the scene and calls the specified method pointer.

Calling this method invokes the specified method pointer for each node in the scene hierarchy.

The visitMethod parameter must be a pointer to a method that has a bool return type and accepts a single parameter of type Node*.

A depth-first traversal of the scene continues while the visit method returns true. Returning false will stop traversing further children for the given node and the traversal will continue at the next sibling.

Parameters:
instanceThe pointer to an instance of the object that contains visitMethod.
visitMethodThe pointer to the class method to call for each node in the scene.
template<class T , class C >
void gameplay::Scene::visit ( T *  instance,
bool(T::*)(Node *, C)  visitMethod,
cookie 
)

Visits each node in the scene and calls the specified method pointer.

Calling this method invokes the specified method pointer for each node in the scene hierarchy, passing the Node and the specified cookie value.

The visitMethod parameter must be a pointer to a method that has a bool return type and accepts two parameters: a Node pointer and a cookie of a user-specified type.

A depth-first traversal of the scene continues while the visit method returns true. Returning false will stop traversing further children for the given node and the traversal will continue at the next sibling.

Parameters:
instanceThe pointer to an instance of the object that contains visitMethod.
visitMethodThe pointer to the class method to call for each node in the scene.
cookieAn optional user-defined parameter that will be passed to each invocation of visitMethod.
void gameplay::Scene::visit ( const char *  visitMethod) [inline]

Visits each node in the scene and calls the specified Lua function.

Calling this method invokes the specified Lua function for each node in the scene hierarchy.

The visitMethod parameter must be a string containing the name of a valid Lua function that has a boolean return type and accepts a single parameter of type Node*.

A depth-first traversal of the scene continues while the visit method returns true. Returning false will stop traversing further children for the given node and the traversal will continue at the next sibling.

Parameters:
visitMethodThe name of the Lua function to call for each node in the scene.
 All Classes Functions Variables Typedefs Enumerations Enumerator