@Kwyrky wrote:
I don't understand why the View Matrix is calculated different in MonoGame and DIrectX.
In DirectX the D3DXMatrixLookAtRH function is calculated like this:
And in MonoGame:
public static void CreateLookAt(ref Vector3 cameraPosition, ref Vector3 cameraTarget, ref Vector3 cameraUpVector, out Matrix result) { var vector = Vector3.Normalize(cameraPosition - cameraTarget); var vector2 = Vector3.Normalize(Vector3.Cross(cameraUpVector, vector)); var vector3 = Vector3.Cross(vector, vector2); result.M11 = vector2.X; result.M12 = vector3.X; result.M13 = vector.X; result.M14 = 0f; result.M21 = vector2.Y; result.M22 = vector3.Y; result.M23 = vector.Y; result.M24 = 0f; result.M31 = vector2.Z; result.M32 = vector3.Z; result.M33 = vector.Z; result.M34 = 0f; result.M41 = -Vector3.Dot(vector2, cameraPosition); result.M42 = -Vector3.Dot(vector3, cameraPosition); result.M43 = -Vector3.Dot(vector, cameraPosition); result.M44 = 1f; }
Why is there a minus sign in the matrix elements 41, 42, 43?
Posts: 7
Participants: 2