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

- Main Page
- Classes

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

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:

List of all members.

## Public Member Functions

const char * | getId () const
void | setId (const char *id)
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
Node * | addNode (const char *id=NULL)
void | addNode (Node *node)
void | removeNode (Node *node)
void | removeAllNodes ()
unsigned int | getNodeCount () const
Node * | getFirstNode () const
Camera * | getActiveCamera ()
void | setActiveCamera (Camera *camera)
void | bindAudioListenerToCamera (bool bind)
const Vector3 & | getAmbientColor () 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)
Node * | getNext ()
void | reset ()

## Static Public Member Functions

static Scene * | create (const char *id=NULL)
static Scene * | load (const char *filePath)
static Scene * | getScene (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:

  id | An optional node ID.

Returns:
  The new node.

void gameplay::Scene::addNode | ( | Node * | node | ) |

Adds the specified node to the scene.

Parameters:

  node | The node to be added to the scene.

void gameplay::Scene::bindAudioListenerToCamera | ( | bool | bind | ) |

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:

  bind | true 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:

  id | ID 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:

  id | The ID of the node to find.
  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 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:

  id | The ID of the node to find.
  nodes | Vector of nodes to be populated with matches.
  recursive | true if a recursive search should be performed, false otherwise.
  exactMatch | true 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.

Camera* gameplay::Scene::getActiveCamera | ( |  | ) |

Gets the active camera for the scene.

Returns:
  The active camera for the scene.

See also:
  VisibleSet::getActiveCamera

const Vector3& gameplay::Scene::getAmbientColor | ( |  | ) | const

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.

Node* gameplay::Scene::getFirstNode | ( |  | ) | const

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.

Node* gameplay::Scene::getNext | ( |  | ) |

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:

  id | ID 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:

  filePath | The 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.

void gameplay::Scene::removeAllNodes | ( |  | ) |

Removes all nodes from the scene.

void gameplay::Scene::removeNode | ( | Node * | node | ) |

Removes the specified node from the scene.

Parameters:

  node | The node to remove.

void gameplay::Scene::reset | ( |  | ) |

See also:
  VisibleSet::reset

void gameplay::Scene::setActiveCamera | ( | Camera * | camera | ) |

Sets the active camera on the scene.

Parameters:

  camera | The 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:

  red | The red channel between 0.0 and 1.0.
  green | The green channel between 0.0 and 1.0.
  blue | The 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:

  id | The 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:

  elapsedTime | Elapsed 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:

  instance | The pointer to an instance of the object that contains visitMethod.
  visitMethod | The 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,
|  | C | 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:

  instance | The pointer to an instance of the object that contains visitMethod.
  visitMethod | The pointer to the class method to call for each node in the scene.
  cookie | An 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:

  visitMethod | The name of the Lua function to call for each node in the scene.

All Classes Functions Variables Typedefs Enumerations Enumerator