当我在X轴上旋转相机时,Y旋转>或者<它也会旋转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);
}
我想我知道是什么导致了它,但我不太确定......
答案 0 :(得分:2)
键盘处理程序中不要glRotate()
,只需更新您正在执行的x / y旋转值,然后在您之前发出单个 glRotate()s
组绘制。