Jump to content
  • Advertisement
Sign in to follow this  
giugio

matrix

This topic is 3550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hy. I have a matrix in collada file like this: <matrix>1 0 0 0.47476 0 0 -1 -0.480625 0 1 0 -0.122112 0 0 0 1</matrix> how ransform it for apply the position transform in directx? THe matrix must be colum major or row major(is correct the term?) And how transform a 16 element array tro a D3DXMATRIX? THanks.

Share this post


Link to post
Share on other sites
Advertisement
D3D uses row vectors/matrices and row major order. Collada uses column matrices but in row major order (if I remember correctly). So you cannot simply load a Collada matrix into a D3D matrix memory and be happy.

E.g. a sequence of elements in Collada like
{ a b c d e f g h i j k l m n o p }
has an equivalent in D3D like
{ a e i m b f j n c g k o d h l p }
(if I made no error ;) )

The mathematical operation to correct this is the transposition. So the simplest way may be to load the D3D matrix storage with the Collada co-efficients and to apply D3DXMatrixTranspose(...). Of course, you can already use the above scheme and put the co-efficients one by one into the correct place during reading the Collada matrix.

Share this post


Link to post
Share on other sites
and , i have a z_up document, and i would transform to a y_up , then i must invert y with z and negate y:
x,z,-y how do the same with matrix?
thanks.

Share this post


Link to post
Share on other sites
To map (x,y,z,w) to (x,z,-y,w) you need a (row) matrix as follows:

[ 1 0 0 0 ]
[ 0 0 -1 0 ]
[ 0 1 0 0 ]
[ 0 0 0 1 ]

Notice please that I've completed the vectors by the homogeneous co-ordinate w, since D3D matrices are homogeneous (i.e. 4x4 elements). You should take the time and perform the multiplication on paper once to see how it works.

Share this post


Link to post
Share on other sites
thanks , but what i do with this matrix?

i have a direct3d matrix ?


dxTransp._11 = vPosition[posRot][0];
dxTransp._12 = vPosition[posRot][4];
dxTransp._13 = vPosition[posRot][8];
dxTransp._14 = vPosition[posRot][12];
dxTransp._21 = vPosition[posRot][1];
dxTransp._22 = vPosition[posRot][5];
dxTransp._23 = vPosition[posRot][9];
dxTransp._24 = vPosition[posRot][13];
dxTransp._31 = vPosition[posRot][2];
dxTransp._32 = vPosition[posRot][6];
dxTransp._33 = vPosition[posRot][10];
dxTransp._34 = vPosition[posRot][14];
dxTransp._41 = vPosition[posRot][3];
dxTransp._42 = vPosition[posRot][11];
dxTransp._43 = -vPosition[posRot][7];// for the translations i'm inverted they/x
dxTransp._44 = vPosition[posRot][15];





for the translate all is ok( i flip 42 with 43 and negate 43), but for the scale and the rotate what change i do(what i flip and what negate) in the matrix?
Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by haegarr
To map (x,y,z,w) to (x,z,-y,w) you need a (row) matrix as follows:

[ 1 0 0 0 ]
[ 0 0 -1 0 ]
[ 0 1 0 0 ]
[ 0 0 0 1 ]

Notice please that I've completed the vectors by the homogeneous co-ordinate w, since D3D matrices are homogeneous (i.e. 4x4 elements). You should take the time and perform the multiplication on paper once to see how it works.


I'm not understand , what I do with this matrix?I must multiply it for my matrix?
why?
Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!