0

No, not a homework, and yeah, wasting a life with this, googling and trying because my math is a ... Please help me. I have Matrix4x4 data input comming from .X files what I want to use in Unity.

So let's say I read those 16 floats like:

Matrix4x4 mx = Matrix4x4.identity;
mx[0,0] = readfloat();
mx[1,0] = readfloat();
mx[2,0] = readfloat();
//...
mx[2,3] = readfloat();
mx[3,3] = readfloat();
return mx;

Using original values leads to have .X animations mirrored on Z axis (like right arm animation has left arm names, etc.).

So I heard, to convert data, I have to switch handedness, and closest I got was: -readfloat(); next to mx[...]: m20, m21, m02, m12, m23, and also all vertices negated on z, but final mx was still not good.

If anyone has experience with this, can help me out with the right negations?

Or maybe I missed to switch read order too? Some pages say that some conversions require to switch y with z, etc. Kinda clueless here :(

Zéiksz
  • 688
  • 1
  • 11
  • 25
  • DirectX historically uses left-handed view coordinates (although with the programmable shader pipeline, there's nothing in the API that is specific to left vs. right-handed view setups). X files therefore use left-handed view. Per the link above, you just need to flip the Z coordinate. – Chuck Walbourn Nov 13 '21 at 23:06
  • Thank you for your comment. I already got on that link before asking and as I write in my question I negated Z on vertices. That flips. But as bones come into the picture for animation, you need the matrices too. That is the ```Frame``` part and a ```Transform[]``` on Unity side. ```m23``` is negating z, rest is some rotation manipulation I do not get fully and hoped to get help here. – Zéiksz Nov 15 '21 at 06:59

0 Answers0