-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.hpp
91 lines (65 loc) · 1.48 KB
/
View.hpp
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
91
/* ------------------------------------------------------
View - Std3D
--------------------------------------------------------*/
#ifndef _VIEW_
#define _VIEW_
#include "Matrix.hpp"
struct SPosition
{
SPosition(const float pitch, const float yaw, const float radius, const Vec3& lookAt);
void setRadius(float value)
{
mRadius = maximum(0.f, this->mRadius + value);
}
void setPitch(float value)
{
mPitch = normalize360(this->mPitch + value);
}
void setYaw(float value)
{
mYaw = normalize360(this->mYaw + value);
}
float mPitch;
float mYaw;
float mRadius;
Vec3 mLookAt;
};
// Orbital view
class CView
{
public:
CView(const SPosition& position);
const Matrix4x4& getMtxView() const
{
return mView;
}
Vec3 right() const
{
return Vec3(mView[0], mView[4], mView[8]);
}
Vec3 up() const
{
return Vec3(mView[1], mView[5], mView[9]);
}
Vec3 dir() const
{
return Vec3(mView[2], mView[6], mView[10]);
}
Vec3 scroll_dir() const
{
Matrix3x3 Myaw = Matrix3x3::makeRotateY(mFinalPosition.mYaw);
Myaw.transpose();
return Vec3(Myaw.m[2], Myaw.m[5], Myaw.m[8]);
}
Vec3 scroll_right() const
{
Matrix3x3 Myaw = Matrix3x3::makeRotateY(mFinalPosition.mYaw);
Myaw.transpose();
return Vec3(Myaw.m[0], Myaw.m[3], Myaw.m[6]);
}
void update(const SPosition& position);
private:
SPosition mFinalPosition;
Matrix4x4 mView;
};
#endif