我正在按照 教程 学习 OpenGL,他们在其中使用了 glm::lookAt()
函数来构建视图,但我无法理解 glm::lookAt()
的工作原理,而且显然没有 GLM 的详细文档.任何人都可以帮我了解 glm::lookAt()
的参数和工作吗?
I am following a tutorial to learn OpenGL in which they used glm::lookAt()
function to build a view but I cannot understand the working of glm::lookAt()
and apparently, there is no detailed documentation of GLM. Can anyone help me understand the parameters and working of glm::lookAt()
please?
GLM 文档说:
detail::tmat4x4<T> glm::gtc::matrix_transform::lookAt
(
detail::tvec3< T > const & eye,
detail::tvec3< T > const & center,
detail::tvec3< T > const & up
)
我目前的理解是摄像头位于eye
,面向center
.(而且我不知道 up
是什么)
My current understanding is that camera is located at eye
and is faced towards center
. (And I don't know what the up
is)
up
向量基本上是一个定义世界向上"方向的向量.在几乎所有正常情况下,这将是向量 (0, 1, 0)
即朝向正 Y.eye
是相机视点的位置,center
是您正在查看的位置(一个位置).如果你想使用方向向量D
代替中心位置,你可以简单地使用eye + D
作为中心位置,其中D
例如可以是单位向量.
The up
vector is basically a vector defining your world's "upwards" direction. In almost all normal cases, this will be the vector (0, 1, 0)
i.e. towards positive Y. eye
is the position of the camera's viewpoint, and center
is where you are looking at (a position). If you want to use a direction vector D
instead of a center position, you can simply use eye + D
as the center position, where D
can be a unit vector for example.
至于内部工作原理,或者更多细节,这是构建视图矩阵的常见基本功能.尝试阅读 gluLookAt() 的文档,它在功能上是等效的.
As for the inner workings, or more details, this is a common basic function for building a view matrix. Try reading the docs for gluLookAt() which is functionally equivalent.
这篇关于理解 glm::lookAt()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!