libgoatvr
diff src/vr_openhmd.c @ 7:6896f9cf9621
- configure now emits config.status with the current confure invocation
- now vr_init will heed the VR_MODULE env var for the name of the module to use
- more stuff on the openhmd module
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 19 Sep 2014 15:16:51 +0300 |
parents | d861e4d6850f |
children | 3d9ec6fe97d7 |
line diff
1.1 --- a/src/vr_openhmd.c Fri Sep 19 05:30:20 2014 +0300 1.2 +++ b/src/vr_openhmd.c Fri Sep 19 15:16:51 2014 +0300 1.3 @@ -56,6 +56,7 @@ 1.4 ohmd_device_geti(dev, OHMD_SCREEN_HORIZONTAL_SIZE, &disp_width); 1.5 ohmd_device_geti(dev, OHMD_SCREEN_VERTICAL_SIZE, &disp_height); 1.6 ohmd_device_getf(dev, OHMD_EYE_IPD, &ipd); 1.7 + ipd /= 100.0f; /* convert ipd to meters */ 1.8 1.9 if((optdb = create_options())) { 1.10 set_option_int(optdb, VR_OPT_DISPLAY_WIDTH, disp_width); 1.11 @@ -104,28 +105,23 @@ 1.12 return -1; 1.13 } 1.14 1.15 -static int translation(int eye, float *vec) 1.16 +static void translation(int eye, float *vec) 1.17 { 1.18 - float xform[16]; 1.19 + /* OpenHMD doesn't support positional tracking, so just return the eye offset */ 1.20 1.21 - view_matrix(eye, xform); 1.22 - 1.23 - vec[0] = xform[3]; 1.24 - vec[1] = xform[7]; 1.25 - vec[2] = xform[11]; 1.26 - return 0; 1.27 + vec[0] = (eye == VR_EYE_LEFT ? -ipd : ipd) / 2.0; 1.28 + vec[1] = vec[2] = 0.0f; 1.29 } 1.30 1.31 -static int rotation(int eye, float *quat) 1.32 +static void rotation(int eye, float *quat) 1.33 { 1.34 if(!dev) { 1.35 quat[0] = quat[1] = quat[2] = 0.0f; 1.36 quat[3] = 1.0f; 1.37 - return -1; 1.38 + return; 1.39 } 1.40 1.41 ohmd_device_getf(dev, OHMD_ROTATION_QUAT, quat); 1.42 - return 0; 1.43 } 1.44 1.45 1.46 @@ -136,8 +132,8 @@ 1.47 1.48 static void proj_matrix(int eye, float znear, float zfar, float *mat) 1.49 { 1.50 - ohmd_device_setf(dev, OHMD_PROJECTION_ZNEAR, znear); 1.51 - ohmd_device_setf(dev, OHMD_PROJECTION_ZFAR, zfar); 1.52 + ohmd_device_setf(dev, OHMD_PROJECTION_ZNEAR, &znear); 1.53 + ohmd_device_setf(dev, OHMD_PROJECTION_ZFAR, &zfar); 1.54 ohmd_device_getf(dev, OHMD_LEFT_EYE_GL_PROJECTION_MATRIX + eye, mat); 1.55 } 1.56 1.57 @@ -166,7 +162,9 @@ 1.58 1.59 static void recenter(void) 1.60 { 1.61 - /* TODO does OHMD support the magnetometer? */ 1.62 + /* TODO grab the current rotation quat, invert it, and use it to 1.63 + * multiply with the rotation quat query results 1.64 + */ 1.65 } 1.66 1.67 1.68 @@ -180,6 +178,8 @@ 1.69 m.cleanup = cleanup; 1.70 m.set_option = set_option; 1.71 m.get_option = get_option; 1.72 + m.translation = translation; 1.73 + m.rotation = rotation; 1.74 m.view_matrix = view_matrix; 1.75 m.proj_matrix = proj_matrix; 1.76 m.begin = begin; 1.77 @@ -187,6 +187,7 @@ 1.78 m.set_eye_texture = set_eye_texture; 1.79 m.recenter = recenter; 1.80 } 1.81 + return &m; 1.82 } 1.83 1.84 #else /* don't use OpenHMD */