Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Mesh.cpp
Go to the documentation of this file.
1 #include "Engine/Mesh/Mesh.hpp"
2 #include "Engine/engine.hpp"
3 
4 namespace Engine
5 {
6  Mesh::Mesh(eastl::vector<Vertex> vertices, eastl::vector<unsigned> indices)
7  {
8  //assign the relevant members
9  this->vertices = vertices;
10  this->indices = indices;
11 
12  //set up the mesh - vbo, vao, ebo
13  Mesh::SetUpMesh();
14  }
15 
16  void Mesh::SetUpMesh()
17  {
18  }
19 
20  Mesh::~Mesh() noexcept
21  {
22 
23  }
24 
25  uint64_t Mesh::GetVAO() const
26  {
27  return vao;
28  }
29 
30  uint64_t Mesh::GetVBO() const
31  {
32  return vbo;
33  }
34 
35  uint64_t Mesh::GetEBO() const
36  {
37  return ebo;
38  }
39 
40  uint64_t Mesh::GetUBO() const
41  {
42  return ubo;
43  }
44 
45  bool Mesh::operator==(Mesh& other)
46  {
47  if (name != other.name) return false;
48 
49  size_t thisVerticesSize = vertices.size();
50  size_t otherVerticesSize = other.vertices.size();
51 
52  if (thisVerticesSize != otherVerticesSize) return false;
53 
54  size_t thisIndicesSize = indices.size();
55  size_t otherIndicesSize = other.indices.size();
56 
57  if (thisIndicesSize != otherIndicesSize) return false;
58 
59  for (size_t i = 0; i < thisIndicesSize; ++i)
60  {
61  if (indices[i] != other.indices[i]) return false;
62  }
63 
64  for (size_t i = 0; i < thisVerticesSize; ++i)
65  {
66  if (vertices[i].normal != other.vertices[i].normal) return false;
67  if (vertices[i].position != other.vertices[i].position) return false;
68  if (vertices[i].texCoords != other.vertices[i].texCoords) return false;
69  }
70 
71  return true;
72  }
73 
74  bool Mesh::operator!=(Mesh& other)
75  {
76  if (name != other.name) return true;
77 
78  size_t thisVerticesSize = vertices.size();
79  size_t otherVerticesSize = other.vertices.size();
80 
81  if (thisVerticesSize != otherVerticesSize) return true;
82 
83  size_t thisIndicesSize = indices.size();
84  size_t otherIndicesSize = other.indices.size();
85 
86  if (thisIndicesSize != otherIndicesSize) return true;
87 
88  for (size_t i = 0; i < thisIndicesSize; ++i)
89  {
90  if (indices[i] != other.indices[i]) return true;
91  }
92 
93  for (size_t i = 0; i < thisVerticesSize; ++i)
94  {
95  if (vertices[i].normal != other.vertices[i].normal) return true;
96  if (vertices[i].position != other.vertices[i].position) return true;
97  if (vertices[i].texCoords != other.vertices[i].texCoords) return true;
98  }
99 
100  return false;
101  }
102 } // namespace Engine
uint64_t ubo
Definition: Mesh.hpp:110
eastl::vector< unsigned > indices
The indices of this mesh.
Definition: Mesh.hpp:24
uint64_t GetVBO() const
This method allows you to get the VBO of this mesh.
Definition: Mesh.cpp:30
uint64_t GetEBO() const
This method allows you to get the EBO of this mesh.
Definition: Mesh.cpp:35
bool operator!=(Mesh &other)
This method allows you to compare a mesh with another mesh.
Definition: Mesh.cpp:74
uint64_t ebo
Definition: Mesh.hpp:110
eastl::vector< Vertex > vertices
The vertices of this mesh.
Definition: Mesh.hpp:20
eastl::string name
The name of this mesh.
Definition: Mesh.hpp:77
uint64_t vbo
Definition: Mesh.hpp:110
uint64_t GetVAO() const
This method allows you to get the VAO of this mesh.
Definition: Mesh.cpp:25
This object is used to store data regarding a mesh. NOTE: only the resource manager is allowed to cre...
Definition: Mesh.hpp:14
uint64_t vao
Definition: Mesh.hpp:110
bool operator==(Mesh &other)
This method allows you to compare a mesh with another mesh.
Definition: Mesh.cpp:45
uint64_t GetUBO() const
This method allows you to get the UBO of this mesh.
Definition: Mesh.cpp:40