cat3d
A tiny OpenGL 3D engine library written in and for C++.
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
cat3d::scene::node Class Reference

Basic, semi-abstract scene node class. Can have children which are other scene nodes, or derived types. More...

#include <node.hpp>

Inherited by cat3d::obj::camera, cat3d::obj::model, cat3d::obj::texture, and cat3d::obj::timer.

Public Member Functions

virtual ~node ()
 virtual destructor for polymorphism
 
void delete_child (node *child)
 Remove the given child node. More...
 
util::transform global_transform () const
 Get this node's transform relative to the world.
 
util::transform local_transform () const
 Get the node's transform relative to itself.
 
util::transformtransform ()
 Access to the underlying transform. More...
 
void update (window &win)
 Called once per frame. Updates this node.
 
void render (window &win)
 Called once per render. Renders this node and all children.
 
nodeparent () const
 Get this node's parent. More...
 
nodecreate_node ()
 Create a child node. More...
 
template<typename Obj , typename... Args>
Obj * create (Args... args)
 Add a derived node class as a child. More...
 
size_t bind (node_bind_loc loc, std::function< void()> fn)
 Add a hook into the update cycle of the node. More...
 
void unbind (size_t id)
 Unbind a hook from the node. More...
 

Static Public Member Functions

static nodenew_root ()
 Create a new root scene node. More...
 

Protected Member Functions

virtual void update_self (window &win)
 Overridden by child classes to implement custom behavior. More...
 
virtual void render_self (window &win)
 Overridden by child classes to implement custom rendering. More...
 

Detailed Description

Basic, semi-abstract scene node class. Can have children which are other scene nodes, or derived types.

Member Function Documentation

◆ bind()

size_t cat3d::scene::node::bind ( node_bind_loc  loc,
std::function< void()>  fn 
)

Add a hook into the update cycle of the node.

Parameters
locThe location in the update cycle to hook into
fnThe function to run
Returns
size_t An event token id, to unbind once the hooked class goes out of scope.

◆ create()

template<typename Obj , typename... Args>
Obj* cat3d::scene::node::create ( Args...  args)
inline

Add a derived node class as a child.

Remarks
These are typically found in cat3d/obj
Template Parameters
ObjThe type of object to add
ArgsThe arguemnts passed to the constructor
Returns
Obj* Pointer to the newly created node instance

◆ create_node()

node* cat3d::scene::node::create_node ( )

Create a child node.

Returns
node* The created node

◆ delete_child()

void cat3d::scene::node::delete_child ( node child)

Remove the given child node.

Parameters
childA child of this node

◆ new_root()

static node* cat3d::scene::node::new_root ( )
static

Create a new root scene node.

Returns
node*

◆ parent()

node* cat3d::scene::node::parent ( ) const

Get this node's parent.

Returns
node*

◆ render_self()

virtual void cat3d::scene::node::render_self ( window win)
protectedvirtual

Overridden by child classes to implement custom rendering.

Parameters
winThe main cat3d window.

Reimplemented in cat3d::obj::model.

◆ transform()

util::transform& cat3d::scene::node::transform ( )

Access to the underlying transform.

Remarks
Safe to modify
Returns
util::transform& Reference to this node's transform.

◆ unbind()

void cat3d::scene::node::unbind ( size_t  id)

Unbind a hook from the node.

Remarks
Not unbinding a function while it goes out of scope is an error!
Parameters
idThe event token id

◆ update_self()

virtual void cat3d::scene::node::update_self ( window win)
protectedvirtual

Overridden by child classes to implement custom behavior.

Parameters
winThe main cat3d window.

Reimplemented in cat3d::obj::timer, cat3d::obj::texture, cat3d::obj::model, and cat3d::obj::camera.


The documentation for this class was generated from the following file: