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_pos.size(); }
17 /// the number of vertex indices this shape has
18 size_t VertexIndexCount() const { return vtx_idx.size(); }
20 /// fill given buffers with this shape's elements with an
23 Model::Positions &vertex,
24 Model::Normals &normal,
25 Model::Indices &index,
26 const Model::Position &elem_offset = { 0.0f, 0.0f, 0.0f },
27 Model::Index idx_offset = 0
30 Model::Positions &vertex,
31 Model::Normals &normal,
32 Model::Indices &index,
33 const glm::mat4 &transform,
34 Model::Index idx_offset = 0
37 /// the number of vertices this shape's outline has
38 size_t OutlineCount() const { return out_pos.size(); }
39 /// the number of vertex indices this shape's outline has
40 size_t OutlineIndexCount() const { return out_idx.size(); }
42 /// fill given buffers with this shape's outline's elements with
43 /// an optional offset
45 OutlineModel::Positions &vertex,
46 OutlineModel::Indices &index,
47 const OutlineModel::Position &offset = { 0.0f, 0.0f, 0.0f },
48 OutlineModel::Index idx_offset = 0
51 /// Check if given ray would pass though this shape if it were
52 /// transformed with given matrix.
53 /// If true, dist and normal hold the intersection distance and
54 /// normal, otherwise their content is undefined.
55 virtual bool Intersects(
63 void SetShape(const Model::Positions &pos, const Model::Normals &nrm, const Model::Indices &idx) {
68 void SetOutline(const OutlineModel::Positions &pos, const OutlineModel::Indices &idx) {
74 Model::Positions vtx_pos;
75 Model::Normals vtx_nrm;
76 Model::Indices vtx_idx;
78 OutlineModel::Positions out_pos;
79 OutlineModel::Indices out_idx;
90 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
99 CuboidShape(const AABB &bounds);
101 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
113 StairShape(const AABB &bounds, const glm::vec2 &clip);
115 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;