问题描述
我有一个使用openGL的应用程序,我必须将其移植到DirectX.总结一下我的问题:如何将基于右手坐标系的旋转矩阵移植到左手坐标系?
I have an application which uses openGL and i have to port it to DirectX.To sum up my issue : How can I port a rotation matrix based on a right-handed coordinate system to a left-handed coordinate system ?
这是我在 MSDN :
-
翻转三角形顶点的顺序,以便系统遍历它们从正面顺时针方向旋转.换句话说,如果顶点是v0,v1,v2,将它们作为v0,v2,v1传递给Direct3D.
Flip the order of triangle vertices so that the system traverses themclockwise from the front. In other words, if the vertices are v0, v1,v2, pass them to Direct3D as v0, v2, v1.
使用视图矩阵在z方向上按-1缩放世界空间.为此,请翻转_31,_32,_33和_34用于视图矩阵的D3DMATRIX结构的成员.
Use the view matrix to scale world space by -1 in the z-direction. To do this, flip the sign of the _31, _32, _33, and_34 member of the D3DMATRIX structure that you use for your view matrix.
这很好,除了我不能轻松翻转顶点,因为我从CATIA获得了3D模型,它不是原始模型,所以我不能使用它.
This works fine except I cannot flip easily my vertices because I got an 3D model from CATIA which is not a primitive, so I can't use it.
(我知道行主要和列主要的区别,没关系)
(I'm aware of row-major and column-major difference, it does not matter)
您知道如何将旋转矩阵从openGL移植到DirectX吗?
Do you know how I can port my rotation matrix from openGL to DirectX ?
推荐答案
关于基础坐标系的手性和给定的 rotation 转换,右手坐标系由右手规则确定,反之亦然.因此,如果您通过在旋转角度前面翻转符号来拥有两个具有不同惯性的坐标系,则您已经调整了旋转矩阵.您已经移植了旋转矩阵:)
Regarding the handedness of your underlying coordinate system and a given rotation transformation, the positive rotation in a right-handed coordinate system is determined by the right-hand rule and vice versa.So, if you have two coordinate systems with a different handedness by flipping the sign in front of the rotation angle you have adjusted the rotation matrix. You have ported your rotation matrix :)
这篇关于从OpenGL到DirectX的投影矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!