PDA

View Full Version : Rotation around specified point


ikk
10-08-2005, 04:59 AM
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?

Reedbeta
10-08-2005, 12:01 PM
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.

ikk
10-08-2005, 12:41 PM
thanks, this clears things for me a bit