예제 #1
0
    public static void R_SetFrustum()
    {
        if (r_refdef.fov_x == 90)
        {
            // front side is visible
            frustum[0].normal = vpn + vright;
            frustum[1].normal = vpn - vright;

            frustum[2].normal = vpn + vup;
            frustum[3].normal = vpn - vup;
        }
        else
        {
            // rotate VPN right by FOV_X/2 degrees
            Mathlib.RotatePointAroundVector(out frustum[0].normal, ref vup, ref vpn, -(90 - r_refdef.fov_x / 2));
            // rotate VPN left by FOV_X/2 degrees
            Mathlib.RotatePointAroundVector(out frustum[1].normal, ref vup, ref vpn, 90 - r_refdef.fov_x / 2);
            // rotate VPN up by FOV_X/2 degrees
            Mathlib.RotatePointAroundVector(out frustum[2].normal, ref vright, ref vpn, 90 - r_refdef.fov_y / 2);
            // rotate VPN down by FOV_X/2 degrees
            Mathlib.RotatePointAroundVector(out frustum[3].normal, ref vright, ref vpn, -(90 - r_refdef.fov_y / 2));
        }

        for (int i = 0; i < 4; i++)
        {
            frustum[i].type     = q_shared.PLANE_ANYZ;
            frustum[i].dist     = Vector3.Dot(r_origin, frustum[i].normal);
            frustum[i].signbits = (byte)SignbitsForPlane(frustum[i]);
        }
    }