Exemplo n.º 1
0
JNIEXPORT void JNICALL Java_de_fruitfly_ovr_OculusRift__1setPredictionEnabled(JNIEnv *, jobject, jfloat delta, jboolean enable) 
{
	if (Initialized)
	{
		FusionResult.SetPrediction(delta, enable);
	}
}
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];
		}
}
extern "C" RIFTAPI_API int InitRiftApi()
{
	OVR::System::Init();
	pManager = *DeviceManager::Create();

	pHMD     = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
	if (!pHMD)
	{
		return 0 ;
	}

	pSensor  = *pHMD->GetSensor();

	// Get DisplayDeviceName, ScreenWidth/Height, etc..

	pHMD->GetDeviceInfo(&hmdInfo);

	if (pSensor)
	{
		SFusion.AttachToSensor(pSensor);
		SFusion.SetPrediction(0.03f);
	}

	if(pSensor)
	{
		return 1;
	}

	return 0;
}