Jump to content
  • Advertisement
Sign in to follow this  
Dark Metamorphosis

build world matrix from vectors

This topic is 4702 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 every body, its been a long time. I am trying to build a world matrix from XYZ direction vectors and a pos vector, (I am not concerned about scaling). so here is what I do: [cpp] D3DXVECTOR3 X, Y, Z, Pos ; //Fill the vectors with Info D3DXMATRIX mat ; D3DXMatrixIdentity(&mat) ; mat._11 = X.x ; mat._12 = Y.x ; mat._13 = Z.x ; mat._21 = X.y ; mat._22 = Y.y ; mat._23 = Z.y ; mat._31 = X.z ; mat._32 = Y.z ; mat._33 = Z.z ; mat._41 = Pos.x ; mat._42 = Pos.y ; mat._43 = Pos.z ; [\cpp] even though this way seems to be logical, it doesn't work, for instance when my 3d object is supposed to point toward the left (z = (-1, 0, 0)), the 3d objects points toward the right, but when my object points toward the bottom (z = (0, 0, -1)), the object renders with correct orientation. do you have any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Assuming this is supposed to be an object rather than a view matrix, your basis vectors are transposed from what they should be. Try transposing the upper-left 3x3 submatrix and see if that doesn't fix the problem.

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!