java - LWJGL FPS Camera rotation is limited to pixels
问题描述
I'm currently working on a small fps project for testing, although I am familiar with OpenGl (LWJGL). My problem here is that the rotation of the camera is not very smooth. It "jumps" from pixel to pixel, which is actually very obvious. How can I smoothen it out? [Link to footage:] https://www.youtube.com/watch?v=6Hgt1hXCKKA&feature=youtu.be
Summary of my code: I'm storing the current mouse position in a Vector2f;
I'm increasing yaw and pitch by the relative movement of the camera (new position - old position);
I'm moving the mouse to the center of the window
I'm storing the currennt position (center of the window) in the old position Vector2f
解决方案
One possible way is to treat the (delta) input of your input device (mouse, keyboard, whatever) not as absolute values for your new camera position or rotation angles, but to treat them as impulse or force to move/rotate in a certain direction. You would then simply use integration over some time differentials dt
to update the camera position/rotation with some damping/friction factor to reduce the translational or angular momentum of the camera for it to quickly come to a stop. This would be a somewhat physical simulation.
Another possible approach is via parametric interpolation: Whenever you receive a (delta) input of your input device, you calculate a new "desired target position or rotation angle" from that and then interpolate between the current and target state over time to reach that target.
推荐阅读
- php - 当我将我的项目上传到在线模式时,在登录 TokenMismatchException Laravel
- java - Android:当 Context 对象不允许 Parcelable 时,我应该如何在活动之间传递 ListView?
- .htaccess - 基于协议限制对目录的访问
- wordpress - 将所有子网址重定向到父页面
- for-loop - 对于表中的行,将行保存在临时表中以在 plpgsql 的选择查询中使用其数据
- azure - Azure 备份 - 文件系统一致、应用程序一致和崩溃一致
- php - 在 laravel 中从 UTC 时区将数据显示到 EST 时区
- r - 将文件名写入列标题
- python - 为什么我不能从 python 的类中导入函数?
- ios - iOS 动态表格视图周围有一个边框