View Full Version : Simple Rotation Question...

05-27-2014, 04:59 PM

Thanks to various members of the forum here I am 90% there. Thank you.

I am just trying to resolve one last bit and I hope someone can point me to any easy errors I am making but not seeing.

My code works except when a person looks left the camera actually rotates right. Vice versa with looking right, camera rotates left.

Any idea what I am doing wrong here? Thank you.

I retrieve the orientation from the Oculus Rift like so.

OVR::Quatf OculusRiftOrientation = PredictedPose.Orientation;
glm::vec3 CurrentEulerAngles;
glm::quat CurrentOrientation;

OculusRiftOrientation.GetEulerAngles<OVR::Axis_X, OVR::Axis_Y, OVR::Axis_Z,
OVR::Rotate_CW, OVR::Handed_R>
(&CurrentEulerAngles.x, &CurrentEulerAngles.y, &CurrentEulerAngles.z);

CurrentOrientation = glm::quat(CurrentEulerAngles);

And here is how I calculate the LookAt:


DirectionOfWhereCameraIsFacing is calculated from mouse and standing position so that you are not constantly rotating after you move your head.


glm::vec3 DirectionOfWhereCameraIsFacing;
glm::vec3 RiftDirectionOfWhereCameraIsFacing;
glm::vec3 RiftCenterOfWhatIsBeingLookedAt;
glm::vec3 PositionOfEyesOfPerson;
glm::vec3 CenterOfWhatIsBeingLookedAt;
glm::vec3 CameraPositionDelta;

RiftDirectionOfWhereCameraIsFacing = DirectionOfWhereCameraIsFacing;
RiftDirectionOfWhereCameraIsFacing = glm::rotate(CurrentOrientation, DirectionOfWhereCameraIsFacing);
PositionOfEyesOfPerson += CameraPositionDelta;
CenterOfWhatIsBeingLookedAt = PositionOfEyesOfPerson + DirectionOfWhereCameraIsFacing * 1.0f;
RiftCenterOfWhatIsBeingLookedAt = PositionOfEyesOfPerson + RiftDirectionOfWhereCameraIsFacing * 1.0f;

RiftView = glm::lookAt(PositionOfEyesOfPerson, RiftCenterOfWhatIsBeingLookedAt, DirectionOfUpForPerson);

Thank you for any help you can provide for this last piece.

06-01-2014, 08:13 PM
I don't know what's wrong but you can try negating your rotation parameters.