View Full Version : view transformation
11-01-2003, 01: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, 02: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-02-2003, 11:44 PM
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.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.