Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Mesh.hpp
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7 #ifndef ENGINE_MESH
8#define ENGINE_MESH
9
10#include "../Utils.hpp"
11#include <vector>
12
13namespace Engine::Graphics {
14
34 struct Vertex {
35 float x, y, z, u, v;
36 float nx = 0.0f, ny = 0.0f, nz = 1.0f;
37
48 void CalculateNormals(Vertex& v2, Vertex& v3);
49
55 bool operator==(const Vertex& rhs);
56 };
57
79 class Mesh {
80 private:
81 std::vector<Vertex> m_vertices;
82 std::vector<unsigned short> m_indices;
83
84 protected:
85
97 Success AddTriangle(Vertex v1, Vertex v2, Vertex v3);
98
107 Success AddQuad(Vertex v1, Vertex v2, Vertex v3, Vertex v4);
108
109 public:
110
117 float* GetVertices();
118
124 unsigned long GetVertexCount();
125
132 unsigned short* GetIndices();
133
139 unsigned long GetIndexCount();
140 };
141
142}
143
144#endif
Success
A generic success type.
Definition Utils.hpp:29
A structure used to store mesh vertices.
Definition Mesh.hpp:34
void CalculateNormals(Vertex &v2, Vertex &v3)
Calculates the normal vector of the vertices.
Definition Mesh.cpp:10
bool operator==(const Vertex &rhs)
Checks if two vertices are equal.
Definition Mesh.cpp:29