예제 #1
0
 static Mat4()
 {
     Zero     = new Mat4(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
     Identity = new Mat4(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
 }
예제 #2
0
        public static void Perspective(float fov, float aspect, float znear, float zfar, out Mat4 result)
        {
            float num  = MathFunctions.Tan((fov * 3.141593f) / 360f);
            float num2 = num * aspect;

            result.Rp.x = 1f / num2;
            result.RQ.x = 0f;
            result.Rq.x = 0f;
            result.RR.x = 0f;
            result.Rp.y = 0f;
            result.RQ.y = 1f / num;
            result.Rq.y = 0f;
            result.RR.y = 0f;
            result.Rp.z = 0f;
            result.RQ.z = 0f;
            result.Rq.z = -(zfar + znear) / (zfar - znear);
            result.RR.z = -((2f * zfar) * znear) / (zfar - znear);
            result.Rp.w = 0f;
            result.RQ.w = 0f;
            result.Rq.w = -1f;
            result.RR.w = 0f;
        }
예제 #3
0
 public void GetTranspose(out Mat4 result)
 {
     result = this;
     result.Transpose();
 }
예제 #4
0
 public void GetInverse(out Mat4 result)
 {
     result = this;
     result.Inverse();
 }
예제 #5
0
 public static Mat4 Multiply(Mat4 v1, Mat4 v2)
 {
     Multiply(ref v1, ref v2, out Mat4 mat);
     return(mat);
 }
예제 #6
0
 public static Mat4 Negate(Mat4 m)
 {
     Negate(ref m, out Mat4 mat);
     return(mat);
 }
예제 #7
0
 public static Vec3 Multiply(Mat4 m, Vec3 v)
 {
     Multiply(ref m, ref v, out Vec3 vec);
     return(vec);
 }
예제 #8
0
 public static Vec4 Multiply(Vec4 v, Mat4 m)
 {
     Multiply(ref m, ref v, out Vec4 vec);
     return(vec);
 }
예제 #9
0
 public static Ray Multiply(Ray r, Mat4 m)
 {
     Multiply(ref m, ref r, out Ray ray);
     return(ray);
 }
예제 #10
0
 public static Mat4 Multiply(float s, Mat4 m)
 {
     Multiply(ref m, s, out Mat4 mat);
     return(mat);
 }
예제 #11
0
 public static Mat4 Subtract(Mat4 v1, Mat4 v2)
 {
     Subtract(ref v1, ref v2, out Mat4 mat);
     return(mat);
 }
예제 #12
0
 public static Mat4 Add(Mat4 v1, Mat4 v2)
 {
     Add(ref v1, ref v2, out Mat4 mat);
     return(mat);
 }
예제 #13
0
 public static void Multiply(ref Vec3 v, ref Mat4 m, out Vec3 result)
 {
     result.x = (((m.Rp.x * v.X) + (m.RQ.x * v.Y)) + (m.Rq.x * v.Z)) + m.RR.x;
     result.y = (((m.Rp.y * v.X) + (m.RQ.y * v.Y)) + (m.Rq.y * v.Z)) + m.RR.y;
     result.z = (((m.Rp.z * v.X) + (m.RQ.z * v.Y)) + (m.Rq.z * v.Z)) + m.RR.z;
 }