Jump to content
  • Advertisement
Sign in to follow this  
Anddos

How to Create an Angle from a Yaw/Pitch matrix

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

i am using this code which takes the Yaw and Pitch angles of the mouse with directx input

 

D3DXMatrixRotationYawPitchRoll(&matYawPitch, Yaw, 0.0f, Pitch);

 

what i want todo is fire bullets in the direction the matrix is set to, i am using std::list for the container type

 

Share this post


Link to post
Share on other sites
Advertisement

Multiply a forward vector ([0,0,1]) by the resulting matrix (matYawPitch).

Normalize for safety (but it should be normalized already).

 

The vector is the direction of the bullets.

 

 

L. Spiro

Share this post


Link to post
Share on other sites

I didnt know you could multiply a vector with a matrix?

 

There are several D3DX functions which use both vectors and matrices. In particular, D3DXVec2[3,4]Transformxxx applies a matrix to a vector. There are also functions such as D3DXVec3Project and ..Unproject which take multiple vectors and matrices.

 

In particular, for graphics work, multiplying a vector by a matrix is a very common math process. You don't see it explicitly as much in D3DX9 because a large portion of the conversion of positions and directions (vectors) by matrices is done in the GPU. But that's the base process for rendering vertices (vectors) using the world, view and projection matrices.

Edited by Buckeye

Share this post


Link to post
Share on other sites

wouldnt i need to use D3DXVec3TransformNormal, as i am looking to get a direction from the matrix?

Share this post


Link to post
Share on other sites

wouldnt i need to use D3DXVec3TransformNormal, as i am looking to get a direction from the matrix?

 

Yes.

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.

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

Sign me up!