我想这样做,使得俯仰偏航或滚动绕世界轴而不是局部轴旋转,但我不确定我是怎么做的。
Vector2 mouse_change = new Vector2(mouse_previous.X - mouse_new.X, mouse_previous.Y - mouse_new.Y);
camera_angles *= Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), mouse_change.X / 800f);
camera_angles *= Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), mouse_change.Y / 800f);
更新每一帧,然后我就有了。
view_matrix = Matrix.Invert(Matrix.CreateFromQuaternion(camera_angles) * Matrix.CreateTranslation(camera_position));
projection_matrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 0.2f, 500f);
答案 0 :(得分:0)
对于一个简单的答案,请将'camera_position'与你正在进行的'camera_angles'进行相同的旋转
//Add these operations
camera_position = Vector3.Transform(camera_position, Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), mouse_change.X / 800f));
camera_position = Vector3.Transform(camera_position, Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), mouse_change.Y / 800f));