C++ OpenGL gluLookAt help

C++ OpenGL gluLookAt help

本文关键字:help gluLookAt OpenGL C++      更新时间:2023-10-16

我一直在尝试使用gluLookAt,但我遇到了一些问题......我首先是相机的默认位置是什么,每当我尝试使用它时,我的整个场景似乎都会横向和向上旋转......我的第二个问题是....从我读到的内容来看,它是gluLookAt(Posx,Posy,PosZ,偏航,俯仰,滚动,然后是三个向上向量)

但是偏航俯仰和滚动应该是什么顺序?

解决
相机的默认位置为 gluLookAt(0, 0, 0, 0, 0,-1, 0, 1, 0);感谢德鲁的所有帮助:D

你似乎得到了一些关于gluLookAt()参数的坏信息。 从 OpenGL 2.1 在线文档中,参数应如下所示:

eyeX, eyeY, eyeZ:
  World coordinates of camera location
centerX, centerY, centerZ:
  World coordinates of camera aimpoint (what it's looking at).
  This point will be in the center of the resulting image, assuming
  that it lies between the near & far clip planes.
upX, upY, upZ:
  A vector (preferrably orthogonal to the line of sight) that specifies the
  roll orientation of the camera (that is, which way is "up" in the image).

如您所见,没有明确提到俯仰、滚动或偏航。

此外,如果我没记错的话,默认情况下,相机位于 (0, 0, -1) - 但这并不重要,因为您几乎总是将 gluLookAt 的模型视图矩阵设置为标识。