2010-12-02 11 views
1

Ich versuche Vector3.TransformNormal ohne die DirectX-Bibliothek zu emulieren.Emulation Vector3.TransformNormal

Kann jemand erklären, wie diese Funktion funktioniert, damit ich die Funktion neu erstellen kann?

Bisher kenne ich die Eingaben und habe die Beschreibung dessen, was es tut, gesehen, aber ich kenne die Berechnungen nicht.

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

Ist jemand mit dem DirectX SDK der Lage, die Funktion zum Reflektor? – Chris

+0

Dies ist ziemlich Standard lineare Algebra .. mroe Informationen können hier gefunden werden: http://www.facstaff.bucknell.edu/mastascu/elessonsHTML/Circuit/MatVecMultiply.htm – Goz

Antwort

3

Dies sollte es tun (nicht getestet)

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 
    }; 
}