8#include "hellfire/ecs/LightComponent.h"
9#include "hellfire/ecs/RenderableComponent.h"
10#include "hellfire/ecs/TransformComponent.h"
11#include "hellfire/ecs/components/MeshComponent.h"
12#include "hellfire/scene/Scene.h"
13#include "hellfire/utilities/SerializerUtils.h"
18 static bool serialize(std::ostream &output,
const T *obj);
20 static bool deserialize(std::istream &input, T *obj);
26 if (obj ==
nullptr)
return false;
28 const nlohmann::json j = {
29 {
"position", obj->get_position()},
30 {
"rotation", obj->get_rotation()},
31 {
"scale", obj->get_scale()}
40 if (obj ==
nullptr)
return false;
45 const auto position = json_get_vec3(j,
"position");
46 const auto rotation = json_get_vec3(j,
"rotation");
47 const auto scale = json_get_vec3(j,
"scale");
49 if (!position || !rotation || !scale)
return false;
53 obj->set_scale(*scale);
64 static bool serialize(std::ostream &output,
const MeshComponent *obj) {
65 if (!obj)
return false;
68 {
"mesh_asset", obj->get_mesh_asset()},
69 {
"is_wireframe", obj->is_wireframe}
77 static bool deserialize(std::istream &input, MeshComponent *obj) {
78 if (!obj)
return false;
96 static bool serialize(std::ostream &output,
const RenderableComponent *obj) {
97 if (!obj)
return false;
100 {
"material_asset", obj->get_material_asset()},
101 {
"cast_shadows", obj->cast_shadows},
102 {
"receive_shadows", obj->receive_shadows},
103 {
"visible", obj->visible},
104 {
"render_layer", obj->render_layer}
108 return output.good();
111 static bool deserialize(std::istream &input, RenderableComponent *obj) {
112 if (!obj)
return false;
134 if (!obj)
return false;
137 {
"light_type", obj->get_light_type()},
138 {
"color", obj->get_color()},
139 {
"intensity", obj->get_intensity()},
140 {
"should_cast_shadows", obj->should_cast_shadows()},
150 return output.good();
154 if (!obj)
return false;
161 obj->set_color(j.value(
"color", glm::vec3(0)));
void import_all_pending()
Import all unprocessed assets in registry.
Registry for storing assets.
void set_intensity(const float intensity)
float get_attenuation() const
LightType get_light_type() const
void set_range(const float range)
void set_attenuation(const float attenuation)
void set_cast_shadows(const bool cast_shadows)
void set_light_type(const LightType type)
void set_mesh_asset(AssetID id)
const std::string & get_name() const
std::unique_ptr< AssetManager > asset_manager_
const ProjectMetadata & get_metadata() const
ProjectMetadata & get_metadata()
std::filesystem::path get_assets_path() const
std::filesystem::path get_settings_path() const
AssetRegistry * get_asset_registry() const
std::unique_ptr< SceneManager > scene_manager_
std::vector< std::filesystem::path > recent_scenes_
void initialize_default_assets()
static std::unique_ptr< Project > create(const std::string &name, const std::filesystem::path &location)
const std::string & get_version() const
static std::unique_ptr< Project > load_data(const std::filesystem::path &project_file)
std::unique_ptr< Renderer > scene_renderer_
std::unique_ptr< AssetRegistry > asset_registry_
Project(const ProjectMetadata &metadata)
SceneManager * get_scene_manager() const
ProjectMetadata metadata_
void create_directory_structure() const
std::filesystem::path project_root_path_
std::filesystem::path project_file_path_
Project(const std::string &name)
void initialize_managers()
std::filesystem::path get_scenes_path() const
std::filesystem::path get_project_root() const
static std::string get_current_timestamp()
void set_material_asset(AssetID id)
constexpr AssetID INVALID_ASSET_ID