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

◆ CreatePerspectiveFieldOfView() [1/2]

static Matrix Microsoft.Xna.Framework.Matrix.CreatePerspectiveFieldOfView ( float fieldOfView,
float aspectRatio,
float nearPlaneDistance,
float farPlaneDistance )
inlinestatic

Definition at line 856 of file Matrix.cs.

857 {
858 if (fieldOfView <= 0f || fieldOfView >= (float)Math.PI)
859 {
860 throw new ArgumentOutOfRangeException("fieldOfView", string.Format(CultureInfo.CurrentCulture, FrameworkResources.OutRangeFieldOfView, new object[1] { "fieldOfView" }));
861 }
862 if (nearPlaneDistance <= 0f)
863 {
864 throw new ArgumentOutOfRangeException("nearPlaneDistance", string.Format(CultureInfo.CurrentCulture, FrameworkResources.NegativePlaneDistance, new object[1] { "nearPlaneDistance" }));
865 }
866 if (farPlaneDistance <= 0f)
867 {
868 throw new ArgumentOutOfRangeException("farPlaneDistance", string.Format(CultureInfo.CurrentCulture, FrameworkResources.NegativePlaneDistance, new object[1] { "farPlaneDistance" }));
869 }
870 if (nearPlaneDistance >= farPlaneDistance)
871 {
872 throw new ArgumentOutOfRangeException("nearPlaneDistance", FrameworkResources.OppositePlanes);
873 }
874 float num = 1f / (float)Math.Tan(fieldOfView * 0.5f);
875 float m = num / aspectRatio;
876 Matrix result = default(Matrix);
877 result.M11 = m;
878 result.M12 = (result.M13 = (result.M14 = 0f));
879 result.M22 = num;
880 result.M21 = (result.M23 = (result.M24 = 0f));
881 result.M31 = (result.M32 = 0f);
882 result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
883 result.M34 = -1f;
884 result.M41 = (result.M42 = (result.M44 = 0f));
885 result.M43 = nearPlaneDistance * farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
886 return result;
887 }
static CultureInfo CurrentCulture
static double Tan(double a)
const double PI
Definition Math.cs:16
Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
Definition Matrix.cs:210

References System.Globalization.CultureInfo.CurrentCulture, System.Globalization.Format, Microsoft.Xna.Framework.FrameworkResources.NegativePlaneDistance, Microsoft.Xna.Framework.FrameworkResources.OppositePlanes, Microsoft.Xna.Framework.FrameworkResources.OutRangeFieldOfView, System.Math.PI, and System.Math.Tan().