Hey, I am just wondering whether the * operator for matrices (IMatrix3 e.g.) has been implemented in Max.net? I got an error when trying to multiply two matrices in that way - it says I can not use the operator for the type IMatrix3. Greets and Thx in advance Michbeck |
| Hey, direct operators aren't supported at the moment (its a feature I will most definitely add though) but you can use the indirect ones for now. For example, operator * should be translated as "Multiply" function, + should be "Add" etc. (I don't remember exact naming off the top of my head), so you should be able to do something like IMatrix3 m3 = m1.Multiply( m2 ); Marsel Khadiyev (Software Developer, EPHERE Inc.) |
| Thx Marsel. There is actually a Multiply function with 15 overloaded version but non takes IMatrix3 as an argument or returns a matrix. Is there a mistake or do I have to look somewhere else for the multiply function - the IMatrix3 class doesn't have this function either. Greets, Michbeck |
| You're right, IMatrix3 seems to have not translated those operators for some reason. I didn't notice this because I only dealt with IPoint3 operators personally. I've put this on todo for next build. Meanwhile perhaps you can implement a custom/standard row/column multiplication function? Here's one I have (from an unrelated project) for 3x3 matrix: public static Matrix3 operator *( Matrix3 m1, Matrix3 m2 ) { Matrix3 result = Matrix3.Zero; for( int i = 0; i < 3; ++i ) { for( int j = 0; j < 3; ++j ) { for( int k = 0; k < 3; ++k ) { result[i, j] += m1[i, k] * m2[k, j]; } } } return result; } And for a 4x3 transform (which is what Matrix3 is in Max, I believe): public static Xform3 operator *( Xform3 xform1, Xform3 xform2 ) { Xform3 result = new Xform3(); Matrix3 mR = xform1.Rotation;
// multiply rotation matrices result.Rotation = mR * xform2.Rotation;
// d = M.R * N.t + M.t result.Translation = ( mR * xform2.Translation ) + xform1.Translation;
return result; } The above function uses column-major format, I think Max uses row-major so some transposing might be required. Sorry for this inconvenience. Marsel Khadiyev (Software Developer, EPHERE Inc.) |
| Thx Marsel, ok until the next build I am going to deal with it according to the method templates you posted. Yes you are right, 3dsmax uses 4x3 matrices in row-major format - so the translation components of the matrix are in the 4th row and not in the 4th column as usual in math. Regards, Michbeck |
| Just fixed this, look for it in the next build. Marsel Khadiyev (Software Developer, EPHERE Inc.) |