Correct matrix layout documentation

Actually, both OpenGL and DirectX specify a matrix layout where the base vectors and the translational
part is consecutive in memory.
OpenGL uses post-multiplication of column-vectors and stores the matrix in column-major storage format:

    | X1  Y1  Z1  T1 |  | a |
    | X2  Y2  Z2  T2 |  | b |
    | X3  Y3  Z3  T3 |  | c |
    |  0   0   0   1 |  | 1 |

DirectX on the other hand uses row-major storage format but also pre-multiplication of
row-vectors

    | a b c 1 | | X1  X2  X3  0 |
                | Y1  Y2  Y3  0 |
                | Z1  Z2  Z3  0 |
                | T1  T2  T3  1 |

So a matrix is stored the same way in both frameworks and both times the translational part is consecutive,
which is not the format that Assimp uses.
pull/1698/head
Manuel Freiberger 2018-01-11 20:58:47 +01:00 committed by GitHub
parent 47c8971b52
commit 33ddbf9aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

@ -566,19 +566,22 @@ A typical 4x4 matrix including a translational part looks like this:
X1 Y1 Z1 T1 X1 Y1 Z1 T1
X2 Y2 Z2 T2 X2 Y2 Z2 T2
X3 Y3 Z3 T3 X3 Y3 Z3 T3
0 0 0 1 0 0 0 1
@endcode @endcode
with <tt>(X1, X2, X3)</tt> being the image of the X base vector, <tt>(Y1, Y2, Y3)</tt> being the image of the with <tt>(X1, X2, X3)</tt> being the local X base vector, <tt>(Y1, Y2, Y3)</tt> being the local
Y base vector, <tt>(Z1, Z2, Z3)</tt> being the image of the Z base vector and <tt>(T1, T2, T3)</tt> being the Y base vector, <tt>(Z1, Z2, Z3)</tt> being the local Z base vector and <tt>(T1, T2, T3)</tt> being the
translation part. offset of the local origin (the translational part).
All matrices in the library are row-major. That means that the matrix elements are stored row by row in memory, All matrices in the library use row-major storage order. That means that the matrix elements are
which is identical to the OpenGL matrix layout. So the above matrix is stored in memory as stored row-by-row, i.e. they end up like this in memory:
<tt>[X1, Y1, Z1, T1, X2, Y2, Z2, T2, X3, Y3, Z3, T3, 0, 0, 0, 1]</tt>. If you want to use these matrices <tt>[X1, Y1, Z1, T1, X2, Y2, Z2, T2, X3, Y3, Z3, T3, 0, 0, 0, 1]</tt>.
in a framework, which expects the matrix layout to be column-major (stored along the columns), such as
DirectX or Matlab, you will have to transpose the matrix first.
To be very precise: The transposition has nothing to do with a left-handed or right-handed coordinate system Note that this is neither the OpenGL format nor the DirectX format, because both of them specify the
but 'converts' between row-major and column-major storage format. matrix layout such that the translational part occupies three consecutive addresses in memory (so those
matrices end with <tt>[..., T1, T2, T3, 1]</tt>), whereas the translation in an Assimp matrix is found at
the offsets 3, 7 and 11 (spread across the matrix). You can transpose an Assimp matrix to end up with
the format that OpenGL and DirectX mandate. To be very precise: The transposition has nothing
to do with a left-handed or right-handed coordinate system but 'converts' between row-major and
column-major storage format.
<hr> <hr>