34 auto ecoregion_element = json_data->find(
"ecoregion");
35 if (ecoregion_element == json_data->end())
36 throw std::runtime_error(
"Invalid ecoregion file.");
39 std::unique_ptr<::ecoregion>
ecoregion = std::make_unique<::ecoregion>();
46 if (
auto element = ecoregion_element->find(
"name");
element != ecoregion_element->end())
49 if (
auto location_element = ecoregion_element->find(
"location"); location_element != ecoregion_element->end())
51 if (
auto element = location_element->find(
"elevation");
element != location_element->end())
53 if (
auto element = location_element->find(
"latitude");
element != location_element->end())
55 if (
auto element = location_element->find(
"longitude");
element != location_element->end())
59 if (
auto terrain_element = ecoregion_element->find(
"terrain"); terrain_element != ecoregion_element->end())
61 if (
auto element = terrain_element->find(
"material");
element != terrain_element->end())
63 if (
auto element = terrain_element->find(
"albedo");
element != terrain_element->end())
65 if (
auto element = terrain_element->find(
"horizon_material");
element != terrain_element->end())
70 if (
auto gene_pools_element = ecoregion_element->find(
"gene_pools"); gene_pools_element != ecoregion_element->end())
73 for (
auto gene_pool_element = gene_pools_element->begin(); gene_pool_element != gene_pools_element->end(); ++gene_pool_element)
80 if (
auto name_element = gene_pool_element->find(
"name"); name_element != gene_pool_element->end())
81 gene_pool.
name = name_element->get<std::string>();
84 if (
auto genes_element = gene_pool_element->find(
"genes"); genes_element != gene_pool_element->end())
87 if (
auto antennae_elements = genes_element->find(
"antennae"); antennae_elements != genes_element->end())
89 for (
auto antennae_element = antennae_elements->begin(); antennae_element != antennae_elements->end(); ++antennae_element)
92 std::shared_ptr<ant_antennae_gene> gene;
94 if (
auto weight_element = antennae_element->find(
"weight"); weight_element != antennae_element->end())
95 weight = weight_element->get<
float>();
96 if (
auto gene_element = antennae_element->find(
"gene"); gene_element != antennae_element->end())
101 gene_pool.
antennae.weights.push_back(weight);
102 gene_pool.
antennae.genes.push_back(gene);
108 if (
auto body_size_elements = genes_element->find(
"body_size"); body_size_elements != genes_element->end())
110 for (
auto body_size_element = body_size_elements->begin(); body_size_element != body_size_elements->end(); ++body_size_element)
113 std::shared_ptr<ant_body_size_gene> gene;
115 if (
auto weight_element = body_size_element->find(
"weight"); weight_element != body_size_element->end())
116 weight = weight_element->get<
float>();
117 if (
auto gene_element = body_size_element->find(
"gene"); gene_element != body_size_element->end())
122 gene_pool.
body_size.weights.push_back(weight);
123 gene_pool.
body_size.genes.push_back(gene);
129 if (
auto pupa_elements = genes_element->find(
"pupa"); pupa_elements != genes_element->end())
131 for (
auto pupa_element = pupa_elements->begin(); pupa_element != pupa_elements->end(); ++pupa_element)
134 std::shared_ptr<ant_pupa_gene> gene;
136 if (
auto weight_element = pupa_element->find(
"weight"); weight_element != pupa_element->end())
137 weight = weight_element->get<
float>();
138 if (
auto gene_element = pupa_element->find(
"gene"); gene_element != pupa_element->end())
143 gene_pool.
pupa.weights.push_back(weight);
144 gene_pool.
pupa.genes.push_back(gene);
150 if (
auto diet_elements = genes_element->find(
"diet"); diet_elements != genes_element->end())
152 for (
auto diet_element = diet_elements->begin(); diet_element != diet_elements->end(); ++diet_element)
155 std::shared_ptr<ant_diet_gene> gene;
157 if (
auto weight_element = diet_element->find(
"weight"); weight_element != diet_element->end())
158 weight = weight_element->get<
float>();
159 if (
auto gene_element = diet_element->find(
"gene"); gene_element != diet_element->end())
164 gene_pool.
diet.weights.push_back(weight);
165 gene_pool.
diet.genes.push_back(gene);
171 if (
auto egg_elements = genes_element->find(
"egg"); egg_elements != genes_element->end())
173 for (
auto egg_element = egg_elements->begin(); egg_element != egg_elements->end(); ++egg_element)
176 std::shared_ptr<ant_egg_gene> gene;
178 if (
auto weight_element = egg_element->find(
"weight"); weight_element != egg_element->end())
179 weight = weight_element->get<
float>();
180 if (
auto gene_element = egg_element->find(
"gene"); gene_element != egg_element->end())
185 gene_pool.
egg.weights.push_back(weight);
186 gene_pool.
egg.genes.push_back(gene);
192 if (
auto eyes_elements = genes_element->find(
"eyes"); eyes_elements != genes_element->end())
194 for (
auto eyes_element = eyes_elements->begin(); eyes_element != eyes_elements->end(); ++eyes_element)
197 std::shared_ptr<ant_eyes_gene> gene;
199 if (
auto weight_element = eyes_element->find(
"weight"); weight_element != eyes_element->end())
200 weight = weight_element->get<
float>();
201 if (
auto gene_element = eyes_element->find(
"gene"); gene_element != eyes_element->end())
206 gene_pool.
eyes.weights.push_back(weight);
207 gene_pool.
eyes.genes.push_back(gene);
213 if (
auto foraging_time_elements = genes_element->find(
"foraging_time"); foraging_time_elements != genes_element->end())
215 for (
auto foraging_time_element = foraging_time_elements->begin(); foraging_time_element != foraging_time_elements->end(); ++foraging_time_element)
218 std::shared_ptr<ant_foraging_time_gene> gene;
220 if (
auto weight_element = foraging_time_element->find(
"weight"); weight_element != foraging_time_element->end())
221 weight = weight_element->get<
float>();
222 if (
auto gene_element = foraging_time_element->find(
"gene"); gene_element != foraging_time_element->end())
234 if (
auto founding_mode_elements = genes_element->find(
"founding_mode"); founding_mode_elements != genes_element->end())
236 for (
auto founding_mode_element = founding_mode_elements->begin(); founding_mode_element != founding_mode_elements->end(); ++founding_mode_element)
239 std::shared_ptr<ant_founding_mode_gene> gene;
241 if (
auto weight_element = founding_mode_element->find(
"weight"); weight_element != founding_mode_element->end())
242 weight = weight_element->get<
float>();
243 if (
auto gene_element = founding_mode_element->find(
"gene"); gene_element != founding_mode_element->end())
255 if (
auto gaster_elements = genes_element->find(
"gaster"); gaster_elements != genes_element->end())
257 for (
auto gaster_element = gaster_elements->begin(); gaster_element != gaster_elements->end(); ++gaster_element)
260 std::shared_ptr<ant_gaster_gene> gene;
262 if (
auto weight_element = gaster_element->find(
"weight"); weight_element != gaster_element->end())
263 weight = weight_element->get<
float>();
264 if (
auto gene_element = gaster_element->find(
"gene"); gene_element != gaster_element->end())
269 gene_pool.
gaster.weights.push_back(weight);
270 gene_pool.
gaster.genes.push_back(gene);
276 if (
auto head_elements = genes_element->find(
"head"); head_elements != genes_element->end())
278 for (
auto head_element = head_elements->begin(); head_element != head_elements->end(); ++head_element)
281 std::shared_ptr<ant_head_gene> gene;
283 if (
auto weight_element = head_element->find(
"weight"); weight_element != head_element->end())
284 weight = weight_element->get<
float>();
285 if (
auto gene_element = head_element->find(
"gene"); gene_element != head_element->end())
290 gene_pool.
head.weights.push_back(weight);
291 gene_pool.
head.genes.push_back(gene);
297 if (
auto larva_elements = genes_element->find(
"larva"); larva_elements != genes_element->end())
299 for (
auto larva_element = larva_elements->begin(); larva_element != larva_elements->end(); ++larva_element)
302 std::shared_ptr<ant_larva_gene> gene;
304 if (
auto weight_element = larva_element->find(
"weight"); weight_element != larva_element->end())
305 weight = weight_element->get<
float>();
306 if (
auto gene_element = larva_element->find(
"gene"); gene_element != larva_element->end())
311 gene_pool.
larva.weights.push_back(weight);
312 gene_pool.
larva.genes.push_back(gene);
318 if (
auto legs_elements = genes_element->find(
"legs"); legs_elements != genes_element->end())
320 for (
auto legs_element = legs_elements->begin(); legs_element != legs_elements->end(); ++legs_element)
323 std::shared_ptr<ant_legs_gene> gene;
325 if (
auto weight_element = legs_element->find(
"weight"); weight_element != legs_element->end())
326 weight = weight_element->get<
float>();
327 if (
auto gene_element = legs_element->find(
"gene"); gene_element != legs_element->end())
332 gene_pool.
legs.weights.push_back(weight);
333 gene_pool.
legs.genes.push_back(gene);
339 if (
auto mandibles_elements = genes_element->find(
"mandibles"); mandibles_elements != genes_element->end())
341 for (
auto mandibles_element = mandibles_elements->begin(); mandibles_element != mandibles_elements->end(); ++mandibles_element)
344 std::shared_ptr<ant_mandibles_gene> gene;
346 if (
auto weight_element = mandibles_element->find(
"weight"); weight_element != mandibles_element->end())
347 weight = weight_element->get<
float>();
348 if (
auto gene_element = mandibles_element->find(
"gene"); gene_element != mandibles_element->end())
353 gene_pool.
mandibles.weights.push_back(weight);
354 gene_pool.
mandibles.genes.push_back(gene);
360 if (
auto mesosoma_elements = genes_element->find(
"mesosoma"); mesosoma_elements != genes_element->end())
362 for (
auto mesosoma_element = mesosoma_elements->begin(); mesosoma_element != mesosoma_elements->end(); ++mesosoma_element)
365 std::shared_ptr<ant_mesosoma_gene> gene;
367 if (
auto weight_element = mesosoma_element->find(
"weight"); weight_element != mesosoma_element->end())
368 weight = weight_element->get<
float>();
369 if (
auto gene_element = mesosoma_element->find(
"gene"); gene_element != mesosoma_element->end())
374 gene_pool.
mesosoma.weights.push_back(weight);
375 gene_pool.
mesosoma.genes.push_back(gene);
381 if (
auto nest_site_elements = genes_element->find(
"nest_site"); nest_site_elements != genes_element->end())
383 for (
auto nest_site_element = nest_site_elements->begin(); nest_site_element != nest_site_elements->end(); ++nest_site_element)
386 std::shared_ptr<ant_nest_site_gene> gene;
388 if (
auto weight_element = nest_site_element->find(
"weight"); weight_element != nest_site_element->end())
389 weight = weight_element->get<
float>();
390 if (
auto gene_element = nest_site_element->find(
"gene"); gene_element != nest_site_element->end())
395 gene_pool.
nest_site.weights.push_back(weight);
396 gene_pool.
nest_site.genes.push_back(gene);
402 if (
auto ocelli_elements = genes_element->find(
"ocelli"); ocelli_elements != genes_element->end())
404 for (
auto ocelli_element = ocelli_elements->begin(); ocelli_element != ocelli_elements->end(); ++ocelli_element)
407 std::shared_ptr<ant_ocelli_gene> gene;
409 if (
auto weight_element = ocelli_element->find(
"weight"); weight_element != ocelli_element->end())
410 weight = weight_element->get<
float>();
411 if (
auto gene_element = ocelli_element->find(
"gene"); gene_element != ocelli_element->end())
416 gene_pool.
ocelli.weights.push_back(weight);
417 gene_pool.
ocelli.genes.push_back(gene);
423 if (
auto pigmentation_elements = genes_element->find(
"pigmentation"); pigmentation_elements != genes_element->end())
425 for (
auto pigmentation_element = pigmentation_elements->begin(); pigmentation_element != pigmentation_elements->end(); ++pigmentation_element)
428 std::shared_ptr<ant_pigmentation_gene> gene;
430 if (
auto weight_element = pigmentation_element->find(
"weight"); weight_element != pigmentation_element->end())
431 weight = weight_element->get<
float>();
432 if (
auto gene_element = pigmentation_element->find(
"gene"); gene_element != pigmentation_element->end())
444 if (
auto pilosity_elements = genes_element->find(
"pilosity"); pilosity_elements != genes_element->end())
446 for (
auto pilosity_element = pilosity_elements->begin(); pilosity_element != pilosity_elements->end(); ++pilosity_element)
449 std::shared_ptr<ant_pilosity_gene> gene;
451 if (
auto weight_element = pilosity_element->find(
"weight"); weight_element != pilosity_element->end())
452 weight = weight_element->get<
float>();
453 if (
auto gene_element = pilosity_element->find(
"gene"); gene_element != pilosity_element->end())
458 gene_pool.
pilosity.weights.push_back(weight);
459 gene_pool.
pilosity.genes.push_back(gene);
465 if (
auto sculpturing_elements = genes_element->find(
"sculpturing"); sculpturing_elements != genes_element->end())
467 for (
auto sculpturing_element = sculpturing_elements->begin(); sculpturing_element != sculpturing_elements->end(); ++sculpturing_element)
470 std::shared_ptr<ant_sculpturing_gene> gene;
472 if (
auto weight_element = sculpturing_element->find(
"weight"); weight_element != sculpturing_element->end())
473 weight = weight_element->get<
float>();
474 if (
auto gene_element = sculpturing_element->find(
"gene"); gene_element != sculpturing_element->end())
486 if (
auto sting_elements = genes_element->find(
"sting"); sting_elements != genes_element->end())
488 for (
auto sting_element = sting_elements->begin(); sting_element != sting_elements->end(); ++sting_element)
491 std::shared_ptr<ant_sting_gene> gene;
493 if (
auto weight_element = sting_element->find(
"weight"); weight_element != sting_element->end())
494 weight = weight_element->get<
float>();
495 if (
auto gene_element = sting_element->find(
"gene"); gene_element != sting_element->end())
500 gene_pool.
sting.weights.push_back(weight);
501 gene_pool.
sting.genes.push_back(gene);
507 if (
auto waist_elements = genes_element->find(
"waist"); waist_elements != genes_element->end())
509 for (
auto waist_element = waist_elements->begin(); waist_element != waist_elements->end(); ++waist_element)
512 std::shared_ptr<ant_waist_gene> gene;
514 if (
auto weight_element = waist_element->find(
"weight"); weight_element != waist_element->end())
515 weight = weight_element->get<
float>();
516 if (
auto gene_element = waist_element->find(
"gene"); gene_element != waist_element->end())
521 gene_pool.
waist.weights.push_back(weight);
522 gene_pool.
waist.genes.push_back(gene);
528 if (
auto wings_elements = genes_element->find(
"wings"); wings_elements != genes_element->end())
530 for (
auto wings_element = wings_elements->begin(); wings_element != wings_elements->end(); ++wings_element)
533 std::shared_ptr<ant_wings_gene> gene;
535 if (
auto weight_element = wings_element->find(
"weight"); weight_element != wings_element->end())
536 weight = weight_element->get<
float>();
537 if (
auto gene_element = wings_element->find(
"gene"); gene_element != wings_element->end())
542 gene_pool.
wings.weights.push_back(weight);
543 gene_pool.
wings.genes.push_back(gene);
A material is associated with exactly one shader program and contains a set of material properties wh...
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.
constexpr T radians(T degrees) noexcept
Converts an angle given in degrees to radians.
Pool of ant genes from which ant genomes can be generated.
ant_gene_frequency_table< ant_ocelli_gene > ocelli
ant_gene_frequency_table< ant_waist_gene > waist
ant_gene_frequency_table< ant_body_size_gene > body_size
ant_gene_frequency_table< ant_legs_gene > legs
ant_gene_frequency_table< ant_sting_gene > sting
ant_gene_frequency_table< ant_foraging_time_gene > foraging_time
ant_gene_frequency_table< ant_founding_mode_gene > founding_mode
ant_gene_frequency_table< ant_pupa_gene > pupa
ant_gene_frequency_table< ant_pigmentation_gene > pigmentation
ant_gene_frequency_table< ant_mesosoma_gene > mesosoma
ant_gene_frequency_table< ant_mandibles_gene > mandibles
ant_gene_frequency_table< ant_pilosity_gene > pilosity
ant_gene_frequency_table< ant_eyes_gene > eyes
std::string name
Gene pool name.
ant_gene_frequency_table< ant_nest_site_gene > nest_site
ant_gene_frequency_table< ant_larva_gene > larva
ant_gene_frequency_table< ant_diet_gene > diet
ant_gene_frequency_table< ant_antennae_gene > antennae
ant_gene_frequency_table< ant_sculpturing_gene > sculpturing
ant_gene_frequency_table< ant_head_gene > head
ant_gene_frequency_table< ant_egg_gene > egg
ant_gene_frequency_table< ant_gaster_gene > gaster
ant_gene_frequency_table< ant_wings_gene > wings
Ant gene with caste-specific phenes.
Provides access to a deserialization state.
std::string name
Ecoregion name.
std::shared_ptr< render::material > horizon_material
Horizon material.
float latitude
Latitude, in radians.
math::fvec3 terrain_albedo
Terrain albedo.
std::shared_ptr< render::material > terrain_material
Terrain material.
float elevation
Elevation, in meters.
float longitude
Longitude, in radians.
std::vector< ant_gene_pool > gene_pools
Array of gene pools.