-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththrottleUI.cpp
More file actions
90 lines (68 loc) · 2.61 KB
/
throttleUI.cpp
File metadata and controls
90 lines (68 loc) · 2.61 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "throttleUI.h"
#include"vertexBuffer.h"
#include "vertexArray.h"
#include "texture.h"
#include "shaderProgram.h"
#include <iostream>
throttleUI::throttleUI()
{
std::vector<glm::vec3> points =
{
glm::vec3(1.0f,1.0f,0.0f),
glm::vec3(0.0f,1.0f,0.0f),
glm::vec3(0.0f,0.0f,0.0f),
glm::vec3(1.0f,1.0f,0.0f),
glm::vec3(0.0f,0.0f,0.0f),
glm::vec3(1.0f,0.0f,0.0f)
};
std::vector<glm::vec2> texCoords =
{
glm::vec2(1.0f, 1.0f),
glm::vec2(0.0f, 1.0f),
glm::vec2(0.0f, 0.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(0.0f, 0.0f),
glm::vec2(1.0f, 0.0f),
};
bodyVertBuffer = std::make_shared<vertexBuffer>();
bodyTexBuffer = std::make_shared<vertexBuffer>();
headVertBuffer = std::make_shared<vertexBuffer>();
headTexBuffer = std::make_shared<vertexBuffer>();
for (int i = 0; i < points.size(); i++)
{
bodyVertBuffer->addData(points.at(i));
bodyTexBuffer->addData(texCoords.at(i));
headVertBuffer->addData(points.at(i));
headTexBuffer->addData(texCoords.at(i));
}
bodyVAO = std::make_shared<vertexArray>();
bodyVAO->setBuffer(0, bodyVertBuffer);
bodyVAO->setBuffer(1, bodyTexBuffer);
bodyVAO->setVertCount(6);
headVAO = std::make_shared<vertexArray>();
headVAO->setBuffer(0, headVertBuffer);
headVAO->setBuffer(1, headTexBuffer);
headVAO->setVertCount(6);
program = std::make_shared<shaderProgram>(shaderProgram::SHADER_ORTHO);
bodyTexture = std::make_shared<texture>("Models/throttle/throttleBase.png");
headTexture = std::make_shared<texture>("Models/throttle/throttleHead.png");
bodyModelMatrix = glm::mat4(1.0f);
bodyModelMatrix = glm::translate(bodyModelMatrix, glm::vec3(0, 0, 0));
bodyModelMatrix = glm::scale(bodyModelMatrix, glm::vec3(200, 400, 0));
//bodyModelMatrix = glm::rotate(bodyModelMatrix, glm::radians(180.0f), glm::vec3(0, 0, 1));
/*headModelMatrix = glm::mat4(1.0f);
headModelMatrix = glm::translate(headModelMatrix, glm::vec3(25, 0, 0));
headModelMatrix = glm::scale(headModelMatrix, glm::vec3(100, 50, 0));*/
projectionMatrix = projectionMatrix = glm::ortho(0.0f, (float)1920, 0.0f, (float)1080, 0.0f, 1.0f);
}
void throttleUI::update(float _throttleValue)
{
float maxUp = 325;
float actualThrottleLoc = maxUp * _throttleValue;
std::cout << actualThrottleLoc << std::endl;
headModelMatrix = glm::mat4(1.0f);
headModelMatrix = glm::translate(headModelMatrix, glm::vec3(25, actualThrottleLoc, 0));
headModelMatrix = glm::scale(headModelMatrix, glm::vec3(100, 50, 0));
program->update(projectionMatrix, glm::mat4(1.0f), headModelMatrix, headVAO, headTexture->getId());
program->update(projectionMatrix, glm::mat4(1.0f), bodyModelMatrix, bodyVAO, bodyTexture->getId());
}