   Matrix Inverses and Coordinate Transforms
  I'm trying to perform a coordinate transform with a complex matrix equation and I'm getting a little bit stuck.Basically I was doing a skinning export from Blender, and using it in OpenGL. The coordinate system in OpenGL I was using is different from blender, it is a -90 degree rotation about the x axis. What I have always been doing is just before writing my matrices to file I rotate them by 90 degrees so that they will match the opengl coordinate system. I've been using this for some time and have had no problems. However doing skinning requires some more complex matrix math and I think this naive approach is not working anymore.Say I have two matrices such that A*B = I (B = inv(A))(I is the identity matrix)If I do this in their original coordinate systems this holds true. But if I apply my coordinate transform to each matrix and do this again in their new coordinate system this equation doesn't hold anymore:(let R be the coordinate transform matrix, i.e a negative 90 degree X rotation)(A*R) * (B*R) != II discovered that I need to rotate one of them by the inverse coordinate transform to work:(inv(R)*A) * (B*R) = ISo that works. However now I have a more complicated equation and I don't know how to handle it:In the original coordinate system:A*B*C = 1However in the rotated system(A*R)*(B*R)*(C*R) != Iand (inv(R)*A)*(B*R)*(C*R) != I, so that's not working anymore.Is it not possible to change coordinate system such that all of my matrix chains will still evaluate properly? I'm thinking that instead of converting all of my matrices to a new coordinate system I need to keep them all in the original, plus maybe one coordinate system rotation matrix that I apply at the end of all of my skinning equations. Does this sound like the right idea?   
  This seems awfully complicated, there's a similar issue in 3ds Max whereby the objects are rotated 90 degrees about the x axis.  For some reason these modelling tools seem to prefer Z up as opposed to Y up.  However, with 3ds Max, when exporting collada files you have the option to export Y as up, which would make you life much easier - is there nothing similar in Blender?Failing that, why don't you just bake the rotation into the vertex positions beforehand?   ;Quote:Original post by karwosts(A*R) * (B*R) != IFirst off, I think that here is your misstake. You have to do a proper space transformation like:X * R = Y * Rinv(R) * X * R = Yin your case it would be X=A*B and Y=I (as you already mentioned):inv(R) * A * B * R = INow, try to transform each matrix M by inv(R)*M*R which leads to (inv(R)*A*R)*(inv(R)*B*R)=I<=>(inv(R)*A *B * R = I Quote:I'm thinking that instead of converting all of my matrices to a new coordinate system I need to keep them all in the original, plus maybe one coordinate system rotation matrix that I apply at the end of all of my skinning equations. Does this sound like the right idea?I use blender and an other ingame coordinate system too and I just convert the matrices AND vertices, try to use a complete space transformation.;Quote:I use blender and an other ingame coordinate system too and I just convert the matrices AND vertices, try to use a complete space transformation.I guess this was kind of what I was going for, although I was having trouble making it happen. What I was trying to show with my A*B example is that maybe for some bone I would have a bind matrix and an inverse bind matrix. I was thinking that I could rotate both matrices to my coordinate system by just rotating them both, but like I said once I rotate them they don't multiply to identity anymore. Sometimes it is more complex, like if I have a bone that is 3 levels from the root hierarchy. I will have one inverse bind matrix and then the bind matrix is composed by multiplying a hierarchy of parent bind matrices together. I was just having trouble figuring out how to treat each matrix that I export if I can't apply a simple "convert to this coordinate system" rotation to each one.Right now I'm leave vertices/bone matrices in blender's space and then just bake the rotation into my final instance matrix when rendering. That's working great at the moment so I'm not sure if its worth changing, but its good to think about options.Quote:However, with 3ds Max, when exporting collada files you have the option to export Y as up, which would make you life much easier - is there nothing similar in Blender?I'm sure there is some exporter that does this, but I'm using my own binary format and not collada files.Thanks for reading!