]> git.localhorst.tv Git - blank.git/blobdiff - src/model/Model.hpp
(data) shape prototype
[blank.git] / src / model / Model.hpp
index 95ad086402a6c58838012b0c9102350538cb9499..118ac2e2004d723d0351c9a458a705006a562bcd 100644 (file)
@@ -1,76 +1,66 @@
 #ifndef BLANK_MODEL_MODEL_HPP_
 #define BLANK_MODEL_MODEL_HPP_
 
-#include <vector>
-#include <GL/glew.h>
+#include "geometry.hpp"
+
+#include <cstdint>
+#include <list>
 #include <glm/glm.hpp>
+#include <glm/gtc/quaternion.hpp>
 
 
 namespace blank {
 
+class Instance;
+class EntityMesh;
+
 class Model {
 
 public:
-       using Position = glm::vec3;
-       using Color = glm::vec3;
-       using Normal = glm::vec3;
-       using Index = unsigned int;
+       Model();
 
-       using Positions = std::vector<Position>;
-       using Colors = std::vector<Color>;
-       using Normals = std::vector<Normal>;
-       using Indices = std::vector<Index>;
+       Model(const Model &) = delete;
+       Model &operator =(const Model &) = delete;
 
-public:
-       struct Buffer {
+       std::uint32_t ID() const noexcept { return id; }
+       void ID(std::uint32_t i) noexcept { id = i; }
 
-               Positions vertices;
-               Colors colors;
-               Normals normals;
-               Indices indices;
+       const AABB &Bounds() const noexcept { return bounds; }
+       void Bounds(const AABB &b) noexcept { bounds = b; }
 
-               void Clear() noexcept {
-                       vertices.clear();
-                       colors.clear();
-                       normals.clear();
-                       indices.clear();
-               }
+       const glm::vec3 &Position() const noexcept { return position; }
+       void Position(const glm::vec3 &p) noexcept { position = p; }
 
-               void Reserve(size_t p, size_t i) {
-                       vertices.reserve(p);
-                       colors.reserve(p);
-                       normals.reserve(p);
-                       indices.reserve(i);
-               }
+       const glm::quat &Orientation() const noexcept { return orientation; }
+       void Orientation(const glm::quat &o) noexcept { orientation = o; }
 
-       };
+       bool HasNodeMesh() const noexcept { return node_mesh; }
+       void SetNodeMesh(const EntityMesh *m) noexcept { node_mesh = m; }
 
-public:
-       Model() noexcept;
-       ~Model() noexcept;
+       const EntityMesh &NodeMesh() const noexcept { return *node_mesh; }
 
-       Model(const Model &) = delete;
-       Model &operator =(const Model &) = delete;
-
-       Model(Model &&) noexcept;
-       Model &operator =(Model &&) noexcept;
+       Model &AddPart();
+       bool HasParent() const noexcept { return parent; }
+       Model &Parent() const noexcept { return *parent; }
+       bool IsRoot() const noexcept { return !HasParent(); }
 
-       void Update(const Buffer &) noexcept;
+       glm::mat4 LocalTransform() const noexcept;
+       glm::mat4 GlobalTransform() const noexcept;
 
-       void Draw() const noexcept;
+       void Instantiate(Instance &) const;
 
 private:
-       enum Attribute {
-               ATTRIB_VERTEX,
-               ATTRIB_COLOR,
-               ATTRIB_NORMAL,
-               ATTRIB_INDEX,
-               ATTRIB_COUNT,
-       };
-
-       GLuint va;
-       GLuint handle[ATTRIB_COUNT];
-       size_t count;
+       Model *parent;
+       const EntityMesh *node_mesh;
+
+       std::uint32_t id;
+
+       AABB bounds;
+
+       glm::vec3 position;
+       glm::quat orientation;
+
+       std::list<Model> parts;
 
 };