Пример #1
0
        public static FrustumSphereIntersection?[] Intersects(Frustum frustum, Sphere sphere)
        {
            FrustumSphereIntersection?[] intersections = new FrustumSphereIntersection?[6];

            for (int i = 0; i < 6; i++)
            {
                float side = frustum[i].PlaneEquation(sphere.position);
                if (side < -sphere.radius)
                {
                    intersections[i] = null;
                }
                else
                {
                    intersections[i] = new FrustumSphereIntersection(frustum[i].normal, side);
                }
            }

            return(intersections);
        }
Пример #2
0
    private void OnDrawGizmos()
    {
        Vector3 parentPosition = transform.parent.position;

        if (fsi == null)
        {
            fsi = new FrustumSphereIntersection(main, parentPosition, mesh.radius);
        }
        else
        {
            fsi.SetSphere(parentPosition, mesh.radius);
        }
        fsi.DrawGizmos();

        if (builder != null)
        {
            builder.DrawGizmos();
        }
    }
Пример #3
0
        public void BuildSegment(FrustumSphereIntersection owner)
        {
            PlaneSphereIntersection psI;
            Color color;

            if (planeIndex >= 0)
            {
                psI   = owner.planeInter[planeIndex];
                color = colors[planeIndex];
            }
            else
            {
                psI   = owner.backPlaneInter;
                color = Color.magenta;
            }

            owner.allSegments.Add(new CircleSegment(psI.onPlane, psI.normal, start, end)
            {
                color = color
            });
        }