[英]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.