Right-Left handed transform matrix conversion - one more time )

Recommended Posts

Kuroyume0161    100
I know that this has been discussed to death, but then there seem to be a deadly number of variations for how to do this. I have a right-handed transformation matrix in this form (row major): R0x R1x R2x 0 - X-Axis Basis Vector R0y R1y R2y 0 - Y-Axis Basis Vector R0z R1z R2z 0 - Z-Axis Basis Vector Tx Ty Tz 1 The application into which this is being read and used uses a left-handed coordinate system. The matrix is applied to a unit sphere at the system origin. I don't care about transposition or row-column issues as this matrix form is being slotted into the native matrix form of the application. All that I need is that the rotations, scales, and translation are converted properly (i.e.: -z translation, -z rotations, no scale negation!) . Converting translation is so easy even a caveman can do it (me). Converting rotations never gets a straight answer on a proper method - and please don't quote linear algebra generalized equations. A direct method would be most appreciated. I've been using a reflection matrix: 1 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 1 And the results are mostly correct - but there are times when they are not. For completeness, the full transformation is thus: M = TL * O * !TL * T * R where M is the resultant transformation matrix, TL is translation to a position, O is an orientation (rotation matrix), T is the read-prepared transform matrix, R is the reflection matrix, '!' inverts the matrix, and the concatenation operations are right to left (!). So the operation is this: Reflect the T matrix (I have reservations about the affect that this might have on the 'TL * O * !TL' concatenation), make the sphere's origin coincident with the world origin, 'orient' it, and move it back to its own origin. Consider that I'm setting the transformation matrix of a primitive sphere in the application. Per my reservations mentioned above, I did try M = TL * O * !TL * !R * T * R but the results were not satisfactory at all so I moved on quickly. Thank you very much, Robert

Share on other sites
Kuroyume0161    100
I found the cause and it indeed was related to the additional matrix concatenation being affected by the reflection. Instead, I followed some advice about just negating the z column and row (minus the overlap [2][2]) and z translation. Works like a charm now!

This was very important as the matrices are applied to two spheres which guide joint weighting and the results were not pleasant with incorrect transforms!

Try the maths for that one! Sphere1 is an inclusion sphere - vertices inside it are weighted 1.0f, vertices outside both spheres are weighted 0.0f. Easy-peasy. Sphere2 is a blend sphere - the vertices within it are weighted by their linear distance from the surface of Sphere1 to the surface of Sphere2. Still easy-peasy, you think. But these spheres just start as unit spheres at the world origin - they are then scaled (non-uniformly mostly), translated, and rotated independently. Good luck! (I already solved it) ;P

Thanks,
Robert