从视图矩阵中获取眼睛、目标和向上向量
在 Direct3D 中,我使用 Matrix.LookAtLH 函数来计算视图矩阵。
我将其用于相机,通过将原点移动到目标位置、旋转,然后将原点移回 (0,0,0),围绕目标进行轨道旋转。
该值与最初由 LookAtLH 计算得出的矩阵相乘。
有没有办法在经过一些这样的操作后,分解矩阵以获得眼睛位置、目标位置和向上向量?
In Direct3D, I'm using the Matrix.LookAtLH function to compute the view matrix.
I am using this for the camera, which I orbit around a target by moving the origin to the target position, rotating, and then moving the origin back to (0,0,0).
This is multiplied to the matrix that was originally computed from LookAtLH.
Is there a way I can, after a few of these operations, decompose the matrix to get the eye position, target position, and up vector?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
视图矩阵很容易从中提取数据。查看您使用的函数的文档(我使用了 D3DXMatrixLookAtLH 的文档):
http://msdn.microsoft.com/en-us/library/bb205342%28v=vs.85%29.aspx
正如您在页面底部看到的,矩阵是在内部生成的,如下所示:
请记住,这仅对 DirectX 有效;当将相同的计算移植到 OpenGL 时,请对上述矩阵进行转置,因为 DirectX 中的坐标系与标准相反。
View matricies are very easy to extract data from. Check out the documentation for the function you used (I've used the documentation for D3DXMatrixLookAtLH):
http://msdn.microsoft.com/en-us/library/bb205342%28v=vs.85%29.aspx
As you can see towards the bottom of the page, the matrix is internally generated like so:
Bear in mind, this is only valid for DirectX; transpose the above matrix when porting the same calculations to OpenGL because the coordinate system in DirectX is backwards to the norm.
两个选项:
Two options :