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!?

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