Skip to main content
GameDev.net gamedev.net
🔒 Locked

matrices

Started by Freaker13 May 7, 2004 at 8:38 AM 2 replies 650+ views
Original Post
Freaker13
Freaker13
Hi all, i alway's used dx matrices but now i implemented my own. i can rorate ,scale and translate but when i first move my object and then rotate it it seems it moves like this - = object
------------ 
|           |   
|     -     | 
|           |
|------------


------------ 
|           |   
|   \       | 
|           |
|------------


------------ 
|           |   
|   /       | 
|           |
|------------


------------ 
|           |   
|     -     | 
|           |
|------------

------------ 
|           |   
|       \   | 
|           |
|------------
------------ 
|           |   
|       /   | 
|           |
|------------
[\code]
it it turns around his own axis and around the world origin
the order of my transformations is(the same as i used with dx)
world = scale*rotation
world = world*translation

thx in advance

   



[edited by - freaker13 on May 7, 2004 9:40:21 AM]   
Prozak
Prozak
Make sure that your matrix code is fully DX-compliant, in other words, check to see if DX''s matrices are row-major or column-major, and be sure yours follow the same type.

Also, instead of aplying a whole sequence of transformations to your model, aply just one, and see if the end result matches. Try to see if the problem arises from rotation and/or translation.

Create 2 similar functions, one that renders with DX alone, and another that does the transformation using your matrix class, see how much they are diferent.

Salsa cooked it, your eyes eat it!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"our stupidity allways comes back to bite us in the ass... in a white-shark sort of way..." - Prozak
Freaker13
Freaker13
its my rotation matrix that's wrong
dx matrix:

0.976588 0 0.215116
0 1 0
-0.215116 0 0.976588


my matrix:

0.976588 0 0.215116
0 1 0
0 0 0.976588

whats my fault? i use this algo to get the rotation matrix:

float A = (float) cos(eulerAngleX);
float B = (float) sin(eulerAngleX);
float C = (float) cos(eulerAngleY);
float D = (float) sin(eulerAngleY);
float E = (float) cos(eulerAngleZ);
float F = (float) sin(eulerAngleZ);
float AD =(float) A * D;
float BD =(float) B * D;

matrix[0][0] = C * E;
matrix[0][1] = -C * F;
matrix[0][2] = D;

matrix[1][0] = BD * E + A * F;
matrix[1][1] = -BD * F + A * E;
matrix[1][2] = -B * C;

matrix[2][0] = -AD * E + B * F;
matrix[2][1] = AD * F + B * E;
matrix[2][2] = A * C;



[edited by - freaker13 on May 7, 2004 6:38:31 PM]

[edited by - freaker13 on May 7, 2004 6:39:21 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.