]> git.localhorst.tv Git - blank.git/blob - src/shape.hpp
434f427ec7b70473d86390288f1b2020e19a79e8
[blank.git] / src / shape.hpp
1 #ifndef BLANK_SHAPE_HPP_
2 #define BLANK_SHAPE_HPP_
3
4 #include "geometry.hpp"
5
6 #include <vector>
7 #include <glm/glm.hpp>
8
9
10 namespace blank {
11
12 struct Shape {
13
14         virtual size_t VertexCount() const = 0;
15         virtual void Vertices(std::vector<glm::vec3> &, const glm::vec3 &pos = { 0.0f, 0.0f, 0.0f }) const = 0;
16         virtual void Normals(std::vector<glm::vec3> &) const = 0;
17
18         virtual size_t OutlineCount() const = 0;
19         virtual void Outline(std::vector<glm::vec3> &, const glm::vec3 &pos = { 0.0f, 0.0f, 0.0f }) const = 0;
20
21         virtual bool Intersects(const Ray &, const glm::mat4 &, float &dist, glm::vec3 &normal) const = 0;
22
23 };
24
25
26 class CuboidShape
27 : public Shape {
28
29 public:
30         CuboidShape(const AABB &bounds);
31
32         size_t VertexCount() const override;
33         void Vertices(std::vector<glm::vec3> &, const glm::vec3 &) const override;
34         void Normals(std::vector<glm::vec3> &) const override;
35
36         size_t OutlineCount() const override;
37         void Outline(std::vector<glm::vec3> &, const glm::vec3 &) const override;
38
39         bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
40
41 private:
42         AABB bb;
43
44 };
45
46
47 class StairShape
48 : public Shape {
49
50 public:
51         StairShape(const AABB &bounds, const glm::vec2 &clip);
52
53         size_t VertexCount() const override;
54         void Vertices(std::vector<glm::vec3> &, const glm::vec3 &) const override;
55         void Normals(std::vector<glm::vec3> &) const override;
56
57         size_t OutlineCount() const override;
58         void Outline(std::vector<glm::vec3> &, const glm::vec3 &) const override;
59
60         bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
61
62 private:
63         AABB top, bot;
64
65 };
66
67 }
68
69 #endif