1#ifndef GENERATOR_EXTRUDEMESH_HPP
2#define GENERATOR_EXTRUDEMESH_HPP
17template<
typename shape_t,
typename path_t>
28 const auto& shapeEdge = shape_edges_.generate();
29 const auto& pathEdge = path_edges_.generate();
33 triangle.
vertices[0] = shapeEdge.vertices[0] + pathEdge.vertices[0] * mesh_->shape_vertex_count_;
34 triangle.
vertices[1] = shapeEdge.vertices[1] + pathEdge.vertices[1] * mesh_->shape_vertex_count_;
35 triangle.
vertices[2] = shapeEdge.vertices[0] + pathEdge.vertices[1] * mesh_->shape_vertex_count_;
39 triangle.
vertices[0] = shapeEdge.vertices[0] + pathEdge.vertices[0] * mesh_->shape_vertex_count_;
40 triangle.
vertices[1] = shapeEdge.vertices[1] + pathEdge.vertices[0] * mesh_->shape_vertex_count_;
41 triangle.
vertices[2] = shapeEdge.vertices[1] + pathEdge.vertices[1] * mesh_->shape_vertex_count_;
49 return path_edges_.done();
59 if(shape_edges_.done())
62 shape_edges_ = mesh_->shape_.edges();
70 typename shape_t::edges_t shape_edges_;
72 typename path_t::edges_t path_edges_;
78 , shape_edges_{mesh.shape_.edges()}
79 , path_edges_{mesh.path_.edges()}
94 const auto& shapeVertex = shape_vertices_.generate();
95 const auto& pathVertex = path_vertices_.generate();
97 gml::dvec3 pathBinormal = pathVertex.binormal();
98 vertex.
position = pathVertex.position + shapeVertex.position[0] * pathVertex.normal +
99 shapeVertex.position[1] * pathBinormal;
101 gml::dvec2 shapeNormal = shapeVertex.normal();
102 vertex.
normal = shapeNormal[0] * pathVertex.normal + shapeNormal[1] * pathBinormal;
104 vertex.
tex_coord[0] = shapeVertex.texCoord;
105 vertex.
tex_coord[1] = pathVertex.texCoord;
112 return path_vertices_.done();
117 shape_vertices_.next();
118 if(shape_vertices_.done())
120 path_vertices_.next();
121 shape_vertices_ = mesh_->shape_.vertices();
128 typename shape_t::vertices_t shape_vertices_;
130 typename path_t::vertices_t path_vertices_;
134 , shape_vertices_{mesh.shape_.
vertices()}
135 , path_vertices_{mesh.path_.
vertices()}
155 : shape_{
std::move(shape)}
156 , path_{
std::move(path)}
166 int shape_vertex_count_;
169template<
typename shape_t,
typename path_t>
bool done() const noexcept
triangle_t generate() const
bool done() const noexcept
mesh_vertex_t generate() const
extrude_mesh_t(shape_t shape, path_t path)
vertices_t vertices() const noexcept
triangles_t triangles() const noexcept
gml::dvec2 tex_coord
UV texture coordinates.
gml::dvec3 normal
Unit vector perpendicular to the surface.
gml::ivec3 vertices
Zero based indices of the triangle vertices in counterclockwise order.
int count(const generator_t &generator) noexcept
Counts the number of steps left in the generator.
extrude_mesh_t< shape_t, path_t > extrude_mesh(shape_t shape, path_t path)