Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
tlopes's avatar
tlopes
Honored Guest
12 years ago

View/Projection Handedness Conversion

The LibOVR documentation, and of course the LibOVR library itself uses a right-handed projection matrix and a right-handed view matrix. However, my game uses D3DXMatrixPerspectiveFovLH and D3DXMatrixLookAtLH to generate left-handed matrices. Which functions and equations should change (and where) to account for this disparity?

3 Replies

  • very cool, thanks
    south paws of the world unite. :)

    I am let handed, I had not noticed and major problems, as most game condition you to play Right Handed. I am glad there is a means of flipping them.
  • I am let handed, I had not noticed and major problems, as most game condition you to play Right Handed. I am glad there is a means of flipping them.

    Actually this isn't about the user being left or right handed.
    Left handed and right handed in this situation refers to the axis arrangement of cartesian space. For example, having X axis point right, Y axis point up and Z axis point backwards is right handed, while having X axis point right, Y axis point up and Z axis point forwards is left handed. It's impossible to just rotate from one handedness to another, you need to negate an axis.
    Left and right handed coordinates also result in different rotation directions. If you have Y axis as up and do a 90 degree rotation around Y, in left handed coordinates you would turn to the right, while in right handed coordinates you would turn to the left.
  • tlopes's avatar
    tlopes
    Honored Guest
    Ah, I figured it out and got it working. I modded my LibOVR such that instead of computing the projCenter projection matrix (see Util_Render_Stereo.cpp in the StereoConfig::UpdateEyeParams() function) like this:
    Matrix4f projCenter = Matrix4f::PerspectiveRH(YFov, Aspect, 0.01f, 1000.0f);

    It actually computes it like this:
    Matrix4f projCenter = Matrix4f::PerspectiveLH(YFov, Aspect, nearclip, farclip);

    Then, when applying the vofs for the ViewAdjust, to account for me using a LH view matrix and LibOVR expecting me to use a RH view matrix, I negated the translation (I guess this swaps the eye positions).

    Finally, and unrelated to handedness conversion, I needed to convert the ViewAdjust from meters to game units in worldspace. So in the case of my game and engine, the conversion is "1 game unit = 1.42cm", so everything was off until I scaled the ViewAdjust by that value (I think this should be mentioned in the SDK documentation as I couldn't find it anywhere!)

    You can watch this on your Rift and it should be 3D like it was when I recorded it (though I have no idea if you'll notice the IPD difference of 64 to my 66).
    http://www.youtube.com/watch?v=DZXGh4C5kmY