1#ifndef OE_SCENE_MANAGER_H
2#define OE_SCENE_MANAGER_H
11#include "component/scene.h"
44 template <
typename T =
Node,
typename... Args>
47 std::shared_ptr<T> result = std::make_shared<T>(std::forward<Args>(args)...);
48 result->_manager =
this;
50 _nodes.push_back(result);
52 T* ptr = result.get();
54 _root_nodes.push_back(ptr);
56 _notify_components_of_node_add(*result);
66 template <
typename T =
Node,
typename... Args>
69 T& result = addNode<T>(std::forward<Args>(args)...);
93 const std::vector<std::shared_ptr<Node>>&
getAllNodes()
const;
108 template <
typename T = Node>
109 T*
search(
const std::string path,
const std::string separator =
"/")
const
111 for (
auto it : _root_nodes)
113 T* result = it->search<T>(path, separator);
115 if (result !=
nullptr)
151 template <
typename ComponentType>
208 void update(
const double delta,
const int8_t flags = 0);
211 std::map<NodeType, std::vector<Node*>> _node_types;
213 std::vector<Node*> _root_nodes;
215 std::vector<std::shared_ptr<Node>> _nodes;
219 std::reference_wrapper<Camera> _camera;
221 void _notify_components_of_node_add(
Node& node);
222 void _notify_components_of_node_remove(
Node& node);
Util class to add components handling to an entity.
Definition component.h:311
The "eye of the scene".
Definition camera.h:33
Scene manager.
Definition manager.h:21
void removeNodeFromAllGroups(Node &node)
Remove node from all of its groups.
void setCamera(Node &node, const std::string &component_name)
Set scene camera using a node's named camera component.
void resetCameraToDefault()
Reset scene camera to the default camera.
void setCamera(Node &node)
Set scene camera using a node's camera component.
Manager()
Default Constructor.
std::vector< Node * > getNodesByType(const NodeType type) const
Get nodes belonging to a type (For exemple nodes that need to be in specific pass)
Camera & getCamera()
Get currently bound scene camera.
void addChildNodeToParent(Node &child, Node *parent)
Attach a child node to a parent one.
void removeNodeFromGroup(Node &node, const NodeType type)
Remove node from specified group.
T * search(const std::string path, const std::string separator="/") const
Search for a node using a name path.
Definition manager.h:109
const std::vector< std::shared_ptr< Node > > & getAllNodes() const
Get all nodes in the scene.
T & addNamedNode(const std::string &name, Args &&... args)
Generate a new root node in the the scene.
Definition manager.h:67
Manager(const Camera &camera)
Constructor where Camera settings are filled from a reference one.
T & addNode(Args &&... args)
Generate a new root node in the the scene.
Definition manager.h:45
void addNodeInGroup(Node &node, const NodeType type)
Add a node in a group (For example nodes that need to be in specific pass)
void deleteNode(Node &node)
Remove a node from the scene.
void setCamera(Camera &camera)
Set scene camera.
void update(const double delta, const int8_t flags=0)
Update the scene.
Camera & getDefaultCamera()
Get a reference to the default camera.
const std::vector< Node * > & getRootNodes() const
Get root nodes of the scene.
Definition manager.h:98
void setCameraFromComponent(ComponentType &component)
Set scene camera using a component providing a camera.
Definition manager.h:152
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19