21 #include "hx3d/ecs/node.hpp" 26 template <
class T,
class... Args>
28 const Ptr<T>& ptr = createNodeChild<T>(
_root, args...);
32 template <
class T,
class... Args>
35 if (container ==
nullptr) {
36 Log.
Error(
"SceneGraph: could not create at `%s`.", path.c_str());
40 const Ptr<T>& ptr = createNodeChild<T>(container, args...);
46 return std::dynamic_pointer_cast<T>(
_indices[path]);
49 template <
class T,
class... Args>
51 const Ptr<T>&
object = Make<T>(args...);
52 auto obj_name =
object->getName();
53 if (container->childNameExists(obj_name)) {
54 Log.
Error(
"Node: a child of `%s` is already named `%s`.", container->_name.c_str(), obj_name.c_str());
58 object->_parent = container;
59 container->_children.push_back(
object);
Ptr< T > createNodeChild(const Ptr< Node > &container, Args...args)
Create a child for a container Node.
Ptr< T > create(const std::string path, Args...args)
Create a game object at a path.
std::map< std::string, Ptr< Node > > _indices
Node indices.
Ptr< Node > _root
Graph root.
void addIndex(const Ptr< Node > &object)
Add an index to the graph.
Ptr< Node > pathExists(const std::string path)
Test if the path exists and returns the node.
void Error(const std::string fmt,...)
Write an error message.
static hx3d::LogImpl Log
Current log implementation.
bool _entityEnabled
Is entity management enabled ?
Ptr< T > fetch(const std::string path)
Fetch a game object from a path.
Ptr< T > createAtRoot(Args...args)
Create a game object at the root.
Engine _engine
Engine for entity management.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
void registerEntity(const Ptr< Entity > &entity)
Affect an ID to a uninitialized entity.