Index: /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h	(revision 29)
+++ /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h	(revision 30)
@@ -71,6 +71,6 @@
 		enum {MODE_QUERY, MODE_RENDER};
 
-		int isLeaf(SceneNode *node);
-		int countSceneNodes(SceneNode *node);
+		bool isLeaf(SceneNode *node);
+		unsigned int countSceneNodes(SceneNode *node);
 		void renderZPass();
 		void traverseNode(SceneNode *node);
@@ -105,14 +105,21 @@
 		PriorityQueue *mDistanceQueue; 
 		
-		unsigned int mFrameId;
-		unsigned int mVisibilityThreshold;
-		unsigned int mNumSceneNodes;
-		int mCurrentTestIdx;
-		int mQueryMode;
-		
-		std::vector<HardwareOcclusionQuery *> mOcclusionQueries;
+			std::vector<HardwareOcclusionQuery *> mOcclusionQueries;
 		// two halfes of a aabb
 		SolidHalfBoundingBox *mHalfBoundingBox[2];	
 		int mCurrentAlgorithm;
+
+		unsigned int mFrameId;
+		unsigned int mVisibilityThreshold;
+		
+		int mCurrentTestIdx;
+		int mQueryMode;
+
+		//--- statistics
+		unsigned int mNumSceneNodes;
+		unsigned int mNumTraversedNodes;
+		unsigned int mNumQueryCulledNodes;
+		unsigned int mNumFrustumCulledNodes;
+		unsigned int mNumRenderedGeometry;
 	};
 
Index: /trunk/VUT/OcclusionCullingSceneManager/scripts/OcclusionDemo.overlay
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/scripts/OcclusionDemo.overlay	(revision 29)
+++ /trunk/VUT/OcclusionCullingSceneManager/scripts/OcclusionDemo.overlay	(revision 30)
@@ -24,5 +24,5 @@
 
 
-		element TextArea(Example/Occlusion/OcclusionTechnique)
+		element TextArea(Example/Occlusion/Algorithm)
 		{
 			metrics_mode pixels
@@ -37,53 +37,41 @@
 			colour_bottom 0.3 0.5 0.3
 		}
