class
#include <engine/scene/node.hpp>
SceneNode Describes a node in a scene hierarchy.
A scene node represents an entity, its components and relations, and its children entities. Optionally, a node may inherit data (components, relations and children) from a root scene node of another scene asset.
Constructors, destructors, conversion operators
Public functions
- auto operator=(SceneNode&&) -> SceneNode& defaulted
- Move assignment.
- auto inherits() const -> Asset<Scene>
- Gets the scene asset from which this node inherits.
- void inherits(Asset<Scene> scene)
- Sets the scene asset from which this node inherits.
-
auto components() const -> const core::
memory:: <nlohmann::json>&TypeMap - Returns the components of the entity.
-
void add(const core::
reflection:: & type, nlohmann::json data)Type - Inserts a component of the given type into the node.
-
void remove(const core::
reflection:: & type)Type - Removes the component of the given type from the node.
-
auto relationsFrom() const -> const core::
memory:: <std::unordered_map<std::string, nlohmann::json>>&TypeMap - Gets all incoming relations.
-
auto relationsTo() const -> const core::
memory:: <std::unordered_map<std::string, nlohmann::json>>&TypeMap - Gets all outgoing relations.
-
void relateFrom(const core::
reflection:: & type, const std::string& entity, nlohmann::json data)Type - Inserts a relation of the given type into the node.
-
void relateTo(const core::
reflection:: & type, const std::string& entity, nlohmann::json data)Type - Inserts a relation of the given type into the node.
-
void unrelateFrom(const core::
reflection:: & type, const std::string& entity)Type - Removes the relation of the given type from the node.
-
void unrelateTo(const core::
reflection:: & type, const std::string& entity)Type - Removes the relation of the given type from the node.
- auto children() const -> const std::unordered_map<std::string, std::unique_ptr<SceneNode>>&
- Gets the map of child nodes.
- auto create(const std::string& name) -> SceneNode&
- Creates a new child node with the given name.
- void destroy(const std::string& name)
- Destroys the child node with the given name.
-
auto load(const nlohmann::json& json,
const core::
reflection:: & components, const core::TypeRegistry reflection:: & relations) -> boolTypeRegistry - Loads the scene node from a JSON object.
Function documentation
const core::memory::TypeMap <nlohmann::json>& cubos::engine::SceneNode:: components() const
Returns the components of the entity.
Returns | Components. |
---|
void cubos::engine::SceneNode:: add(const core::reflection::Type & type,
nlohmann::json data)
Inserts a component of the given type into the node.
Parameters | |
---|---|
type | Component type. |
data | Component data. |
void cubos::engine::SceneNode:: remove(const core::reflection::Type & type)
Removes the component of the given type from the node.
Parameters | |
---|---|
type | Component type. |
const core::memory::TypeMap <std::unordered_map<std::string, nlohmann::json>>& cubos::engine::SceneNode:: relationsFrom() const
Gets all incoming relations.
Returns | Incoming relations. |
---|
const core::memory::TypeMap <std::unordered_map<std::string, nlohmann::json>>& cubos::engine::SceneNode:: relationsTo() const
Gets all outgoing relations.
Returns | Outgoing relations. |
---|
void cubos::engine::SceneNode:: relateFrom(const core::reflection::Type & type,
const std::string& entity,
nlohmann::json data)
Inserts a relation of the given type into the node.
Parameters | |
---|---|
type | Relation type. |
entity | Path to entity which the relation originates from. |
data | Relation data. |
void cubos::engine::SceneNode:: relateTo(const core::reflection::Type & type,
const std::string& entity,
nlohmann::json data)
Inserts a relation of the given type into the node.
Parameters | |
---|---|
type | Relation type. |
entity | Path to entity which the relation points to. |
data | Relation data. |
void cubos::engine::SceneNode:: unrelateFrom(const core::reflection::Type & type,
const std::string& entity)
Removes the relation of the given type from the node.
Parameters | |
---|---|
type | Relation type. |
entity | Path to entity which the relation originates from. |
void cubos::engine::SceneNode:: unrelateTo(const core::reflection::Type & type,
const std::string& entity)
Removes the relation of the given type from the node.
Parameters | |
---|---|
type | Relation type. |
entity | Path to entity which the relation points to. |
void cubos::engine::SceneNode:: destroy(const std::string& name)
Destroys the child node with the given name.
Parameters | |
---|---|
name | Name of the child node. |
bool cubos::engine::SceneNode:: load(const nlohmann::json& json,
const core::reflection::TypeRegistry & components,
const core::reflection::TypeRegistry & relations)
Loads the scene node from a JSON object.
Parameters | |
---|---|
json | JSON object. |
components | Component type registry. |
relations | Relation type registry. |
Returns | Whether the scene node was successfully loaded. |