Exemplo n.º 1
0
        // Build a BSP tree out of `polygons`. When called on an existing tree, the
        // new polygons are filtered down to the bottom of the tree and become new
        // nodes there. Each set of polygons is partitioned using the first polygon
        // (no heuristic is used to pick a good split).
        public void BuildFromPolygons(List <CsgPolygon> list)
        {
            if (list.Count <= 0)
            {
                return;
            }
            if (!this.plane.ok())
            {
                this.plane = list[0].plane;
            }
            List <CsgPolygon> list_front = new List <CsgPolygon>();
            List <CsgPolygon> list_back  = new List <CsgPolygon>();

            for (int i = 0; i < list.Count; i++)
            {
                this.plane.SplitPolygon(list[i], this.polygons, this.polygons, list_front, list_back);
                int count = CsgNode.GetTotalPolygons(this);
            }

            if (list_front.Count > 0)
            {
                if (this.front == null)
                {
                    this.front = new CsgNode();
                }
                this.front.BuildFromPolygons(list_front);
            }

            if (list_back.Count > 0)
            {
                if (this.back == null)
                {
                    this.back = new CsgNode();
                }
                this.back.BuildFromPolygons(list_back);
            }
        }
Exemplo n.º 2
0
        // Build a BSP tree out of `polygons`. When called on an existing tree, the
        // new polygons are filtered down to the bottom of the tree and become new
        // nodes there. Each set of polygons is partitioned using the first polygon
        // (no heuristic is used to pick a good split).
        public void BuildFromPolygons(List<CsgPolygon> list)
        {
            if (list.Count <= 0) return;
            if (!this.plane.ok()) this.plane = list[0].plane;
            List<CsgPolygon> list_front = new List<CsgPolygon>();
            List<CsgPolygon> list_back = new List<CsgPolygon>();

            for (int i = 0; i < list.Count; i++)
            {
                this.plane.SplitPolygon(list[i], this.polygons, this.polygons, list_front, list_back);
                int count = CsgNode.GetTotalPolygons(this);
            }

            if (list_front.Count > 0)
            {
                if (this.front == null) this.front = new CsgNode();
                this.front.BuildFromPolygons(list_front);
            }

            if (list_back.Count > 0)
            {
                if (this.back == null) this.back = new CsgNode();
                this.back.BuildFromPolygons(list_back);
            }
        }
Exemplo n.º 3
0
		public CsgPolygon(List<Vertex> list)
		{
			vertices = new List<Vertex>(list);
			plane = new CsgPlane(vertices[0].Position, vertices[1].Position, vertices[2].Position);
		}
Exemplo n.º 4
0
 public CsgPolygon(List <IVertex> list)
 {
     vertices = new List <IVertex>(list);
     plane    = new CsgPlane(vertices[0].Position, vertices[1].Position, vertices[2].Position);
 }