-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshadermodel.cpp
53 lines (34 loc) · 1.03 KB
/
shadermodel.cpp
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
/* START OF 'shadermodel.cpp' FILE */
#include "shadermodel.h"
SHADER_MODEL::SHADER_MODEL (void) :
model(NULL)
{
}
glm::vec4 SHADER_MODEL::Vertex (int index, int vert)
{
uvs[vert] = model->uvCoords[model->uvIndices[index]];
glm::vec4 vertex = glm::vec4(model->vertices[model->vertexIndices[index]], 1);
return transformMatrix * vertex;
}
bool SHADER_MODEL::Fragment (glm::vec3 bar, COLORREF & color)
{
float intensityModified = glm::dot(bar, intensity);
if (model->mat.map.GetWidth() > 0) {
glm::vec2 uv = uvs * bar;
int y = (int)(uv.y * (model->mat.map.GetHeight() - 1));
int x = (int)(uv.x * (model->mat.map.GetWidth() - 1));
color = model->mat.map.GetColor(y * model->mat.map.GetWidth() + x);
} else {
color = WireFrameColor;
}
return false;
}
void SHADER_MODEL::SetModel (const objMODEL * model)
{
this->model = const_cast<objMODEL *>(model);
}
void SHADER_MODEL::SetTransformMatrix(const glm::mat4x4 & matr)
{
transformMatrix = matr;
}
/* END OF 'shadermodel.cpp' FILE */