Decomposing a 4x4 3D matrix

BlitzMax Forums/BlitzMax Programming/Decomposing a 4x4 3D matrix

Difference(Posted 2009) [#1]
For my opensource module assimp blitzmax I'm having major trouble decomposing and applying a 4x4 matrix into minib3d space.

I need to decompose this matrix: http://assimp.sourceforge.net/lib_html/data.html

see also http://assimp.svn.sourceforge.net/viewvc/assimp/trunk/include/aiMatrix4x4.inl?view=markup

into miniB3D space witch I think is a lefthanded coordinate system?

The Decompositions I have tried to make, are in the Decompose function here: http://code.google.com/p/blitzmax-assimp/source/browse/trunk/assimp.bmx

they are then applied in my test program:

http://code.google.com/p/blitzmax-assimp/source/browse/trunk/examples/hierarchy.bmx

in the ProccesIaNodeAndChildren() function.

Values does not look all bad, but I really need some help to find out where I'm going wrong.

(I've tried a lot of sign swapping and axis changing, but can't seem to get it right.)

Any help is mush appreciated!


gman(Posted 2009) [#2]
greetings :) a long while back i wrote something similar for minib3d that utilized the mesh loading features of irrlicht to load models into minib3d. i will take a peek when i get home tonight (about 6 hours from now). if you dont have an answer by then i will see if there is anything in that project that can help you out.


Difference(Posted 2009) [#3]
greetings :) Sounds great gman.


Difference(Posted 2009) [#4]
I seem to be onto something with this one

rx = bank
ry = heading
rz = attitude





gman(Posted 2009) [#5]
greetings :) my apologies on the delay. it looks like the only thing i did to accomplish it was to change the Z to negative Z while loading the tris. didnt really have to do anything with the matrices at all. it might be a bit different than what you are trying to do. my goal was to load the tris from the models loaded in Irrlicht and then load them into minib3d surfaces. here is a running project with source:

http://www.gprogs.com/irrlicht.mod/model_loader.zip

the beef is in minib3d_meshloader.bmx. specifically in the CreateSurfaceFromMeshBuffer() method. also included is the underlying C file (imeshbuffer_wrap.h) that does the translation. the bSwap parameter was added for minib3d. in specific, check out the function:

IrrScene_IMeshBuffer_fillS3DVertexVerticesPtrs()

if you have any questions shoot :) dont mind all the ramblings in there. i type comments while i ideate :)


Difference(Posted 2009) [#6]
hi again. thanks gman.

You're right, I can't find any decomposition formulas in there :-)

Your tip on the z negation helped me out, so that now everything looks ok.

I'll have to do a little more swapping, to get Y_UP, but it seems ok for now.


gman(Posted 2009) [#7]
fantastic :) glad i could help out! cant wait to see the results :)