Notifications
Clear all

[Closed] Matrix3 to matrix 4×4

I’m in the process of writing a new exporter, it expects the transform of objects to be in a matrix 4×4 format, like this:


 <transform>
 <matrix>
 0.001000000047497 0.000000000000000 0.000000000000000 0.000000000000000
 0.000000000000000 0.001000000047497 0.000000000000000 0.000000000000000
 0.000000000000000 0.000000000000000 0.001000000047497 0.000000000000000
 0.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000
 </matrix>
 </transform>

As I’ve understood it – maxscript gives it as matrix3,
I’m not too good with matrix math, so I’m seeking some help on getting the result I need from maxscript.

Do anyone of you have any suggestions?

7 Replies

if there is not specific rules how matrix4x4 handles the animation the conversion is simple:
this is matrix3
row1: r00, r01, r02
row2: r10, r11, r12
row3: r20, r21, r22
row4: r30, r31, r32
where rows 1…3 make rotation and scale, and row4 is position

the corresponding matrix4x4 is:
row1: r00, r01, r02, 0
row2: r10, r11, r12, 0
row3: r20, r21, r22, 0
row4: r30, r31, r32, 1

so if I understand you correct, then this would be how to get it?

 
 obj.transform.row1[1] obj.transform.row1[2] obj.transform.row1[3] 0
   obj.transform.row2[1] obj.transform.row2[2] obj.transform.row2[3] 0
 obj.transform.row3[1] obj.transform.row3[2] obj.transform.row3[3] 0
  obj.transform.row4[1] obj.transform.row4[2] obj.transform.row4[3] 1
 
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

that’s correct. but as i said above, double check that the engine that you convert to uses the same rotation rule as the max does.

Thanks DenisT, your explanation made it much easier to understand, it was much simpler then what I expected, so thanks a lot.

I’ll check the rotation order.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

also check that the engine uses inverse rotation (as max does).
max animation matrix3 is made as:
scale * (inverse rotation) * position
some engines use direct rotation.

i posted a pretty simple conversion manager if you need to work in other systems

Thanks for the help guys, I appreciate it.
I got some results now that seems to work.