Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Simple Rotation Question...

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 tmason   Members   

326
Like
0Likes
Like

Posted 27 May 2014 - 05:24 PM

Hello,

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.



#2 JohnnyCode   Members   

1164
Like
0Likes
Like

Posted 01 June 2014 - 07:49 AM

 

/*

DirectionOfWhereCameraIsFacing is calculated from mouse....

This.

 

You have a constant 2d vector you subtract from volatile mouse 2d position- very likely. Just change the order of subtraction on the X component, it will inverse mouse horizontaly. Do not change the routine

 






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.