Unravel Engine C++ Reference
Loading...
Searching...
No Matches
shape_to_path.hpp
Go to the documentation of this file.
1#ifndef GENERATOR_SHAPETOPATH_HPP
2#define GENERATOR_SHAPETOPATH_HPP
3
4#include "path_vertex.hpp"
5#include "shape_vertex.hpp"
6#include "utils.hpp"
7
8namespace generator
9{
10
15template<typename shape_t>
17{
18private:
19 using impl_t = shape_t;
20 impl_t shape_;
21
22public:
24 {
25 public:
27 {
28 shape_vertex_t shapeVertex = vertices_.generate();
29
30 path_vertex_t vertex;
31
32 vertex.position = gml::dvec3(shapeVertex.position, 0.0);
33
34 vertex.tangent = gml::dvec3(shapeVertex.tangent, 0.0);
35 vertex.normal = gml::dvec3{0.0, 0.0, 1.0};
36
37 vertex.tex_coord = shapeVertex.tex_coord;
38
39 return vertex;
40 }
41
42 bool done() const noexcept
43 {
44 return vertices_.done();
45 }
46
47 void next()
48 {
49 vertices_.next();
50 }
51
52 private:
53 typename vertex_generator_type<shape_t>::type vertices_;
54
55 explicit vertices_t(const shape_t& shape) : vertices_{shape.vertices()}
56 {
57 }
58
59 friend class shape_to_path_t;
60 };
61
62 shape_to_path_t(shape_t shape) : shape_{std::move(shape)}
63 {
64 }
65
66 using edges_t = typename impl_t::edges_t;
67
68 edges_t edges() const noexcept
69 {
70 return shape_.edges();
71 }
72
74 {
75 return vertices_t{*this};
76 }
77};
78
79template<typename shape_t>
81{
82 return shape_to_path_t<shape_t>{std::move(shape)};
83}
84} // namespace generator
85
86#endif
vertices_t vertices() const
typename impl_t::edges_t edges_t
edges_t edges() const noexcept
shape_to_path_t< shape_t > shape_to_path(shape_t shape)