-		element TextArea(Example/Occlusion/OcclusionTechniqueInfo)
-		{
-			metrics_mode pixels
-			left 155
-			top 5
-			width 90
-			height 30
-			font_name TrebuchetMSBold
-			char_height 16
-			caption :
-			colour_top 0.5 0.7 0.5
-			colour_bottom 0.3 0.5 0.3
-		}
-
-		element TextArea(Example/Occlusion/Materials)
-		{
-			metrics_mode pixels
-			left 5
-			top 20
-			width 90
-			height 30
-			font_name TrebuchetMSBold
-			char_height 16
-			caption [M] Athene Material
-			colour_top 0.5 0.7 0.5
-			colour_bottom 0.3 0.5 0.3
-		}
-		element TextArea(Example/Occlusion/MaterialInfo)
-		{
-			metrics_mode pixels
-			left 155
-			top 20
-			width 90
-			height 30
-			font_name TrebuchetMSBold
-			char_height 16
-			caption :
-			colour_top 0.5 0.7 0.5
-			colour_bottom 0.3 0.5 0.3
-		}
-		element TextArea(Example/Occlusion/OcclusionInfo)
-		{
-			metrics_mode pixels
-			left 5
-			top 35
-			width 250
-			height 30
-			font_name TrebuchetMSBold
-			char_height 16
+		element TextArea(Example/Occlusion/AlgorithmInfo)
+		{
+			metrics_mode pixels
+			left 155
+			top 5
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption :
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
+
+		element TextArea(Example/Occlusion/Threshold)
+		{
+			metrics_mode pixels
+			left 5
+			top 20
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption [-][+] Thresholdz
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
+		element TextArea(Example/Occlusion/ThresholdInfo)
+		{
+			metrics_mode pixels
+			left 155
+			top 20
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption :dddd
 			colour_top 0.5 0.7 0.5
 			colour_bottom 0.3 0.5 0.3
@@ -112,18 +100,108 @@
 	    	border_bottomright_uv 0.9961 0.0039 1.0000 0.0000
 
-
-		element TextArea(Example/Occlusion/CulledNodes)
-		{
-			metrics_mode pixels
-			left 5
-			top 5
-			width 180
-			height 30
-			font_name TrebuchetMSBold
-			char_height 16
-			caption Culled Nodes
+		element TextArea(Example/Occlusion/FrustumCulledNodes)
+		{
+			metrics_mode pixels
+			left 5
+			top 5
+			width 180
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption Frustum Culled Nodes
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
+		element TextArea(Example/Occlusion/FrustumCulledNodesInfo)
+		{
+			metrics_mode pixels
+			left 155
+			top 5
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption :jjkj
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
+		element TextArea(Example/Occlusion/QueryCulledNodes)
+		{
+			metrics_mode pixels
+			left 5
+			top 20
+			width 180
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption Query Query Culled Nodes
 			colour_top 0.5 0.7 0.5
 			colour_bottom 0.3 0.5 0.3
 		}	
+		element TextArea(Example/Occlusion/QueryCulledNodesInfo)
+		{
+			metrics_mode pixels
+			left 155
+			top 20
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption :
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
+		element TextArea(Example/Occlusion/TraversedNodes)
+		{
+			metrics_mode pixels
+			left 5
+			top 35
+			width 180
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption Traversed Nodes
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}	
+		element TextArea(Example/Occlusion/TraversedNodesInfo)
+		{
+			metrics_mode pixels
+			left 155
+			top 35
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption :
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
+		element TextArea(Example/Occlusion/SceneNodes)
+		{
+			metrics_mode pixels
+			left 5
+			top 50
+			width 180
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption Traversed Scene Nodes
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}	
+		element TextArea(Example/Occlusion/SceneNodesInfo)
+		{
+			metrics_mode pixels
+			left 155
+			top 50
+			width 90
+			height 30
+			font_name TrebuchetMSBold
+			char_height 16
+			caption :
+			colour_top 0.5 0.7 0.5
+			colour_bottom 0.3 0.5 0.3
+		}
 	}
 }
Index: /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp	(revision 29)
+++ /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp	(revision 30)
@@ -15,5 +15,6 @@
 	OcclusionCullingSceneManager::OcclusionCullingSceneManager(): 
 	mFrameId(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0),
-	mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT)
+	mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT),
+	mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0), mNumRenderedGeometry(0)
 	{		
 		mHalfBoundingBox[0] = mHalfBoundingBox[1] = 0;
@@ -36,10 +37,12 @@
 	void OcclusionCullingSceneManager::_renderVisibleObjects(void)
 	{
+		mNumTraversedNodes = 0;
+		mNumQueryCulledNodes = 0;
+		mNumFrustumCulledNodes = 0;
+		mNumRenderedGeometry = 0;
+		
 		mDistanceQueue = new PriorityQueue(myless<SceneNode *>(mCameraInProgress));
-		
 		mDistanceQueue->push(mSceneRoot);
-
 		mCurrentTestIdx = 0;
-
 		//renderZPass();
 
@@ -62,12 +65,4 @@
 		delete mDistanceQueue;
 
-		/*mDestRenderSystem->_setDepthBufferParams(true, false, CMPF_LESS);
-		  SceneManager::_renderVisibleObjects();
-		  mDestRenderSystem->_setDepthBufferParams();
-          mDistanceQueue.push(mSceneRoot);
-		  Preprocess();
-		  //ResetQueries();
-		*/
-		
 		mFrameId ++;
 	}
@@ -102,4 +97,8 @@
 					traverseNode(node);
 				}
+				else
+				{
+					mNumQueryCulledNodes ++;
+				}
 			}	
 
@@ -108,5 +107,4 @@
 			{
 				SceneNode *node = mDistanceQueue->top();
-
 				mDistanceQueue->pop();
 	
@@ -134,5 +132,11 @@
 					// always traverse a node if it was visible
 					if(wasVisible)
+					{
 						traverseNode(node);
+					}
+				}
+				else
+				{
+					mNumFrustumCulledNodes ++;
 				}
 			}
@@ -157,4 +161,8 @@
 				traverseNode(node);
 			}
+			else
+			{			
+				mNumFrustumCulledNodes ++;
+			}
 		}
 	}	
@@ -179,7 +187,4 @@
 				query->pullOcclusionQuery(&visiblePixels);
 				
