Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


D3DX Matrix math screwed, or mine?

This topic is 5649 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

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_-

Share this post

Link to post
Share on other sites

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.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!