Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp	(revision 2788)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp	(revision 2790)
@@ -15,5 +15,53 @@
 {
 
-	GLUquadric *mSphere;
+GLUquadric *mSphere;
+
+
+static void RenderBoxForViz(const AxisAlignedBox3 &box)
+{
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Min().x, box.Min().y, box.Min().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Max().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Max().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Min().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Min().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Min().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Min().y, box.Max().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Max().z);
+
+	glEnd();
+}
+
 
 /******************************************************/
@@ -63,5 +111,5 @@
 	RenderViewPoint();
 	RenderFrustum();
-	RenderBox(mBvh->GetBox());
+	RenderBoxForViz(mBvh->GetBox());
 
 	glEnable(GL_LIGHTING);
@@ -106,111 +154,4 @@
 
 
-void Visualization::RenderBox(const AxisAlignedBox3 &box)
-{
-	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-	glDisable(GL_CULL_FACE);
-	glColor3f(1.0f, 0.0f, 0.0f);
-
-	glBegin(GL_QUADS);
-	glVertex3f(box.Min().x, box.Max().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Max().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Min().y, box.Min().z);
-	glVertex3f(box.Min().x, box.Min().y, box.Min().z);
-	glEnd();
-
-	glBegin(GL_QUADS);
-	glVertex3f(box.Min().x, box.Min().y, box.Max().z);
-	glVertex3f(box.Max().x, box.Min().y, box.Max().z);
-	glVertex3f(box.Max().x, box.Max().y, box.Max().z);
-	glVertex3f(box.Min().x, box.Max().y, box.Max().z);
-	glEnd();
-
-	glBegin(GL_QUADS);
-	glVertex3f(box.Max().x, box.Min().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Min().y, box.Max().z);
-	glVertex3f(box.Max().x, box.Max().y, box.Max().z);
-	glVertex3f(box.Max().x, box.Max().y, box.Min().z);
-	glEnd();
-
-	glBegin(GL_QUADS);
-	glVertex3f(box.Min().x, box.Min().y, box.Min().z);
-	glVertex3f(box.Min().x, box.Min().y, box.Max().z);
-	glVertex3f(box.Min().x, box.Max().y, box.Max().z);
-	glVertex3f(box.Min().x, box.Max().y, box.Min().z);
-	glEnd();
-
-	glBegin(GL_QUADS);
-	glVertex3f(box.Min().x, box.Min().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Min().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Min().y, box.Max().z);
-	glVertex3f(box.Min().x, box.Min().y, box.Max().z);
-	glEnd();
-
-	glBegin(GL_QUADS);
-	glVertex3f(box.Min().x, box.Max().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Max().y, box.Min().z);
-	glVertex3f(box.Max().x, box.Max().y, box.Max().z);
-	glVertex3f(box.Min().x, box.Max().y, box.Max().z);
-	glEnd();
-
-	glEnable(GL_CULL_FACE);
-	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-}
-
-
-void Visualization::RenderFrustum()
-{
-	glColor3f(1.0f, 0.0f, 0.0f);
-
-	Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;
-	mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr);
-
-	glLineWidth(2);
-
-	glBegin(GL_LINE_LOOP);
-	glVertex3d(fbl.x, fbl.y, fbl.z);
-	glVertex3d(fbr.x, fbr.y, fbr.z);
-	glVertex3d(ftr.x, ftr.y, ftr.z);
-	glVertex3d(ftl.x, ftl.y, ftl.z);
-	glEnd();
-
-	glBegin(GL_LINE_LOOP);
-	glVertex3d(nbl.x, nbl.y, nbl.z);
-	glVertex3d(nbr.x, nbr.y, nbr.z);
-	glVertex3d(ntr.x, ntr.y, ntr.z);
-	glVertex3d(ntl.x, ntl.y, ntl.z);
-	glEnd();
-
-	glBegin(GL_LINE_LOOP);
-	glVertex3d(fbl.x, fbl.y, fbl.z);
-	glVertex3d(ftl.x, ftl.y, ftl.z);
-	glVertex3d(ntl.x, ntl.y, ntl.z);
-	glVertex3d(nbl.x, nbl.y, nbl.z);
-	glEnd();
-
-	glBegin(GL_LINE_LOOP);
-	glVertex3d(fbr.x, fbr.y, fbr.z);
-	glVertex3d(ftr.x, ftr.y, ftr.z);
-	glVertex3d(ntr.x, ntr.y, ntr.z);
-	glVertex3d(nbr.x, nbr.y, nbr.z);
-	glEnd();
-
-	glBegin(GL_LINE_LOOP);
-	glVertex3d(fbr.x, fbr.y, fbr.z);
-	glVertex3d(fbl.x, fbl.y, fbl.z);
-	glVertex3d(nbl.x, nbl.y, nbl.z);
-	glVertex3d(nbr.x, nbr.y, nbr.z);
-	glEnd();
-
-	glBegin(GL_LINE_LOOP);
-	glVertex3d(ftr.x, ftr.y, ftr.z);
-	glVertex3d(ftl.x, ftl.y, ftl.z);
-	glVertex3d(ntl.x, ntl.y, ntl.z);
-	glVertex3d(ntr.x, ntr.y, ntr.z);
-	glEnd();
-}
-
-
-
 void Visualization::RenderViewPoint()
 {
@@ -232,3 +173,57 @@
 }
 
