使用JOGL和gluLookAt的FPS相机

时间:2013-11-27 23:21:57

标签: opengl camera jogl

在显示中我有:

Camera c = new Camera(canvas);
glu.gluLookAt(c.eyeX, c.eyeY, c.eyeZ, c.point_X, c.point_Y, c.point_Z, 0, 1, 0);

这些变量来自我的Camera类中的对象:

float eyeX = 5.0f, eyeY = 5.0f, eyeZ = 5.0f;
float camYaw = 0.0f;       //camera rotation in X axis
float camPitch = 0.0f;     //camera rotation in Y axis
float point_X = 10.0f;
float point_Y = 5.0f;
float point_Z = 5.0f;

我计算鼠标移动的delta值,camYaw从0度到360度 和camPitch从-90到90度(或0 - 2PI和 - + PI / 2)

这很好但是当我把计算出的point_X,point_Y,point_Z放到gluLookAt()时,它以一种奇怪的方式移动凸轮(似乎它会根据等值中的给定半径将相机旋转到不可见的球体)< / p>

public void updateCamera() {
float radius = 5.0f;

point_X = (float) (radius * Math.cos(camYaw) * Math.sin(camPitch));
point_Z = (float) (radius * Math.sin(camPitch) * Math.sin(camYaw));
point_Y = (float) (radius * Math.cos(camPitch));

}

我试图将极地转换为笛卡尔坐标。

半径越大越“工作”。

从度数变为弧度仍然无效。

0 个答案:

没有答案
相关问题