Commit 6106b8cd authored by Dalai Felinto's avatar Dalai Felinto
Browse files

head transformations working

parent 06cc89ce
......@@ -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
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment