class
#include <engine/scene/scene.hpp>
Scene Asset which holds a blueprint generated from a scene file.
A scene represents an entity, its components and relations, and its children entities (i.e, sub-scenes). Optionally, a scene can inherit another scene asset, which means that it inherits all the entities and components.
Scene assets produce a blueprint when loaded which can be used to spawn them. Spawned entities are given names based on the names of the entities in the scene file. The root entity is given the name of the scene file. Child entities are given the name of their parent entity followed by a '#' and the name of the child entity in the file.
Scene assets are loaded from JSON files with the .cubos extension. They follow the format:
json { "inherit": "ba19170e-65a0-47cd-9bd2-b4ea9447fe22", "game::Player": {}, "#camera": { "cubos::engine::PerspectiveCamera": { "fovY": 90, } }, "#gun": { "inherit": "6cb09eea-4156-4a75-b0ae-488aac843e05" } }
In this example, the scene first inherits the scene with the UUID "ba19170e-65a0-47cd-9bd2-b4ea9447fe22". Then, it adds a "game::Player" component to the root entity. It also adds (or modifies) a child entity with the name "camera", adding a component "cubos::engine::PerspectiveCamera". Finally, it adds a child entity with the name "gun" which inherits the scene with the UUID "6cb09eea-4156-4a75-b0ae-488aac843e05".
Constructors, destructors, conversion operators
Public functions
- auto loadFromNode(SceneNode root, const Assets& assets) -> bool
- Sets the root node of the scene.
- auto node() const -> const SceneNode&
- Gets the root node of the scene.
-
auto blueprint() const -> const core::
ecs:: Blueprint& - Gets the blueprint generated from the scene node tree.
Function documentation
cubos:: engine:: Scene:: operator const core::ecs::Blueprint&() const
Overload which casts the scene reference to a reference to its blueprint.
Returns | Blueprint. |
---|
bool cubos:: engine:: Scene:: loadFromNode(SceneNode root,
const Assets& assets)
Sets the root node of the scene.
Parameters | |
---|---|
root | Root node. |
assets | Assets manager used to load sub-scenes. |
Returns | Whether all data was successfully deserialized. |
const core:: ecs:: Blueprint& cubos:: engine:: Scene:: blueprint() const
Gets the blueprint generated from the scene node tree.
Returns | Blueprint. |
---|