Resolution independent 2D graphics engine
qr::scene_node

Class Description

Scene node base. Scene nodes are the basic building blocks of the scene graph, they can be attached to the scene manager, or other scene nodes. Children are transformed relative to there parents. This class is pure virtual and defines an interface allowing scene nodes to be implemented.

Public Methods

void register_node (scene_manager *scene_man)
void register_node (scene_node *parent)
scene_manager * get_scene_manager ()
renderer * get_renderer ()
void raise_event (event *n_event)
void drop ()
void create_var (T value, std::string name)
void set_var (std::string name, T value)
T & get_var (std::string name)
void delete_var (std::string name)
void set_event_receiver (event_receiver *receiver)
event_receiver * get_event_receiver ()
void set_animator (animator *l_animator)
animator * get_animator ()
void set_sprite (sprite *new_sprite)
sprite * get_sprite ()
void set_frame (int new_frame)
int get_frame ()
void set_location (vector2d_f new_loc)
vector2d_f get_location ()
void set_size (vector2d_f new_size)
void set_scale_base ()
vector2d_f get_size ()
void set_rotation (float angle)
float get_rotation ()
void set_layer (unsigned int new_layer)
unsigned int get_layer ()

Protected Methods

void add_polygon (vector2d_f P1, vector2d_f P2, vector2d_f P3, vector2d_f P1c, vector2d_f P2c, vector2d_f P3c)
void clear_mesh ()
void on_register ()=0
void on_render ()=0
void on_drop ()=0

Details

void qr::scene_node::register_node ( scene_manager * scene_man
)

Description

Create a new root scene node and register it with the scene manager.

Paramiters

scene_man Pointer to scene manager.
void qr::scene_node::register_node ( scene_node * parent
)

Description

Create a new scene node and attach it to another scene node.

Paramiters

parent Pointer to parent node.
scene_manager * qr::scene_node::get_scene_manager ( )

Description

Get a pointer to the scene manager.

Retunes

Pointer to scene manager

renderer * qr::scene_node::get_renderer ( )

Description

Get a pointer to the renderer.

Retunes

Pointer to renderer

void qr::scene_node::raise_event ( event * n_event
)

Description

Pass a new event into the event system.

Paramiters

n_event Event object.
void qr::scene_node::drop ( )

Description

Deletes the current node and all of its children.

void qr::scene_node::create_var ( T value,
std::string name
) [inline]

Description

Create a new scene graph variable on the current node. Scene graph variables are variables which are lexically scoped within the scene graph and are inherited up the node hierarchy. They provide a method for moving data between scene nodes, event receivers and animators without resorting to using globals. If the provided name is already used on the current node, throws a Tree_variable_already_exists exception.

Paramiters

value Initial type and value of var.
name Scene graph variable name.
void qr::scene_node::set_var ( std::string name,
T value
) [inline]

Description

Set the value of a scene graph variable. Looks for the variable on the current scene node and recursively on all the parents of the current node. If the named variable does not exist, throws a Undefined_tree_variable exception. Throws a Wrong_type_for_tree_variable exception if the type of the value provided does not match the type of the named scene graph variable.

Paramiters

name Name of the scene graph variable.
value New value.
T& qr::scene_node::get_var ( std::string name
) [inline]

Description

Get the value of a scene graph variable, the type of the variable must be provided as a template parameter. Looks for the variable on the current scene node and recursively on all the parents of the current node. If the named variable does not exist, throws a Undefined_tree_variable exception. Throws a Wrong_type_for_tree_variable exception if the type of the value provided does not match the type of the named scene graph variable.

Paramiters

name Name of the scene graph variable.
void qr::scene_node::delete_var ( std::string name
) [inline]

Description

Deletes the named scene graph variable from the current scene node, does not look for the variable in the parents of the node. If the named variable does not exist, throws a Undefined_tree_variable exception.

Paramiters

name Name of the scene graph variable.
void qr::scene_node::set_event_receiver ( event_receiver * receiver
) [inline]

Description

Attaches an event receiver.

Paramiters

receiver New event receiver.
event_receiver* qr::scene_node::get_event_receiver ( ) [inline]

Description

Gets the currently registered event receiver, returns NULL if no animator is attached..

Retunes

Currently registered event receiver.

void qr::scene_node::set_animator ( animator * l_animator
) [inline]

Description

Attaches an animator.

Paramiters

l_animator New animator.
animator* qr::scene_node::get_animator ( ) [inline]

Description

Gets the currently registered animator, returns NULL if no animator is attached.

Retunes

Currently registered animator.

void qr::scene_node::set_sprite ( sprite * new_sprite
) [inline]

Description

Replaces the registered sprite.

Paramiters

new_sprite New sprite.
sprite* qr::scene_node::get_sprite ( ) [inline]

Description

Gets the currently registered sprite.

Retunes

Currently registered sprite.

void qr::scene_node::set_frame ( int new_frame
) [inline]

Description

Sets the animation frame.

Paramiters

new_frame New frame number.
int qr::scene_node::get_frame ( ) [inline]

Description

Gets the animation frame.

Retunes

Current animation frame number.

void qr::scene_node::set_location ( vector2d_f new_loc
) [inline]

Description

Sets the location of the node.

Paramiters

new_loc New node location.
vector2d_f qr::scene_node::get_location ( ) [inline]

Description

Gets the location of the node.

Retunes

Current location of the scene node.

void qr::scene_node::set_size ( vector2d_f new_size
) [inline]

Description

Sets the size of the node.

Paramiters

new_size New node size.
void qr::scene_node::set_scale_base ( ) [inline]

Description

Sets the current node size as '1' for scale calculation. Allows nodes to be resized without effecting the size of child nodes. Call this method after resizing the node.

vector2d_f qr::scene_node::get_size ( ) [inline]

Description

Gets the current size of the node.

Retunes

Current size of the scene node.

void qr::scene_node::set_rotation ( float angle
) [inline]

Description

Sets the rotation of the node(in degrees).

Paramiters

angle New rotation angle.
float qr::scene_node::get_rotation ( ) [inline]

Description

Gets the rotation of the node(in degrees).

Retunes

Current rotation of the scene node.

void qr::scene_node::set_layer ( unsigned int new_layer
) [inline]

Description

Sets the layer the node is on.

Paramiters

new_layer Layer number.
unsigned int qr::scene_node::get_layer ( ) [inline]

Description

Gets the layer the node is on.

Retunes

Current layer number.

void qr::scene_node::add_polygon ( vector2d_f P1,
vector2d_f P2,
vector2d_f P3,
vector2d_f P1c,
vector2d_f P2c,
vector2d_f P3c
) [protected]

Description

Adds a polygon to the mesh.

Paramiters

P1 Vertex 1.
P2 Vertex 2.
P3 Vertex 3.
P1c Vertex 1 texture coord.
P2c Vertex 2 texture coord.
P3c Vertex 3 texture coord.
void qr::scene_node::clear_mesh ( ) [protected]

Description

Deletes the nodes current mesh data.

virtual void qr::scene_node::on_register ( ) [protected, pure virtual]

Description

Method gets called when the node registers.

virtual void qr::scene_node::on_render ( ) [protected, pure virtual]

Description

Method gets called when the node renders.

virtual void qr::scene_node::on_drop ( ) [protected, pure virtual]

Description

Method gets called when the node is dropped.