2010-12-02 48 views
1

我想模擬Vector3.TransformNormal沒有DirectX庫。如何模擬Vector3.TransformNormal

是否有人能夠解釋這個函數如何工作,讓我重新創建函數?

到目前爲止,我知道輸入並已經看到它所做的描述,但我不知道計算。

public static Vector3 TransformNormal(
    Vector3 source, 
    Matrix sourceMatrix 
) 
+0

是否有人在DirectX SDK中能夠反射器的功能? – Chris 2010-12-02 15:45:20

回答

3

這應該這樣做(未測試)

public Vector3 TransformNormal(Vector3 normal, Matrix matrix) 
{  
    return new Vector3 
    { 
     X = normal.X * matrix.M11 + normal.Y * matrix.M21 + normal.Z * matrix.M31, 
     Y = normal.X * matrix.M12 + normal.Y * matrix.M22 + normal.Z * matrix.M32, 
     Z = normal.X * matrix.M13 + normal.Y * matrix.M23 + normal.Z * matrix.M33 
    }; 
}