X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel.hpp;h=6e9583b3ec84f6ae05c7f1beaeeaa05b7e36e75b;hb=82426ae2997d2b21703d2d5afb631a84736e975f;hp=b2a6e21a64a424fbd02639ef78004ddd369b9f3b;hpb=49c81f76b80e0de99ca57db49510eb5e3385e1d1;p=blank.git diff --git a/src/model.hpp b/src/model.hpp index b2a6e21..6e9583b 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -1,6 +1,8 @@ #ifndef BLANK_MODEL_HPP_ #define BLANK_MODEL_HPP_ +#include +#include #include @@ -8,31 +10,87 @@ namespace blank { class Model { +public: + using Index = unsigned int; + +public: + std::vector vertices; + std::vector colors; + std::vector normals; + std::vector indices; + public: Model(); ~Model(); - glm::mat4 Transform() const; + Model(const Model &) = delete; + Model &operator =(const Model &) = delete; - void Velocity(glm::vec3 vel) { velocity = vel; } - void Position(glm::vec3 pos) { position = pos; } - void Move(glm::vec3 delta) { position += delta; } + Model(Model &&); + Model &operator =(Model &&); - // all angles in radians (full circle = 2π) - float Pitch() const { return pitch; } - void Pitch(float p) { pitch = p; } - void RotatePitch(float delta) { pitch += delta; } - float Yaw() const { return yaw; } - void Yaw(float y) { yaw = y; } - void RotateYaw(float delta) { yaw += delta; } + void Invalidate() { dirty = true; } - void Update(int dt); + void Clear(); + void Reserve(int vtx_count, int idx_count); + + void Draw(); + +private: + void Update(); private: - glm::vec3 velocity; - glm::vec3 position; - float pitch; - float yaw; + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_COLOR, + ATTRIB_NORMAL, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + GLuint handle[ATTRIB_COUNT]; + bool dirty; + +}; + + +class OutlineModel { + +public: + using Index = unsigned short; + +public: + std::vector vertices; + std::vector colors; + std::vector indices; + +public: + OutlineModel(); + ~OutlineModel(); + + OutlineModel(const OutlineModel &) = delete; + OutlineModel &operator =(const OutlineModel &) = delete; + + void Invalidate() { dirty = true; } + + void Clear(); + void Reserve(int vtx_count, int idx_count); + + void Draw(); + +private: + void Update(); + +private: + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_COLOR, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + GLuint handle[ATTRIB_COUNT]; + bool dirty; };