Rotation around specified point

E0613df9e198a3ebbad23b02b714eb42
0
ikk 101 Oct 08, 2005 at 10:59

Hi.

How to specify point around which to rotate object ?
im using following directx functioms

to move object:

D3DXMatrixTranslation( &m, lpvMovement->x, lpvMovement->y, lpvMovement->z );
mat *= m;

to rotate object:

D3DXMatrixRotationYawPitchRoll( &m, lpvRotation->x, lpvRotation->y, lpvRotation->z );
mat *= m;

lpvRotation points to vector that specifies how much to rotate.
lpvMovement points to vector that specifies how much to move.
later, before object is to be rendered im using mat matrix to set its placment:

pDev3d->SetTransform( D3DTS_WORLD, &mat );
lpcMesh->Render( pDev3d );

how to put together this + rotation around specified point?

2 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Oct 08, 2005 at 18:01

To rotate around a specified point p, you need to first translate by -p (this places p at the origin); then do the rotation; then translate by p (this moves the object back to where it was originally). Then you can continue with the other translation.

E0613df9e198a3ebbad23b02b714eb42
0
ikk 101 Oct 08, 2005 at 18:41

thanks, this clears things for me a bit