-
Notifications
You must be signed in to change notification settings - Fork 8
/
r_pipeline.cpp
81 lines (61 loc) · 1.5 KB
/
r_pipeline.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
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
#include <string.h>
#include "r_pipeline.h"
namespace r {
pipeline::pipeline()
: m_scale(1.0f, 1.0f, 1.0f)
, m_time(0.0f)
, m_delta(0.0f)
{
m_rotate = m::mat4::rotate(m::vec3::origin);
}
void pipeline::setScale(const m::vec3 &scale) {
m_scale = scale;
}
void pipeline::setWorld(const m::vec3 &world) {
m_world = world;
}
void pipeline::setRotate(const m::mat4 &rotate) {
m_rotate = rotate;
}
void pipeline::setRotation(const m::quat &rotation) {
m_rotation = rotation;
}
void pipeline::setPosition(const m::vec3 &position) {
m_position = position;
}
void pipeline::setPerspective(const m::perspective &p) {
m_perspective = p;
}
void pipeline::setTime(float time) {
m_time = time;
}
void pipeline::setDelta(float delta) {
m_delta = delta;
}
const m::mat4 pipeline::world() const {
return m::mat4::translate(m_world) * m_rotate * m::mat4::scale(m_scale);
}
const m::mat4 pipeline::view() const {
m::vec3 target, up;
m_rotation.getOrient(&target, &up, nullptr);
return m::mat4::lookat(target, up) * m::mat4::translate(-m_position);
}
const m::mat4 pipeline::projection() const {
return m::mat4::project(m_perspective);
}
const m::perspective &pipeline::perspective() const {
return m_perspective;
}
const m::vec3 &pipeline::position() const {
return m_position;
}
const m::quat &pipeline::rotation() const {
return m_rotation;
}
float pipeline::time() const {
return m_time;
}
float pipeline::delta() const {
return m_delta;
}
}