View Full Version : view transformation
11-01-2003, 02:44 PM
I have created several models in opengl. if i want to press the left and right arrow key for spinning models in horizontal direction, and press the up and down key for spinning models in vertical direction, how can i set up?
11-01-2003, 03:05 PM
You rotate objects with glRotatef(angle, xdir, ydir, zdir);
Angle is in degrees, not in radians. If you want to rotate "in horizontal direction", then you want to rotate in the XOZ plane, hence rotate by glRotatef(angle, 0, 1, 0);
(the OY axis). For the other case rotate around the OX axis, hence glRotatef(angle, 1, 0, 0);
11-03-2003, 12:44 AM
glRotatef(rotx,1,0,0); //rot in vert
glRotatef(roty,0,1,0); //rot in horz
void Keyboard(unsigned char key, int , int )
Hope it can help. Thanks.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.