SimpleScene() { ipd = ovrHmd_GetFloat(hmd, OVR_KEY_IPD, OVR_DEFAULT_IPD); eyeHeight = ovrHmd_GetFloat(hmd, OVR_KEY_PLAYER_HEIGHT, OVR_DEFAULT_PLAYER_HEIGHT); if (!ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0)) { SAY_ERR("Could not attach to sensor device"); } for_each_eye([&](ovrEyeType eye){ textureIds[eye] = 0; }); memset(eyeTextures, 0, 2 * sizeof(ovrGLTexture)); float eyeHeight = 1.5f; player = glm::inverse(glm::lookAt( glm::vec3(0, eyeHeight, 4), glm::vec3(0, eyeHeight, 0), glm::vec3(0, 1, 0))); for_each_eye([&](ovrEyeType eye){ ovrSizei eyeTextureSize = ovrHmd_GetFovTextureSize(hmd, eye, hmd->MaxEyeFov[eye], 1.0f); ovrTextureHeader & eyeTextureHeader = eyeTextures[eye].Header; eyeTextureHeader.TextureSize = eyeTextureSize; eyeTextureHeader.RenderViewport.Size = eyeTextureSize; eyeTextureHeader.API = ovrRenderAPI_OpenGL; }); resetCamera(); }
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"); } }
RiftRenderingApp::RiftRenderingApp() { Platform::sleepMillis(200); if (!ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0)) { SAY_ERR("Could not attach to sensor device"); } memset(eyeTextures, 0, 2 * sizeof(ovrGLTexture)); for_each_eye([&](ovrEyeType eye){ ovrSizei eyeTextureSize = ovrHmd_GetFovTextureSize(hmd, eye, hmd->MaxEyeFov[eye], 1.0f); ovrTextureHeader & eyeTextureHeader = eyeTextures[eye].Header; eyeTextureHeader.TextureSize = eyeTextureSize; eyeTextureHeader.RenderViewport.Size = eyeTextureSize; eyeTextureHeader.API = ovrRenderAPI_OpenGL; }); }