Browse Source

Improve morphogenesis handling of waist, rename tarsus segment bones to tarsomere, add _socket suffix to socket bone names

master
C. J. Howard 1 year ago
parent
commit
ffcc806645
12 changed files with 394 additions and 263 deletions
  1. +6
    -6
      src/game/ant/ant-bone-set.hpp
  2. +84
    -77
      src/game/ant/ant-morphogenesis.cpp
  3. +117
    -124
      src/game/ant/ant-skeleton.cpp
  4. +42
    -44
      src/game/ant/ant-skeleton.hpp
  5. +16
    -1
      src/game/ant/genes/ant-antennae-gene.hpp
  6. +8
    -1
      src/game/ant/genes/ant-gaster-gene.hpp
  7. +16
    -1
      src/game/ant/genes/ant-head-gene.hpp
  8. +1
    -0
      src/game/ant/genes/ant-legs-gene.cpp
  9. +57
    -1
      src/game/ant/genes/ant-legs-gene.hpp
  10. +22
    -1
      src/game/ant/genes/ant-mesosoma-gene.hpp
  11. +7
    -4
      src/game/ant/genes/ant-waist-gene.cpp
  12. +18
    -3
      src/game/ant/genes/ant-waist-gene.hpp

+ 6
- 6
src/game/ant/ant-bone-set.hpp View File

@ -32,27 +32,27 @@ struct ant_bone_set
bone_index_type procoxa_l;
bone_index_type profemur_l;
bone_index_type protibia_l;
bone_index_type protarsus_l;
bone_index_type protarsomere1_l;
bone_index_type procoxa_r;
bone_index_type profemur_r;
bone_index_type protibia_r;
bone_index_type protarsus_r;
bone_index_type protarsomere1_r;
bone_index_type mesocoxa_l;
bone_index_type mesofemur_l;
bone_index_type mesotibia_l;
bone_index_type mesotarsus_l;
bone_index_type mesotarsomere1_l;
bone_index_type mesocoxa_r;
bone_index_type mesofemur_r;
bone_index_type mesotibia_r;
bone_index_type mesotarsus_r;
bone_index_type mesotarsomere1_r;
bone_index_type metacoxa_l;
bone_index_type metafemur_l;
bone_index_type metatibia_l;
bone_index_type metatarsus_l;
bone_index_type metatarsomere1_l;
bone_index_type metacoxa_r;
bone_index_type metafemur_r;
bone_index_type metatibia_r;
bone_index_type metatarsus_r;
bone_index_type metatarsomere1_r;
bone_index_type head;
bone_index_type mandible_l;
bone_index_type mandible_r;

+ 84
- 77
src/game/ant/ant-morphogenesis.cpp View File

