You can decompose an affine transformation matrix T
into translation Pos
and rotation Rot
matrices using the following code:
mat4 Rot;
mat4 Pos;
mat4 InvT = T.GetInversed();
for ( int i = 0 ; i < 3 ; i++ )
{
for ( int j = 0 ; j < 3 ; j++ )
{
Rot[i][j] = InvT[j][i];
}
}
Pos = Rot.GetInversed() * vec3( -InvT[3].x, -InvT[3].y, -InvT[3].z );