PDA

View Full Version : Rotating the axis?



Loopy
01-14-2001, 12:28 AM
Howdy

I've got a problem that I'm pretty sure I've solved before but I can't work it out and I'm running out of hair to pull out. I've got something I want to rotate and then rotate again depending on user input. Which is fine and it works etc.

I'm storing the rotation of the object as rotx,roty,rotz.

The problem is that I want the axis to move with the object, if that makes sense. So it rotates as if its rotating from 0 each time. So that if rotx=90, rotating around y doesn't cause it just to spin.

I really hope that makes sense. It's driving me nuts.

Thanks.

Loopy
01-15-2001, 01:44 AM
And incase it matter I'm using my own rotation function instead of glRotatef because I need to keep track of the positions of things.

Any ideas??

01-15-2001, 04:36 AM
When you create the rotation matrix just start with the
identity every time.

So (in hypothetical C++):

Matrix m;
m.loadIdentity();
m.myRotate(rotx,roty,rotz);

Michael Steinberg
01-15-2001, 04:52 AM
Are you talking about having your own modelview matrix that is affected any frame while rotation?
I can provide you with working code with which you can rotate the object about it's local axises even after a rotation.

Loopy
01-15-2001, 06:00 PM
Yup that sounds like it. I've got multiple objects that I want to be able to rotate around their own axis without that affect of them rotating around the "wrong" axis when they've already been rotated abit.

I'd be interested in seeing any code or pseudo code you think will help.

Thanks!