/// <summary>
        ///		Intersection test with <see cref="Sphere"/>.
        /// </summary>
        /// <param name="sphere">Sphere to test.</param>
        /// <returns>True if the sphere intersects this volume, and false otherwise.</returns>
        public bool Intersects(Sphere sphere)
        {
            for (int i = 0; i < planes.Count; i++)
            {
                Plane plane = planes[i];

                // Test which side of the plane the sphere is
                float d = plane.GetDistance(sphere.Center);

                // Negate d if planes point inwards
                if (outside == PlaneSide.Negative)
                {
                    d = -d;
                }

                if ((d - sphere.Radius) > 0)
                {
                    return(false);
                }
            }

            // assume intersecting
            return(true);
        }
        protected bool CalculateForPointLight(Plane plane, Vector3[] vertices, out Vector2[] texCoors, out ColorEx[] colors)
        {
            texCoors = new Vector2[vertices.Length];
            colors = new ColorEx[vertices.Length];

            Vector3 lightPos, faceLightPos;

            lightPos = this.DerivedPosition;

            float dist = plane.GetDistance(lightPos);
            if (MathUtil.Abs(dist) < range)
            {
                // light is visible

                //light pos on face
                faceLightPos = lightPos - plane.Normal * dist;

                Vector3 verAxis = plane.Normal.Perpendicular();
                Vector3 horAxis = verAxis.Cross(plane.Normal);
                Plane verPlane = new Plane(verAxis, faceLightPos);
                Plane horPlane = new Plane(horAxis, faceLightPos);

                float lightRadiusSqr = range * range;
                float relRadiusSqr = lightRadiusSqr - dist * dist;
                float relRadius = MathUtil.Sqrt(relRadiusSqr);
                float scale = 0.5f / relRadius;

                float brightness = relRadiusSqr / lightRadiusSqr;
                ColorEx lightCol = new ColorEx(brightness * textureColor.a,
                    textureColor.r, textureColor.g, textureColor.b);

                for (int i = 0; i < vertices.Length; i++)
                {
                    texCoors[i].x = horPlane.GetDistance(vertices[i]) * scale + 0.5f;
                    texCoors[i].y = verPlane.GetDistance(vertices[i]) * scale + 0.5f;
                    colors[i] = lightCol;
                }

                return true;
            }

            return false;
        }