-
Notifications
You must be signed in to change notification settings - Fork 0
/
vrprojection.h
124 lines (108 loc) · 2.76 KB
/
vrprojection.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef VRSETUP_H
#define VRSETUP_H
#include <QMatrix4x4>
#include <QtMath>
#include "vrgoggles.h"
/**
* @brief The VrProjection class holds properties of rendering system
*/
class VrProjection
{
public:
VrProjection();
~VrProjection();
class Viewport{
public:
float x;
float y;
float width;
float height;
float eyeX;
float eyeY;
};
class FieldOfView{
public:
FieldOfView(): mLeft(0),mRight(0),mBottom(0),mTop(0){}
float left() const;
void setLeft(float left);
float right() const;
void setRight(float right);
float bottom() const;
void setBottom(float bottom);
float top() const;
void setTop(float top);
QMatrix4x4 toPerspectiveMatrix(float near, float far) const;
private:
float mLeft;
float mRight;
float mBottom;
float mTop;
};
const FieldOfView &leftFOV() const;
const FieldOfView &rightFOV() const;
/**
* @brief viewport
* @param fov
* @param xOffsetM
* @return
*/
Viewport viewport(const FieldOfView& fov, float xOffsetM) const;
/**
* @brief updateFov
* @param screen_size_m Size of screen in m
* @param screen_size Size of screen in px
*/
void resize(const QSizeF &view_size_m, const QSize &view_size);
/**
* @brief canvasSize The canvas is virtual space which should be used for rendering of image for glasses in order to maintain
* detail all over the rendered goggles.
* @return Size of virtual canvas in px.
*/
QSize canvasSize() const;
/**
* @brief viewSize
* @return size of actual screen in px
*/
QSize viewSize() const;
/**
* @brief viewSizeM
* @return size of actual screen in m
*/
QSizeF viewSizeM() const;
/**
* @brief goggles
* @return
*/
const VrGoggles *goggles() const;
/**
* @brief setParamas The class will take care of params
* @param params
*/
void setGoggles(const VrGoggles& goggles);
/**
* @brief dpm
* @return Display point per meter
*/
float dpm() const;
float unitToM() const;
/**
* @brief rightViewProjection Apply right eye offset on given rotation
* @param rotation
* @return
*/
QMatrix4x4 rightViewProjection(const QQuaternion & rotation) const;
/**
* @brief leftViewProjection Apply left eye offset on giver rotataion
* @param rotation
* @return
*/
QMatrix4x4 leftViewProjection(const QQuaternion & rotation) const;
private:
FieldOfView leftEyeFov,rightEyeFov;
VrGoggles m_goggles;
float m_dpm;
QSize view_size;
QSizeF view_size_m;
QSize canvas_size;
};
#endif // VRSETUP_H