了解glm :: lookAt() [英] Understanding glm::lookAt()

查看:142
本文介绍了了解glm :: lookAt()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循教程来学习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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