Jump to content
  • Advertisement
Sign in to follow this  
silvia_steven_2000

Spin the cube on 2 axes

This topic is 4849 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 All I have a cube centered at the origin. I am not gonna scale it nor translate it but I need to spin the cube around the x, y and z axes. here is what I do : device->setTransform(world, rot) where rot = quaternion to matrix4 (axisAngleToQuaternion(x-axis, angle)) each time I change the angle to make it spin. it works fine around a single axis. but I need the combined effect on 3 or 2 axes at the same time. I tied something like : rot = quat2mat4(current rot quat * axisAngleToQuaternion(x-axis, angle)) but I got a weird movement. I am almost sure that I do have quaternion multiplication and conversion to mat4 working fine. does any one see where I might be missing thanks allot, I appreciate your time.

Share this post


Link to post
Share on other sites
Advertisement
Since this is the DirectX forum, I'll assume you're using D3D and D3DX.

Try this:

float RotationAboutXAxis;
float RotationAboutYAxis; // Set these with your rotation values

D3DXMATRIX rot, m;

D3DXMatrixRotationY(&m, RotationAboutYAxis);
D3DXMatrixRotationX(&rot, RotationAboutXAxis);

rot *= m;

device->SetTransform(D3DTS_WORLD, &rot);

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!