27 template <
typename T>
void to_json(
json &Json,
const vec3<T> &Vector) { Json = { Vector.
X, Vector.
Y, Vector.
Z }; }
28 template <
typename T>
void to_json(
json &Json,
const vec4<T> &Vector) { Json = { Vector.
X, Vector.
Y, Vector.
Z, Vector.
W }; }
34 if (!Json.is_array())
return;
35 for (
int i = 0; i < 2 && i < Json.size(); i++) Vector[i] = Json[i];
39 if (!Json.is_array())
return;
40 for (
int i = 0; i < 3 && i < Json.size(); i++) Vector[i] = Json[i];
44 if (!Json.is_array())
return;
45 for (
int i = 0; i < 4 && i < Json.size(); i++) Vector[i] = Json[i];
49 if (!Json.is_array())
return;
50 for (
int i = 0; i < 9 && i < Json.size(); i++) Matrix[i] = Json[i];
54 if (!Json.is_array())
return;
55 for (
int i = 0; i < 16 && i < Json.size(); i++) Matrix[i] = Json[i];
63 void to_json(
json &Json,
const name_component &NameComponent);
64 void to_json(
json &Json,
const transform_component &TransformComponent);
65 void to_json(
json &Json,
const camera_component &CameraComponent);
66 void to_json(
json &Json,
const point_light_component &PointLightComponent);
67 void to_json(
json &Json,
const directional_light_component &DirectionalLightComponent);
68 void to_json(
json &Json,
const spot_light_component &SpotLightComponent);
70 bool from_json(
const json &Json, name_component &NameComponent);
71 bool from_json(
const json &Json, transform_component &TransformComponent);
72 bool from_json(
const json &Json, camera_component &CameraComponent);
73 bool from_json(
const json &Json, point_light_component &PointLightComponent);
74 bool from_json(
const json &Json, directional_light_component &DirectionalLightComponent);
75 bool from_json(
const json &Json, spot_light_component &SpotLightComponent);
92 template <
typename Tcomponent>
96 Json[
typeid(Tcomponent).name()] = SceneObject.
GetComponent<Tcomponent>();
99 template <
typename Tcomponent>
100 static void DeserializeComponent(
const json &Json,
scene_object &SceneObject)
102 const auto &component_json = Json.find(
typeid(Tcomponent).name());
103 if (component_json == Json.end())
return;
105 Tcomponent component {};
106 if (
from_json(*component_json, component))
decltype(auto) AddComponent(Targs &&... Args)
const bool HasComponent() const
static void Serialize(const shared< scene > &Scene, const std::filesystem::path &OutFileName)
static void Deserialize(shared< scene > &Scene, const std::filesystem::path &InFileName)
Application scene objects system components include module.
void to_json(json &Json, const vec2< T > &Vector)
void from_json(const json &Json, vec2< T > &Vector)
std::shared_ptr< T > shared
void to_json(json &Json, const name_component &NameComponent)
bool from_json(const json &Json, name_component &NameComponent)
Scene class defintion module.
Application scene object class defintion module.