43 if (
element.contains(
"upper_limit"))
45 if (
element.contains(
"index_of_refraction"))
48 if (
element.contains(
"rayleigh_concentration"))
50 if (
element.contains(
"rayleigh_scale_height"))
53 if (
element.contains(
"mie_concentration"))
55 if (
element.contains(
"mie_scale_height"))
57 if (
element.contains(
"mie_anisotropy"))
59 if (
element.contains(
"mie_albedo"))
62 if (
element.contains(
"ozone_concentration"))
64 if (
element.contains(
"ozone_lower_limit"))
66 if (
element.contains(
"ozone_upper_limit"))
68 if (
element.contains(
"ozone_mode"))
71 if (
element.contains(
"airglow_luminance"))
73 const auto& airglow_luminance =
element[
"airglow_luminance"];
81 [component](entt::handle& handle)
83 handle.emplace_or_replace<decltype(component)>(component);
95 if (
element.contains(
"temperature"))
100 [component](entt::handle& handle)
102 handle.emplace_or_replace<decltype(component)>(component);
113 if (
element.contains(
"radius"))
117 if (
element.contains(
"pole_ra"))
120 auto& pole_ra_element =
element[
"pole_ra"];
121 for (
auto it = pole_ra_element.rbegin(); it != pole_ra_element.rend(); ++it)
124 if (
element.contains(
"pole_dec"))
127 auto& pole_dec_element =
element[
"pole_dec"];
128 for (
auto it = pole_dec_element.rbegin(); it != pole_dec_element.rend(); ++it)
131 if (
element.contains(
"prime_meridian"))
134 auto& prime_meridian_element =
element[
"prime_meridian"];
135 for (
auto it = prime_meridian_element.rbegin(); it != prime_meridian_element.rend(); ++it)
138 if (
element.contains(
"albedo"))
141 archetype.
stamps.push_back
143 [component](entt::handle& handle)
145 handle.emplace_or_replace<decltype(component)>(component);
157 if (
element.contains(
"albedo"))
160 archetype.
stamps.push_back
162 [component](entt::handle& handle)
164 handle.emplace_or_replace<decltype(component)>(component);
173 std::shared_ptr<render::model> model;
179 archetype.
stamps.push_back
181 [model](entt::handle& handle)
185 std::make_shared<scene::static_mesh>(model),
186 std::uint8_t{0b00000001}
198 component.
parent = entt::null;
200 component.
scale = 1.0;
203 if (
element.contains(
"ephemeris_index"))
208 archetype.
stamps.push_back
210 [component](entt::handle& handle)
212 handle.emplace_or_replace<decltype(component)>(component);
224 if (
element.contains(
"translation"))
226 auto translation =
element[
"translation"];
232 if (
element.contains(
"rotation"))
234 auto translation =
element[
"rotation"];
243 auto translation =
element[
"scale"];
244 component.
local.
scale.
x() = translation[0].get<
float>();
245 component.
local.
scale.
y() = translation[1].get<
float>();
246 component.
local.
scale.
z() = translation[2].get<
float>();
251 archetype.
stamps.push_back
253 [component](entt::handle& handle)
255 handle.emplace_or_replace<decltype(component)>(component);
264 if (
element.key() ==
"atmosphere")
265 return load_component_atmosphere(archetype,
element.value());
268 if (
element.key() ==
"blackbody")
269 return load_component_blackbody(archetype,
element.value());
270 if (
element.key() ==
"celestial_body")
271 return load_component_celestial_body(archetype,
element.value());
272 if (
element.key() ==
"diffuse_reflector")
273 return load_component_diffuse_reflector(archetype,
element.value());
277 return load_component_orbit(archetype,
element.value());
278 if (
element.key() ==
"transform")
279 return load_component_transform(archetype,
element.value());
293 std::unique_ptr<entity::archetype> archetype = std::make_unique<entity::archetype>();
300 throw std::runtime_error(
"Failed to load component \"" +
element.key() +
"\"");
static std::unique_ptr< T > load(::resource_manager &resource_manager, deserialize_context &ctx)
Loads a resource.
Manages the loading, caching, and saving of resources.
std::shared_ptr< T > load(const std::filesystem::path &path)
Loads and caches a resource.
nlohmann::json json
JSON data.
constexpr T radians(T degrees) noexcept
Converts an angle given in degrees to radians.
double mie_albedo
Mie single-scattering albedo.
double ozone_mode
Elevation of the mode of the triangular distribution of ozone particles, in meters.
double upper_limit
Elevation of the upper limit of the atmosphere, in meters.
math::dvec3 airglow_luminance
Airglow luminance, in cd/m^2.
double mie_concentration
Molar concentration of Mie particles at sea level, in mol/m-3.
double rayleigh_concentration
Molar concentration of Rayleigh particles at sea level, in mol/m-3.
double ozone_upper_limit
Elevation of the upper limit of the triangular distribution of ozone particles, in meters.
double ozone_lower_limit
Elevation of the lower limit of the triangular distribution of ozone particles, in meters.
double mie_anisotropy
Mie phase function anisotropy factor.
double ozone_concentration
Concentration of ozone in the atmosphere, unitless.
double index_of_refraction
Index of refraction of air at sea level.
double rayleigh_scale_height
Scale height of the exponential distribution of Rayleigh particles, in meters.
double mie_scale_height
Scale height of the exponential distribution of Mie particles, in meters.
double temperature
Effective temperature, in Kelvin.
std::vector< double > pole_dec
Polynomial coefficients, in descending order of degree, of the declination of the body's north pole,...
double albedo
Geometric albedo.
std::vector< double > prime_meridian
Polynomial coefficients, in descending order of degree, of the rotation state of the body's prime mer...
double mass
Mass of the body, in kilograms.
std::vector< double > pole_ra
Polynomial coefficients, in descending order of degree, of the right ascension of the body's north po...
double radius
Mean radius of the body, in meters.
Provides access to a deserialization state.
std::list< std::function< void(entt::handle &)> > stamps
List of stamp functions which construct instances of the archetype's components.
constexpr scalar_type & w() noexcept
Returns a reference to the quaternion real part.
constexpr scalar_type & y() noexcept
Returns a reference to the second element of the quaternion imaginary part.
constexpr scalar_type & z() noexcept
Returns a reference to the third element of the quaternion imaginary part.
constexpr scalar_type & x() noexcept
Returns a reference to the first element of the quaternion imaginary part.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.
constexpr element_type & z() noexcept
Returns a reference to the third element.
int ephemeris_index
Index of the orbit in the ephemeris.
math::dvec3 position
Cartesian position of the orbit, w.r.t. the ICRF frame.
entity::id parent
Entity ID of the parent orbit.
double scale
Orbit scale, for two-body orbits with one ephemeris item.