Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateLookAt() [1/2]

static void Microsoft.Xna.Framework.Matrix.CreateLookAt ( ref Vector3 cameraPosition,
ref Vector3 cameraTarget,
ref Vector3 cameraUpVector,
out Matrix result )
inlinestatic

Definition at line 1109 of file Matrix.cs.

1110 {
1111 Vector3 vector = Vector3.Normalize(cameraPosition - cameraTarget);
1112 Vector3 vector2 = Vector3.Normalize(Vector3.Cross(cameraUpVector, vector));
1113 Vector3 vector3 = Vector3.Cross(vector, vector2);
1114 result.M11 = vector2.X;
1115 result.M12 = vector3.X;
1116 result.M13 = vector.X;
1117 result.M14 = 0f;
1118 result.M21 = vector2.Y;
1119 result.M22 = vector3.Y;
1120 result.M23 = vector.Y;
1121 result.M24 = 0f;
1122 result.M31 = vector2.Z;
1123 result.M32 = vector3.Z;
1124 result.M33 = vector.Z;
1125 result.M34 = 0f;
1126 result.M41 = 0f - Vector3.Dot(vector2, cameraPosition);
1127 result.M42 = 0f - Vector3.Dot(vector3, cameraPosition);
1128 result.M43 = 0f - Vector3.Dot(vector, cameraPosition);
1129 result.M44 = 1f;
1130 }

References Microsoft.Xna.Framework.Vector3.Cross(), Microsoft.Xna.Framework.Vector3.Dot(), Microsoft.Xna.Framework.Vector3.Normalize(), Microsoft.Xna.Framework.Vector3.X, Microsoft.Xna.Framework.Vector3.Y, and Microsoft.Xna.Framework.Vector3.Z.