]> git.localhorst.tv Git - blank.git/blobdiff - src/shape.hpp
abstract block shape
[blank.git] / src / shape.hpp
diff --git a/src/shape.hpp b/src/shape.hpp
new file mode 100644 (file)
index 0000000..438fa10
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef BLANK_SHAPE_HPP_
+#define BLANK_SHAPE_HPP_
+
+#include "geometry.hpp"
+
+#include <vector>
+#include <glm/glm.hpp>
+
+
+namespace blank {
+
+struct Shape {
+
+       virtual size_t VertexCount() const = 0;
+       virtual void Vertices(std::vector<glm::vec3> &, const glm::vec3 &pos = { 0.0f, 0.0f, 0.0f }) const = 0;
+       virtual void Normals(std::vector<glm::vec3> &) const = 0;
+
+       virtual size_t OutlineCount() const = 0;
+       virtual void Outline(std::vector<glm::vec3> &, const glm::vec3 &pos = { 0.0f, 0.0f, 0.0f }) const = 0;
+
+       virtual bool Intersects(const Ray &, const glm::mat4 &, float &dist, glm::vec3 &normal) const = 0;
+
+};
+
+
+class CuboidShape
+: public Shape {
+
+public:
+       CuboidShape(const AABB &bounds);
+
+       size_t VertexCount() const override;
+       void Vertices(std::vector<glm::vec3> &, const glm::vec3 &) const override;
+       void Normals(std::vector<glm::vec3> &) const override;
+
+       size_t OutlineCount() const override;
+       void Outline(std::vector<glm::vec3> &, const glm::vec3 &) const override;
+
+       bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
+
+private:
+       AABB bb;
+
+};
+
+}
+
+#endif