-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertex.h
72 lines (67 loc) · 1.84 KB
/
Vertex.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <glm/vec2.hpp> // glm::vec3
#include <glm/vec3.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4
struct Vertex {
glm::vec3 pos;
glm::vec3 color;
glm::vec3 normal;
glm::vec2 textureCoord;
glm::vec3 tangents;
glm::vec3 bitangents;
Vertex()
{
pos = glm::vec3(0.0f, 0.0f, 0.0f);
color = glm::vec3(0.0f, 0.0f, 0.0f);
normal = glm::vec3(0.0f, 0.0f, 0.0f);
textureCoord = glm::vec2(0.0f, 0.0f);
tangents = glm::vec3(0.0f, 0.0f, 0.0f);
bitangents = glm::vec3(0.0f, 0.0f, 0.0f);
}
Vertex(float x, float y, float z)
{
initPos(x, y, z);
float red = (float)rand() / (float)RAND_MAX;
float green = (float)rand() / (float)RAND_MAX;
float blue = (float)rand() / (float)RAND_MAX;
initColor(red, green, blue);
initTexture(x, y);
}
Vertex(float x, float y, float z, float r, float g, float b)
{
initPos(x, y, z);
initColor(r, g, b);
initTexture(x, y);
}
Vertex(float x, float y, float z, float r, float g, float b, float nx, float ny, float nz, float u, float v)
{
initPos(x, y, z);
initColor(r, g, b);
initNormals(nx, ny, nz);
textureCoord = glm::vec2(u, v);
}
void initPos(float x, float y, float z)
{
pos = glm::vec3(x, y, z);
}
void initColor(float r, float g, float b)
{
color = glm::vec3(r, g, b);
}
void initNormals(float nx, float ny, float nz)
{
normal = glm::vec3(nx, ny, nz);
}
void initTexture(float u, float v)
{
textureCoord = glm::vec2(u, v);
}
void initTangents(float x, float y, float z)
{
tangents = glm::vec3(x, y, z);
}
void initBitangents(float x, float y, float z)
{
bitangents = glm::vec3(x, y, z);
}
};