View Full Version : a problem about ROTATION, thanks.
11-10-2002, 05:43 AM
I want image rotation controled by hand.
For example if i press left key then image rotate horizontally,
I want to control the image in 6 direction(left ,right ,up ,down ,outside and inside according to the screen).
At first I use glRotatef(X.XX,1.0,0.0,0.0);glRotatef(X.XX,0.0,1.0 ,0.0);glRotatef(X.XX,0.0,0.0,1.0);
But it can't rotate according to screen, later rotate axis was affected by the former rotation.if have a example code will be the best.
thanks a lot, help me please.
my e-mail: firstname.lastname@example.org
11-10-2002, 12:17 PM
If I understand right you only want the rotation to work once for each axis at a time...
EG... Pressing UP/DOWN will only rotate the object on the y axis and leaves the x and z axis alone... similar for LEFT/RIGHT for x and +/- for z
If so then I would suggest that you use 3 live variables xRot,yRot and zRot and 3 stored variables oldx,oldy,oldz and do something like the following:
if (key == UP) yRot++;
if (key == DN) yRot--;
if (key == LT) xRot++;
if (key == RT) xRot--;
if (key == '+') zRot++;
if (key == '-') zRot--;
Something like this would keep the history of the rotation angles but would only rotate the angles on the next scene draw if the appropriate button was drawn otherwise the last angle used when be kept and thus no rotation.
Theoretically anyway... I did a quick test with one of my programs and this theory worked... just remember the Pop and Push Matrix to make sure that the object rotates on its own axis.
Hope this helps somewhat..
11-10-2002, 06:23 PM
thanks for tina.
I do as your think at first,but I need continuesly change the rotation angle.And later I use glMultMatrixf(float &a);It can rotate at each own asix.But It can't rotate according to the screen(in another word, rotate in a fixed coordinate, image rotate the rotate asix didn't rotate).
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.