Matrix Multiply Prob!
Hello!
I my app I need to get 1 matrix out of a few lets say for instance 5 matrixes. All the time i tried it with multipliing with a Identity Matrix! But it did not work! Do you have any idea how to find a solution!
By the way I used the D3DXMatrixMultiply function!
Thanks
Retrieving 1 matrix out of 5 already concatenated matrices is not easy. Basically, you need to know the other four. You find each of the other four matrices'' inverses and multiply them with the concatenated one. This will give you the one your looking for. It''s much easier however to just store the 5 matrices and retrieve them when needed. Is that the answer you needed?
---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
Thank you! But I think I explained the prob wrong! I want to concate 5 matrixes to one! Is it the right way to use D3DXMatrixMultiply or do I have to do something special??
Nope, D3DXMatrixMultiply should work. Many problems come from the order of multiplication. Matrix multiplication is not commutative. I don''t know the situation you''re in, but if you''re trying to multiply transforms together, it can produce wierd results if not done right. If you think out the order first though, it makes sense. For example, if you want to rotate and translate an object and you want a world matrix for it, think it through. You don''t want to translate the object first becuase then when you rotate it, it will orbit around the world. Instead, you want to rotate it in local coords and then translate the matrix. D3DXMatrixMultiply just multiplies two matrices together so to do multiple ones, you need to call it multiple times and use the previous results as the matrix for the next call. Lol, Did that help?
---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
I tried it exactly the way you said! But it dosent work! In my app I need this for a mesh animation with frames! So i miltiplied the matrix of the mesh from the base frame to the frame the matrix is in! And it seems as if only the last two matrixes(top & 2nd level matrix) are conducted. Does anyone hav a solution!
This should work:
MATRIX A,B,C,D,E,Result;
Result=MatrixMultiply(A,B);
Result=MatrixMultiply(Result,C);
Result=MatrixMultiply(Result,D);
Result=MatrixMultiply(Result,E);
This is pseudo-code notation. D3DXMatrixMultiply takes the result matrix as a parameter.
A,B,C,D,E are your frame matrices. "A" should be the parent.
MATRIX A,B,C,D,E,Result;
Result=MatrixMultiply(A,B);
Result=MatrixMultiply(Result,C);
Result=MatrixMultiply(Result,D);
Result=MatrixMultiply(Result,E);
This is pseudo-code notation. D3DXMatrixMultiply takes the result matrix as a parameter.
A,B,C,D,E are your frame matrices. "A" should be the parent.
since D3DXMatrixMultiply returns a pointer, you can use it as a parameter eg
D3DXMatrixMultiply(A,D3DXMatrixMultiply(B,D3DXMatrixMultiply(C,D))
or should it be
D3DXMatrixMultiply(D3DXMatrixMultiply(D3DXMatrixMultiply(A,B),C),D)
given that i want to multiply in the order ABCD?
[edited by - walkingcarcass on July 31, 2002 7:36:34 AM]
D3DXMatrixMultiply(A,D3DXMatrixMultiply(B,D3DXMatrixMultiply(C,D))
or should it be
D3DXMatrixMultiply(D3DXMatrixMultiply(D3DXMatrixMultiply(A,B),C),D)
given that i want to multiply in the order ABCD?
[edited by - walkingcarcass on July 31, 2002 7:36:34 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement