-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transform.cpp
54 lines (41 loc) · 936 Bytes
/
Transform.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
#include <stdio.h>
#include <unistd.h>
#include "Transform.h"
Transform::Transform(glm::mat4 M, glm::mat4 updateM)
{
this->M = M;
this->updateM = updateM;
}
void Transform::draw(GLuint shaderProgram, glm::mat4 C)
{
//traverse the list of children and call each child node's draw function
glm::mat4 M_new = C*M;
if(!culled) {
for(Node* node : children) {
node->draw(shaderProgram, M_new);
}
}
}
void Transform::update(glm::mat4 C)
{
M = M * updateM;
// traverse the list of children and call each child node's update function
for(Node* node : children) {
node->update(C*M);
}
}
void Transform::addChild(Node* n)
{
children.push_back(n);
}
void Transform::setCulling(GLboolean b)
{
this->culled = b;
}
void Transform::setUpdateMatrix(glm::mat4 Ma)
{
updateM = Ma;
}
glm::mat4 Transform::getUpdateMatrix() {
return updateM;
}