我是OpenGL的新手,想知道我们使用矩阵是什么,如果有人能用抽象的直观方式解释我,因为在阅读参考书或任何教程时,所有这些都将矩阵作为已知的机制.我已经学习了数学矩阵,但由于英语不是我的母语,因此很难弄清楚某些东西是什么意思.
我在www.learnopengl.com找到了一个很好的例子,它说:
The model matrix. This matrix is used to place a model somewhere in the “world”. For example, if you have a model of a car and you want it located 1000 meters to the east, you will use the model matrix to do this.
The view matrix. This matrix represents the camera. If we want to view our car which is 1000 meters to the east, we’ll have to move ourselves 1000 meters to the east as well (another way of thinking about it is that we remain stationary, and the rest of the world moves 1000 meters to the west). We use the view matrix to do this.
The projection matrix. Since our screens are flat, we need to do a final transformation to “project” our view onto our screen and get that nice 3D perspective. This is what the projection matrix is used for.
这解释得非常好.但是,我们如何构建它们?它们有多大?
另外,我读过这个问题: glLoadIdentity()在OpenGL中做了什么?
那:
glMatrixMode(GL_PROJECTION)处理透视变换或正交变换使用的矩阵.
glMatrixMode(GL_MODELVIEW)处理模型视图转换使用的矩阵.也就是说,将对象(也称为模型)转换为视图坐标空间(或相机空间).
这些转变意味着什么以及如何计算?
我知道这里有很多问题,但我正在努力更好地构思所有这些,以便更好地了解OpenGL.这就是为什么我需要一些抽象的解释来深入了解所有细节,理解超越概念.
平移,旋转和缩放都是仿射变换,可以使用矩阵乘法和加法来实现.实际上,通过使用w始终为1 的元素来扩充向量,3维中的仿射变换将成为4维的线性变换,并且您需要的只是矩阵乘法.
使用矩阵乘法来做这件事是非常好的,因为(1)它很快并且(2)你不需要任何操作的特殊逻辑 - 你甚至可以根据需要编写这些仿射操作中的许多并仍然代表它用一个矩阵.
具有多种矩阵模式在编写时很有用.如果只有一个矩阵,则可以在任一端添加新操作,但不能在中间添加.通过稍后将3个矩阵相乘,您可以在顺序中的四个不同点处插入新操作.
矩阵堆栈也非常有用,因为它允许您对一些基元执行操作然后将其删除.如果您尝试通过执行逆操作来撤消操作,则最终舍入错误将失控.但是通过记住前面的矩阵,您可以将其恢复,就像旋转或任何从未发生的一样.
| 归档时间: | 
 | 
| 查看次数: | 480 次 | 
| 最近记录: |