示例#1
0
 public CSG_Node(List <CSG_Polygon> list, CSG_Plane plane, CSG_Node front, CSG_Node back)
 {
     this.polygons = list;
     this.plane    = plane;
     this.front    = front;
     this.back     = back;
 }
示例#2
0
		public CSG_Node(List<CSG_Polygon> list, CSG_Plane plane, CSG_Node front, CSG_Node back)
		{
			this.polygons = list;
			this.plane = plane;
			this.front = front;
			this.back = back;
		}
示例#3
0
 public CSG_Node()
 {
     front    = null;
     back     = null;
     polygons = null;
     plane    = null;
 }
示例#4
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 Build(List <CSG_Polygon> list)
        {
            if (list == null || list.Count < 1)
            {
                return;
            }

            if (plane == null || !plane.Valid())
            {
                plane = new CSG_Plane
                {
                    normal = list[0].plane.normal,
                    w      = list[0].plane.w
                };
            }

            if (polygons == null)
            {
                polygons = new List <CSG_Polygon>();
            }

            var listFront = new List <CSG_Polygon>();
            var listBack  = new List <CSG_Polygon>();

            for (int i = 0; i < list.Count; i++)
            {
                plane.SplitPolygon(list[i], polygons, polygons, ref listFront, ref listBack);
            }

            if (listFront.Count > 0)
            {
                if (front == null)
                {
                    front = new CSG_Node();
                }

                front.Build(listFront);
            }

            if (listBack.Count > 0)
            {
                if (back == null)
                {
                    back = new CSG_Node();
                }

                back.Build(listBack);
            }
        }
示例#5
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 Build(List <CSG_Polygon> list)
        {
            if (list.Count < 1)
            {
                return;
            }

            if (this.plane == null || !this.plane.Valid())
            {
                this.plane        = new CSG_Plane();
                this.plane.normal = list[0].plane.normal;
                this.plane.w      = list[0].plane.w;
            }


            if (this.polygons == null)
            {
                this.polygons = new List <CSG_Polygon>();
            }

            List <CSG_Polygon> list_front = new List <CSG_Polygon>();
            List <CSG_Polygon> list_back  = new List <CSG_Polygon>();

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

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

                this.front.Build(list_front);
            }

            if (list_back.Count > 0)
            {
                if (this.back == null)
                {
                    this.back = new CSG_Node();
                }

                this.back.Build(list_back);
            }
        }
示例#6
0
		public CSG_Polygon(List<CSG_Vertex> list)
		{
			this.vertices = list;
			this.plane = new CSG_Plane(list[0].position, list[1].position, list[2].position);
		}
示例#7
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 Build(List<CSG_Polygon> list)
		{
			if (list.Count < 1)
				return;

			if (this.plane == null || !this.plane.Valid())
			{
				this.plane = new CSG_Plane();
				this.plane.normal = list[0].plane.normal;
				this.plane.w = list[0].plane.w;
			}


			if(this.polygons == null)
				this.polygons = new List<CSG_Polygon>();

			List<CSG_Polygon> list_front = new List<CSG_Polygon>();
			List<CSG_Polygon> list_back = new List<CSG_Polygon>();

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

			if (list_front.Count > 0) 
			{
				if (this.front == null)
					this.front = new CSG_Node();

				this.front.Build(list_front);
			}

			if (list_back.Count > 0) 
			{
				if (this.back == null)
					this.back = new CSG_Node();

				this.back.Build(list_back);
			}
		}
示例#8
0
 public CSG_Polygon(List <CSG_Vertex> list)
 {
     this.vertices = list;
     this.plane    = new CSG_Plane(list[0].position, list[1].position, list[2].position);
 }
示例#9
0
 public CSG_Polygon(List <CSG_Vertex> list, Material mat)
 {
     vertices = list;
     plane    = new CSG_Plane(list[0].position, list[1].position, list[2].position);
     material = mat;
 }