Jump to content
  • Advertisement
Sign in to follow this  
Gelroth

Rotating Object

This topic is 3784 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Translate the object to the origin, perform the rotation and then translate the object back.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!