0

当我在 X 轴上旋转我的相机而 Y 旋转 > 或 < 小于 0 时,它也会旋转 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);
}

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

4

1 回答 1

2

不要在键盘处理程序中,只需像您正在做的那样更新 x/y 旋转值并在您绘制之前glRotate()发出一glRotate()s

于 2013-01-31T15:20:16.193 回答