Beispiel #1
0
        private void Draw(BSPNodeTri node, Vector3D ptEye, ref List <Triangle> triangles)
        {
            if (null == node)
            {
                return;
            }
            double result = node.ClassifyPoint(ptEye);

            if (result < 0)
            {
                Draw(node.NodeLeft, ptEye, ref triangles);
                triangles.Add(node.Triangle);
                Draw(node.NodeRight, ptEye, ref triangles);
            }
            else if (result > 0)
            {
                Draw(node.NodeRight, ptEye, ref triangles);
                triangles.Add(node.Triangle);
                Draw(node.NodeLeft, ptEye, ref triangles);
            }
            else // result == 0
            {
                Draw(node.NodeRight, ptEye, ref triangles);
                Draw(node.NodeLeft, ptEye, ref triangles);
            }
        }
Beispiel #2
0
        public void Insert(Triangle f)
        {
            if (f.IsFlat)
            {
                return;
            }

            if (null == Root)
            {
                Root = new BSPNodeTri(f);
            }
            else
            {
                Root.Insert(f);
            }
        }
Beispiel #3
0
        public void Insert(Triangle t)
        {
            if (t.IsFlat)
            {
                return;
            }
            List <Triangle> side_left  = new List <Triangle>();
            List <Triangle> side_right = new List <Triangle>();

            Split(t, ref side_left, ref side_right);

            foreach (var tr in side_left)
            {
                if (tr.IsFlat)
                {
                    continue;
                }
                if (null == NodeLeft)
                {
                    NodeLeft = new BSPNodeTri(tr);
                }
                else
                {
                    NodeLeft.Insert(tr);
                }
            }
            foreach (var tr in side_right)
            {
                if (tr.IsFlat)
                {
                    continue;
                }
                if (null == NodeRight)
                {
                    NodeRight = new BSPNodeTri(tr);
                }
                else
                {
                    NodeRight.Insert(tr);
                }
            }
        }