#include <SceneNode.h>
Public Member Functions | |
SceneNode (bool manageMemory=false) | |
Construct a new SceneNode. | |
void | init () |
Initialises the rendering state. | |
void | updateScene (float delta) |
Steps the world forward in time by some amount. | |
void | setActiveCamera (Camera *camera) |
Sets the active Camera. | |
Camera * | getActiveCamera () |
Returns the active Camera or 0 if none. | |
void | setInputSystem (InputSystem *input) |
Assign an InputSystem to this SceneNode. | |
InputSystem * | getInputSystem () |
Get the InputSystem used by this SceneNode or 0 for none. | |
Vector2f | screenToWorld (const Vector2f &coord) |
Convert from screen to world coordinates. | |
Vector2f | worldToScreen (const Vector2f &coord) |
Convert from world to screen coordinates. | |
void | disablePhysics () |
Disables physics stepping for this SceneNode. | |
void | enablePhysics () |
Enables physics stepping for this SceneNode. | |
void | createPhysicsWorld (const Vector2f &minPoint, const Vector2f &maxPoint, const Vector2f &gravity) |
Creates a physics world for this SceneNode with given parameters. | |
void | setPhysicsWorld (b2World *world) |
Assign a new physics world to this SceneNode. | |
b2World * | getPhysicsWorld () |
Get the physics world for this SceneNode. | |
void | addPhysicsObject (Shape *shape) |
Add a physically controlled Shape to this scene. | |
void | setBackgroundColour (const Colour4f &colour) |
Sets the background colour of the renderer. | |
Colour4f | getBackgroundColour () const |
Gets the background colour of the renderer. | |
void | draw () |
Performs per-frame rendering initialisation and set up. |
This Node should generally be used as the root node of the scene graph. It handles the InputSystem, physics simulation, the active camera, and other properties.
SceneNode::SceneNode | ( | bool | manageMemory = false |
) |
Construct a new SceneNode.
By default, SceneNodes do not enable automatic scene graph management. Setting the manageMemory parameter to true will change this. SceneNodes which manage memory will automatically delete Nodes and Controllers that have been disconnected or are no longer used.
manageMemory | determines whether automatic scene graph management is enabled. |
void SceneNode::updateScene | ( | float | delta | ) |
Steps the world forward in time by some amount.
This method will update physics, update all Controllers, and delete any objects scheduled for deletion.
delta | amount of time to step the world |
void SceneNode::setActiveCamera | ( | Camera * | camera | ) |
void SceneNode::setInputSystem | ( | InputSystem * | input | ) |
Assign an InputSystem to this SceneNode.
The assigned InputSystem is updated in the updateScene(float) method.
input | InputSystem for SceneNode to use |
Convert from screen to world coordinates.
This method uses the currently active Camera to transform a point into world coordinates.
coord | screen position to translate |
Convert from world to screen coordinates.
This method uses the currently active Camera to transform a point into screen coordinates.
coord | world position to translate |
void SceneNode::disablePhysics | ( | ) |
Disables physics stepping for this SceneNode.
This can be used to pause the physics in a game or application. Only applicable to SceneNodes which contain a physics world.
void SceneNode::enablePhysics | ( | ) |
Enables physics stepping for this SceneNode.
This can be used to resume the physics in a game or application. Only applicable to SceneNodes which contain a physics world.
void SceneNode::createPhysicsWorld | ( | const Vector2f & | minPoint, | |
const Vector2f & | maxPoint, | |||
const Vector2f & | gravity | |||
) |
Creates a physics world for this SceneNode with given parameters.
Creates a world using the Box2D API with specific bounds and gravity.
minPoint | minimum point in the world's bounding box | |
maxPoint | maximum point in the world's bounding box | |
gravity | vector describing the direction and intensity of gravity |
void SceneNode::addPhysicsObject | ( | Shape * | shape | ) |
Add a physically controlled Shape to this scene.
This method is a convenience method, it simply creates a PhysicsController for the specified Shape, adds the controller to the InputSystem and attaches the Shape to the scene graph.
shape | Shape to attach |