-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.h
More file actions
50 lines (43 loc) · 906 Bytes
/
Vertex.h
File metadata and controls
50 lines (43 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <array>
// Struct for the data a vertex contains ( used in the mesh.cpp )
struct Vertex
{
float pos[3];
float tex[2];
float nor[3];
Vertex() = default;
Vertex(const std::array<float, 3>& position, const std::array<float, 2>& textureCoords, const std::array<float, 3>& normal)
{
for (int i = 0; i < 3; ++i)
{
pos[i] = position[i];
nor[i] = normal[i];
}
tex[0] = textureCoords[0];
tex[1] = textureCoords[1];
}
// Assignment-operator
Vertex& operator=(const Vertex& vertex)
{
for (int i = 0; i < 3; ++i)
{
pos[i] = vertex.pos[i];
nor[i] = vertex.nor[i];
}
tex[0] = vertex.tex[0];
tex[1] = vertex.tex[1];
return *this;
}
};
struct Face
{
Vertex vertices[3];
Face() = default;
Face(Vertex v1, Vertex v2, Vertex v3)
{
vertices[0] = v1;
vertices[1] = v2;
vertices[2] = v3;
}
};