void IN_MotionSensor_Read(float &roll, float &pitch, float &yaw) { if (SFusion.IsAttachedToSensor()) { float predictionDelta = in_sensorPrediction.GetFloat() * (1.0f / 1000.0f); if (SFusion.GetPredictionDelta() != predictionDelta) { SFusion.SetPrediction(predictionDelta); } Quatf hmdOrient = SFusion.GetPredictedOrientation(); float y = 0.0f, p = 0.0f, r = 0.0f; hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&y, &p, &r); roll = -RADIANS_TO_DEGREES(r); // ??? pitch = -RADIANS_TO_DEGREES(p); // should be degrees down yaw = RADIANS_TO_DEGREES(y); // should be degrees left } else if (hasVR920Tracker && IWRGetTracking) { LONG y=0, p=0, r=0; if (IWRGetTracking(&y, &p, &r)==ERROR_SUCCESS) { yaw = y * 180.0f/32767.0f; pitch = p * -180.0f/32767.0f; roll = r * 180.0f/32767.0f; } } else { roll = angles[ROLL]; pitch = angles[PITCH]; yaw = angles[YAW]; } }
JNIEXPORT void JNICALL Java_de_fruitfly_ovr_OculusRift_pollSubsystem(JNIEnv *, jobject) { if (!Initialized) return; if (!pSensor) return; bool isPredictionEnabled = FusionResult.IsPredictionEnabled(); if (isPredictionEnabled) quaternion = FusionResult.GetPredictedOrientation(); else quaternion = FusionResult.GetOrientation(); quaternion.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll); }
__declspec(dllexport) void get_orientation(float *yaw, float *pitch, float *roll) { Quatf hmdOrient = SFusion.GetPredictedOrientation(); hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(yaw, pitch, roll); }