Talion

02-15-2004, 02:55 PM

This is a pretty basic issue so sorry if this has been answered before. For objects in my world I save orientation with a lookat and up vector. I'm having trouble finding the right euler angle rotations for it, though. I can get the yaw and pitch rotations fine, but I just can't get the object's roll to match the up vector in all (or even most) cases.

Unfortunately most stuff online dealing with this sort of maneuver are talking about cameras.

Basically the technique I'm using now is to get the yaw and then pitch rotations using the usual algebra. Then I take the up and do the opposite of the rotations I just found and compare it to the local up, i.e. 0,1,0 to find the roll. This is a bit of a special case nightmare but the results seem to come out about right when I eyeball them. It just doesn't work at all when all this goes into 3 sequential glRotatef calls. The order I'm using is y axis (yaw), x axis (pitch), z axis (roll).

Any suggestions?

Unfortunately most stuff online dealing with this sort of maneuver are talking about cameras.

Basically the technique I'm using now is to get the yaw and then pitch rotations using the usual algebra. Then I take the up and do the opposite of the rotations I just found and compare it to the local up, i.e. 0,1,0 to find the roll. This is a bit of a special case nightmare but the results seem to come out about right when I eyeball them. It just doesn't work at all when all this goes into 3 sequential glRotatef calls. The order I'm using is y axis (yaw), x axis (pitch), z axis (roll).

Any suggestions?