X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2Fmodel.cpp;h=70a1fc233be73a3de3b407ca3abc8ee516a327af;hb=ba55bf4293f3abc742eef710545a4b207ba2c820;hp=987d86c3be4fbcc655324f2da8d8bd6edc989741;hpb=eba29c8ad489194cd1e3cd64b5f23424ad4384ef;p=blank.git diff --git a/src/model/model.cpp b/src/model/model.cpp index 987d86c..70a1fc2 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -2,7 +2,9 @@ #include "Instance.hpp" #include "Skeletons.hpp" -#include "shapes.hpp" +#include "Shape.hpp" +#include "ShapeRegistry.hpp" +#include "../app/TextureIndex.hpp" #include "../graphics/DirectionalLighting.hpp" #include "../graphics/EntityMesh.hpp" @@ -118,66 +120,64 @@ Skeletons::~Skeletons() { void Skeletons::LoadHeadless() { skeletons.clear(); skeletons.reserve(4); + AABB bounds{{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }}; { - AABB bounds{{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }}; skeletons.emplace_back(new Model); skeletons[0]->ID(1); skeletons[0]->Bounds(bounds); } { - AABB bounds{{ -0.5f, -0.25f, -0.5f }, { 0.5f, 0.25f, 0.5f }}; skeletons.emplace_back(new Model); skeletons[1]->ID(2); skeletons[1]->Bounds(bounds); } { - AABB bounds{{ -0.25f, -0.5f, -0.25f }, { 0.25f, 0.5f, 0.25f }}; skeletons.emplace_back(new Model); skeletons[2]->ID(3); skeletons[2]->Bounds(bounds); } { - AABB bounds{{ -0.25f, -0.5f, -0.35f }, { 0.25f, 0.5f, 0.35f }}; skeletons.emplace_back(new Model); skeletons[3]->ID(4); skeletons[3]->Bounds(bounds); } } -void Skeletons::Load() { +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 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()); { - CuboidShape shape(skeletons[0]->Bounds()); - shape.Vertices(buf, 3.0f); + 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]); } { - CuboidShape shape(skeletons[1]->Bounds()); buf.Clear(); - shape.Vertices(buf, 0.0f); + 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]); } { - StairShape shape(skeletons[2]->Bounds(), { 0.4f, 0.4f }); buf.Clear(); - shape.Vertices(buf, 1.0f); + 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]); } { - CuboidShape shape(skeletons[3]->Bounds()); buf.Clear(); - shape.Vertices(buf, 2.0f); + 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);