Sign in to follow this  
Gelroth

Rotating Object

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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
);[/source

Builds a matrix that rotates around an arbitrary axis.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this