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
6106b8cd
Commit
6106b8cd
authored
Oct 07, 2015
by
Dalai Felinto
Browse files
head transformations working
parent
06cc89ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
space_view3d_virtual_reality/hmd/__init__.py
View file @
6106b8cd
...
...
@@ -3,7 +3,7 @@ TODO = True
from
mathutils
import
(
Matrix
,
Vector
,
Quaternion
,
)
import
gpu
...
...
@@ -70,8 +70,8 @@ class HMD_Base:
self
.
_framebuffer_object
=
[
0
,
0
]
self
.
_color_object
=
[
0
,
0
]
self
.
_offscreen_object
=
[
None
,
None
]
self
.
_eye_
pose
=
[
Vector
((
0.0
,
0.0
,
0.0
)),
Vector
((
0.0
,
0.0
,
0.0
)
)]
self
.
_
head_transformation
=
Matrix
.
Identity
(
4
)
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
)]]
@
property
def
width
(
self
):
...
...
@@ -193,7 +193,19 @@ class HMD_Base:
"""
Update OpenGL drawing matrices
"""
TODO
camera_matrix
=
self
.
_getCamera
(
context
).
matrix_world
.
copy
()
camera_matrix_inv
=
camera_matrix
.
inverted
()
for
i
in
range
(
2
):
rotation_raw
=
self
.
_eye_orientation_raw
[
i
]
position_raw
=
self
.
_eye_position_raw
[
i
]
rotation
=
Quaternion
(
rotation_raw
).
to_matrix
().
to_4x4
()
position
=
Matrix
.
Translation
(
position_raw
)
transformation
=
position
*
rotation
self
.
_modelview_matrix
[
i
]
=
transformation
*
camera_matrix_inv
def
_getCamera
(
self
,
context
):
return
context
.
scene
.
camera
...
...
space_view3d_virtual_reality/hmd/oculus.py
View file @
6106b8cd
...
...
@@ -9,11 +9,6 @@ The bridge code is hosted at Visgraf:
http://git.impa.br/dfelinto/oculus_sdk_bridge
"""
from
mathutils
import
(
Vector
,
Matrix
,
)
from
.
import
HMD_Base
from
..lib
import
(
...
...
@@ -84,13 +79,12 @@ class Oculus(HMD_Base):
Get fresh tracking data
"""
try
:
TODO
# the data will change
data
=
self
.
_hmd
.
update
()
self
.
_head_transformation
=
Matrix
(
data
[
0
])
self
.
_eye_pose
[
0
]
=
Vector
(
data
[
1
])
self
.
_eye_pose
[
1
]
=
Vector
(
data
[
2
])
self
.
_eye_orientation_raw
[
0
]
=
data
[
0
]
self
.
_eye_orientation_raw
[
1
]
=
data
[
2
]
self
.
_eye_position_raw
[
0
]
=
data
[
1
]
self
.
_eye_position_raw
[
1
]
=
data
[
3
]
# update matrices
super
(
Oculus
,
self
).
loop
(
context
)
...
...
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