Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Simple Rotation Question...

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2014

    Question Simple Rotation Question...


    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.

    Code :
    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:

    Code :
        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.

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2012
    I don't know what's wrong but you can try negating your rotation parameters.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts