本文介绍了C ++ OpenGL gluLookAt帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用gluLookAt,但是遇到了一些问题...我的第一个问题是相机的默认位置,每当我尝试使用它时,我的整个场景似乎都向侧向旋转. ..我的第二个问题是....根据我的阅读,它是gluLookAt(Posx,Posy,PosZ,yaw,pitch,roll,然后是三个向上向量)

但是偏航俯仰应该处于什么顺序?

已解决
相机的默认位置为gluLookAt(0,0,0,0,0,-1,0,1,0);感谢德鲁(Drew)的所有帮助: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)-但这没关系,因为您几乎总是在将modelview矩阵设置为恒等的情况下调用gluLookAt. /p>

I have been attempting to use gluLookAt but i have come across some issues...my first is what is the default position of the camera, whenever i try to use it, my whole scene seems to rotate sideways and up....my second question is....from what i have read it is gluLookAt(Posx,Posy,PosZ,yaw,pitch,roll,then three up vectors)

but what order is yaw pitch and roll suppose to be in?

Solved
the default position of the camera is at gluLookAt(0, 0, 0, 0, 0,-1, 0, 1, 0); Thanks Drew for all your help :D

解决方案

You seem to have gotten some bad information about the arguments to gluLookAt(). From the OpenGL 2.1 online documentation, the arguments should be as follows:

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).

As you can see, there is no explicit mention of pitch, roll, or yaw.

Also, by default, the camera is at (0, 0, -1) if I recall correctly--but it doesn't matter since you'll almost always call gluLookAt with the modelview matrix set to the identity.

这篇关于C ++ OpenGL gluLookAt帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 13:08