1 #ifndef BLANK_SHAPE_HPP_
2 #define BLANK_SHAPE_HPP_
4 #include "geometry.hpp"
15 /// the number of vertices (and normals) this shape has
16 size_t VertexCount() const { return vtx; }
17 /// the number of vertex indices this shape has
18 size_t VertexIndexCount() const { return vtx_idx; }
20 /// fill given buffers with this shape's elements with an
22 virtual void Vertices(
23 std::vector<glm::vec3> &vertex,
24 std::vector<glm::vec3> &normal,
25 std::vector<Model::Index> &index,
26 const glm::vec3 &elem_offset = { 0.0f, 0.0f, 0.0f },
27 Model::Index idx_offset = 0
30 /// the number of vertices this shape's outline has
31 size_t OutlineCount() const { return outl; }
32 /// the number of vertex indices this shape's outline has
33 size_t OutlineIndexCount() const { return outl_idx; }
35 /// fill given buffers with this shape's outline's elements with
36 /// an optional offset
38 std::vector<glm::vec3> &vertex,
39 std::vector<OutlineModel::Index> &index,
40 const glm::vec3 &offset = { 0.0f, 0.0f, 0.0f },
41 OutlineModel::Index idx_offset = 0
44 /// Check if given ray would pass though this shape if it were
45 /// transformed with given matrix.
46 /// If true, dist and normal hold the intersection distance and
47 /// normal, otherwise their content is undefined.
48 virtual bool Intersects(
56 Shape(size_t vtx, size_t vtx_idx, size_t outl, size_t outl_idx)
57 : vtx(vtx), vtx_idx(vtx_idx), outl(outl), outl_idx(outl_idx) { }
75 std::vector<glm::vec3> &vertex,
76 std::vector<glm::vec3> &normal,
77 std::vector<Model::Index> &index,
78 const glm::vec3 &elem_offset = { 0.0f, 0.0f, 0.0f },
79 Model::Index idx_offset = 0
83 std::vector<glm::vec3> &vertex,
84 std::vector<OutlineModel::Index> &index,
85 const glm::vec3 &offset = { 0.0f, 0.0f, 0.0f },
86 OutlineModel::Index idx_offset = 0
89 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
98 CuboidShape(const AABB &bounds);
101 std::vector<glm::vec3> &vertex,
102 std::vector<glm::vec3> &normal,
103 std::vector<Model::Index> &index,
104 const glm::vec3 &elem_offset = { 0.0f, 0.0f, 0.0f },
105 Model::Index idx_offset = 0
109 std::vector<glm::vec3> &vertex,
110 std::vector<OutlineModel::Index> &index,
111 const glm::vec3 &offset = { 0.0f, 0.0f, 0.0f },
112 OutlineModel::Index idx_offset = 0
115 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
127 StairShape(const AABB &bounds, const glm::vec2 &clip);
130 std::vector<glm::vec3> &vertex,
131 std::vector<glm::vec3> &normal,
132 std::vector<Model::Index> &index,
133 const glm::vec3 &elem_offset = { 0.0f, 0.0f, 0.0f },
134 Model::Index idx_offset = 0
138 std::vector<glm::vec3> &vertex,
139 std::vector<OutlineModel::Index> &index,
140 const glm::vec3 &offset = { 0.0f, 0.0f, 0.0f },
141 OutlineModel::Index idx_offset = 0
144 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;