void initRift() { OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All)); pManager = *OVR::DeviceManager::Create(); //pManager->SetMessageHandler(this); pHMD = *pManager->EnumerateDevices<OVR::HMDDevice>().CreateDevice(); if (pHMD) { pSensor = *pHMD->GetSensor(); InfoLoaded = pHMD->GetDeviceInfo(&Info); strncpy(Info.DisplayDeviceName, RiftMonitorName, 32); RiftDisplayId = Info.DisplayId; EyeDistance = Info.InterpupillaryDistance; DistortionK[0] = Info.DistortionK[0]; DistortionK[1] = Info.DistortionK[1]; DistortionK[2] = Info.DistortionK[2]; DistortionK[3] = Info.DistortionK[3]; } else { pSensor = *pManager->EnumerateDevices<OVR::SensorDevice>().CreateDevice(); } if (pSensor) { FusionResult.AttachToSensor(pSensor); FusionResult.SetPredictionEnabled(true); float motionPred = FusionResult.GetPredictionDelta(); // adjust in 0.01 increments if(motionPred < 0) motionPred = 0; FusionResult.SetPrediction(motionPred); if(InfoLoaded) { riftConnected = true; riftX = Info.DesktopX; riftY = Info.DesktopY; riftResolutionX = Info.HResolution; riftResolutionY = Info.VResolution; } } #ifdef WIN32 getRiftDisplay(); #endif }
SensorFusionPredictionExample() { ovrManager = *OVR::DeviceManager::Create(); if (!ovrManager) { FAIL("Unable to create device manager"); } ovrSensor = *ovrManager->EnumerateDevices<OVR::SensorDevice>().CreateDevice(); if (!ovrSensor) { FAIL("Unable to locate Rift sensor device"); } ovrSensorFusion.SetGravityEnabled(true); ovrSensorFusion.SetPredictionEnabled(true); ovrSensorFusion.SetYawCorrectionEnabled(true); ovrSensorFusion.AttachToSensor(ovrSensor); }