Sign in to follow this  

How to rotate in local axes in Direct3D

This topic is 2586 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 guys,
my problem i've figured out is that i want to rotate a model in local X(or Y,Z) axis to give it a desired look. But it is getting rotated in global X after using D3DXMatrixRotationX(&matRotX, D3DXToRadian(angle)). (Obvious since World is global matrix)

Guys forgive me if this question is too trivial but i dint got any clue how to do it.

Pls help me out
Thanks

Share this post


Link to post
Share on other sites
You can first multiply with the inverse translation matrix (to place it back at the origin) and then multiply with the rotationmatrix. Then you multiply it again with the translation matrix. I'm not sure if there was a faster way of doing it using D3DX because i use my own math library.

Share this post


Link to post
Share on other sites
Hi thanks for replying but the approach u told its not working. i am already doing the translation in the end. What is the idea exactly i cant figure it out

Share this post


Link to post
Share on other sites
I'm going to jump the gun and assume that you are looking for a 6dof system. If so, you want to store your objects local axii, and use an arbitrary axis rotation, suppling the local axis as the vector to rotate around. Use this matrix to transform the other 2 axii.

some psuedocode


class object {
Vector3 front, right, up;

void Pitch(float radians) {

// to pitch we rotate about the local X axis
Matrix m;
m = AxisAngleRotationMatrix(right, radians);

// and transform our local z and y axii
Transform(up, m);
Transform(front, m);
}
void Roll(float radians) {
// to roll we rotate about the local Z axis
Matrix m;
m = AxisAngleRotationMatrix(front, radians);

// and transform the other 2 axii
Transform(right,m);
Transform(up,m);
}
}

Share this post


Link to post
Share on other sites

This topic is 2586 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.

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