09-10-2014 07:07 AM
glm::mat4 BulletOrientationMatrix = glm::mat4(1.0f);
ovrMatrix4f OculusRiftOrientation = OVR::Matrix4f(Current_HeadPose[EyeToCalculate].Orientation).Inverted();
for (int o = 0; o < 4; o++) {
for (int i = 0; i < 4; i++) {
BulletOrientationMatrix[o][i] = OculusRiftOrientation.M[o][i];
}
}
AdjustedPitch += HorizontalAngle;
HorizontalAngle = 0;
BulletOrientationMatrix = glm::transpose(BulletOrientationMatrix);
BulletOrientationMatrix = glm::rotate(BulletOrientationMatrix, AdjustedPitch, glm::vec3(0.0f, 1.0f, 0.0f));
09-10-2014 07:38 AM
09-10-2014 01:24 PM
09-10-2014 01:48 PM
{ 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, -1, 0,
0, 0, 0, 1 }
09-10-2014 02:45 PM
"vrdaveb" wrote:
You may need to change the handedness of your matrix. Try multiplying by:{ 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, -1, 0,
0, 0, 0, 1 }
09-10-2014 03:04 PM
{ -1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 }
09-10-2014 03:34 PM
"vrdaveb" wrote:
Not sure what conventions your project is using. The first matrix just scaled the Z axis by -1. You might try scaling X and Y by -1 instead:{ -1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 }
09-10-2014 05:34 PM
OculusToGLMMatrix = glm::mat4(1.0f);
ovrMatrix4f OculusRiftOrientation = OVR::Matrix4f(Current_HeadPose[EyeToCalculate].Orientation);
for (int o = 0; o < 4; o++) {
for (int i = 0; i < 4; i++) {
OculusToGLMMatrix[o][i] = OculusRiftOrientation.M[o][i];
}
}
/*
The AdjustedPitch stays a certain value such that when the person moves their mouse the resultant rotation inside the
3D environment is added/subtracted from the Adjusted pitch.
In this way the person can rotate using the mouse and the Oculus Rift device freely.
*/
AdjustedPitch += HorizontalAngle;
HorizontalAngle *= CurrentMouseMovementSpeed * (*deltaTime);
OculusToGLMMatrix = glm::transpose(OculusToGLMMatrix);
/*
Change the "handedness" of the rotation using the following Rotation Fix matrix.
*/
GLfloat* RotationFixArray = new GLfloat[16] { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, -1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
glm::mat4 RotationFixOrientation = glm::make_mat4(RotationFixArray);
OculusToGLMMatrix *= RotationFixOrientation;
OculusToGLMMatrix = glm::rotate(OculusToGLMMatrix, AdjustedPitch, glm::vec3(0.0f, 1.0f, 0.0f));
CurrentRightDirection = glm::vec3(OculusToGLMMatrix[0][0], OculusToGLMMatrix[1][0], OculusToGLMMatrix[2][0]);
CurrentUpDirection = glm::vec3(OculusToGLMMatrix[0][1], OculusToGLMMatrix[1][1], OculusToGLMMatrix[2][1]);
CurrentViewingDirection = glm::vec3(OculusToGLMMatrix[0][2], OculusToGLMMatrix[1][2], OculusToGLMMatrix[2][2]);
/*
View adjusted position is from prior calculations based on the position of the eyes and the position of the device relative to the computer.
*/
CurrentCameraMatrix = glm::lookAt(ViewAdjustedPosition, ViewAdjustedPosition + CurrentViewingDirection, CurrentUpDirection);
09-10-2014 05:35 PM
02-26-2015 12:25 PM
"tmason101" wrote:
The problem with the above code that remains is head tilting not working.
Currently with the above code when you TILT your head left you tilt right and vice versa.
Is there anything I can do to fix that based on what you see above?
Thank you.