-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transform.h
50 lines (32 loc) · 1.04 KB
/
Transform.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
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include <memory>
#include <unordered_set>
#include <glm/vec3.hpp>
#include "Node.h"
class Transform : public Node {
public:
explicit Transform(const glm::mat4 &M);
Transform() = default;
void draw(const glm::mat4 &parent,
const glm::mat4 &view,
const glm::mat4 &projection) override;
void update(std::chrono::milliseconds delta) override;
std::list<Node *> hit(const Ray &ray) override;
std::list<Node *> hit(const Bound &bound, const glm::mat4 &parent) override;
void addChild(Node *node);
void removeChild(Node *node);
void translate(const glm::vec3 &direction);
void rotate(float angle, const glm::vec3 &axis);
void scale(const glm::vec3 &mag);
void position(glm::vec3 position);
glm::vec3 position() const;
const glm::mat4 & matrix() const;
protected:
glm::mat4 M;
glm::mat4 base;
glm::mat4 rotation, translation, scaletion;
std::unordered_set<Node *> children;
void updateM();
};
#endif // TRANSFORM_H