Jump to content
  • Advertisement

Archived

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

d_a_p_a_n03

How to rotate a triangle around 2 axi!?

This topic is 5603 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 very new to DirectX Programming and I am just getting around to the rotating part. But what I wish to do now is not only rotate a triangle around the x axis but also simultaneously around the y - in otherwords, x and y together rotating. Here''s the code I have so far. Thanx in advance! static int iRotationDegrees = 0; //Setup a matrix to rotate iRotationDegrees degrees around the Y axis D3DXMATRIX matRotation; D3DXMatrixRotationZ(&matRotation, D3DXToRadian(iRotationDegrees)); //Set that matrix to the world transformation g_pDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matRotation); //Increment the degree of rotation iRotationDegrees++; if (iRotationDegrees == 360) iRotationDegrees = 0; From, The NeWbIe!

Share this post


Link to post
Share on other sites
Advertisement
//Setup a matrix to rotate iRotationDegrees degrees around the Y axis
D3DXMATRIX matRotation;
D3DXMatrixRotationZ(&matRotation, D3DXToRadian(iRotationDegrees));

D3DXMATRIX matYRotation;
D3DXMatrixRotationY( &matYRotation, D3DXToRadian( iRotationDegrees ) );

matYRotation *= matRotation;

// END MY CODE

This is known as concatenation - which is more or less just multiplying one matrix by another to produce a matrix that has the properties of both.

You might also want to look into D3DXMatrixRotationAxis.

Tom L

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.

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!