Newer
Older
Dalai Felinto
committed
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
"""
Head Mounted Display
====================
Base class to be inherited by all HMDs
"""
TODO = True
class HMD:
def __init__(self):
self._device = None
self._near = -1
self._far = -1
self._projection_matrix = [[i for i in range(16)], [i for i in range(16)]]
self._orientation = [[i for i in range(4)] for i in range(2)]
self._position = [[i for i in range(3)] for i in range(2)]
self._width = [0, 0]
self._height = [0, 0]
@property
def projection_matrix_left(self):
return self._projection_matrix[0]
@projection_matrix_left.setter
def projection_matrix_left(self, value):
self._projection_matrix[0] = value
@property
def projection_matrix_right(self):
return self._projection_matrix[1]
@projection_matrix_right.setter
def projection_matrix_right(self, value):
self._projection_matrix[1] = value
@property
def width_left(self):
return self._width[0]
@property
def width_right(self):
return self._width[1]
@property
def height_left(self):
return self._height[0]
@property
def height_right(self):
return self._height[1]
def init(self):
"""
Initialize device
:return: return True if the device was properly initialized
:rtype: bool
"""
return TODO
def setup(self, color_texture_left, color_texture_right):
"""
Initialize device
:param color_texture_left: framebuffer object created externally
:type color_texture_left: GLuint
:param color_texture_right: framebuffer object created externally
:type color_texture_right: GLuint
:return: return True if the device was properly initialized
:rtype: bool
"""
return TODO
Dalai Felinto
committed
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
def update(self):
"""
Get fresh tracking data
:return: return left orientation, left_position, right_orientation, right_position
:rtype: tuple(list(4), list(3), list(4), list(3))
"""
return self._orientation[0], self._position[0], self._orientation[1], self._position[1]
def frameReady(self):
"""
The frame is ready to be send to the device
"""
return TODO
def quit(self):
"""
Garbage collection
"""
return TODO
def _cameraClippingChanged(self, near, far):
"""
check if near of far values changed
"""
if near == self._near and far == self._far:
return False
self._near = near
self._far = far
return True
def getProjectionMatrixLeft(self, near, far):
if self._cameraClippingChanged(near, far):
self._updateProjectionMatrix(near, far)
return self.projection_matrix_left
def getProjectionMatrixRight(self, near, far):
if self._cameraClippingChanged(near, far):
self._updateProjectionMatrix(near, far)
return self.projection_matrix_right