1 #ifndef BLANK_MODEL_SHAPE_HPP_
2 #define BLANK_MODEL_SHAPE_HPP_
4 #include "BlockModel.hpp"
6 #include "OutlineModel.hpp"
18 /// the number of vertices (and normals) this shape has
19 size_t VertexCount() const noexcept { return vtx_pos.size(); }
20 /// the number of vertex indices this shape has
21 size_t VertexIndexCount() const noexcept { return vtx_idx.size(); }
23 const Model::Normal &VertexNormal(size_t idx) const noexcept { return vtx_nrm[idx]; }
24 Model::Normal VertexNormal(
25 size_t idx, const glm::mat4 &transform
27 return Model::Normal(transform * glm::vec4(vtx_nrm[idx], 0.0f));
30 /// fill given buffers with this shape's elements with an
31 /// optional transform and offset
33 Model::Positions &vertex,
34 Model::Normals &normal,
38 Model::Positions &vertex,
39 Model::Normals &normal,
40 Model::Indices &index,
41 const glm::mat4 &transform,
42 Model::Index idx_offset = 0
45 BlockModel::Positions &vertex,
46 BlockModel::Indices &index,
47 const glm::mat4 &transform,
48 BlockModel::Index idx_offset = 0
51 /// the number of vertices this shape's outline has
52 size_t OutlineCount() const { return out_pos.size(); }
53 /// the number of vertex indices this shape's outline has
54 size_t OutlineIndexCount() const { return out_idx.size(); }
56 /// fill given buffers with this shape's outline's elements with
57 /// an optional offset
59 OutlineModel::Positions &vertex,
60 OutlineModel::Indices &index,
61 const OutlineModel::Position &offset = { 0.0f, 0.0f, 0.0f },
62 OutlineModel::Index idx_offset = 0
65 /// Check if given ray would pass though this shape if it were
66 /// transformed with given matrix.
67 /// If true, dist and normal hold the intersection distance and
68 /// normal, otherwise their content is undefined.
69 virtual bool Intersects(
77 void SetShape(const Model::Positions &pos, const Model::Normals &nrm, const Model::Indices &idx) {
82 void SetOutline(const OutlineModel::Positions &pos, const OutlineModel::Indices &idx) {
88 Model::Positions vtx_pos;
89 Model::Normals vtx_nrm;
90 Model::Indices vtx_idx;
92 OutlineModel::Positions out_pos;
93 OutlineModel::Indices out_idx;