|
cat3d
A tiny OpenGL 3D engine library written in and for C++.
|
6 #include <unordered_map>
8 #include "cat3d/util/clock.hpp"
9 #include "cat3d/util/transform.hpp"
10 #include "cat3d/window.hpp"
12 namespace cat3d::scene {
105 template <
typename Obj,
typename... Args>
107 Obj* o =
new Obj(args...);
110 m_children.push_back((
node*)o);
122 size_t bind(node_bind_loc loc, std::function<
void()> fn);
153 node* m_parent =
nullptr;
156 std::vector<node*> m_children;
159 std::unordered_map<size_t, std::pair<node_bind_loc, std::function<void()>>> m_hooks;
162 size_t m_next_hook_id = 0;
165 void run_hooks(node_bind_loc l);
171 void push_transform(
window& win);
static node * new_root()
Create a new root scene node.
Manages internal window api / state.
Definition: window.hpp:17
Obj * create(Args... args)
Add a derived node class as a child.
Definition: node.hpp:106
void delete_child(node *child)
Remove the given child node.
virtual void render_self(window &win)
Overridden by child classes to implement custom rendering.
void render(window &win)
Called once per render. Renders this node and all children.
virtual ~node()
virtual destructor for polymorphism
util::transform global_transform() const
Get this node's transform relative to the world.
void update(window &win)
Called once per frame. Updates this node.
virtual void update_self(window &win)
Overridden by child classes to implement custom behavior.
util::transform local_transform() const
Get the node's transform relative to itself.
Basic, semi-abstract scene node class. Can have children which are other scene nodes,...
Definition: node.hpp:28
node * create_node()
Create a child node.
util::transform & transform()
Access to the underlying transform.
size_t bind(node_bind_loc loc, std::function< void()> fn)
Add a hook into the update cycle of the node.
void unbind(size_t id)
Unbind a hook from the node.
node * parent() const
Get this node's parent.