CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
FlipMesh.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 "TransformMesh.hpp"
11#include "Triangle.hpp"
12
14
16 template<typename Mesh> class FlipMesh {
17 private:
20
21 public:
22 class Triangles {
23 public:
25 Triangle triangle = mTriangles.generate();
26 std::swap(triangle.vertices[0], triangle.vertices[2]);
27 return triangle;
28 }
29
30 [[nodiscard]] bool done() const noexcept { return mTriangles.done(); }
31
32 void next() { mTriangles.next(); }
33
34 private:
36
38
39 friend class FlipMesh;
40 };
41
44 : mTransformMesh{std::move(mesh), [](MeshVertex& vertex) {
45 vertex.normal *= -1.0;
46 }} {}
47
48 [[nodiscard]] Triangles triangles() const noexcept { return this->mTransformMesh; }
49
50 using Vertices = typename Impl::Vertices;
51 [[nodiscard]] Vertices vertices() const noexcept { return mTransformMesh.vertices(); }
52 };
53
54 template<typename Mesh> FlipMesh<Mesh> flipMesh(Mesh mesh) { return FlipMesh<Mesh>{std::move(mesh)}; }
55
56} // namespace CeresEngine::MeshGenerator
void next()
Definition FlipMesh.hpp:32
Triangles(const TransformMesh< Mesh > &mesh)
Definition FlipMesh.hpp:37
bool done() const noexcept
Definition FlipMesh.hpp:30
TriangleGeneratorType< TransformMesh< Mesh > >::Type mTriangles
Definition FlipMesh.hpp:35
Triangle generate() const
Definition FlipMesh.hpp:24
Flips mesh inside out. Reverses triangles and normals.
Definition FlipMesh.hpp:16
FlipMesh(Mesh mesh)
Definition FlipMesh.hpp:43
Impl mTransformMesh
Definition FlipMesh.hpp:19
Triangles triangles() const noexcept
Definition FlipMesh.hpp:48
Vertices vertices() const noexcept
Definition FlipMesh.hpp:51
typename Impl::Vertices Vertices
Definition FlipMesh.hpp:50
Definition MeshVertex.hpp:14
Apply a mutator function to each vertex.
Definition TransformMesh.hpp:18
Will have a type named "Type" that has same type as value returned by method triangles() for type Pri...
Definition Utility.hpp:30
Definition Triangle.hpp:14
A base class for all mesh implementations.
Definition Mesh.hpp:112
Definition AnyGenerator.hpp:12
FlipMesh< Mesh > flipMesh(Mesh mesh)
Definition FlipMesh.hpp:54
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