当我尝试更新我的相机时遇到问题。
我想通过鼠标更改相机的俯仰和偏航(它的外观)但我希望鼠标保持定位在窗口的中心。
//where MouseP.x .y is the mouse position
//(which is centered to the current window)
//get old position of the mouse
OldP.x = MouseP.x;
OldP.y = MouseP.y;
//work out the distance traveled
Delta.x = MouseP.x - OldP.x;
Delta.y = MouseP.y - OldP.y;
//update the camera(using distance traveled)
Rot.Yaw -=Delta.x/5;
Rot.Pitch -= Delta.y/5;
//move mouse to the center of the screen
SetCursorPos(CENTER_SCREEN_X,CENTER_SCREEN_Y);
问题是当鼠标设置为返回原点时,相机会快速返回到某个点。
我想通过从原点行进的距离而不是返回原点的距离来更新相机。
如果我把它拿出来,它会很好地工作,但当时的鼠标可能会离开窗口。