]> git.localhorst.tv Git - blank.git/blobdiff - src/model/composite.cpp
split graphics stuff from AI spawner
[blank.git] / src / model / composite.cpp
index 4cf2f12f2aef7be9607e4296754d5879f41acee5..ffb58572eae4bafaceea5f14978a8ec36e7b9089 100644 (file)
@@ -1,7 +1,9 @@
 #include "CompositeModel.hpp"
 #include "CompositeInstance.hpp"
+#include "Skeletons.hpp"
 
 #include "EntityModel.hpp"
+#include "shapes.hpp"
 #include "../graphics/DirectionalLighting.hpp"
 
 #include <glm/gtx/quaternion.hpp>
@@ -99,4 +101,64 @@ void CompositeInstance::Render(const glm::mat4 &M, DirectionalLighting &prog) co
        }
 }
 
+
+Skeletons::Skeletons()
+: skeletons()
+, models() {
+
+}
+
+Skeletons::~Skeletons() {
+
+}
+
+void Skeletons::LoadHeadless() {
+       skeletons.clear();
+       skeletons.reserve(3);
+       {
+               AABB bounds{{ -0.25f, -0.5f, -0.25f }, { 0.25f, 0.5f, 0.25f }};
+               skeletons.emplace_back(new CompositeModel);
+               skeletons[0]->Bounds(bounds);
+       }
+       {
+               AABB bounds{{ -0.5f, -0.25f, -0.5f }, { 0.5f, 0.25f, 0.5f }};
+               skeletons.emplace_back(new CompositeModel);
+               skeletons[1]->Bounds(bounds);
+       }
+       {
+               AABB bounds{{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }};
+               skeletons.emplace_back(new CompositeModel);
+               skeletons[2]->Bounds(bounds);
+       }
+}
+
+void Skeletons::Load() {
+       LoadHeadless();
+       models.resize(3);
+       EntityModel::Buffer buf;
+       {
+               CuboidShape shape(skeletons[0]->Bounds());
+               shape.Vertices(buf, 1.0f);
+               buf.colors.resize(shape.VertexCount(), { 1.0f, 1.0f, 0.0f });
+               models[0].Update(buf);
+               skeletons[0]->SetNodeModel(&models[0]);
+       }
+       {
+               CuboidShape shape(skeletons[1]->Bounds());
+               buf.Clear();
+               shape.Vertices(buf, 2.0f);
+               buf.colors.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f });
+               models[1].Update(buf);
+               skeletons[1]->SetNodeModel(&models[1]);
+       }
+       {
+               StairShape shape(skeletons[2]->Bounds(), { 0.4f, 0.4f });
+               buf.Clear();
+               shape.Vertices(buf, 3.0f);
+               buf.colors.resize(shape.VertexCount(), { 1.0f, 0.0f, 1.0f });
+               models[2].Update(buf);
+               skeletons[2]->SetNodeModel(&models[2]);
+       }
+}
+
 }