如何从 4x4 矩阵中获取 gluLookAt 参数
如果这是一个非常基本的 Matrix/OpenGl 问题,请提前抱歉。我遇到一种情况,我想转换为 4x4 矩阵,但不想使用 glMultMatrixf。我宁愿使用我在大多数其他翻译中使用的 gluLookAt 方法。从 4x4 矩阵获取所需的值是否像提取正确的列值一样简单?如果是,哪些列映射到哪些参数?
gluLookAt的签名:
void gluLookAt( GLdouble eyeX,
GLdouble eyeY,
GLdouble eyeZ,
GLdouble centerX,
GLdouble centerY,
GLdouble centerZ,
GLdouble upX,
GLdouble upY,
GLdouble upZ )
http://pyopengl.sourceforge.net/documentation/ref /glu/lookat.html http://www.opengl.org/wiki/GluLookAt_code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些参数本身并不存在于矩阵中。矩阵是根据它们计算的。它是通过将三个顶点(眼睛、中心和“向上”)乘以当前视图矩阵而生成的。
OpenGL 红皮书(如果您还没有的话,您确实应该得到它)对此进行了更详细的解释。
The parameters don't exist in the matrix, per se. The matrix is calculated from them. It's produced by multiplying the three vertexes (eye, center, and "up") into the current view matrix.
The OpenGL Red Book (which you really should get, if you don't have it already) explains it in more detail.
查看 DirectX 版本:
http://msdn.microsoft .com/en-gb/library/ee417299(VS.85).aspx
http://msdn.microsoft.com/en-gb/library/ee417302(VS.85).aspx
这些解释了外观是如何制作的。
由此您应该能够逆转该过程,或者至少确定它是否可能。
你到底想做什么?为什么你需要能够做到这一点?
这个问题给人的印象是您有一个 LookAt 矩阵,但您不想直接应用该矩阵,而是想提取参数以便将它们传递给 gluLookAt?
我只是想知道为什么你想从 LookAt 矩阵中提取参数?
check out the DirectX versions:
http://msdn.microsoft.com/en-gb/library/ee417299(VS.85).aspx
http://msdn.microsoft.com/en-gb/library/ee417302(VS.85).aspx
those explain how the look ats are made.
from that you should be able to reverse the process, or at least determine if it's possible.
What are you trying to do exactly? why do you need to be able to do this?
the question gives the impression that you have a lookAt matrix, but rather than just directly applying that matrix, you want to pull out the parameters just so you can pass them to gluLookAt?
I'm just interested to know why exactly you want to pull the parameters out of a lookAt matrix?
在这里你可以找到答案:
如何将 modelview 矩阵转换为 gluLookAt 参数?
或
粘贴这里的解决方案相同:
从任何 4x4 矩阵中,我们可以获得 gluLookAt 参数,即 CameraPos、CameraTarget、UpVector。
以下是从 ModelView 矩阵获取 CameraPos、CameraTarget、UpVector 的代码。
Here you can find the answer:
how to convert modelview matrix to gluLookAt parameters?
or
Pasted the same solution here:
From any 4x4 matrix we can get gluLookAt parameters which are CameraPos, CameraTarget, UpVector.
Here is the code to get CameraPos, CameraTarget, UpVector from ModelView matrix.