【发布时间】:2014-12-23 09:52:28
【问题描述】:
我的问题非常直接:如何构建 FPS 相机,就像在射击游戏中一样(你有枪,每当你旋转相机时,枪也会旋转。)
实际上,移动是没有问题的,只是(好吧,在我开始编码之前,我想说,我使用的是 libGDX,它是一个 opengl 框架,但是你会像我对 opengl 代码的理解一样理解所有人):
gun.transform.setTranslation(camera.position);// sets gun to the center of the camera
camera.rotate(0,1,0,-3); //rotates direction and up vector of the camera
gun.transform.rotate(0,1,0,-3); // rotates the gun
gum.transform.trn(0.18f, -0.12f, -0.24f); //offseting the gun, to be everytime in the right bottom corner of the screen
但这不起作用。相机的旋转比枪还多。它看起来像相机是球体......这不是我想要的。
【问题讨论】:
-
相机的位置必须随着枪的角度而改变。
-
如何计算?我试图做类似的事情,但它不是很精确
-
移除视图矩阵和任何转换模型相对于玩家位置的变换。