D3DX Matrix math screwed, or mine?

Started by
0 comments, last by steve_- 21 years, 4 months ago
Hi, I''m having some troubles with my matrix math using D3DX. I hope somebody is willing and able to help me. Ok, here is the setup: I''ve got a matrix. It represents the position, rotation and scaling (duh) in a world. I can rotate/translate/scale it using the DX functions. For example, the translation code is: D3DXMATRIX matTmp; D3DXMatrixTranslation(&matTmp, x, y, z); m_Mat = matTmp * m_Mat; m_Mat is the matrix I''m talking about (which is in its initial state, an identity matrix). Now I want to shoot a projectile in the same direction the "player" is looking at. I copy the matrix and calculate a vector for the projectile, this way: D3DXVECTOR3 vec1, vec2, vec3; D3DXMATRIX matTmp; D3DXMatrixIdentity(&matTmp); D3DXVec3TransformCoord(&vec1, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), &m_Mat); D3DXVec3TransformCoord(&vec2, &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &matTmp); D3DXVec3Subtract(&vec3, &vec1, &vec2); m_Vect = vec3; I thought this should give me a rotated (by the matrix) vector. Actually, it does, but its rotation is twice of that its supposed to be. For example: 90 degrees on the x axis instead of 45 degrees like the original matrix. I guess I''m doing something wrong, but I don''t know what. As far as I know, this should work, but it doesn''t. Thx, Steve_-
Advertisement
Ok,

I figured out the problem myself.

I was using the matrix (which is already rotated ''n stuff) and a rotated vector. ((DUH)^10)

Sorry for this.

Steve_-

This topic is closed to new replies.

Advertisement