Hey!
So, I’ve had a bit of a mind bending investigation into how USD performs transforms with GfMatrix4d.
It appears, that GfMatrix4d, as documented, is row order.
So m1
:
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15,
Is stored as:
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
Following a matrix where it’s stored in row-major, I would expect 3
(or [3]
) to be transformX.
I.e a transformation matrix would be:
m2
:
1, 0, 0, Tx,
0, 1, 0, Ty,
0, 0, 1, Tz,
0, 0, 0, 1,
However, it appears in USD that 12
is transformX, if we look at the order of values in a matrix where I have translated by 5
in X
. This would appear to be column-major.
( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (5, 0, 0, 1) )
So, in the above Translation matrix format, USD is expecting:
m3
:
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
Tx, Ty, Tz, 1,
This means when creating a matrix in row order following a typical transformation matrix definition of (matching my first row-major format matrix, m2
):
( (1, 0, 0, 5), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )
or:
1, 0, 0, 5,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
I definitely do not get the expected transform (the cube explodes).
Is there somewhere this is documented, such that we can apply the transposition in the best place possible?
Cheers,
James