-}
+
+void Visualization::RenderFrustum()
+{
+	glColor3f(1.0f, 0.0f, 0.0f);
+
+	Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;
+	mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr);
+
+	glLineWidth(2);
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(fbl.x, fbl.y, fbl.z);
+	glVertex3d(fbr.x, fbr.y, fbr.z);
+	glVertex3d(ftr.x, ftr.y, ftr.z);
+	glVertex3d(ftl.x, ftl.y, ftl.z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(nbl.x, nbl.y, nbl.z);
+	glVertex3d(nbr.x, nbr.y, nbr.z);
+	glVertex3d(ntr.x, ntr.y, ntr.z);
+	glVertex3d(ntl.x, ntl.y, ntl.z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(fbl.x, fbl.y, fbl.z);
+	glVertex3d(ftl.x, ftl.y, ftl.z);
+	glVertex3d(ntl.x, ntl.y, ntl.z);
+	glVertex3d(nbl.x, nbl.y, nbl.z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(fbr.x, fbr.y, fbr.z);
+	glVertex3d(ftr.x, ftr.y, ftr.z);
+	glVertex3d(ntr.x, ntr.y, ntr.z);
+	glVertex3d(nbr.x, nbr.y, nbr.z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(fbr.x, fbr.y, fbr.z);
+	glVertex3d(fbl.x, fbl.y, fbl.z);
+	glVertex3d(nbl.x, nbl.y, nbl.z);
+	glVertex3d(nbr.x, nbr.y, nbr.z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(ftr.x, ftr.y, ftr.z);
+	glVertex3d(ftl.x, ftl.y, ftl.z);
+	glVertex3d(ntl.x, ntl.y, ntl.z);
+	glVertex3d(ntr.x, ntr.y, ntr.z);
+	glEnd();
+}
+
+
+}
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2788)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2790)
@@ -47,5 +47,5 @@
 mAssumedVisibleFrames(10),
 mMaxBatchSize(50),
-mUseTightBounds(false)
+mUseTightBounds(false), mShowBounds(false)
 {
 }
@@ -72,4 +72,7 @@
 	{
 		RenderNode(node);
+
+		if (mShowBounds)
+			mBvh->RenderBoundsForViz(node, mUseTightBounds);		
 	}
 	else 
@@ -198,8 +201,14 @@
 
 
+void RenderTraverser::SetShowBounds(bool showBounds)
+{
+	mShowBounds = showBounds;
+}
+
+
 void RenderTraverser::SetUseTightBounds(bool useTightBounds)
 {
 	mUseTightBounds = useTightBounds;
-	cout << "using tight bounds: " << useTightBounds << endl;
+	//cout << "using tight bounds: " << useTightBounds << endl;
 }
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2786)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2790)
@@ -967,3 +967,77 @@
 }
 
-}
+
+
+
+static void RenderBoxForViz(const AxisAlignedBox3 &box)
+{
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Min().x, box.Min().y, box.Min().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Max().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Max().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Min().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Min().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Min().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Min().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Min().y, box.Max().z);
+	glEnd();
+
+	glBegin(GL_LINE_LOOP);
+	glVertex3d(box.Min().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Min().z);
+	glVertex3d(box.Max().x, box.Max().y, box.Max().z);
+	glVertex3d(box.Min().x, box.Max().y, box.Max().z);
+
+	glEnd();
+}
+
+
+void Bvh::RenderBoundsForViz(BvhNode *node, bool useTightBounds)
+{
+	glDisable(GL_TEXTURE_2D);
+	glDisable(GL_LIGHTING);
+	glColor3f(1, 1, 1);
+	
+	if (!useTightBounds)
+	{
+		RenderBoxForViz(node->GetBox());
+	}
+	else
+	{
+		for (int i = 0; i < node->mNumTestNodes; ++ i)
+		{
+			RenderBoxForViz(mTestNodes[node->mTestNodesIdx + i]->GetBox());
+		}
+	}
+
+	glEnable(GL_LIGHTING);
+	glEnable(GL_TEXTURE_2D);
+}
+
+
+
+}
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2788)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2790)
@@ -72,4 +72,5 @@
 bool showHelp = false;
 bool showStatistics = true;
+bool showOptions = true;
 bool showBoundingVolumes = false;
 bool visMode = false;
@@ -243,4 +244,9 @@
 		"",
 		"'F1'           - shows/dismisses this message",
+		"'F2'           - shows/hides statistics",
+		"'F3'           - shows/hides bounds (boxes or tight bounds)",
+		"'F4'           - shows/hides bird eye view",
+		"'f5',          - load helpScreen",
+		"'SPACE'        - cycles through occlusion culling algorithms",
 		"",
 		"'MOUSE-LEFT'   - turn left/right, move forward/backward",
@@ -252,5 +258,4 @@
 		"'CURSOR LEFT'  - turn left",
 		"",
-		"'SPACE'        - cycles through occlusion culling algorithms",
 		"'-'            - decreases max batch size",
 		"'+'            - increases max batch size",
@@ -261,9 +266,6 @@
 		"",
 		"'R'            - use render queue",
-		"",
-		"'S'            - shows/hides statistics",
-		"'V'            - shows/hides bounding volumes",
-		"",
-		"'1'            - shows/hides bird eye view",
+		"'B'            - use tight bounds",
+		"'M'            - use multiqueries",
 		0,
 	};
@@ -441,13 +443,4 @@
 		showHelp = !showHelp;
 		break;
-	case 'v':
-	case 'V':
-		showBoundingVolumes = !showBoundingVolumes;
-		//HierarchyNode::SetRenderBoundingVolume(showBoundingVolumes);
-		break;
-	case 'O':
-	case 'o':
-		showStatistics = !showStatistics;
-		break;
 	case '+':
 		maxBatchSize += 10;
@@ -472,7 +465,4 @@
 		useMultiQueries = !useMultiQueries;
 		traverser->SetUseMultiQueries(useMultiQueries);
-		break;
-	case '1':
-		visMode = !visMode;
 		break;
 	case '8':
@@ -537,4 +527,5 @@
 			traverser->SetUseRenderQueue(useRenderQueue);
 		}
+		break;
 	case 'b':
 	case 'B':
@@ -543,4 +534,5 @@
 			traverser->SetUseTightBounds(useTightBounds);
 		}
+		break;
 	default:
 		return;
@@ -560,4 +552,17 @@
 	case GLUT_KEY_F1:
 		showHelp = !showHelp;
+		break;
+	case GLUT_KEY_F2:
+		showStatistics = !showStatistics;
+		break;
+	case GLUT_KEY_F3:
+		showBoundingVolumes = !showBoundingVolumes;
+		traverser->SetShowBounds(showBoundingVolumes);
+		break;
+	case GLUT_KEY_F4:
+		visMode = !visMode;
+		break;
+	case GLUT_KEY_F5:
+		showOptions = !showOptions;
 		break;
 	case GLUT_KEY_LEFT:
@@ -927,4 +932,5 @@
 	char msg5[200];
 	char msg6[200];
+	char msg7[200];
 
 
@@ -951,6 +957,9 @@
 	}
 
-	sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d, using render queue: %d", 
-		      assumedVisibleFrames, maxBatchSize, useRenderQueue);
+	sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d", 
+		      assumedVisibleFrames, maxBatchSize);
+
+	sprintf_s(msg3, "render queue: %d, multiqueries: %d, tight bounds: %d", 
+		      useRenderQueue, useMultiQueries, useTightBounds);
 
 	string str;
@@ -960,13 +969,13 @@
 	CalcDecimalPoint(str2, bvh->GetBvhStats().mTriangles);
 
-	sprintf_s(msg3, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)", 
+	sprintf_s(msg4, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)", 
 			  renderedNodes, bvh->GetNumVirtualNodes(), str.c_str(), str2.c_str()); 
 
-	sprintf_s(msg4, "traversed: %5d, frustum culled: %5d, query culled: %5d",
+	sprintf_s(msg5, "traversed: %5d, frustum culled: %5d, query culled: %5d",
 			  traversedNodes, frustumCulledNodes, queryCulledNodes);
 
-	sprintf_s(msg5, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges);
-
-	sprintf_s(msg6, "fps: %6.1f", fps);
+	sprintf_s(msg6, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges);
+
+	sprintf_s(msg7, "fps: %6.1f", fps);
 	//cout << "previously visible node queries: " << traverser->GetStats().mNumPreviouslyVisibleNodeQueries << endl;
 
@@ -982,11 +991,17 @@
 		Output(850, 30, msg[renderMode]);
 
+		
 		if (showStatistics)
 		{
-			Output(20, 30, msg2);
-			Output(20, 60, msg3);
-			Output(20, 90, msg4);
-			Output(20, 120, msg5);
-			Output(20, 150, msg6);
+			Output(20, 30, msg4);
+			Output(20, 60, msg5);
+			Output(20, 90, msg6);
+			Output(20, 120, msg7);
+		}
+
+		if (showOptions)
+		{
+			Output(20, 150, msg2);
+			Output(20, 180, msg3);
 		}
 	}
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp	(revision 2782)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp	(revision 2790)
@@ -82,4 +82,5 @@
 	{
 		bool resultAvailable = false;
+
 		while (!mQueryQueue.empty() && 
 			   (mDistanceQueue.empty() || (resultAvailable = mQueryQueue.front()->ResultAvailable())))
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h	(revision 2788)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h	(revision 2790)
@@ -48,8 +48,6 @@
 	*/
 	void RenderFrustum();
-	/** Renders a bounding box for visualization.
+	/** Renders the current view point.
 	*/
-	void RenderBox(const AxisAlignedBox3 &box);
-
 	void RenderViewPoint();
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2787)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2790)
@@ -115,4 +115,7 @@
 	*/
 	void SetUseTightBounds(bool useTightBounds);
+	/** If bounds should be shown
+	*/
+	void SetShowBounds(bool showBounds);
 
 protected:
@@ -179,4 +182,6 @@
 
 	bool mUseTightBounds;
+
+	bool mShowBounds;
 };
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2787)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2790)
@@ -536,4 +536,7 @@
 	*/
 	int GetNumVirtualNodes() const  { return mNumVirtualNodes; }
+	/** Render wireframe bvh for visualization purpose.
+	*/
+	void RenderBoundsForViz(BvhNode *node, bool useTightBounds);
 
 
