-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransformController.cpp
More file actions
57 lines (47 loc) · 1.9 KB
/
TransformController.cpp
File metadata and controls
57 lines (47 loc) · 1.9 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
#include "TransformController.h"
#include "Math.h"
TransformController::TransformController()
{
_controlPosition = glm::vec3(0.0f);
_visible = false;
_xControl = new Cube(AXIS_HEIGHT/2 - AXIS_WIDTH/2, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, AXIS_HEIGHT, AXIS_WIDTH, AXIS_WIDTH);
_yControl = new Cube(0.0f, AXIS_HEIGHT/2 - AXIS_WIDTH/2, 0.0f, 0.0f, 0.0f, 0.0f, AXIS_WIDTH, AXIS_HEIGHT, AXIS_WIDTH);
_zControl = new Cube(0.0f, 0.0f, AXIS_HEIGHT/2 - AXIS_WIDTH/2, 0.0f, 0.0f, 0.0f, AXIS_WIDTH, AXIS_WIDTH, AXIS_HEIGHT);
}
TransformController::~TransformController()
{
}
void TransformController::deselectAxis()
{
_xControl->isSelected = false;
_yControl->isSelected = false;
_zControl->isSelected = false;
}
void TransformController::render(Camera& camera, TransformShader& shader)
{
if(_visible == false)
return;
shader.start();
shader.getUniformLocations();
shader.loadProjectionMatrix(camera.createProjectionMatrix());
shader.loadViewMatrix(camera.getViewMatrix());
//X Axis Controller
glm::mat4 model = Math::createTransformationMatrix(_controlPosition + _xControl->getPosition(), _xControl->getRotation(), _xControl->getScale());
shader.loadModelMatrix(model);
shader.loadAxisID(0);
shader.loadSelected(_xControl->isSelected);
_xControl->render();
//Y Axis Controller
model = Math::createTransformationMatrix(_controlPosition + _yControl->getPosition(), _yControl->getRotation(), _yControl->getScale());
shader.loadModelMatrix(model);
shader.loadAxisID(1);
shader.loadSelected(_yControl->isSelected);
_yControl->render();
//Z Axis Controller
model = Math::createTransformationMatrix(_controlPosition + _zControl->getPosition(), _zControl->getRotation(), _zControl->getScale());
shader.loadModelMatrix(model);
shader.loadAxisID(2);
shader.loadSelected(_zControl->isSelected);
_zControl->render();
shader.stop();
}