Esempio n. 1
0
        private void Draw(BSPNode node, Vector3D ptEye, ref List <Face> faces)
        {
            if (null == node)
            {
                return;
            }
            double result = node.ClassifyPoint(ptEye);

            if (result > 0)
            {
                Draw(node.NodeLeft, ptEye, ref faces);
                faces.Add(node.Face);
                Draw(node.NodeRight, ptEye, ref faces);
            }
            else if (result < 0)
            {
                Draw(node.NodeRight, ptEye, ref faces);
                faces.Add(node.Face);
                Draw(node.NodeLeft, ptEye, ref faces);
            }
            else // result == 0
            {
                Draw(node.NodeRight, ptEye, ref faces);
                Draw(node.NodeLeft, ptEye, ref faces);
            }
        }
Esempio n. 2
0
        public void Insert(Face f)
        {
            if (f.IsDegenerate)
            {
                return;
            }

            if (null == Root)
            {
                Root = new BSPNode(f);
            }
            else
            {
                Root.Insert(f);
            }
        }
Esempio n. 3
0
        // insertion methods
        public void Insert(Face f)
        {
            if (f.IsDegenerate)
            {
                return;
            }

            // check on which side the polygon is, posibly split
            List <Face> side_left  = new List <Face>();
            List <Face> side_right = new List <Face>();

            Split(f, ref side_left, ref side_right);

            // insert triangles
            foreach (Face face in side_left)
            {
                if (null == NodeLeft)
                {
                    NodeLeft = new BSPNode(face);
                }
                else
                {
                    NodeLeft.Insert(face);
                }
            }
            foreach (Face face in side_right)
            {
                if (null == NodeRight)
                {
                    NodeRight = new BSPNode(face);
                }
                else
                {
                    NodeRight.Insert(face);
                }
            }
        }