Exemplo n.º 1
0
        public static Mat4 Translate(Vec3 offset)
        {
            Mat4 result = Mat4.identity();

            result[3] = new Vec4(offset, 1.0f);
            return(result);
        }
Exemplo n.º 2
0
        public static void SetNone()
        {
            Shader shader = Shader.GetUberShader();

            shader.Draw();
            var viewLoc = shader.GetLocation("View");

            shader.SetMat4(viewLoc, Mat4.identity());
        }
Exemplo n.º 3
0
        public static Mat4 RotateZ(float angle)
        {
            Mat4 result = Mat4.identity();

            result[0][0] = MathF.Cos(angle);
            result[0][1] = -MathF.Sin(angle);
            result[1][0] = MathF.Sin(angle);
            result[1][1] = MathF.Cos(angle);
            return(result);
        }
Exemplo n.º 4
0
        public static Mat4 Ortho(float left, float right, float bottom, float top, float zNear, float zFar)
        {
            Mat4 result = Mat4.identity();

            result[0][0] = 2.0F / (right - left);
            result[1][1] = 2.0F / (top - bottom);
            result[2][2] = -2.0F / (zFar - zNear);
            result[3][0] = -(right + left) / (right - left);
            result[3][1] = -(top + bottom) / (top - bottom);
            result[3][2] = -(zFar + zNear) / (zFar - zNear);
            result[3][3] = 1.0f;
            return(result);
        }
Exemplo n.º 5
0
        public static Mat4 LookAt(Vec3 eye, Vec3 at, Vec3 up)
        {
            Vec3 f   = (at - eye).Normalize();
            Vec3 s   = up.Cross(f).Normalize();
            Vec3 u   = f.Cross(s);
            Mat4 res = Mat4.identity();

            res[0][0] = s.x;
            res[1][0] = s.y;
            res[2][0] = s.z;
            res[0][1] = u.x;
            res[1][1] = u.y;
            res[2][1] = u.z;
            res[0][2] = f.x;
            res[1][2] = f.y;
            res[2][2] = f.z;
            res[3][0] = -s.Dot(eye);
            res[3][1] = -u.Dot(eye);
            res[3][2] = -f.Dot(eye);

            return(res);
        }