OpenGL 投影矩阵
我有一个关于观察者及其投影平面以及如何准确计算应创建的投影点的问题。
前任。 观察者在原点,朝负 Z 方向看。 z = -2 处的投影平面。 点(-6,1,-4)。
我见过一些网站谈论使用相似的三角形,还有一些网站有一个矩阵来相乘。 对我来说,问题是我不知道如何设置其中之一。
我猜我的观众的观点是在原点(0,0,0,1)。 当我搜索透视投影矩阵时,我找到了一个设置这样的矩阵的网站。
1 0 0 0
0 1 0 0
0 0 0 0
0 0 1 0
但据我所知,我的观看者的点位于 (0, 0, 0, 1),那么投影对于如何将其纳入方程就没有意义。 该矩阵还需要根据在本网站上设置的公式进行调整:
http://www.cs.nps.navy.mil/people/faculty/capps/iap/class2/viewing/projection.html
我只是需要一点帮助来解决这个问题,我们在课堂上讨论的只是使用相似的三角形,这对我来说没有意义......
I have a question on taking a viewer and their projection plane and how exactly to calculate the projected point that should be created.
EX. Viewer at the origin, looking in the negative Z direction. Projection plane at z = -2. Point (-6,1,-4).
I have seen some websites talking about using similar triangles and some that have a matrix to multiply it by. The problem for me is I don't know how to set either one up.
I would guess that my viewer's point seeing as it is at origin (0, 0, 0, 1). When I search for the perspective projection matrix I find a site that sets up a matrix like this.
1 0 0 0
0 1 0 0
0 0 0 0
0 0 1 0
But seeing as my viewer's point as far as I can tell is at (0, 0, 0, 1) then the projection makes no sense as to how it factors into the equation. That matrix also needs to be adjusted as according to the formula to set it up on this site:
http://www.cs.nps.navy.mil/people/faculty/capps/iap/class2/viewing/projection.html
I just need a little help in figuring this out and what we discussed in class was only using similar triangles which does not make sense to me...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
观察者的位置通常不通过投影矩阵处理,而是通过模型视图矩阵处理。 投影矩阵仅处理从眼睛空间到剪辑空间的变换。
相机变换是通过将相机的逆变换应用为模型视图堆栈上的第一个矩阵来实现的。
使用 openGL 的高级图形编程
< a href="http://www.songho.ca/opengl/gl_transform.html" rel="nofollow noreferrer">OpenGL 变换
The viewer's position is usually not handled through the projection matrix, but the modelview matrix. The projection matrix only handles the transformation from eye-space to clip-space.
Camera transformation is achieved by applying the camera's inverse transformation as the first Matrix on the modelview stack.
Advanced graphics programming using openGL
OpenGL Transformation
考虑使用
glGet...()
函数读取 OpenGL 的矩阵,并自己通过相关矩阵运行顶点。 当然,首先要阅读转换管道的详细信息,这样您就知道如何应用矩阵,顺序一如既往地很重要。Consider reading out OpenGL's matrixes, using
glGet...()
functions, and running the vertex through the relevant matrices yourself. First read up on the details of the transformation pipeline of course, so you know how to apply the matrices, ordering matters a great deal as always.我在我的网站上详细讨论了(opengl)投影矩阵的推导。 您可以在这里查看
http:// divineabomination.blogspot.com/2009/12/derivation-of-perspective-matrix-part-1.html
第二部分也可以从右侧的菜单中找到。
I talk about the derivation of the (opengl) projection matrix in detail on my site. You can have a look here
http://divineabomination.blogspot.com/2009/12/derivation-of-perspective-matrix-part-1.html
and the second part is available there too from the menu on the right.