Newer
Older
"""
Oculus
======
Oculus (oculus.com) head mounted display
It uses a C app to connect with the SDK
The bridge code is hosted at Visgraf:
from ..lib import (
checkModule,
)
def __init__(self, context, error_callback):
super(Oculus, self).__init__('Oculus', True, context, error_callback)
@property
def projection_matrix(self):
if self._current_eye:
matrix = self._hmd.getProjectionMatrixRight(self._near, self._far)
else:
matrix = self._hmd.getProjectionMatrixLeft(self._near, self._far)
self.projection_matrix = matrix
return super(Oculus, self).projection_matrix
@projection_matrix.setter
def projection_matrix(self, value):
self._projection_matrix[self._current_eye] = \
self._convertMatrixTo4x4(value)
"""
Initialize device
:return: return True if the device was properly initialized
:rtype: bool
"""
self.setEye(0)
self.width = self._hmd.width_left
self.height = self._hmd.height_left
self.setEye(1)
self.width = self._hmd.width_right
self.height = self._hmd.height_right
if not super(Oculus, self).init():
raise Exception("Failed to initialize HMD")
raise Exception("Failed to setup Oculus")
self._hmd = None
return False
else:
return True
return self._hmd.setup(self._color_texture[0], self._color_texture[1])
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)
The frame is ready to be sent to the device
def reCenter(self):
"""
Re-center the HMD device
:return: return True if success
:rtype: bool
"""
return self._hmd.reCenter()
def quit(self):
"""
Garbage collection
"""
return super(Oculus, self).quit()