Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Matrix XNA and OpenVR
Hi,
For information, OpenVR matrix are left handed and XNA/DirectX matrix are right handed.
Some rotations / positions are reversed.
Thank you for your help, it'll allow me to bring VR to MonoGame :)
# XNA Matrix
SX Rot Rot 0
Rot SY Rot 0
Rot Rot SZ 0
TX TY TZ 1
## Rotation X
1 0 0 0
0 -0.83 -0.54 0
0 0.54 -0.83 0
0 0 0 1
## Perspective : FOV 45°, Ratio 1024/800, near 0.1 far 1000
2.33 0 0 0
0 1.83 0 0
0 0 -1 -1
0 0 -1 0
# OpenVR Matrix
## Perspective
### Raw data
m0 1.19
m1 0
m2 -0.14
m3 0
m4 0
m5 0.99
m6 -0.11
m7 0
m8 0
m9 0
m10 -1
m11 -0.1
m12 0
m13 0
m14 -1
m15 0
### To XNA Matrix
var m = new Matrix(
mat.m0, mat.m4, mat.m8, mat.m12,
mat.m1, mat.m5, mat.m9, mat.m13,
mat.m2, mat.m6, mat.m10, mat.m14,
mat.m3, mat.m7, mat.m11, mat.m15);
1.19 0 0 0
0 0.99 0 0
-0.14 -0.11 -1 -1
0 0 -0.1 0
## Transform
### Raw data
m0 -0.94
m1 0
m2 -0.12
m3 -0.97
m4 0
m5 1
m6 0
m7 0.99
m8 0.12
m9 0
m10 -0.94
m11 -1.7
### To XNA Matrix
var m = new Matrix(
mat.m0, mat.m4, mat.m8, 0.0f,
mat.m1, mat.m5, mat.m9, 0.0f,
mat.m2, mat.m6, mat.m10, 0.0f,
mat.m3, mat.m7, mat.m11, 1.0f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.