Rotating Object

Started by
6 comments, last by Gelroth 15 years, 11 months ago
Hi everyone. Just imagine i have an object in 10.0f,10.0f,10.0f coordinates and i want to rotate this object itself not around the origin. I couldn't find any function about it? How can i solve this problem?
Advertisement
Translate the object to the origin, perform the rotation and then translate the object back.
Quote:Original post by SiCrane
Translate the object to the origin, perform the rotation and then translate the object back.



D3DXMATRIX * D3DXMatrixRotationAxis(  D3DXMATRIX *pOut,  CONST D3DXVECTOR3 *pV,  FLOAT Angle);[/sourceBuilds a matrix that rotates around an arbitrary axis.
Quote:Original post by XVincentX
Quote:Original post by SiCrane
Translate the object to the origin, perform the rotation and then translate the object back.



*** Source Snippet Removed ***
That has nothing to do with performing a rotation in different coordinate space, that rotates in the current coordinate space, around an arbitrary axis.
Quote:Translate the object to the origin, perform the rotation and then translate the object back.

SiCrane is correct if the object vertices are constructed at (10,10,10).

If the object is constructed at (0,0,0), then just rotate it as desired, then translate it to (10,10,10).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hi everyone.
Thanks for the function.
But i still have some problems about it.
http://img501.imageshack.us/my.php?image=rotatepl7.jpg

There are many object with different coordinates and i want to rotate them in axis y but when i give these coordinates in this function they dont rotate correctly.

first objects coordinates
cans[0].center_x=-70.0f;
cans[0].center_y=35.0f;

first vector coordinates
Rotate[0].x=-69;
Rotate[0].y=35;

for(int say=0;say<16;say++)
{
D3DXMatrixRotationAxis(&matRotate[say],&Rotate[say],rotation+=0.01);
}

Any suggestion?
I found that when i assign x and y coordinates for the function it rotates not only in y but also in x axis but i want it to rotate in only for axis y so i think that this function is useless for me.I also tried SiCranes solution but i couldnt succeed.Can anyone explain more about it?
Thanks already.
I solved it now
Thanks for everything.
By the way i used SiCrane's solution.

This topic is closed to new replies.

Advertisement