public void RenderNodeBoundingBox <T>(DX11Game game, IQuadTreeNode <T> quadTreeNode) where T : IQuadTreeNode <T>
        {
            if (quadTreeNode == null)
            {
                return;
            }

            QuadTreeNodeData <T> node = quadTreeNode.NodeData;

            RenderNodeBoundingBox(game, node.UpperLeft);
            RenderNodeBoundingBox(game, node.UpperRight);
            RenderNodeBoundingBox(game, node.LowerLeft);
            RenderNodeBoundingBox(game, node.LowerRight);

            //TODO: Calculate level is quite lame here and slow, since we loop the tree level by level
            int    level = QuadTree.CalculateLevel(quadTreeNode);
            Color4 col;

            if (level < levelColor4s.Length)
            {
                col = levelColor4s[level];
            }
            else
            {
                col = levelColor4s[levelColor4s.Length - 1];
            }

            game.LineManager3D.AddBox(quadTreeNode.NodeData.BoundingBox, col);
        }
        public void RenderNodeGroundBoundig <T>(DX11Game game, IQuadTreeNode <T> quadTreeNode) where T : IQuadTreeNode <T>
        {
            if (quadTreeNode == null)
            {
                return;
            }

            QuadTreeNodeData <T> node = quadTreeNode.NodeData;

            RenderNodeGroundBoundig(game, node.UpperLeft);
            RenderNodeGroundBoundig(game, node.UpperRight);
            RenderNodeGroundBoundig(game, node.LowerLeft);
            RenderNodeGroundBoundig(game, node.LowerRight);

            //if ( node.IsLeaf == false ) return;
            //FloorLowerLeft = min
            //TopUpperRight = max

            //TODO: Calculate level is quite lame here and slow, since we loop the tree level by level
            int    level = QuadTree.CalculateLevel(quadTreeNode);
            Color4 col;

            if (level < levelColor4s.Length)
            {
                col = levelColor4s[level];
            }
            else
            {
                col = levelColor4s[levelColor4s.Length - 1];
            }

            Vector3 radius = (node.BoundingBox.Maximum - node.BoundingBox.Minimum);
            Vector3 radX   = new Vector3(radius.X, 0, 0);
            Vector3 radY   = new Vector3(0, radius.Y, 0);
            Vector3 radZ   = new Vector3(0, 0, radius.Z);
            Vector3 min    = node.BoundingBox.Minimum;

            min.Y = -1 + level;


            Vector3 fll = min;
            Vector3 flr = min + radX;
            Vector3 ful = min + radZ;
            Vector3 fur = min + radX + radZ;



            //grondvlak
            game.LineManager3D.AddLine(fll, flr, col);
            game.LineManager3D.AddLine(flr, fur, col);
            game.LineManager3D.AddLine(fur, ful, col);
            game.LineManager3D.AddLine(ful, fll, col);
        }
        /// <summary>
        /// This functions loops through all nodes and renders the node when the given predicate returns true for given node. It uses the out Color4 argument to determine the Color4 of the rendered node.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="game"></param>
        /// <param name="quadTreeNode"></param>
        /// <param name="predicate"></param>
        public void RenderNodeGroundBoundig <T>(DX11Game game, T quadTreeNode, RenderNodePredicate <T> predicate) where T : class, IQuadTreeNode <T>
        {
            if (quadTreeNode == null)
            {
                return;
            }

            QuadTreeNodeData <T> node = quadTreeNode.NodeData;

            RenderNodeGroundBoundig(game, node.UpperLeft, predicate);
            RenderNodeGroundBoundig(game, node.UpperRight, predicate);
            RenderNodeGroundBoundig(game, node.LowerLeft, predicate);
            RenderNodeGroundBoundig(game, node.LowerRight, predicate);


            Color4 col;

            if (!predicate(quadTreeNode, out col))
            {
                return;
            }

            //TODO: Calculate level is quite lame here and slow, since we loop the tree level by level
            int level = QuadTree.CalculateLevel(quadTreeNode);


            Vector3 radius = (node.BoundingBox.Maximum - node.BoundingBox.Minimum);
            Vector3 radX   = new Vector3(radius.X, 0, 0);
            Vector3 radY   = new Vector3(0, radius.Y, 0);
            Vector3 radZ   = new Vector3(0, 0, radius.Z);
            Vector3 min    = node.BoundingBox.Minimum;

            min.Y = -1 + level;


            Vector3 fll = min;
            Vector3 flr = min + radX;
            Vector3 ful = min + radZ;
            Vector3 fur = min + radX + radZ;



            //grondvlak
            game.LineManager3D.AddLine(fll, flr, col);
            game.LineManager3D.AddLine(flr, fur, col);
            game.LineManager3D.AddLine(fur, ful, col);
            game.LineManager3D.AddLine(ful, fll, col);
        }