public static Vector3[] ProjectFrustumOnXZPlane(this Camera camera)
        {
            Plane plane = new Plane(Vector3.up, Vector3.zero);

            Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
            Line    L0;

            MUtils.Intersects(planes[0], plane, out L0);
            Line L1;

            MUtils.Intersects(planes[1], plane, out L1);
            Line L2;

            MUtils.Intersects(planes[2], plane, out L2);
            Line L3;

            MUtils.Intersects(planes[3], plane, out L3);

            Line2D l2d0 = MappingAxis.Map(L0);
            Line2D l2d1 = MappingAxis.Map(L1);
            Line2D l2d2 = MappingAxis.Map(L2);
            Line2D l2d3 = MappingAxis.Map(L3);

            float s, t;

            l2d0.Intersects(l2d2, out t, out s);
            Vector3 rightTop = MappingAxis.Map(l2d0.GetPoint(t));

            l2d0.Intersects(l2d3, out t, out s);
            Vector3 rightBottom = MappingAxis.Map(l2d0.GetPoint(t));

            l2d1.Intersects(l2d2, out t, out s);
            Vector3 leftTop = MappingAxis.Map(l2d1.GetPoint(t));

            l2d1.Intersects(l2d3, out t, out s);
            Vector3 leftBottom = MappingAxis.Map(l2d1.GetPoint(t));

            return(new Vector3[] { leftTop, rightTop, rightBottom, leftBottom });
        }
Exemple #2
0
 public static Bounds2D FromBounds(Bounds bounds)
 {
     return(new Bounds2D(
                MappingAxis.Map(bounds.min),
                MappingAxis.Map(bounds.max)));
 }