Jump to content


- - - - -

Rotation around specified point


2 replies to this topic

#1 ikk

    Member

  • Members
  • PipPip
  • 87 posts

Posted 08 October 2005 - 10: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?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationBellevue, WA

Posted 08 October 2005 - 06: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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 ikk

    Member

  • Members
  • PipPip
  • 87 posts

Posted 08 October 2005 - 06:41 PM

thanks, this clears things for me a bit





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users