X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fshape.hpp;fp=src%2Fshape.hpp;h=438fa101d1a9a748cbce4c345762dbf7d1b804d6;hb=b79bc060068daf80c707f7ca08cb40a716367784;hp=0000000000000000000000000000000000000000;hpb=d5a078a95bb406936e472ba6b22257a442a7b2d4;p=blank.git diff --git a/src/shape.hpp b/src/shape.hpp new file mode 100644 index 0000000..438fa10 --- /dev/null +++ b/src/shape.hpp @@ -0,0 +1,48 @@ +#ifndef BLANK_SHAPE_HPP_ +#define BLANK_SHAPE_HPP_ + +#include "geometry.hpp" + +#include +#include + + +namespace blank { + +struct Shape { + + virtual size_t VertexCount() const = 0; + virtual void Vertices(std::vector &, const glm::vec3 &pos = { 0.0f, 0.0f, 0.0f }) const = 0; + virtual void Normals(std::vector &) const = 0; + + virtual size_t OutlineCount() const = 0; + virtual void Outline(std::vector &, 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 &, const glm::vec3 &) const override; + void Normals(std::vector &) const override; + + size_t OutlineCount() const override; + void Outline(std::vector &, const glm::vec3 &) const override; + + bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override; + +private: + AABB bb; + +}; + +} + +#endif