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 /// the number of vertices this shape's outline has
31 size_t OutlineCount() const { return out_pos.size(); }
32 /// the number of vertex indices this shape's outline has
33 size_t OutlineIndexCount() const { return out_idx.size(); }
35 /// fill given buffers with this shape's outline's elements with
36 /// an optional offset
38 OutlineModel::Positions &vertex,
39 OutlineModel::Indices &index,
40 const OutlineModel::Position &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 void SetShape(const Model::Positions &pos, const Model::Normals &nrm, const Model::Indices &idx) {
61 void SetOutline(const OutlineModel::Positions &pos, const OutlineModel::Indices &idx) {
67 Model::Positions vtx_pos;
68 Model::Normals vtx_nrm;
69 Model::Indices vtx_idx;
71 OutlineModel::Positions out_pos;
72 OutlineModel::Indices out_idx;
83 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
92 CuboidShape(const AABB &bounds);
94 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;
106 StairShape(const AABB &bounds, const glm::vec2 &clip);
108 bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const override;