c++ - OpenGL 相机方向

标签 c++ c opengl camera

所以我在读this教程的“反转相机方向矩阵”部分,我不明白为什么在计算相机的向上方向时,我需要将方向乘以向上方向 vector ,而不仅仅是方向

我画了下图来说明我对阅读的教程的理解。 我做错了什么?

enter image description here

最佳答案

好吧,该教程明确指出:

The way we calculate the up direction of the camera is by taking the "directly upwards" unit vector (0,1,0) and "unrotate" it by using the inverse of the camera's orientation matrix. Or, to explain it differently, the up direction is always (0,1,0) after the camera rotation has been applied, so we multiply (0,1,0) by the inverse rotation, which gives us the up direction before the camera rotation was applied.

此处计算的向上方向是世界空间中的向上方向。在眼睛空间中,向上 vector 是(0,1,0)(按照惯例,可以不同地定义它)。由于 View 矩阵会将坐标从世界空间转换为眼睛空间,因此我们需要使用逆矩阵将向上 vector 从眼睛空间转换为世界空间。您的图像是错误的,因为它与眼睛和世界空间没有正确关联。

关于c++ - OpenGL 相机方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27410921/

相关文章:

c++ - 如何捕获 sscanf 字符串的长度?

c - 很难在 C 中将结果相加(For 循环)

c++ - 正在同时修改指向的值和指针 UB

c++ - QTimer for QGLWidget,在其他机器上的绘图和计时不正确

c++ - 推送到 std::deque 时如何检测动态内存分配失败?

c++ - VSZ 和 RSS 在 AIX 上不断增加

c++ - 将大对象放在堆上的最佳方法是什么?

c - 指针未在 main 中更新

c++ - 在 OpenGL 中加载纹理时颜色错误

c++ - OpenGL 阴影故障