Jump to content
  • Advertisement

Archived

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

gumball

rotation in Immediate Mode

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

currently I can rotate an object one of its own axis, but how do I go about rotating an object around any point in space? to rotate around its own axis I go: D3DUtil_SetTranslateMatrix(matTrans,x,y,z); D3DUtil_SetRotateYMatrix( matRotate, m_fRotationCurrent ); D3DMath_MatrixMultiply( matWorld, matRotate, matTrans ); m_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&matWorld); m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX,lpVertices,TOTAL_VERTICES,0);

Share this post


Link to post
Share on other sites
Advertisement
Rotations are always performed around the origin (0,0,0) so if you wish to rotate about an arbitrary point in space:

1. translate so the point lies in the origin
2. rotate
3. translate it back to its original position.

In D3D you would do it like this:

D3DMATRIX T,R,TInv,World;
D3DUtil_SetTranslateMatrix(T,-Point.x,-Point.y,-Point.z);
D3DUtil_SetRotateYMatrix(R, m_fRotationCurrent);
D3DUtil_SetTranslateMatrix(TInv,Point.x,Point.y,Point.z);
D3DMath_MatrixMultiply(World,T,R);
D3DMath_MatrixMultiply(World,World,TInv);
m_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&matWorld);




- WitchLord

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!