-				//char str[100]; sprintf(str, "number: %d, id: %d", (int)visiblePixels, mCurrentTestIdx);
-				//MessageBox( NULL, str, "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);
-
 				// node visible
 				if(visiblePixels > mVisibilityThreshold)
@@ -187,5 +192,13 @@
 					traverseNode(node);
 				}
-			}					
+				else
+				{
+					mNumQueryCulledNodes ++;
+				}
+			}
+			else
+			{
+				mNumFrustumCulledNodes ++;
+			}
 		}
 	}
@@ -203,8 +216,5 @@
 		/*
 		static RenderOperation ro;
-
-		// Issue view / projection changes if any
 		useRenderableViewProjMode(&box);
-
 		box.getRenderOperation(ro);
 		ro.srcRenderable = &box; 
@@ -237,24 +247,25 @@
 	void OcclusionCullingSceneManager::traverseNode(SceneNode *node)
 	{
-		if(isLeaf(node))
+		mNumTraversedNodes ++;
+
+		if(node->numAttachedObjects() > 0)
 		{
 			render(node);
 		}
-		else // internal node: add children to priority queue for further processing
-		{
-			Node::ChildNodeIterator it = node->getChildIterator();
+
+		// internal node: add children to priority queue for further processing
+		Node::ChildNodeIterator it = node->getChildIterator();
 					
-			while (it.hasMoreElements())
-			{ 
-				SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext());
-				mDistanceQueue->push(sceneChild);
-			}
-		 }
+		while (it.hasMoreElements())			
+		{ 
+			SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext());
+			mDistanceQueue->push(sceneChild);
+		}
 	}
 	//-----------------------------------------------------------------------
 	void OcclusionCullingSceneManager::render(SceneNode *node)
 	{
-		//setRenderingMode(MODE_RENDER);
-		//MessageBox( NULL, "harhar", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);
+		setRenderingMode(MODE_RENDER);
+		
 		//HACK (too slow)
 		node->_findVisibleObjects(mCameraInProgress, getRenderQueue(), false, 
@@ -266,17 +277,17 @@
 	void OcclusionCullingSceneManager::_updateSceneGraph(Camera* cam)
 	{
-		int numnodes = countSceneNodes(mSceneRoot);
-		
+		unsigned int numnodes = countSceneNodes(mSceneRoot);
+	
 		//-- initialise occlusion queries.
 		if(numnodes != mNumSceneNodes)
 		{
 			deleteQueries();
+			
 			mNumSceneNodes = numnodes;
 
 			for(unsigned int i=0; i < mNumSceneNodes; i++)
 			{
-				HardwareOcclusionQuery *hw = mDestRenderSystem->createHardwareOcclusionQuery();
-				mOcclusionQueries.push_back(hw);
-			}
+				mOcclusionQueries.push_back(mDestRenderSystem->createHardwareOcclusionQuery());
+			}	
 		}
 
@@ -284,12 +295,8 @@
 	}
 	//-----------------------------------------------------------------------
-	int OcclusionCullingSceneManager::countSceneNodes(SceneNode *node)
-	{
-		int num = 1;
-		if(isLeaf(node))
-		{
-			return num;
-		}
-
+	unsigned int OcclusionCullingSceneManager::countSceneNodes(SceneNode *node)
+	{
+		unsigned int result = 1;
+		
 		Node::ChildNodeIterator it = node->getChildIterator();
 		
@@ -297,11 +304,11 @@
 		{ 
 			SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext());
-			num += countSceneNodes(sceneChild);
+			result += countSceneNodes(sceneChild);
         }
 
-		return num;
-	}
-	//-----------------------------------------------------------------------
-	int OcclusionCullingSceneManager::isLeaf(SceneNode *node)
+		return result;
+	}
+	//-----------------------------------------------------------------------
+	bool OcclusionCullingSceneManager::isLeaf(SceneNode *node)
 	{
 		return (node->numChildren() == 0);
@@ -353,5 +360,10 @@
 			return true;
 		}
-	
+		if ( key == "Threshold" )
+		{
+			mCurrentAlgorithm = * static_cast < const int * > ( val );
+			return true;
+		}
+		
 		return SceneManager::setOption( key, val );
 	}
@@ -362,4 +374,29 @@
 		{
 			* static_cast < int * > ( val ) = mCurrentAlgorithm;
+			return true;
+		}
+		if ( key == "Threshold" )
+		{
+			* static_cast < int * > ( val ) = mVisibilityThreshold;
+			return true;
+		}
+		if ( key == "NumSceneNodes" )
+		{
+			* static_cast < unsigned int * > ( val ) = mNumSceneNodes;
+			return true;
+		}
+		if ( key == "NumTraversedNodes" )
+		{
+			* static_cast < unsigned int * > ( val ) = mNumTraversedNodes;
+			return true;
+		}
+		if ( key == "NumQueryCulledNodes" )
+		{
+			* static_cast < unsigned int * > ( val ) = mNumQueryCulledNodes;
+			return true;
+		}
+		if ( key == "NumFrustumCulledNodes" )
+		{
+			* static_cast < unsigned int * > ( val ) = mNumFrustumCulledNodes;
 			return true;
 		}
@@ -377,5 +414,10 @@
 		SceneManager::getOptionKeys( refKeys );
 		refKeys.push_back( "Algorithm" );
-	
+		refKeys.push_back( "Threshold" );
+		refKeys.push_back( "NumSceneNodes" );
+		refKeys.push_back( "NumTraversedNodes" );
+		refKeys.push_back( "NumQueryCulledNodes" );
+		refKeys.push_back( "NumFrustumCulledNodes" );
+		//refKeys.push_back( "mNumRenderedGeometry" );
 		return true;
 	}
Index: /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp	(revision 29)
+++ /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp	(revision 30)
@@ -114,11 +114,21 @@
 
 		// show overlay
-        Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionDemoOverlay");    
-        mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/OcclusionTechniqueInfo");
-        //mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo");
+        Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionDemoOverlay"); 
+
+        mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/AlgorithmInfo");
+		mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/ThresholdInfo");
+		mFrustumCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/FrustumCulledNodesInfo");
+		mQueryCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/QueryCulledNodesInfo");
+        mTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/TraversedNodesInfo");
+		
+		//mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo");
         //mInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/Info");
 
 		mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);
-        //mMaterialInfo->setCaption(": " + mAtheneMaterials[mCurrentAtheneMaterial]);
+		mThresholdInfo->setCaption(": dfddfdffdfd0");
+		mFrustumCulledNodesInfo->setCaption(": 0");
+		mQueryCulledNodesInfo->setCaption(": 0");
+		mTraversedNodesInfo->setCaption(": 0");
+
         pOver->show();
 } // MouseQueryListener
@@ -185,5 +195,8 @@
 
     KEY_PRESSED(KC_O, 1, changeAlgorithm());
+	//KEY_PRESSED(KC_T, 1, changeAlgorithm());
       
+	changeStats();
+
     return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt);        
 }
@@ -192,9 +205,19 @@
 {
     mCurrentAlgorithm = ++mCurrentAlgorithm % OcclusionCullingSceneManager::NUM_RENDERMODES;
-    mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);
-
+
+	mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);
 	mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm);
 }
-
+//-----------------------------------------------------------------------
+void MouseQueryListener::changeStats()
+{
+	unsigned int opt = 0;
+	
+	mSceneMgr->getOption("Threshold", &opt); mThresholdInfo->setCaption(": " + opt);
+	mSceneMgr->getOption("NumFrustumCulledNodes", &opt); mFrustumCulledNodesInfo->setCaption(": " + opt);
+	mSceneMgr->getOption("NumQueryCulledNodes", &opt); mQueryCulledNodesInfo->setCaption(": " + opt);
+	mSceneMgr->getOption("NumTraversedNodes", &opt); mTraversedNodesInfo->setCaption(": " + opt);
+}
+//-----------------------------------------------------------------------
 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
 {
Index: /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h	(revision 29)
+++ /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h	(revision 30)
@@ -88,5 +88,5 @@
 */
 	void changeAlgorithm();
-
+	void changeStats();
 
 protected:
@@ -98,5 +98,11 @@
 //	bool mShutdownRequested;
 	int mCurrentAlgorithm;
+	
 	OverlayElement *mAlgorithmInfo;
+	OverlayElement *mThresholdInfo;
+	OverlayElement *mFrustumCulledNodesInfo;
+	OverlayElement *mQueryCulledNodesInfo;
+    OverlayElement *mTraversedNodesInfo;
+
 };
 
@@ -142,5 +148,4 @@
 
     }*/
-    // Override scene manager (use indoor instead of generic)
     
 
