From 1af2996cf2923522c19af27729b82941558ccd01 Mon Sep 17 00:00:00 2001 From: barnold1953 Date: Fri, 27 Jun 2014 09:53:31 -0700 Subject: [PATCH] Properly use body orientation for Oculus camera --- interface/resources/shaders/oculus.vert | 4 ++-- interface/src/devices/OculusManager.cpp | 4 ++-- interface/src/devices/OculusManager.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/resources/shaders/oculus.vert b/interface/resources/shaders/oculus.vert index 389615dde1..800fbd9317 100644 --- a/interface/resources/shaders/oculus.vert +++ b/interface/resources/shaders/oculus.vert @@ -35,7 +35,7 @@ vec2 TimewarpTexCoord(vec2 texCoord, mat4 rotMat) // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic // aberration and distortion). These are now "real world" vectors in direction (x,y,1) // relative to the eye of the HMD. Apply the 3x3 timewarp rotation to these vectors. - vec3 transformed = vec3( rotMat * vec4(texCoord.xy, 1, 1) ).xyz; + vec3 transformed = vec3( rotMat * vec4(texCoord.xy, 1, 1) ); // Project them back onto the Z=1 plane of the rendered images. vec2 flattened = (transformed.xy / transformed.z); @@ -47,7 +47,7 @@ vec2 TimewarpTexCoord(vec2 texCoord, mat4 rotMat) void main() { float timewarpMixFactor = color.a; - mat4 mixedEyeRot = EyeRotationStart * mat4(1.0 - timewarpMixFactor) + EyeRotationEnd * mat4(timewarpMixFactor); + mat4 mixedEyeRot = EyeRotationStart * (1.0 - timewarpMixFactor) + EyeRotationEnd * (timewarpMixFactor); oTexCoord0 = TimewarpTexCoord(texCoord0, mixedEyeRot); oTexCoord1 = TimewarpTexCoord(texCoord1, mixedEyeRot); diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 42aec65d82..dbcc1daaf0 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -258,7 +258,7 @@ void OculusManager::configureCamera(Camera& camera, int screenWidth, int screenH } //Displays everything for the oculus, frame timing must be active -void OculusManager::display(Camera& whichCamera) { +void OculusManager::display(const glm::quat &bodyOrientation, Camera& whichCamera) { #ifdef HAVE_LIBOVR //beginFrameTiming must be called before display if (!_frameTimingActive) { @@ -306,7 +306,7 @@ void OculusManager::display(Camera& whichCamera) { orientation.y = eyeRenderPose[eye].Orientation.y; orientation.z = eyeRenderPose[eye].Orientation.z; orientation.w = eyeRenderPose[eye].Orientation.w; - _camera->setTargetRotation(orientation); + _camera->setTargetRotation(orientation * bodyOrientation); _camera->update(1.0f / Application::getInstance()->getFps()); Matrix4f proj = ovrMatrix4f_Projection(eyeDesc[eye].Fov, whichCamera.getNearClip(), whichCamera.getFarClip(), true); diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index 607484b98d..34c93fd8f1 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -33,7 +33,7 @@ public: static void beginFrameTiming(); static void endFrameTiming(); static void configureCamera(Camera& camera, int screenWidth, int screenHeight); - static void display(Camera& whichCamera); + static void display(const glm::quat &bodyOrientation, Camera& whichCamera); static void reset(); /// param \yaw[out] yaw in radians