#ifndef BLANK_MODEL_MODEL_HPP_
#define BLANK_MODEL_MODEL_HPP_
+#include "Part.hpp"
+#include "../graphics/glm.hpp"
+
+#include <cstdint>
+#include <list>
#include <vector>
-#include <GL/glew.h>
-#include <glm/glm.hpp>
+#include <glm/gtc/quaternion.hpp>
namespace blank {
-class Model {
-
-public:
- using Position = glm::vec3;
- using Color = glm::vec3;
- using Normal = glm::vec3;
- using Index = unsigned int;
-
- using Positions = std::vector<Position>;
- using Colors = std::vector<Color>;
- using Normals = std::vector<Normal>;
- using Indices = std::vector<Index>;
-
-public:
- struct Buffer {
+class Instance;
+class EntityMesh;
- Positions vertices;
- Colors colors;
- Normals normals;
- Indices indices;
-
- void Clear() noexcept {
- vertices.clear();
- colors.clear();
- normals.clear();
- indices.clear();
- }
-
- void Reserve(size_t p, size_t i) {
- vertices.reserve(p);
- colors.reserve(p);
- normals.reserve(p);
- indices.reserve(i);
- }
-
- };
+class Model {
public:
- Model() noexcept;
- ~Model() noexcept;
+ Model();
Model(const Model &) = delete;
Model &operator =(const Model &) = delete;
- Model(Model &&) noexcept;
- Model &operator =(Model &&) noexcept;
+ std::uint32_t ID() const noexcept { return id; }
+ void ID(std::uint32_t i) noexcept { id = i; }
+
+ Part &RootPart() noexcept { return root; }
+ const Part &RootPart() const noexcept { return root; }
+ Part &GetPart(std::size_t i) noexcept { return *part[i]; }
+ const Part &GetPart(std::size_t i) const noexcept { return *part[i]; }
+
+ void SetBody(std::uint16_t id) { body_id = id; }
+ const Part &GetBodyPart() const noexcept { return GetPart(body_id); }
- void Update(const Buffer &) noexcept;
+ void SetEyes(std::uint16_t id) { eyes_id = id; }
+ const Part &GetEyesPart() const noexcept { return GetPart(eyes_id); }
- void Draw() const noexcept;
+ void Enumerate();
+ 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;
+ std::uint32_t id;
+ Part root;
+ std::vector<Part *> part;
+ std::uint16_t body_id;
+ std::uint16_t eyes_id;
};