CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ShapeToPath.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "PathVertex.hpp"
11#include "ShapeVertex.hpp"
12#include "Utility.hpp"
13
15
20 template<typename Shape> class ShapeToPath {
21 private:
22 using Impl = Shape;
24
25 public:
26 class Vertices {
27 public:
29 const ShapeVertex shapeVertex = vertices_.generate();
30
31 PathVertex vertex;
32
33 vertex.position = Vector3(shapeVertex.position, 0.0);
34
35 vertex.tangent = Vector3(shapeVertex.tangent, 0.0);
36 vertex.normal = Vector3{0.0, 0.0, 1.0};
37
38 vertex.texCoord = shapeVertex.texCoord;
39
40 return vertex;
41 }
42
43 [[nodiscard]] bool done() const noexcept { return vertices_.done(); }
44
45 void next() { vertices_.next(); }
46
47 private:
49
50 Vertices(const Shape& shape) : vertices_{shape.vertices()} {}
51
52 friend class ShapeToPath;
53 };
54
55 ShapeToPath(Shape shape) : mShape{std::move(shape)} {}
56
57 using Edges = typename Impl::Edges;
58
59 [[nodiscard]] Edges edges() const noexcept { return mShape.edges(); }
60
61 [[nodiscard]] Vertices vertices() const { return *this; }
62 };
63
64 template<typename Shape> ShapeToPath<Shape> shapeToPath(Shape shape) { return ShapeToPath<Shape>{std::move(shape)}; }
65
66} // namespace CeresEngine::MeshGenerator
Definition PathVertex.hpp:14
double texCoord
Definition PathVertex.hpp:26
Vector3 normal
Unit length vector perpendicular to the path at this point.
Definition PathVertex.hpp:18
Vector3 tangent
Unit length vector parallel to the path at this point.
Definition PathVertex.hpp:24
Vector3 position
Definition PathVertex.hpp:20
void next()
Definition ShapeToPath.hpp:45
PathVertex generate() const
Definition ShapeToPath.hpp:28
Vertices(const Shape &shape)
Definition ShapeToPath.hpp:50
VertexGeneratorType< Shape >::Type vertices_
Definition ShapeToPath.hpp:48
bool done() const noexcept
Definition ShapeToPath.hpp:43
Converts a Shape to a Path.
Definition ShapeToPath.hpp:20
Edges edges() const noexcept
Definition ShapeToPath.hpp:59
Vertices vertices() const
Definition ShapeToPath.hpp:61
Impl mShape
Definition ShapeToPath.hpp:23
ShapeToPath(Shape shape)
Definition ShapeToPath.hpp:55
typename Impl::Edges Edges
Definition ShapeToPath.hpp:57
A point on a path.
Definition ShapeVertex.hpp:16
decltype(std::declval< const Primitive * >() ->vertices()) Type
Definition Utility.hpp:39
A type that describes a conjunction of shapes that can be filled and stroked.
Definition Shape.hpp:198
Definition AnyGenerator.hpp:12
ShapeToPath< Shape > shapeToPath(Shape shape)
Definition ShapeToPath.hpp:64
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668