SimpleScene() { OVR::Ptr<OVR::ProfileManager> profileManager = *OVR::ProfileManager::Create(); OVR::Ptr<OVR::Profile> profile = *(profileManager->GetDeviceDefaultProfile( OVR::ProfileType::Profile_RiftDK1)); ipd = profile->GetIPD(); eyeHeight = profile->GetEyeHeight(); // setup the initial player location player = glm::inverse(glm::lookAt( glm::vec3(0, eyeHeight, ipd * 4.0f), glm::vec3(0, eyeHeight, 0), GlUtils::Y_AXIS)); OVR::Util::Render::StereoConfig ovrStereoConfig; ovrStereoConfig.SetHMDInfo(ovrHmdInfo); gl::Stacks::projection().top() = glm::perspective(ovrStereoConfig.GetYFOVRadians(), glm::aspect(eyeSize), 0.01f, 1000.0f); eyes[LEFT].viewportPosition = glm::uvec2(0, 0); eyes[LEFT].modelviewOffset = glm::translate(glm::mat4(), glm::vec3(ipd / 2.0f, 0, 0)); eyes[LEFT].projectionOffset = glm::translate(glm::mat4(), glm::vec3(ovrStereoConfig.GetProjectionCenterOffset(), 0, 0)); eyes[RIGHT].viewportPosition = glm::uvec2(hmdNativeResolution.x / 2, 0); eyes[RIGHT].modelviewOffset = glm::translate(glm::mat4(), glm::vec3(-ipd / 2.0f, 0, 0)); eyes[RIGHT].projectionOffset = glm::translate(glm::mat4(), glm::vec3(-ovrStereoConfig.GetProjectionCenterOffset(), 0, 0)); distortionScale = ovrStereoConfig.GetDistortionScale(); ovrSensor = *ovrManager->EnumerateDevices<OVR::SensorDevice>(). CreateDevice(); if (ovrSensor) { sensorFusion.AttachToSensor(ovrSensor); } if (!sensorFusion.IsAttachedToSensor()) { SAY_ERR("Could not attach to sensor device"); } }
SimpleScene() : eyes({ { PerEyeArg(LEFT), PerEyeArg(RIGHT) } }) { eyeHeight = 1.0f; applyProjectionOffset = true; applyModelviewOffset = true; { OVR::Ptr<OVR::ProfileManager> profileManager = *OVR::ProfileManager::Create(); OVR::Ptr<OVR::Profile> profile = *(profileManager->GetDeviceDefaultProfile(OVR::ProfileType::Profile_RiftDK1)); ipd = profile->GetIPD(); eyeHeight = profile->GetEyeHeight(); glm::mat4 modelviewOffset = glm::translate(glm::mat4(), glm::vec3(ipd / 2.0f, 0, 0)); eyes[LEFT].modelviewOffset = modelviewOffset; eyes[RIGHT].modelviewOffset = glm::inverse(modelviewOffset); } if (ovrManager) { ovrSensor = *ovrManager->EnumerateDevices<OVR::SensorDevice>().CreateDevice(); if (ovrSensor) { sensorFusion.AttachToSensor(ovrSensor); } } if (sensorFusion.IsAttachedToSensor()) { SAY("Attached"); } else { SAY("Attach failed"); } { OVR::HMDInfo hmdInfo; Rift::getHmdInfo(ovrManager, hmdInfo); OVR::Util::Render::StereoConfig config; config.SetHMDInfo(hmdInfo); gl::Stacks::projection().top() = glm::perspective(config.GetYFOVRadians(), eyeAspect, 0.01f, 1000.0f); glm::mat4 projectionOffset = glm::translate(glm::mat4(), glm::vec3(config.GetProjectionCenterOffset(), 0, 0)); eyes[LEFT].projectionOffset = projectionOffset; eyes[RIGHT].projectionOffset = glm::inverse(projectionOffset); } glm::vec3 playerPosition(0, eyeHeight, ipd * 4.0f); player = glm::inverse(glm::lookAt(playerPosition, glm::vec3(0, eyeHeight, 0), GlUtils::Y_AXIS)); CameraControl::instance().enableHydra(true); }