Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


iLikeCarrots

Member Since 19 Apr 2012
Offline Last Active Apr 23 2012 08:21 AM

Posts I've Made

In Topic: Skinning Matrices [Solved]

22 April 2012 - 11:23 AM

Thank you - I'll look over this and see where my code differs. Posted Image

EDIT: I found that my code is correct, but I didn't notice that all of the joints were using global positions, which is why the rotations appear to be offset. In Modo 401 'weightmap deformers' were used to rig geometry, and I didn't realize that the center of all the deformers was zero while the pivot position was always relative to the model center.

In Topic: Invert Transform Matrix [Solved]

22 April 2012 - 11:13 AM

Thank you, it appears to be working. I'm assuming that 1/scale will remove scaling on the inverse, but that alone won't remove the scaling multiplied with the original matrix, which is why I have to square it. I just hope that this is correct and won't end up with bugs later! Posted Image

Here is the fixed code: http://pastebin.com/EMu7zjcF
And the compile command: gcc -o Matrix Matrix.c -lm

In Topic: Invert Transform Matrix [Solved]

22 April 2012 - 09:23 AM

how did you end up with a 4 in position 14?

Sorry - those are remains from an earlier test that I didn't change correctly.

Also, can you print out those matrices at the bottom of the first post with more precision?

I'll post directly from the console to prevent typos..
  Object
   1.000000  0.000000  0.000000  0.000000
   0.000000  0.540302 -2.524413  0.000000
   0.000000  0.841471  1.620907  0.000000
   0.000000  0.000000  0.000000  1.000000
  Inverse
   1.000000  0.000000  0.000000 -0.000000
   0.000000  0.540302  0.841471 -0.000000
   0.000000 -0.841471  0.540302  0.000000
   0.000000  0.000000  0.000000  1.000000
  Inverse * Object
   1.000000  0.000000  0.000000  0.000000
   0.000000  1.000000 -0.000000  0.000000
   0.000000  0.000000  3.000000  0.000000
   0.000000  0.000000  0.000000  1.000000

Note: I wonder if the inverse of scale (1/scale) should be squared? Perhaps I should get another piece of paper and work through the math.

Also, here is code that compiles to demonstrate the problem. http://pastebin.com/ks07zNm2
Name the file as Matrix.c then compile with the command 'gcc -o Matrix Matrix.c -lm'

In Topic: Invert Transform Matrix [Solved]

21 April 2012 - 11:45 PM

I use the invertMatrix function from the first post. Argument A is the resulting inverted matrix, and B would be the object's matrix.

In Topic: Invert Transform Matrix [Solved]

21 April 2012 - 10:51 PM

you need to compute the product of the inverses in reverse order

I'm assuming that I did this part correctly - I performed Scaling * Rotation * Translation. I flipped the 3x3 rotation section along the diagonal, so the transformed indices (OpenGL) would be..

[0  1  2]
[4  5  6]
[8  9 10]

I don't know what "rot(1,0,0)" means.

I modified the description of my test. They are the values that I use in my object matrix, which is combined in the order Translation, Rotation, Scale.

Also for completeness, this is how I create the matrix. Position, rotation, and scale are arrays with three floats.
mat[12] = node->position[0];
mat[13] = node->position[1];
mat[14] = node->position[2];

float A = cos(node->rotation[1]), B = sin(node->rotation[1]);
float C = cos(node->rotation[0]), D = sin(node->rotation[0]);
float E = cos(node->rotation[2]), F = sin(node->rotation[2]);

mat[0] = ( A*E + B*D*F) * node->scale[0];
mat[1] = ( C*F		) * node->scale[0];
mat[2] = (-B*E + A*D*F) * node->scale[0];

mat[4] = ( B*D*E - A*F) * node->scale[1];
mat[5] = ( C*E		) * node->scale[1];
mat[6] = ( B*F + A*D*E) * node->scale[1];

mat[8] = ( B*C		) * node->scale[2];
mat[9] = (-D           ) * node->scale[2];
mat[10]= ( A*C		) * node->scale[2];

PARTNERS