2013-01-31 32 views
0

当我在X轴上旋转相机时,如果Y旋转>或<大于0,它也旋转Z轴。
它为什么这样做?OpenGL - 不需要的z轴相机旋转

if(Keyboard.isKeyDown(Keyboard.KEY_UP)){ 
    xRot-=speed_rotation; 
    glRotatef(-speed_rotation, 1, 0, 0); 
} 
if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)){ 
    xRot+=speed_rotation; 
    glRotatef(speed_rotation, 1, 0, 0); 
} 
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)){ 
    yRot-=speed_rotation; 
    glRotatef(-speed_rotation, 0, 1, 0); 
} 

if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)){ 
    yRot+=speed_rotation; 
    glRotatef(speed_rotation, 0, 1, 0); 
} 

我想我知道是什么原因造成的,但我不那么肯定......

回答

2

不要glRotate()在键盘处理程序,只需更新你一样的X/Y轴旋转值”在你画画之前重新做和发出单人glRotate()s

+0

谢谢!我的代码现在看起来好多了。 – McDucky