Esempio n. 1
0
        public static Tuple <bool, float> Intersects(Ray ray, IEnumerable <Plane> planes, bool normalIsOutside)
        {
            bool  allInside = true;
            bool  hit       = false;
            float distance  = 0.0f;

            Plane.Side side = normalIsOutside ? Plane.Side.POSITIVE_SIDE : Plane.Side.NEGATIVE_SIDE;

            foreach (var plane in planes)
            {
                Vector3 origin = ray.Origin;
                if (plane.GetSide(origin) == side)
                {
                    allInside = false;
                    Tuple <bool, float> pair = ray.Intersects(plane);
                    if (pair.Item1)
                    {
                        hit      = true;
                        distance = System.Math.Max(distance, pair.Item2);
                    }
                }
            }

            if (allInside)
            {
                return(Tuple.Create(true, 0.0f));
            }

            return(Tuple.Create(hit, distance));
        }
 public PlaneBoundedVolume(Plane.Side theOutside) : this(OgrePINVOKE.new_PlaneBoundedVolume__SWIG_1((int)theOutside), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 3
0
 public Plane.Side getSide(Vector3 centre, Vector3 halfSize)
 {
     Plane.Side ret = (Plane.Side)OgrePINVOKE.Plane_getSide__SWIG_2(swigCPtr, Vector3.getCPtr(centre), Vector3.getCPtr(halfSize));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
     return(ret);
 }
Esempio n. 4
0
 public Plane.Side getSide(AxisAlignedBox box)
 {
     Plane.Side ret = (Plane.Side)OgrePINVOKE.Plane_getSide__SWIG_1(swigCPtr, AxisAlignedBox.getCPtr(box));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
     return(ret);
 }
Esempio n. 5
0
 public Plane.Side getSide(Vector3 rkPoint)
 {
     Plane.Side ret = (Plane.Side)OgrePINVOKE.Plane_getSide__SWIG_0(swigCPtr, Vector3.getCPtr(rkPoint));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
     return(ret);
 }
Esempio n. 6
0
        public static bool Intersects(Plane plane, AxisAlignedBox box)
        {
            if (box.IsNull)
            {
                return(false);
            }

            // Get corners of the box
            var corners = box.GetAllCorners();

            // Test which side of the plane the corners are
            // Intersection occurs when at least one corner is on the
            // opposite side to another
            Plane.Side lastSide = plane.GetSide(corners[0]);
            for (int corner = 1; corner < 8; ++corner)
            {
                if (plane.GetSide(corners[corner]) != lastSide)
                {
                    return(true);
                }
            }

            return(false);
        }