所以我在读this教程的“反转相机方向矩阵”部分,我不明白为什么在计算相机的向上方向时,我需要将方向的逆乘以向上方向 vector ,而不仅仅是方向。
我画了下图来说明我对阅读的教程的理解。 我做错了什么?
最佳答案
好吧,该教程明确指出:
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/