Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dalai Felinto
virtual_reality_viewport
Commits
2215e406
Commit
2215e406
authored
Oct 16, 2015
by
Dalai Felinto
Browse files
Debug backend: improvement
parent
880bd637
Changes
2
Hide whitespace changes
Inline
Side-by-side
space_view3d_virtual_reality/hmd/__init__.py
View file @
2215e406
...
...
@@ -78,8 +78,8 @@ class HMD_Base:
self
.
_framebuffer_object
=
[
0
,
0
]
self
.
_color_object
=
[
0
,
0
]
self
.
_offscreen_object
=
[
None
,
None
]
self
.
_eye_orientation_raw
=
[[
i
for
i
in
range
(
4
)],
[
i
for
i
in
range
(
4
)
]]
self
.
_eye_position_raw
=
[[
i
for
i
in
range
(
3
)],
[
i
for
i
in
range
(
3
)
]]
self
.
_eye_orientation_raw
=
[[
1.0
,
0.0
,
0.0
,
0.0
],
[
1.0
,
0.0
,
0.0
,
0.0
]]
self
.
_eye_position_raw
=
[[
0.0
,
0.0
,
0.0
],
[
0.0
,
0.0
,
0.0
]]
self
.
_scale
=
self
.
_calculateScale
(
context
)
self
.
_updateViewClipping
(
context
)
...
...
@@ -239,7 +239,7 @@ class HMD_Base:
if
region
.
view_perspective
==
'CAMERA'
:
space
=
context
.
space_data
camera
=
space
.
camera
return
camera
.
matrix_world
.
copy
().
inverted
()
return
camera
.
matrix_world
.
inverted
()
else
:
return
region
.
view_matrix
.
copy
()
...
...
space_view3d_virtual_reality/hmd/debug.py
View file @
2215e406
...
...
@@ -37,8 +37,47 @@ class Debug(HMD_Base):
Get fresh tracking data
"""
print_debug
(
'loop()'
)
from
math
import
fmod
,
radians
from
mathutils
import
Matrix
global
time
speed
=
0.001
_range
=
45.0
time
=
fmod
(
time
+
speed
,
1.0
)
factor
=
time
*
2.0
if
factor
>
1.0
:
factor
=
2.0
-
factor
one
=
1.0
-
factor
# one goes from 0.0 to 1.0, and then from 1.0 to 0.0
# angle goes from - range * 0.5 to + range * 0.5
angle
=
(
one
*
_range
)
-
(
_range
*
0.5
)
quaternion
=
list
(
Matrix
.
Rotation
(
radians
(
angle
),
4
,
'Y'
).
to_quaternion
())
projection_matrix
=
self
.
_getProjectionMatrix
(
context
)
for
eye
in
range
(
2
):
self
.
_eye_orientation_raw
[
eye
]
=
quaternion
self
.
_projection_matrix
[
eye
]
=
projection_matrix
super
(
Debug
,
self
).
loop
(
context
)
def
_getProjectionMatrix
(
self
,
context
):
region
=
context
.
region_data
if
region
.
view_perspective
==
'CAMERA'
:
space
=
context
.
space_data
camera
=
space
.
camera
return
camera
.
calc_matrix_camera
()
else
:
return
region
.
perspective_matrix
.
copy
()
def
frameReady
(
self
):
"""
The frame is ready to be send to the device
...
...
@@ -52,17 +91,5 @@ class Debug(HMD_Base):
print_debug
(
'quit()'
)
return
super
(
Debug
,
self
).
quit
()
def
updateMatrices
(
self
,
context
):
"""
Update OpenGL drawing matrices
"""
camera
=
context
.
scene
.
camera
modelview_matrix
=
camera
.
matrix_world
.
inverted
()
projection_matrix
=
camera
.
calc_matrix_camera
()
for
i
in
range
(
2
):
self
.
_modelview_matrix
[
i
]
=
modelview_matrix
self
.
_projection_matrix
[
i
]
=
projection_matrix
global
time
time
=
0.0
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment