/// <summary> /// Draw the bounding boxes that exists in the <c>OcTree</c> structure. /// </summary> /// <param name="viewMatrix">View matrix of the active camera.</param> /// <param name="projectionMatrix">Projection matrix of the active camera.</param> /// <param name="cameraFrustum">Bounding frustum of the camera.</param> /// <param name="effect">Effect to apply to the models.</param> public void DrawBoxes(Matrix viewMatrix, Matrix projectionMatrix, BoundingFrustum cameraFrustum, BasicEffect effect, bool checkFrustum = true) { Dictionary <string, Matrix> dictionary = new Dictionary <string, Matrix>(); Stack <OcTreeNode> auxStack = new Stack <OcTreeNode>(); auxStack.Push(RootNode); while (auxStack.Count != 0) { OcTreeNode node = auxStack.Pop(); ContainmentType cameraNodeContainment = cameraFrustum.Contains(node.BoundingBox); if (!checkFrustum || (checkFrustum && cameraNodeContainment != ContainmentType.Disjoint)) { if (node.ChildList.Count == 0) { node.DrawBoundingBox(Matrix.Identity, viewMatrix, projectionMatrix, effect); } else { for (int i = node.ChildList.Count - 1; i >= 0; i--) { auxStack.Push(node.ChildList[i]); } node.DrawBoundingBox(Matrix.Identity, viewMatrix, projectionMatrix, effect); } } } }