D3DMATRIX to D3DVECTOR

Started by
4 comments, last by Pactuul 22 years, 8 months ago
I have the "players" position, rotation, scaling, etc all stored in a D3DMatrix. I know that the _41, _42, _43 of the matrix store the player''s position. The question I have is how do I extract a vector for which direction it''s pointing. This would seem easy but with all programming projects shit happens =) I have looked over all the sdk and web sites and haven''t been able to find the answer Thanks in advance for the help, Pactuul "The thing I like about friends in my classes is that they can''t access my private members directly."
-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
Advertisement
While a relatively cheap trick, I''d just keep a D3DVECTOR copy of my player and read from that. I realize this is a hassle but its how I know how to do it. Because of the way I transform my players I find it works more reliably than matrices because of gimbal lock.

Just my 2 cents.
I''ve thought about doing that but like you said it seems like a hassle, keeping up with both , when I should only have to keep up with one.

There has to be a way to get the vector in which the final matrix is facing.

Pactuul

"The thing I like about friends in my classes is that they can''t access my private members directly."



-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
What if I took that matrix and a "unit matrix" that faced in the direction that I want and then multiply them some how or do a calculation to find the angle of two matrixs?


Pactuul

"The thing I like about friends in my classes is that they can''t access my private members directly."



-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
Few ideas.

D3DXVec3TransformNormal(&side,&D3DXVECTOR3(1,0,0),&matrix);
D3DXVec3TransformNormal(&up, &D3DXVECTOR3(0,1,0),&matrix);
D3DXVec3TransformNormal(&dir, &D3DXVECTOR3(0,0,1),&matrix);
D3DXVec3TransformCoord( &pos, &D3DXVECTOR3(0,0,0),&matrix);

This will get you the vectors. Should I inverse matrix first? Maybe, try out!

Or:

base = vec(m._11,m._12,m._13);
up = vec(m._21,m._22,m._23);
dir = vec(m._31,m._32,m._33);
pos = vec(m._41,m._42,m._43);

Does it work this way? Try out.
THANK YOU....that''s exactly what I need.
I used the transformcoords and normals to get those vectors.. I did have to inverse the matrix to produce the right numbers.

Now I can use the dot product to figure out the angle between those vectors and the respect normals to extract how many degrees off the normals they are.. That was a lot help stefu..


Pactuul

"The thing I like about friends in my classes is that they can''t access my private members directly."



-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."

This topic is closed to new replies.

Advertisement