X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2FModel.hpp;h=54b5256c13f34e4767475735d259d3161272aa9c;hb=refs%2Fheads%2Fmaster;hp=95ad086402a6c58838012b0c9102350538cb9499;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/model/Model.hpp b/src/model/Model.hpp index 95ad086..54b5256 100644 --- a/src/model/Model.hpp +++ b/src/model/Model.hpp @@ -1,76 +1,51 @@ #ifndef BLANK_MODEL_MODEL_HPP_ #define BLANK_MODEL_MODEL_HPP_ +#include "Part.hpp" +#include "../graphics/glm.hpp" + +#include +#include #include -#include -#include +#include 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; - using Colors = std::vector; - using Normals = std::vector; - using Indices = std::vector; - -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; + std::uint16_t body_id; + std::uint16_t eyes_id; };