Ejemplo n.º 1
0
        public List <CSGPolygon> allPolygons()
        {
            /*
             * Create a shallow copy of the list
             */
            CSGPolygon[] plist = new CSGPolygon[this.polygons.Count];

            polygons.CopyTo(plist);

            polygons = plist.ToList <CSGPolygon>();

            if (this.front != null)
            {
                foreach (CSGPolygon p in this.front.allPolygons())
                {
                    polygons.Add(p);
                }
            }

            if (this.back != null)
            {
                foreach (CSGPolygon p in this.back.allPolygons())
                {
                    polygons.Add(p);
                }
            }

            return(polygons);
        }
Ejemplo n.º 2
0
        public List <CSGPolygon> clipPolygons(List <CSGPolygon> polygons)
        {
            if (this.plane == null)
            {
                /*
                 * Create a shallow copy of the list
                 */
                CSGPolygon[] plist = new CSGPolygon[polygons.Count];

                polygons.CopyTo(plist);

                return(plist.ToList <CSGPolygon>());
            }

            List <CSGPolygon> front = new List <CSGPolygon>();
            List <CSGPolygon> back  = new List <CSGPolygon>();

            for (int i = 0; i < polygons.Count; i++)
            {
                this.plane.splitPolygon(polygons[i], front, back, front, back);
            }

            if (this.front != null)
            {
                front = this.front.clipPolygons(front);
            }
            if (this.back != null)
            {
                back = this.back.clipPolygons(back);
            }
            else
            {
                back = new List <CSGPolygon>();
            }

            foreach (CSGPolygon p in back)
            {
                front.Add(p);
            }

            return(front);
        }