-
-void SpriteModel::LoadRect(
- float w, float h,
- const glm::vec2 &pivot,
- const glm::vec2 &tex_begin,
- const glm::vec2 &tex_end
-) {
- Clear();
- Reserve(4, 6);
-
- vertices.emplace_back( -pivot.x, -pivot.y, 0.0f);
- vertices.emplace_back(w-pivot.x, -pivot.y, 0.0f);
- vertices.emplace_back( -pivot.x, h-pivot.y, 0.0f);
- vertices.emplace_back(w-pivot.x, h-pivot.y, 0.0f);
-
- coords.emplace_back(tex_begin.x, tex_begin.y);
- coords.emplace_back(tex_end.x, tex_begin.y);
- coords.emplace_back(tex_begin.x, tex_end.y);
- coords.emplace_back(tex_end.x, tex_end.y);
-
- indices.assign({ 0, 2, 1, 1, 2, 3 });
-
- Invalidate();
+void Skeletons::Load(const ShapeRegistry &shapes, TextureIndex &tex_index) {
+ LoadHeadless();
+ meshes.resize(4);
+ const Shape &shape = shapes.Get("player_head_block");
+ EntityMesh::Buffer buf;
+ std::vector<float> tex_map;
+ tex_map.push_back(tex_index.GetID("rock-1"));
+ tex_map.push_back(tex_index.GetID("rock-face"));
+ buf.Reserve(shape.VertexCount(), shape.IndexCount());
+ {
+ shape.Fill(buf, tex_map);
+ buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f });
+ buf.rgb_mods.resize(shape.VertexCount(), { 1.0f, 1.0f, 0.0f });
+ meshes[0].Update(buf);
+ skeletons[0]->SetNodeMesh(&meshes[0]);
+ }
+ {
+ buf.Clear();
+ shape.Fill(buf, tex_map);
+ buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f });
+ buf.rgb_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f });
+ meshes[1].Update(buf);
+ skeletons[1]->SetNodeMesh(&meshes[1]);
+ }
+ {
+ buf.Clear();
+ shape.Fill(buf, tex_map);
+ buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f });
+ buf.rgb_mods.resize(shape.VertexCount(), { 1.0f, 0.0f, 1.0f });
+ meshes[2].Update(buf);
+ skeletons[2]->SetNodeMesh(&meshes[2]);
+ }
+ {
+ buf.Clear();
+ shape.Fill(buf, tex_map);
+ buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f });
+ buf.rgb_mods.resize(shape.VertexCount(), { 1.0f, 0.25f, 0.5f });
+ meshes[3].Update(buf);
+ skeletons[3]->SetNodeMesh(&meshes[3]);
+ }