1 #ifndef BLANK_MODEL_SHAPE_HPP_
2 #define BLANK_MODEL_SHAPE_HPP_
4 #include "BlockModel.hpp"
5 #include "EntityModel.hpp"
6 #include "OutlineModel.hpp"
7 #include "SkyBoxModel.hpp"
19 /// the number of vertices (and normals) this shape has
20 size_t VertexCount() const noexcept { return vtx_pos.size(); }
21 /// the number of vertex indices this shape has
22 size_t VertexIndexCount() const noexcept { return vtx_idx.size(); }
24 const EntityModel::Normal &VertexNormal(size_t idx) const noexcept { return vtx_nrm[idx]; }
25 EntityModel::Normal VertexNormal(
26 size_t idx, const glm::mat4 &transform
28 return EntityModel::Normal(transform * glm::vec4(vtx_nrm[idx], 0.0f));
31 /// fill given buffers with this shape's elements with an
32 /// optional transform and offset
34 EntityModel::Buffer &out,
35 float tex_offset = 0.0f
38 EntityModel::Buffer &out,
39 const glm::mat4 &transform,
40 float tex_offset = 0.0f,
41 EntityModel::Index idx_offset = 0
44 BlockModel::Buffer &out,
45 const glm::mat4 &transform,
46 float tex_offset = 0.0f,
47 BlockModel::Index idx_offset = 0
50 SkyBoxModel::Buffer &out
53 /// the number of vertices this shape's outline has
54 size_t OutlineCount() const { return out_pos.size(); }
55 /// the number of vertex indices this shape's outline has
56 size_t OutlineIndexCount() const { return out_idx.size(); }
58 /// fill given buffers with this shape's outline's elements
59 void Outline(OutlineModel::Buffer &out) const;
61 /// Check if given ray would pass though this shape if it were
62 /// transformed with given matrix.
63 /// If true, dist and normal hold the intersection distance and
64 /// normal, otherwise their content is undefined.
65 virtual bool Intersects(
72 /// Check for intersection with given OBB.
73 /// The OBB is defined by box and box_M, M is applied to the shape.
74 virtual bool Intersects(
77 const glm::mat4 &box_M,
84 const EntityModel::Positions &pos,
85 const EntityModel::Normals &nrm,
86 const EntityModel::Indices &idx);
88 const BlockModel::TexCoords &tex_coords);
90 const OutlineModel::Positions &pos,
91 const OutlineModel::Indices &idx);
94 EntityModel::Positions vtx_pos;
95 EntityModel::Normals vtx_nrm;
96 EntityModel::Indices vtx_idx;
98 BlockModel::TexCoords vtx_tex_coords;
100 OutlineModel::Positions out_pos;
101 OutlineModel::Indices out_idx;