def _getMatrix(self): from oculusvr import Hmd from mathutils import ( Quaternion, Matrix, ) if self._hmd and Hmd.detect() == 1: self._frame += 1 poses = self._hmd.get_eye_poses(self._frame, self._eyes_offset) # oculus may be returning the matrix for both eyes # but we are using a single eye without offset rotation_raw = poses[0].Orientation.toList() position_raw = poses[0].Position.toList() rotation = Quaternion(rotation_raw).to_matrix().to_4x4() position = Matrix.Translation(position_raw) matrix = position * rotation matrix.invert() return matrix return None
def _startOculus(self): from oculusvr import ( Hmd, cast, POINTER, ovrHmdDesc, ovrVector3f, ) try: Hmd.initialize() except SystemError as err: self.logger.error( "Oculus initialization failed, check the physical connections and run again" ) if Hmd.detect() == 1: self._hmd = Hmd() self._description = cast(self._hmd.hmd, POINTER(ovrHmdDesc)).contents self._frame = 0 self._eyes_offset = [ovrVector3f(), ovrVector3f()] self._eyes_offset[0] = 0.0, 0.0, 0.0 self._eyes_offset[1] = 0.0, 0.0, 0.0 self._hmd.configure_tracking() self.logger.info(self._description.ProductName) else: self.logger.error("Oculus not connected") raise Exception
def _startOculus(self): from oculusvr import ( Hmd, cast, POINTER, ovrHmdDesc, ovrVector3f, ) try: Hmd.initialize() except SystemError as err: self.logger.error("Oculus initialization failed, check the physical connections and run again") if Hmd.detect() == 1: self._hmd = Hmd() self._description = cast(self._hmd.hmd, POINTER(ovrHmdDesc)).contents self._frame = 0 self._eyes_offset = [ ovrVector3f(), ovrVector3f() ] self._eyes_offset[0] = 0.0, 0.0, 0.0 self._eyes_offset[1] = 0.0, 0.0, 0.0 self._hmd.configure_tracking() self.logger.info(self._description.ProductName) else: self.logger.error("Oculus not connected") raise Exception
def quit(self): from oculusvr import Hmd if self._camera: self._camera.matrix_world = self._matrix_world self._camera.data.lens = self._lens if Hmd.detect() == 1: self._hmd.destroy() self._hmd = None Hmd.shutdown()