@ -442,39 +442,42 @@ std::unique_ptr ant_morphogenesis(const ant_phenome& phenome)
// Calculate transformations from part space to body space
const math::transform<float> legs_to_body = math::transform<float>::identity();
const math::transform<float> head_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "head");
const math::transform<float> mandible_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "mandible_l");
const math::transform<float> mandible_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "mandible_r");
const math::transform<float> antenna_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "antenna_l");
const math::transform<float> antenna_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "antenna_r");
const math::transform<float> waist_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "petiole");
const math::transform<float> head_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "head_socket");
const math::transform<float> mandible_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "mandible_socket_l");
const math::transform<float> mandible_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "mandible_socket_r");
const math::transform<float> antenna_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "antenna_socket_l");
const math::transform<float> antenna_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "antenna_socket_r");
const math::transform<float> waist_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "petiole_socket");
math::transform<float> gaster_to_body;
if (phenome.waist->postpetiole_present)
if (phenome.waist->present)
{
gaster_to_body = rest_pose.get_absolute_transform(*bones.postpetiole) * get_bone_transform(waist_skeleton, "gaster");
}
else if (phenome.waist->petiole_present)
{
gaster_to_body = rest_pose.get_absolute_transform(*bones.petiole) * get_bone_transform(waist_skeleton, "gaster");
if (phenome.waist->postpetiole_present)
{
gaster_to_body = rest_pose.get_absolute_transform(*bones.postpetiole) * get_bone_transform(waist_skeleton, "gaster_socket");
}
else
{
gaster_to_body = rest_pose.get_absolute_transform(*bones.petiole) * get_bone_transform(waist_skeleton, "gaster_socket");
}
}
else
{
gaster_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(waist_skeleton, "gaster");
gaster_to_body = waist_to_body;
}
math::transform<float> sting_to_body;
if (phenome.sting->present)
{
sting_to_body = gaster_to_body * get_bone_transform(gaster_skeleton, "sting");
sting_to_body = gaster_to_body * get_bone_transform(gaster_skeleton, "sting_socket");
}
math::transform<float> eye_l_to_body;
math::transform<float> eye_r_to_body;
if (phenome.eyes->present)
{
eye_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "eye_l");
eye_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "eye_r");
eye_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "eye_socket_l");
eye_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "eye_socket_r");
}
math::transform<float> ocellus_l_to_body;
@ -482,12 +485,12 @@ std::unique_ptr ant_morphogenesis(const ant_phenome& phenome)
math::transform<float> ocellus_m_to_body;
if (phenome.ocelli->lateral_ocelli_present)
{
ocellus_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "ocellus_l");
ocellus_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "ocellus_r");
ocellus_l_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "ocellus_socket_l");
ocellus_r_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "ocellus_socket_r");
}
if (phenome.ocelli->median_ocellus_present)
{
ocellus_m_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "ocellus_m");
ocellus_m_to_body = rest_pose.get_absolute_transform(bones.head) * get_bone_transform(head_skeleton, "ocellus_socket_m");
}
math::transform<float> forewing_l_to_body;
@ -496,63 +499,63 @@ std::unique_ptr ant_morphogenesis(const ant_phenome& phenome)
math::transform<float> hindwing_r_to_body;
if (phenome.wings->present)
{
forewing_l_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "forewing_l");
forewing_r_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "forewing_r");
hindwing_l_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "hindwing_l");
hindwing_r_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "hindwing_r");
forewing_l_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "forewing_socket_l");
forewing_r_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "forewing_socket_r");
hindwing_l_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "hindwing_socket_l");
hindwing_r_to_body = rest_pose.get_absolute_transform(bones.mesosoma) * get_bone_transform(mesosoma_skeleton, "hindwing_socket_r");
}
// Build legs vertex reskin map
const std::unordered_map<bone_index_type, std::tuple<bone_index_type, const math::transform<float>*>> legs_reskin_map
{
{*legs_skeleton.get_bone_index("procoxa_l"), {bones.procoxa_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("profemur_l"), {bones.profemur_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protibia_l"), {bones.protibia_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus1_l"), {bones.protarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus2_l"), {bones.protarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus3_l"), {bones.protarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus4_l"), {bones.protarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus5_l"), {bones.protarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("procoxa_r"), {bones.procoxa_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("profemur_r"), {bones.profemur_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protibia_r"), {bones.protibia_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus1_r"), {bones.protarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus2_r"), {bones.protarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus3_r"), {bones.protarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus4_r"), {bones.protarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsus5_r"), {bones.protarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesocoxa_l"), {bones.mesocoxa_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesofemur_l"), {bones.mesofemur_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotibia_l"), {bones.mesotibia_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus1_l"), {bones.mesotarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus2_l"), {bones.mesotarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus3_l"), {bones.mesotarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus4_l"), {bones.mesotarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus5_l"), {bones.mesotarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesocoxa_r"), {bones.mesocoxa_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesofemur_r"), {bones.mesofemur_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotibia_r"), {bones.mesotibia_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus1_r"), {bones.mesotarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus2_r"), {bones.mesotarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus3_r"), {bones.mesotarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus4_r"), {bones.mesotarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsus5_r"), {bones.mesotarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metacoxa_l"), {bones.metacoxa_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metafemur_l"), {bones.metafemur_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatibia_l"), {bones.metatibia_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus1_l"), {bones.metatarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus2_l"), {bones.metatarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus3_l"), {bones.metatarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus4_l"), {bones.metatarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus5_l"), {bones.metatarsus_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metacoxa_r"), {bones.metacoxa_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metafemur_r"), {bones.metafemur_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatibia_r"), {bones.metatibia_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus1_r"), {bones.metatarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus2_r"), {bones.metatarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus3_r"), {bones.metatarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus4_r"), {bones.metatarsus_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsus5_r"), {bones.metatarsus_r, &legs_to_body}}
{*legs_skeleton.get_bone_index("procoxa_l"), {bones.procoxa_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("profemur_l"), {bones.profemur_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protibia_l"), {bones.protibia_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere1_l"), {bones.protarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere2_l"), {bones.protarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere3_l"), {bones.protarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere4_l"), {bones.protarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere5_l"), {bones.protarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("procoxa_r"), {bones.procoxa_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("profemur_r"), {bones.profemur_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protibia_r"), {bones.protibia_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere1_r"), {bones.protarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere2_r"), {bones.protarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere3_r"), {bones.protarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere4_r"), {bones.protarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("protarsomere5_r"), {bones.protarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesocoxa_l"), {bones.mesocoxa_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesofemur_l"), {bones.mesofemur_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotibia_l"), {bones.mesotibia_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere1_l"), {bones.mesotarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere2_l"), {bones.mesotarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere3_l"), {bones.mesotarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere4_l"), {bones.mesotarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere5_l"), {bones.mesotarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesocoxa_r"), {bones.mesocoxa_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesofemur_r"), {bones.mesofemur_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotibia_r"), {bones.mesotibia_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere1_r"), {bones.mesotarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere2_r"), {bones.mesotarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere3_r"), {bones.mesotarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere4_r"), {bones.mesotarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("mesotarsomere5_r"), {bones.mesotarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metacoxa_l"), {bones.metacoxa_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metafemur_l"), {bones.metafemur_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatibia_l"), {bones.metatibia_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere1_l"), {bones.metatarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere2_l"), {bones.metatarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere3_l"), {bones.metatarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere4_l"), {bones.metatarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere5_l"), {bones.metatarsomere1_l, &legs_to_body}},
{*legs_skeleton.get_bone_index("metacoxa_r"), {bones.metacoxa_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metafemur_r"), {bones.metafemur_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatibia_r"), {bones.metatibia_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere1_r"), {bones.metatarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere2_r"), {bones.metatarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere3_r"), {bones.metatarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere4_r"), {bones.metatarsomere1_r, &legs_to_body}},
{*legs_skeleton.get_bone_index("metatarsomere5_r"), {bones.metatarsomere1_r, &legs_to_body}}
};
// Build head vertex reskin map
@ -590,13 +593,14 @@ std::unique_ptr ant_morphogenesis(const ant_phenome& phenome)
// Build waist vertex reskin map
std::unordered_map<bone_index_type, std::tuple<bone_index_type, const math::transform<float>*>> waist_reskin_map;
if (phenome.waist->petiole_present)
if (phenome.waist->present)
{
waist_reskin_map.emplace(*waist_skeleton.get_bone_index("petiole"), std::tuple(*bones.petiole, &waist_to_body));
}
if (phenome.waist->postpetiole_present)
{
waist_reskin_map.emplace(*waist_skeleton.get_bone_index("postpetiole"), std::tuple(*bones.postpetiole, &waist_to_body));
if (phenome.waist->postpetiole_present)
{
waist_reskin_map.emplace(*waist_skeleton.get_bone_index("postpetiole"), std::tuple(*bones.postpetiole, &waist_to_body));
}
}
// Build gaster vertex reskin map
@ -659,7 +663,10 @@ std::unique_ptr ant_morphogenesis(const ant_phenome& phenome)
reskin_vertices(vertex_buffer_data.data() + antennae_vbo_offset, antennae_vertex_count, *position_attribute, *normal_attribute, *tangent_attribute, *bone_index_attribute, antennae_reskin_map);
// Reskin waist vertices
reskin_vertices(vertex_buffer_data.data() + waist_vbo_offset, waist_vertex_count, *position_attribute, *normal_attribute, *tangent_attribute, *bone_index_attribute, waist_reskin_map);
if (phenome.waist->present)
{
reskin_vertices(vertex_buffer_data.data() + waist_vbo_offset, waist_vertex_count, *position_attribute, *normal_attribute, *tangent_attribute, *bone_index_attribute, waist_reskin_map);
}
// Reskin gaster vertices
reskin_vertices(vertex_buffer_data.data() + gaster_vbo_offset, gaster_vertex_count, *position_attribute, *normal_attribute, *tangent_attribute, *bone_index_attribute, gaster_reskin_map);

+ 117
- 124
src/game/ant/ant-skeleton.cpp View File

@ -23,7 +23,6 @@
namespace {
/**
* Generates the rest pose of ant skeleton.
*
@ -51,8 +50,6 @@ void generate_ant_rest_pose(::skeleton& skeleton, const ant_bone_set& bones, con
};
const auto& mesosoma_transform = get_bone_transform(mesosoma_skeleton, "mesosoma");
const auto& head_socket_transform = get_bone_transform(mesosoma_skeleton, "head");
const auto& head_transform = get_bone_transform(head_skeleton, "head");
const auto inverse_mesosoma_transform = math::inverse(mesosoma_transform);
@ -62,64 +59,68 @@ void generate_ant_rest_pose(::skeleton& skeleton, const ant_bone_set& bones, con
skeleton.set_bone_transform(bones.procoxa_l, inverse_mesosoma_transform * get_bone_transform(legs_skeleton, "procoxa_l"));
skeleton.set_bone_transform(bones.profemur_l, get_bone_transform(legs_skeleton, "profemur_l"));
skeleton.set_bone_transform(bones.protibia_l, get_bone_transform(legs_skeleton, "protibia_l"));
skeleton.set_bone_transform(bones.protarsus_l, get_bone_transform(legs_skeleton, "protarsus1_l"));
skeleton.set_bone_transform(bones.protarsomere1_l, get_bone_transform(legs_skeleton, "protarsomere1_l"));
skeleton.set_bone_transform(bones.procoxa_r, inverse_mesosoma_transform * get_bone_transform(legs_skeleton, "procoxa_r"));
skeleton.set_bone_transform(bones.profemur_r, get_bone_transform(legs_skeleton, "profemur_r"));
skeleton.set_bone_transform(bones.protibia_r, get_bone_transform(legs_skeleton, "protibia_r"));
skeleton.set_bone_transform(bones.protarsus_r, get_bone_transform(legs_skeleton, "protarsus1_r"));
skeleton.set_bone_transform(bones.protarsomere1_r, get_bone_transform(legs_skeleton, "protarsomere1_r"));
skeleton.set_bone_transform(bones.mesocoxa_l, inverse_mesosoma_transform * get_bone_transform(legs_skeleton, "mesocoxa_l"));
skeleton.set_bone_transform(bones.mesofemur_l, get_bone_transform(legs_skeleton, "mesofemur_l"));
skeleton.set_bone_transform(bones.mesotibia_l, get_bone_transform(legs_skeleton, "mesotibia_l"));
skeleton.set_bone_transform(bones.mesotarsus_l, get_bone_transform(legs_skeleton, "mesotarsus1_l"));
skeleton.set_bone_transform(bones.mesotarsomere1_l, get_bone_transform(legs_skeleton, "mesotarsomere1_l"));
skeleton.set_bone_transform(bones.mesocoxa_r, inverse_mesosoma_transform * get_bone_transform(legs_skeleton, "mesocoxa_r"));
skeleton.set_bone_transform(bones.mesofemur_r, get_bone_transform(legs_skeleton, "mesofemur_r"));
skeleton.set_bone_transform(bones.mesotibia_r, get_bone_transform(legs_skeleton, "mesotibia_r"));
skeleton.set_bone_transform(bones.mesotarsus_r, get_bone_transform(legs_skeleton, "mesotarsus1_r"));
skeleton.set_bone_transform(bones.mesotarsomere1_r, get_bone_transform(legs_skeleton, "mesotarsomere1_r"));
skeleton.set_bone_transform(bones.metacoxa_l, inverse_mesosoma_transform * get_bone_transform(legs_skeleton, "metacoxa_l"));
skeleton.set_bone_transform(bones.metafemur_l, get_bone_transform(legs_skeleton, "metafemur_l"));
skeleton.set_bone_transform(bones.metatibia_l, get_bone_transform(legs_skeleton, "metatibia_l"));
skeleton.set_bone_transform(bones.metatarsus_l, get_bone_transform(legs_skeleton, "metatarsus1_l"));
skeleton.set_bone_transform(bones.metatarsomere1_l, get_bone_transform(legs_skeleton, "metatarsomere1_l"));
skeleton.set_bone_transform(bones.metacoxa_r, inverse_mesosoma_transform * get_bone_transform(legs_skeleton, "metacoxa_r"));
skeleton.set_bone_transform(bones.metafemur_r, get_bone_transform(legs_skeleton, "metafemur_r"));
skeleton.set_bone_transform(bones.metatibia_r, get_bone_transform(legs_skeleton, "metatibia_r"));
skeleton.set_bone_transform(bones.metatarsus_r, get_bone_transform(legs_skeleton, "metatarsus1_r"));
skeleton.set_bone_transform(bones.metatarsomere1_r, get_bone_transform(legs_skeleton, "metatarsomere1_r"));
skeleton.set_bone_transform(bones.head, head_socket_transform * head_transform);
skeleton.set_bone_transform(bones.mandible_l, get_bone_transform(head_skeleton, "mandible_l") * get_bone_transform(mandibles_skeleton, "mandible_l"));
skeleton.set_bone_transform(bones.mandible_r, get_bone_transform(head_skeleton, "mandible_r") * get_bone_transform(mandibles_skeleton, "mandible_r"));
skeleton.set_bone_transform(bones.antennomere1_l, get_bone_transform(head_skeleton, "antenna_l") * get_bone_transform(antennae_skeleton, "antennomere1_l"));
skeleton.set_bone_transform(bones.head, get_bone_transform(mesosoma_skeleton, "head_socket") * get_bone_transform(head_skeleton, "head"));
skeleton.set_bone_transform(bones.mandible_l, get_bone_transform(head_skeleton, "mandible_socket_l") * get_bone_transform(mandibles_skeleton, "mandible_l"));
skeleton.set_bone_transform(bones.mandible_r, get_bone_transform(head_skeleton, "mandible_socket_r") * get_bone_transform(mandibles_skeleton, "mandible_r"));
skeleton.set_bone_transform(bones.antennomere1_l, get_bone_transform(head_skeleton, "antenna_socket_l") * get_bone_transform(antennae_skeleton, "antennomere1_l"));
skeleton.set_bone_transform(bones.antennomere2_l, get_bone_transform(antennae_skeleton, "antennomere2_l"));
skeleton.set_bone_transform(bones.antennomere1_r, get_bone_transform(head_skeleton, "antenna_r") * get_bone_transform(antennae_skeleton, "antennomere1_r"));
skeleton.set_bone_transform(bones.antennomere1_r, get_bone_transform(head_skeleton, "antenna_socket_r") * get_bone_transform(antennae_skeleton, "antennomere1_r"));
skeleton.set_bone_transform(bones.antennomere2_r, get_bone_transform(antennae_skeleton, "antennomere2_r"));
if (bones.petiole)
if (phenome.waist->present)
{
skeleton.set_bone_transform(*bones.petiole, get_bone_transform(mesosoma_skeleton, "petiole") * get_bone_transform(waist_skeleton, "petiole"));
skeleton.set_bone_transform(*bones.petiole, get_bone_transform(mesosoma_skeleton, "petiole_socket") * get_bone_transform(waist_skeleton, "petiole"));
if (phenome.waist->postpetiole_present)
{
skeleton.set_bone_transform(*bones.postpetiole, get_bone_transform(waist_skeleton, "postpetiole"));
}
skeleton.set_bone_transform(bones.gaster, get_bone_transform(waist_skeleton, "gaster_socket") * get_bone_transform(gaster_skeleton, "gaster"));
}
if (bones.postpetiole)
else
{
skeleton.set_bone_transform(*bones.postpetiole, get_bone_transform(waist_skeleton, "postpetiole"));
skeleton.set_bone_transform(bones.gaster, get_bone_transform(mesosoma_skeleton, "petiole_socket") * get_bone_transform(gaster_skeleton, "gaster"));
}
skeleton.set_bone_transform(bones.gaster, get_bone_transform(waist_skeleton, "gaster") * get_bone_transform(gaster_skeleton, "gaster"));
if (bones.sting)
{
skeleton.set_bone_transform(*bones.sting, get_bone_transform(gaster_skeleton, "sting") * get_bone_transform(*sting_skeleton, "sting"));
skeleton.set_bone_transform(*bones.sting, get_bone_transform(gaster_skeleton, "sting_socket") * get_bone_transform(*sting_skeleton, "sting"));
}
if (bones.forewing_l)
{
skeleton.set_bone_transform(*bones.forewing_l, get_bone_transform(mesosoma_skeleton, "forewing_l") * get_bone_transform(*forewings_skeleton, "forewing_l"));
skeleton.set_bone_transform(*bones.forewing_r, get_bone_transform(mesosoma_skeleton, "forewing_r") * get_bone_transform(*forewings_skeleton, "forewing_r"));
skeleton.set_bone_transform(*bones.hindwing_l, get_bone_transform(mesosoma_skeleton, "hindwing_l") * get_bone_transform(*hindwings_skeleton, "hindwing_l"));
skeleton.set_bone_transform(*bones.hindwing_r, get_bone_transform(mesosoma_skeleton, "hindwing_r") * get_bone_transform(*hindwings_skeleton, "hindwing_r"));
skeleton.set_bone_transform(*bones.forewing_l, get_bone_transform(mesosoma_skeleton, "forewing_l_socket") * get_bone_transform(*forewings_skeleton, "forewing_l"));
skeleton.set_bone_transform(*bones.forewing_r, get_bone_transform(mesosoma_skeleton, "forewing_r_socket") * get_bone_transform(*forewings_skeleton, "forewing_r"));
skeleton.set_bone_transform(*bones.hindwing_l, get_bone_transform(mesosoma_skeleton, "hindwing_l_socket") * get_bone_transform(*hindwings_skeleton, "hindwing_l"));
skeleton.set_bone_transform(*bones.hindwing_r, get_bone_transform(mesosoma_skeleton, "hindwing_r_socket") * get_bone_transform(*hindwings_skeleton, "hindwing_r"));
}
skeleton.update_rest_pose();
@ -159,11 +160,11 @@ void generate_ant_pupa_pose(skeleton& skeleton, const ant_bone_set& bones)
fold_protibia_l.rotation = math::angle_axis(-protibia_fold_angle, float3{1, 0, 0});
fold_protibia_r.rotation = math::angle_axis(-protibia_fold_angle, float3{1, 0, 0});
constexpr float protarsus_fold_angle = math::radians(20.0f);
auto fold_protarsus_l = math::transform<float>::identity();
auto fold_protarsus_r = math::transform<float>::identity();
fold_protarsus_l.rotation = math::angle_axis(-protarsus_fold_angle, float3{1, 0, 0});
fold_protarsus_r.rotation = math::angle_axis(-protarsus_fold_angle, float3{1, 0, 0});
constexpr float protarsomere1_fold_angle = math::radians(20.0f);
auto fold_protarsomere1_l = math::transform<float>::identity();
auto fold_protarsomere1_r = math::transform<float>::identity();
fold_protarsomere1_l.rotation = math::angle_axis(-protarsomere1_fold_angle, float3{1, 0, 0});
fold_protarsomere1_r.rotation = math::angle_axis(-protarsomere1_fold_angle, float3{1, 0, 0});
pupa_pose.set_relative_transform(bones.procoxa_l, rest_pose.get_relative_transform(bones.procoxa_l) * fold_procoxa_l);
pupa_pose.set_relative_transform(bones.procoxa_r, rest_pose.get_relative_transform(bones.procoxa_r) * fold_procoxa_r);
@ -171,8 +172,8 @@ void generate_ant_pupa_pose(skeleton& skeleton, const ant_bone_set& bones)
pupa_pose.set_relative_transform(bones.profemur_r, rest_pose.get_relative_transform(bones.profemur_r) * fold_profemur_r);
pupa_pose.set_relative_transform(bones.protibia_l, rest_pose.get_relative_transform(bones.protibia_l) * fold_protibia_l);
pupa_pose.set_relative_transform(bones.protibia_r, rest_pose.get_relative_transform(bones.protibia_r) * fold_protibia_r);
pupa_pose.set_relative_transform(bones.protarsus_l, rest_pose.get_relative_transform(bones.protarsus_l) * fold_protarsus_l);
pupa_pose.set_relative_transform(bones.protarsus_r, rest_pose.get_relative_transform(bones.protarsus_r) * fold_protarsus_r);
pupa_pose.set_relative_transform(bones.protarsomere1_l, rest_pose.get_relative_transform(bones.protarsomere1_l) * fold_protarsomere1_l);
pupa_pose.set_relative_transform(bones.protarsomere1_r, rest_pose.get_relative_transform(bones.protarsomere1_r) * fold_protarsomere1_r);
}
// Fold midlegs
@ -197,11 +198,11 @@ void generate_ant_pupa_pose(skeleton& skeleton, const ant_bone_set& bones)
fold_mesotibia_l.rotation = math::angle_axis(-mesotibia_fold_angle, float3{1, 0, 0});
fold_mesotibia_r.rotation = math::angle_axis(-mesotibia_fold_angle, float3{1, 0, 0});
constexpr float mesotarsus_fold_angle = math::radians(20.0f);
auto fold_mesotarsus_l = math::transform<float>::identity();
auto fold_mesotarsus_r = math::transform<float>::identity();
fold_mesotarsus_l.rotation = math::angle_axis(-mesotarsus_fold_angle, float3{1, 0, 0});
fold_mesotarsus_r.rotation = math::angle_axis(-mesotarsus_fold_angle, float3{1, 0, 0});
constexpr float mesotarsomere1_fold_angle = math::radians(20.0f);
auto fold_mesotarsomere1_l = math::transform<float>::identity();
auto fold_mesotarsomere1_r = math::transform<float>::identity();
fold_mesotarsomere1_l.rotation = math::angle_axis(-mesotarsomere1_fold_angle, float3{1, 0, 0});
fold_mesotarsomere1_r.rotation = math::angle_axis(-mesotarsomere1_fold_angle, float3{1, 0, 0});
pupa_pose.set_relative_transform(bones.mesocoxa_l, rest_pose.get_relative_transform(bones.mesocoxa_l) * fold_mesocoxa_l);
pupa_pose.set_relative_transform(bones.mesocoxa_r, rest_pose.get_relative_transform(bones.mesocoxa_r) * fold_mesocoxa_r);
@ -209,8 +210,8 @@ void generate_ant_pupa_pose(skeleton& skeleton, const ant_bone_set& bones)
pupa_pose.set_relative_transform(bones.mesofemur_r, rest_pose.get_relative_transform(bones.mesofemur_r) * fold_mesofemur_r);
pupa_pose.set_relative_transform(bones.mesotibia_l, rest_pose.get_relative_transform(bones.mesotibia_l) * fold_mesotibia_l);
pupa_pose.set_relative_transform(bones.mesotibia_r, rest_pose.get_relative_transform(bones.mesotibia_r) * fold_mesotibia_r);
pupa_pose.set_relative_transform(bones.mesotarsus_l, rest_pose.get_relative_transform(bones.mesotarsus_l) * fold_mesotarsus_l);
pupa_pose.set_relative_transform(bones.mesotarsus_r, rest_pose.get_relative_transform(bones.mesotarsus_r) * fold_mesotarsus_r);
pupa_pose.set_relative_transform(bones.mesotarsomere1_l, rest_pose.get_relative_transform(bones.mesotarsomere1_l) * fold_mesotarsomere1_l);
pupa_pose.set_relative_transform(bones.mesotarsomere1_r, rest_pose.get_relative_transform(bones.mesotarsomere1_r) * fold_mesotarsomere1_r);
}
// Fold hindlegs
@ -235,11 +236,11 @@ void generate_ant_pupa_pose(skeleton& skeleton, const ant_bone_set& bones)
fold_metatibia_l.rotation = math::angle_axis(-metatibia_fold_angle, float3{1, 0, 0});
fold_metatibia_r.rotation = math::angle_axis(-metatibia_fold_angle, float3{1, 0, 0});
constexpr float metatarsus_fold_angle = math::radians(0.0f);
auto fold_metatarsus_l = math::transform<float>::identity();
auto fold_metatarsus_r = math::transform<float>::identity();
fold_metatarsus_l.rotation = math::angle_axis(-metatarsus_fold_angle, float3{1, 0, 0});
fold_metatarsus_r.rotation = math::angle_axis(-metatarsus_fold_angle, float3{1, 0, 0});
constexpr float metatarsomere1_fold_angle = math::radians(0.0f);
auto fold_metatarsomere1_l = math::transform<float>::identity();
auto fold_metatarsomere1_r = math::transform<float>::identity();
fold_metatarsomere1_l.rotation = math::angle_axis(-metatarsomere1_fold_angle, float3{1, 0, 0});
fold_metatarsomere1_r.rotation = math::angle_axis(-metatarsomere1_fold_angle, float3{1, 0, 0});
pupa_pose.set_relative_transform(bones.metacoxa_l, rest_pose.get_relative_transform(bones.metacoxa_l) * fold_metacoxa_l);
pupa_pose.set_relative_transform(bones.metacoxa_r, rest_pose.get_relative_transform(bones.metacoxa_r) * fold_metacoxa_r);
@ -247,8 +248,8 @@ void generate_ant_pupa_pose(skeleton& skeleton, const ant_bone_set& bones)
pupa_pose.set_relative_transform(bones.metafemur_r, rest_pose.get_relative_transform(bones.metafemur_r) * fold_metafemur_r);
pupa_pose.set_relative_transform(bones.metatibia_l, rest_pose.get_relative_transform(bones.metatibia_l) * fold_metatibia_l);
pupa_pose.set_relative_transform(bones.metatibia_r, rest_pose.get_relative_transform(bones.metatibia_r) * fold_metatibia_r);
pupa_pose.set_relative_transform(bones.metatarsus_l, rest_pose.get_relative_transform(bones.metatarsus_l) * fold_metatarsus_l);
pupa_pose.set_relative_transform(bones.metatarsus_r, rest_pose.get_relative_transform(bones.metatarsus_r) * fold_metatarsus_r);
pupa_pose.set_relative_transform(bones.metatarsomere1_l, rest_pose.get_relative_transform(bones.metatarsomere1_l) * fold_metatarsomere1_l);
pupa_pose.set_relative_transform(bones.metatarsomere1_r, rest_pose.get_relative_transform(bones.metatarsomere1_r) * fold_metatarsomere1_r);
}
// Fold head
@ -332,27 +333,27 @@ void generate_ant_skeleton(skeleton& skeleton, ant_bone_set& bones, const ant_ph
bones.procoxa_l = ++bone_index;
bones.profemur_l = ++bone_index;
bones.protibia_l = ++bone_index;
bones.protarsus_l = ++bone_index;
bones.protarsomere1_l = ++bone_index;
bones.procoxa_r = ++bone_index;
bones.profemur_r = ++bone_index;
bones.protibia_r = ++bone_index;
bones.protarsus_r = ++bone_index;
bones.protarsomere1_r = ++bone_index;
bones.mesocoxa_l = ++bone_index;
bones.mesofemur_l = ++bone_index;
bones.mesotibia_l = ++bone_index;
bones.mesotarsus_l = ++bone_index;
bones.mesotarsomere1_l = ++bone_index;
bones.mesocoxa_r = ++bone_index;
bones.mesofemur_r = ++bone_index;
bones.mesotibia_r = ++bone_index;
bones.mesotarsus_r = ++bone_index;
bones.mesotarsomere1_r = ++bone_index;
bones.metacoxa_l = ++bone_index;
bones.metafemur_l = ++bone_index;
bones.metatibia_l = ++bone_index;
bones.metatarsus_l = ++bone_index;
bones.metatarsomere1_l = ++bone_index;
bones.metacoxa_r = ++bone_index;
bones.metafemur_r = ++bone_index;
bones.metatibia_r = ++bone_index;
bones.metatarsus_r = ++bone_index;
bones.metatarsomere1_r = ++bone_index;
bones.head = ++bone_index;
bones.mandible_l = ++bone_index;
bones.mandible_r = ++bone_index;
@ -361,14 +362,14 @@ void generate_ant_skeleton(skeleton& skeleton, ant_bone_set& bones, const ant_ph
bones.antennomere1_r = ++bone_index;
bones.antennomere2_r = ++bone_index;
if (phenome.waist->petiole_present)
if (phenome.waist->present)
{
bones.petiole = ++bone_index;
}
if (phenome.waist->postpetiole_present)
{
bones.postpetiole = ++bone_index;
if (phenome.waist->postpetiole_present)
{
bones.postpetiole = ++bone_index;
}
}
bones.gaster = ++bone_index;
@ -390,69 +391,56 @@ void generate_ant_skeleton(skeleton& skeleton, ant_bone_set& bones, const ant_ph
skeleton.add_bones(bone_index + 1);
// Assign bone parents
skeleton.set_bone_parent(bones.mesosoma, bones.mesosoma);
skeleton.set_bone_parent(bones.procoxa_l, bones.mesosoma);
skeleton.set_bone_parent(bones.profemur_l, bones.procoxa_l);
skeleton.set_bone_parent(bones.protibia_l, bones.profemur_l);
skeleton.set_bone_parent(bones.protarsus_l, bones.protibia_l);
skeleton.set_bone_parent(bones.procoxa_r, bones.mesosoma);
skeleton.set_bone_parent(bones.profemur_r, bones.procoxa_r);
skeleton.set_bone_parent(bones.protibia_r, bones.profemur_r);
skeleton.set_bone_parent(bones.protarsus_r, bones.protibia_r);
skeleton.set_bone_parent(bones.mesocoxa_l, bones.mesosoma);
skeleton.set_bone_parent(bones.mesofemur_l, bones.mesocoxa_l);
skeleton.set_bone_parent(bones.mesotibia_l, bones.mesofemur_l);
skeleton.set_bone_parent(bones.mesotarsus_l, bones.mesotibia_l);
skeleton.set_bone_parent(bones.mesocoxa_r, bones.mesosoma);
skeleton.set_bone_parent(bones.mesofemur_r, bones.mesocoxa_r);
skeleton.set_bone_parent(bones.mesotibia_r, bones.mesofemur_r);
skeleton.set_bone_parent(bones.mesotarsus_r, bones.mesotibia_r);
skeleton.set_bone_parent(bones.metacoxa_l, bones.mesosoma);
skeleton.set_bone_parent(bones.metafemur_l, bones.metacoxa_l);
skeleton.set_bone_parent(bones.metatibia_l, bones.metafemur_l);
skeleton.set_bone_parent(bones.metatarsus_l, bones.metatibia_l);
skeleton.set_bone_parent(bones.metacoxa_r, bones.mesosoma);
skeleton.set_bone_parent(bones.metafemur_r, bones.metacoxa_r);
skeleton.set_bone_parent(bones.metatibia_r, bones.metafemur_r);
skeleton.set_bone_parent(bones.metatarsus_r, bones.metatibia_r);
skeleton.set_bone_parent(bones.head, bones.mesosoma);
skeleton.set_bone_parent(bones.mandible_l, bones.head);
skeleton.set_bone_parent(bones.mandible_r, bones.head);
skeleton.set_bone_parent(bones.antennomere1_l, bones.head);
skeleton.set_bone_parent(bones.antennomere2_l, bones.antennomere1_l);
skeleton.set_bone_parent(bones.antennomere1_r, bones.head);
skeleton.set_bone_parent(bones.antennomere2_r, bones.antennomere1_r);
if (bones.petiole)
skeleton.set_bone_parent(bones.mesosoma, bones.mesosoma);
skeleton.set_bone_parent(bones.procoxa_l, bones.mesosoma);
skeleton.set_bone_parent(bones.profemur_l, bones.procoxa_l);
skeleton.set_bone_parent(bones.protibia_l, bones.profemur_l);
skeleton.set_bone_parent(bones.protarsomere1_l, bones.protibia_l);
skeleton.set_bone_parent(bones.procoxa_r, bones.mesosoma);
skeleton.set_bone_parent(bones.profemur_r, bones.procoxa_r);
skeleton.set_bone_parent(bones.protibia_r, bones.profemur_r);
skeleton.set_bone_parent(bones.protarsomere1_r, bones.protibia_r);
skeleton.set_bone_parent(bones.mesocoxa_l, bones.mesosoma);
skeleton.set_bone_parent(bones.mesofemur_l, bones.mesocoxa_l);
skeleton.set_bone_parent(bones.mesotibia_l, bones.mesofemur_l);
skeleton.set_bone_parent(bones.mesotarsomere1_l, bones.mesotibia_l);
skeleton.set_bone_parent(bones.mesocoxa_r, bones.mesosoma);
skeleton.set_bone_parent(bones.mesofemur_r, bones.mesocoxa_r);
skeleton.set_bone_parent(bones.mesotibia_r, bones.mesofemur_r);
skeleton.set_bone_parent(bones.mesotarsomere1_r, bones.mesotibia_r);
skeleton.set_bone_parent(bones.metacoxa_l, bones.mesosoma);
skeleton.set_bone_parent(bones.metafemur_l, bones.metacoxa_l);
skeleton.set_bone_parent(bones.metatibia_l, bones.metafemur_l);
skeleton.set_bone_parent(bones.metatarsomere1_l, bones.metatibia_l);
skeleton.set_bone_parent(bones.metacoxa_r, bones.mesosoma);
skeleton.set_bone_parent(bones.metafemur_r, bones.metacoxa_r);
skeleton.set_bone_parent(bones.metatibia_r, bones.metafemur_r);
skeleton.set_bone_parent(bones.metatarsomere1_r, bones.metatibia_r);
skeleton.set_bone_parent(bones.head, bones.mesosoma);
skeleton.set_bone_parent(bones.mandible_l, bones.head);
skeleton.set_bone_parent(bones.mandible_r, bones.head);
skeleton.set_bone_parent(bones.antennomere1_l, bones.head);
skeleton.set_bone_parent(bones.antennomere2_l, bones.antennomere1_l);
skeleton.set_bone_parent(bones.antennomere1_r, bones.head);
skeleton.set_bone_parent(bones.antennomere2_r, bones.antennomere1_r);
if (phenome.waist->present)
{
skeleton.set_bone_parent(*bones.petiole, bones.mesosoma);
}
if (bones.postpetiole)
{
if (bones.petiole)
if (phenome.waist->postpetiole_present)
{
skeleton.set_bone_parent(*bones.postpetiole, *bones.petiole);
skeleton.set_bone_parent(bones.gaster, *bones.postpetiole);
}
else
{
skeleton.set_bone_parent(*bones.postpetiole, bones.mesosoma);
skeleton.set_bone_parent(bones.gaster, *bones.petiole);
}
}
if (bones.postpetiole)
{
skeleton.set_bone_parent(bones.gaster, *bones.postpetiole);
}
else
{
if (bones.petiole)
{
skeleton.set_bone_parent(bones.gaster, *bones.petiole);
}
else
{
skeleton.set_bone_parent(bones.gaster, bones.mesosoma);
}
skeleton.set_bone_parent(bones.gaster, bones.mesosoma);
}
if (bones.sting)
@ -473,27 +461,27 @@ void generate_ant_skeleton(skeleton& skeleton, ant_bone_set& bones, const ant_ph
skeleton.set_bone_name(bones.procoxa_l, "procoxa_l");
skeleton.set_bone_name(bones.profemur_l, "profemur_l");
skeleton.set_bone_name(bones.protibia_l, "protibia_l");
skeleton.set_bone_name(bones.protarsus_l, "protarsus_l");
skeleton.set_bone_name(bones.protarsomere1_l, "protarsomere1_l");
skeleton.set_bone_name(bones.procoxa_r, "procoxa_r");
skeleton.set_bone_name(bones.profemur_r, "profemur_r");
skeleton.set_bone_name(bones.protibia_r, "protibia_r");
skeleton.set_bone_name(bones.protarsus_r, "protarsus_r");
skeleton.set_bone_name(bones.protarsomere1_r, "protarsomere1_r");
skeleton.set_bone_name(bones.mesocoxa_l, "mesocoxa_l");
skeleton.set_bone_name(bones.mesofemur_l, "mesofemur_l");
skeleton.set_bone_name(bones.mesotibia_l, "mesotibia_l");
skeleton.set_bone_name(bones.mesotarsus_l, "mesotarsus_l");
skeleton.set_bone_name(bones.mesotarsomere1_l, "mesotarsomere1_l");
skeleton.set_bone_name(bones.mesocoxa_r, "mesocoxa_r");
skeleton.set_bone_name(bones.mesofemur_r, "mesofemur_r");
skeleton.set_bone_name(bones.mesotibia_r, "mesotibia_r");
skeleton.set_bone_name(bones.mesotarsus_r, "mesotarsus_r");
skeleton.set_bone_name(bones.mesotarsomere1_r, "mesotarsomere1_r");
skeleton.set_bone_name(bones.metacoxa_l, "metacoxa_l");
skeleton.set_bone_name(bones.metafemur_l, "metafemur_l");
skeleton.set_bone_name(bones.metatibia_l, "metatibia_l");
skeleton.set_bone_name(bones.metatarsus_l, "metatarsus_l");
skeleton.set_bone_name(bones.metatarsomere1_l, "metatarsomere1_l");
skeleton.set_bone_name(bones.metacoxa_r, "metacoxa_r");
skeleton.set_bone_name(bones.metafemur_r, "metafemur_r");
skeleton.set_bone_name(bones.metatibia_r, "metatibia_r");
skeleton.set_bone_name(bones.metatarsus_r, "metatarsus_r");
skeleton.set_bone_name(bones.metatarsomere1_r, "metatarsomere1_r");
skeleton.set_bone_name(bones.head, "head");
skeleton.set_bone_name(bones.mandible_l, "mandible_l");
skeleton.set_bone_name(bones.mandible_r, "mandible_r");
@ -501,20 +489,25 @@ void generate_ant_skeleton(skeleton& skeleton, ant_bone_set& bones, const ant_ph
skeleton.set_bone_name(bones.antennomere2_l, "antennomere2_l");
skeleton.set_bone_name(bones.antennomere1_r, "antennomere1_r");
skeleton.set_bone_name(bones.antennomere2_r, "antennomere2_r");
if (bones.petiole)
if (phenome.waist->present)
{
skeleton.set_bone_name(*bones.petiole, "petiole");
if (phenome.waist->postpetiole_present)
{
skeleton.set_bone_name(*bones.postpetiole, "postpetiole");
}
}
if (bones.postpetiole)
{
skeleton.set_bone_name(*bones.postpetiole, "postpetiole");
}
skeleton.set_bone_name(bones.gaster, "gaster");
if (bones.sting)
if (phenome.sting->present)
{
skeleton.set_bone_name(*bones.sting, "sting");
}
if (bones.forewing_l)
if (phenome.wings->present)
{
skeleton.set_bone_name(*bones.forewing_l, "forewing_l");
skeleton.set_bone_name(*bones.forewing_r, "forewing_r");

+ 42
- 44
src/game/ant/ant-skeleton.hpp View File

@ -31,56 +31,54 @@
* @param[out] bones Ant bone set.
* @param[in] phenome Ant phenome.
*
* The following bones will always be present:
* The following bone hierarchy will be constructed:
*
* * antennomere1_l
* * antennomere1_r
* * antennomere2_l
* * antennomere2_r
* * gaster
* * head
* * mandible_l
* * mandible_r
* * mesocoxa_l
* * mesocoxa_r
* * mesofemur_l
* * mesofemur_r
* * mesosoma
* * mesotarsus_l
* * mesotarsus_r
* * mesotibia_l
* * mesotibia_r
* * metacoxa_l
* * metacoxa_r
* * metafemur_l
* * metafemur_r
* * metatarsus_l
* * metatarsus_r
* * metatibia_l
* * metatibia_r
* * procoxa_l
* * procoxa_r
* * profemur_l
* * profemur_r
* * protarsus_l
* * protarsus_r
* * protibia_l
* * protibia_r
* * * procoxa_l
* * * * profemur_l
* * * * * protibia_l
* * * * * * protarsomere1_l
* * * procoxa_r
* * * * profemur_r
* * * * * protibia_r
* * * * * * protarsomere1_r
* * * mesocoxa_l
* * * * mesofemur_l
* * * * * mesotibia_l
* * * * * * mesotarsomere1_l
* * * mesocoxa_r
* * * * mesofemur_r
* * * * * mesotibia_r
* * * * * * mesotarsomere1_r
* * * metacoxa_l
* * * * metafemur_l
* * * * * metatibia_l
* * * * * * metatarsomere1_l
* * * metacoxa_r
* * * * metafemur_r
* * * * * metatibia_r
* * * * * * metatarsomere1_r
* * * head
* * * * mandible_l
* * * * mandible_r
* * * * antennomere1_l
* * * * * antennomere2_l
* * * * antennomere1_r
* * * * * antennomere2_r
* * * petiole
* * * * postpetiole
* * * * * gaster
* * * * * * sting
* * * forewing_l
* * * forewing_r
* * * hindwing_l
* * * hindwing_r
*
* The presence of the following bones depend on the ant phenome:
*
* * forewing_l
* * forewing_r
* * hindwing_l
* * hindwing_r
* * petiole
* * postpetiole
* * sting
* : bone presence dependent on phenome.
*
* The following poses will be generated:
*
* * rest pose
* * "pupa"
* * pupa
*/
void generate_ant_skeleton(skeleton& skeleton, ant_bone_set& bones, const ant_phenome& phenome);

+ 16
- 1
src/game/ant/genes/ant-antennae-gene.hpp View File

@ -39,7 +39,22 @@ struct ant_antennae_phene
/// Number of antennal segments that constitute a club.
std::uint8_t club_antennomere_count{0};
/// 3D model of the antennae.
/**
* 3D model of the antennae.
*
* The antennae model skeleton must contain the following bones:
*
* * antennomere1_l
* * * antennomere2_l
* * * * ...
* * * * * antennomere`<n>`_l
* * antennomere1_r
* * * antennomere2_r
* * * * ...
* * * * * antennomere`<n>`_r
*
* Where `<n>` is the total number of antennal segments per antenna.
*/
std::shared_ptr<render::model> model;
};

+ 8
- 1
src/game/ant/genes/ant-gaster-gene.hpp View File

@ -34,7 +34,14 @@ struct ant_gaster_phene
/// Degree of phragmosis.
float phragmosis{0.0f};
/// 3D model of the gaster.
/**
* 3D model of the gaster.
*
* The gaster model skeleton must contain the following bones:
*
* * gaster
* * * sting_socket
*/
std::shared_ptr<render::model> model;
};

+ 16
- 1
src/game/ant/genes/ant-head-gene.hpp View File

@ -41,7 +41,22 @@ struct ant_head_phene
/// Degree of phragmosis.
float phragmosis{0.0f};
/// 3D model of the head.
/**
* 3D model of the head.
*
* The head model skeleton must contain the following bones:
*
* * head
* * * mandible_socket_l
* * * mandible_socket_r
* * * antenna_socket_l
* * * antenna_socket_r
* * * eye_socket_l
* * * eye_socket_r
* * * ocellus_socket_l
* * * ocellus_socket_r
* * * ocellus_socket_m
*/
std::shared_ptr<render::model> model;
};

+ 1
- 0
src/game/ant/genes/ant-legs-gene.cpp View File

@ -27,6 +27,7 @@ namespace {
void load_ant_legs_phene(ant_legs_phene& phene, ::resource_manager& resource_manager, deserialize_context& ctx)
{
ctx.read32<std::endian::little>(reinterpret_cast<std::byte*>(&phene.standing_height), 1);
ctx.read32<std::endian::little>(reinterpret_cast<std::byte*>(&phene.speed), 1);
ctx.read32<std::endian::little>(reinterpret_cast<std::byte*>(&phene.grip), 1);

+ 57
- 1
src/game/ant/genes/ant-legs-gene.hpp View File

@ -31,13 +31,69 @@
*/
struct ant_legs_phene
{
/// Distance from the mesosoma to the ground when standing, in mesosomal lengths.
float standing_height{0.0f};
/// Running speed, in mesosomal lengths per second.
float speed{0.0f};
/// Grip factor.
float grip{0.0f};
/// 3D model of the legs.
/**
* 3D model of the legs.
*
* The legs model skeleton must contain the following bone chains:
*
* * procoxa_l
* * * profemur_l
* * * * protibia_l
* * * * * protarsomere1_l
* * * * * * protarsomere2_l
* * * * * * * protarsomere3_l
* * * * * * * * protarsomere4_l
* * * * * * * * * protarsomere5_l
* * procoxa_r
* * * profemur_r
* * * * protibia_r
* * * * * protarsomere1_r
* * * * * * protarsomere2_r
* * * * * * * protarsomere3_r
* * * * * * * * protarsomere4_r
* * * * * * * * * protarsomere5_r
* * mesocoxa_l
* * * mesofemur_l
* * * * mesotibia_l
* * * * * mesotarsomere1_l
* * * * * * mesotarsomere2_l
* * * * * * * mesotarsomere3_l
* * * * * * * * mesotarsomere4_l
* * * * * * * * * mesotarsomere5_l
* * mesocoxa_r
* * * mesofemur_r
* * * * mesotibia_r
* * * * * mesotarsomere1_r
* * * * * * mesotarsomere2_r
* * * * * * * mesotarsomere3_r
* * * * * * * * mesotarsomere4_r
* * * * * * * * * mesotarsomere5_r
* * metacoxa_l
* * * metafemur_l
* * * * metatibia_l
* * * * * metatarsomere1_l
* * * * * * metatarsomere2_l
* * * * * * * metatarsomere3_l
* * * * * * * * metatarsomere4_l
* * * * * * * * * metatarsomere5_l
* * metacoxa_r
* * * metafemur_r
* * * * metatibia_r
* * * * * metatarsomere1_r
* * * * * * metatarsomere2_r
* * * * * * * metatarsomere3_r
* * * * * * * * metatarsomere4_r
* * * * * * * * * metatarsomere5_r
*/
std::shared_ptr<render::model> model;
};

+ 22
- 1
src/game/ant/genes/ant-mesosoma-gene.hpp View File

@ -43,7 +43,28 @@ struct ant_mesosoma_phene
/// Degree of spinescence on the propodeum.
float propodeum_spinescence{0.0f};
/// 3D model of the mesosoma.
/**
* 3D model of the mesosoma.
*
* The mesosoma model skeleton must contain the following bones:
*
* * mesosoma
* * * head_socket
* * * procoxa_socket_l
* * * procoxa_socket_r
* * * mesocoxa_socket_l
* * * mesocoxa_socket_r
* * * metacoxa_socket_l
* * * metacoxa_socket_r
* * * petiole_socket
*
* In alate phenes, the mesosoma model skeleton must additionally contain the following bones:
*
* * forewing_socket_l
* * forewing_socket_r
* * hindwing_socket_l
* * hindwing_socket_r
*/
std::shared_ptr<render::model> model;
};

+ 7
- 4
src/game/ant/genes/ant-waist-gene.cpp View File

@ -27,9 +27,9 @@ namespace {
void load_ant_waist_phene(ant_waist_phene& phene, ::resource_manager& resource_manager, deserialize_context& ctx)
{
std::uint8_t petiole_present{0};
ctx.read8(reinterpret_cast<std::byte*>(&petiole_present), 1);
phene.petiole_present = static_cast<bool>(petiole_present);
std::uint8_t present{0};
ctx.read8(reinterpret_cast<std::byte*>(&present), 1);
phene.present = static_cast<bool>(present);
ctx.read32<std::endian::little>(reinterpret_cast<std::byte*>(&phene.petiole_length), 1);
ctx.read32<std::endian::little>(reinterpret_cast<std::byte*>(&phene.petiole_width), 1);
@ -50,7 +50,10 @@ void load_ant_waist_phene(ant_waist_phene& phene, ::resource_manager& resource_m
std::string model_filename(model_filename_length, '\0');
ctx.read8(reinterpret_cast<std::byte*>(model_filename.data()), model_filename_length);
phene.model = resource_manager.load<render::model>(model_filename);
if (phene.present)
{
phene.model = resource_manager.load<render::model>(model_filename);
}
}
} // namespace

+ 18
- 3
src/game/ant/genes/ant-waist-gene.hpp View File

@ -31,8 +31,8 @@
*/
struct ant_waist_phene
{
//// Petiole presence.
bool petiole_present{false};
//// Waist presence.
bool present{false};
/// Petiole length, in mesosomal lengths.
float petiole_length{0.0f};
@ -61,7 +61,22 @@ struct ant_waist_phene
/// Degree of postpetiole spinescence
float postpetiole_spinescence{0.0f};
/// 3D model of the waist.
/**
* 3D model of the waist.
*
* If the waist is present, the waist model skeleton can have one of two forms: single-segmented or double-segmented.
*
* If the postpetiole is absent, the waist is single-segmented and its skeleton must contain the following bones:
*
* * petiole
* * * gaster_socket
*
* If the postpetiole is present, the waist is double-segmented and its skeleton must contains the following bones:
*
* * petiole
* * * postpetiole
* * * * gaster_socket
*/
std::shared_ptr<render::model> model;
};

Loading…
Cancel
Save