sandbox
Loading...
Searching...
No Matches
scene_serializer.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCENES_SCENE_SERIALIZER_HPP_
3#define LIBSBX_SCENES_SCENE_SERIALIZER_HPP_
4
5#include <filesystem>
6#include <string>
7
8#include <yaml-cpp/yaml.h>
9
10#include <libsbx/math/uuid.hpp>
11
12#include <libsbx/scenes/node.hpp>
13#include <libsbx/scenes/scene_graph.hpp>
14#include <libsbx/scenes/asset_registry.hpp>
15#include <libsbx/scenes/component_io.hpp>
16#include <libsbx/scenes/asset_io.hpp>
17
18namespace sbx::scenes {
19
20struct scene_data {
21 std::string name;
22 math::uuid camera_id;
23}; // struct scene_data
24
26
27public:
28
30 : _component_io{component_io},
31 _asset_io{asset_io},
32 _registry{registry} { }
33
34 auto save(const std::filesystem::path& path, const std::string& name, scene_graph& graph, const scenes::node camera) -> void;
35
36 auto load(const std::filesystem::path& path, scene_graph& graph) -> scene_data;
37
38private:
39
40 auto _save_assets(YAML::Emitter& emitter) -> void;
41
42 auto _save_node(YAML::Emitter& emitter, scene_graph& graph, const scenes::node node) -> void;
43
44 auto _save_components(YAML::Emitter& emitter, scene_graph& graph, const scenes::node node) -> void;
45
46 auto _load_assets(const YAML::Node& assets_node) -> void;
47
48 auto _load_asset_category(const std::string& category, const YAML::Node& entries) -> void;
49
50 auto _load_nodes(const YAML::Node& nodes_node, scene_graph& graph) -> void;
51
52 component_io_registry& _component_io;
53 asset_io_registry& _asset_io;
54 asset_registry& _registry;
55
56}; // class scene_serializer
57
58} // namespace sbx::scenes
59
60#endif // LIBSBX_SCENES_SCENE_SERIALIZER_HPP_
Definition: tests.cpp:6
Definition: uuid.hpp:160
Definition: asset_io.hpp:17
Definition: asset_registry.hpp:81
Definition: camera.hpp:96
Definition: component_io.hpp:27
Definition: scene_graph.hpp:32
Definition: scene_serializer.hpp:25
Definition: component_io.hpp:19
Definition: scene_serializer.hpp:20