]> git.localhorst.tv Git - blank.git/blob - src/model/Shape.hpp
actually load shapes
[blank.git] / src / model / Shape.hpp
1 #ifndef BLANK_MODEL_SHAPE_HPP_
2 #define BLANK_MODEL_SHAPE_HPP_
3
4 #include "../graphics/BlockMesh.hpp"
5 #include "../graphics/EntityMesh.hpp"
6
7 #include <memory>
8 #include <vector>
9 #include <glm/glm.hpp>
10
11
12 namespace blank {
13
14 struct CollisionBounds;
15 class TokenStreamReader;
16
17 class Shape {
18
19 public:
20         Shape();
21
22         void Read(TokenStreamReader &);
23
24         void Fill(
25                 EntityMesh::Buffer &,
26                 const std::vector<float> &tex_map
27         ) const;
28         void Fill(
29                 EntityMesh::Buffer &,
30                 const glm::mat4 &transform,
31                 const std::vector<float> &tex_map
32         ) const;
33         void Fill(
34                 BlockMesh::Buffer &,
35                 const glm::mat4 &transform,
36                 const std::vector<float> &tex_map,
37                 std::size_t idx_offset = 0
38         ) const;
39
40 private:
41         static float TexR(const std::vector<float> &, std::size_t) noexcept;
42
43 private:
44         std::unique_ptr<CollisionBounds> bounds;
45         struct Vertex {
46                 glm::vec3 position;
47                 glm::vec3 normal;
48                 glm::vec2 tex_st;
49                 std::size_t tex_id;
50         };
51         std::vector<Vertex> vertices;
52         std::vector<std::size_t> indices;
53
54 };
55
56 }
57
58 #endif