CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ScaleMesh.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
13
15 template<typename Mesh> class ScaleMesh {
16 private:
19
20 public:
23 ScaleMesh(Mesh mesh, const Vector3& scale)
24 : mTransformMesh{std::move(mesh), [scale](MeshVertex& value) {
25 value.position *= scale;
26 value.normal = normalize(scale * value.normal);
27 }} {}
28
29 using Triangles = typename Impl::Triangles;
30 [[nodiscard]] Triangles triangles() const noexcept { return mTransformMesh.triangles(); }
31
32 using Vertices = typename Impl::Vertices;
33 [[nodiscard]] Vertices vertices() const noexcept { return mTransformMesh.vertices(); }
34 };
35
36 template<typename Mesh> ScaleMesh<Mesh> scaleMesh(Mesh mesh, const Vector3& delta) { return ScaleMesh<Mesh>{std::move(mesh), delta}; }
37
38} // namespace CeresEngine::MeshGenerator
Definition MeshVertex.hpp:14
Scales a mesh (keeps normals unit length)
Definition ScaleMesh.hpp:15
ScaleMesh(Mesh mesh, const Vector3 &scale)
Definition ScaleMesh.hpp:23
typename Impl::Triangles Triangles
Definition ScaleMesh.hpp:29
Triangles triangles() const noexcept
Definition ScaleMesh.hpp:30
Impl mTransformMesh
Definition ScaleMesh.hpp:18
Vertices vertices() const noexcept
Definition ScaleMesh.hpp:33
typename Impl::Vertices Vertices
Definition ScaleMesh.hpp:32
Apply a mutator function to each vertex.
Definition TransformMesh.hpp:18
typename Impl::Triangles Triangles
Definition TransformMesh.hpp:50
A base class for all mesh implementations.
Definition Mesh.hpp:112
Definition AnyGenerator.hpp:12
ScaleMesh< Mesh > scaleMesh(Mesh mesh, const Vector3 &delta)
Definition ScaleMesh.hpp:36
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
auto scale(Vector3 scale)
Applies a scale to the entity.
Definition Helpers.hpp:32
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668