tmason101
11 years agoHonored Guest
Quick question about getting orientation for OpenGL
Hello,
So I have a weird issue with orientation. Essentially I can get the correct position without an issue but my orientation is screwed up such that either looking up means I am looking down in the OpenGL environment OR looking left means I am looking right in the environment.
Obviously I would like it such that I am looking in the right direction at all times.
So, here is my code example:
With this code I currently look up in the OpenGL environment when I look down physically in real life.
My position, adjusted for both DK2 position tracking and eye-adjustment, is fine so it is just this orientation stuff.
Any assistance greatly appreciated!
So I have a weird issue with orientation. Essentially I can get the correct position without an issue but my orientation is screwed up such that either looking up means I am looking down in the OpenGL environment OR looking left means I am looking right in the environment.
Obviously I would like it such that I am looking in the right direction at all times.
So, here is my code example:
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));
With this code I currently look up in the OpenGL environment when I look down physically in real life.
My position, adjusted for both DK2 position tracking and eye-adjustment, is fine so it is just this orientation stuff.
Any assistance greatly appreciated!