Properly use body orientation for Oculus camera

This commit is contained in:
barnold1953 2014-06-27 09:53:31 -07:00
parent 67c5281205
commit 1af2996cf2
3 changed files with 5 additions and 5 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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