LWJGL中实现相机看向指定坐标功能技术求助
游戏相机看向指定世界坐标的实现求助
我正在尝试编写代码,实现游戏中相机看向世界指定坐标的功能,之前的尝试效果不佳,以下是我目前的实现代码(思路有可取之处,但实际效果不好):
public void lookAtCoordinate(Vector3f target) { double xSide = target.x - position.x; double ySide = target.y - position.y; double zSide = target.z - position.z; setRotation((float) Math.toDegrees(Math.acos(xSide / ySide)), (float) -Math.toDegrees(Math.acos(xSide / zSide)), 0); //setRotation(target.x - position.x, target.y - position.x, 0; }
请求技术帮助。游戏控制代码如下:
Game.newKeybind(GLFW_KEY_S, () -> { Game.cameraInc.z = 1; }); Game.newKeybind(GLFW_KEY_W, () -> { Game.cameraInc.z = -1; }); Game.newKeybind(GLFW_KEY_D, () -> { Game.cameraInc.x = 1; }); Game.newKeybind(GLFW_KEY_A, () -> { Game.cameraInc.x = -1; }); Game.newKeybind(GLFW_KEY_SPACE, () -> { Game.cameraInc.y = 1; }); Game.newKeybind(GLFW_KEY_LEFT_SHIFT, () -> { Game.cameraInc.y = -1; });
内容的提问来源于stack exchange,提问作者The Typholorian
相关产品推荐
相关产品推荐

