]> git.localhorst.tv Git - blank.git/blob - src/shape.hpp
438fa101d1a9a748cbce4c345762dbf7d1b804d6
[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
48 #endif