[英]how to convert world space transform to object space transform?
我正在尝试实现:
使用opengl中的glm库进行transform.InverseTransformPoint(Vector3)和transform.InverseTransformDirection(Vector3) 。 我有每个对象的视图,投影,模型矩阵。
实际上,我不知道要使用该方法的功能该如何处理该矩阵。
通常,可以通过执行以下数学运算将局部空间中的点转换为NDC空间:
Pworld = M * Plocal;
Pview = V * Pworld;
Pndc = P * Pview;
其中M =模型,V =视图,P =投影。
因此,如果您在世界坐标系中有一个点并希望在局部坐标系中得到它,则只需将第一个方程式求反即可:
Plocal = inv(M) * Pworld;
这应该等效于transform.InverseTransformPoint(Vector3)
(只需添加第四个坐标向量H = 1)
要实现不受比例影响的transform.InverseTransformDirection(Vector3)
,必须使用以下公式:
Plocal = transpose(inverse(M)) * Pworld
其中M是原始模型的左上3x3矩阵。 为了了解您为什么要使用此数学运算,我邀请您查看以下页面: 正常转换
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.