Index: trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp	(revision 39)
+++ trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp	(revision 40)
@@ -1,24 +1,36 @@
 #include "OgreOcclusionCullingTerrainSceneTraverser.h"
-//#include <windows.h>
+#include "OgreOcclusionCullingTerrainSceneManager.h"
+
+#include <windows.h>
 
 namespace Ogre {
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::traverseNode( Camera *cam, Octree *node )
+	OcclusionCullingTerrainSceneTraverser::OcclusionCullingTerrainSceneTraverser(SceneManager *sm, RenderSystem *rsys): 
+	OcclusionCullingSceneTraverser(sm, rsys)
+	{
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::traverseOctree( Camera *cam, Octree *octree )
 	{
 		mNumTraversedNodes ++;
 	
-	/*	if(node->numAttachedObjects() > 0)
+		if(octree->numNodes() > 0)
 		{
-			renderSceneNode(cam, node);
-		}*/
+			renderOctree(cam, octree);
+		}
 
 		for(int i=0; i<8; i++)
 		{
-			if(node->mChildren[i & 4][i & 2][i & 1] != 0)
-				traverseNode(cam, node->mChildren[i & 4][i & 2][i & 1]);
+			char msg[100];
+			sprintf(msg,"current node: %d\n", i);
+			OutputDebugString(msg);
+
+			if(octree->mChildren[i & 4][i & 2][i & 1] != 0)
+				traverseOctree(cam, octree->mChildren[i & 4][i & 2][i & 1]);			
 		}
 	}
 	//-----------------------------------------------------------------------
 	void OcclusionCullingTerrainSceneTraverser::renderScene( Camera *cam, Octree *root )
+		//TODO: Renderscene independent from hierarchynode => implement only once
 	{
 		mNumTraversedNodes = 0;
@@ -27,8 +39,8 @@
 		mNumRenderedGeometry = 0;
 		
-		mDistanceQueue = new OctreePriorityQueue(myless<Octree *>(cam));
-//		mDistanceQueue->push(root);
+		mDistanceQueue = new OctreePriorityQueue(octreeless<Octree *>(cam));
+		mDistanceQueue->push(root);
 		mCurrentTestIdx = 0;
-
+		
 mCurrentAlgorithm = RENDER_CULL_FRUSTUM;
 		switch(mCurrentAlgorithm)
@@ -37,10 +49,10 @@
 				renderCullFrustum(cam);
 		        break;
-		/*	case RENDER_STOP_AND_WAIT:
+			case RENDER_STOP_AND_WAIT:
 				renderStopAndWait(cam);
 				break;
 			case RENDER_COHERENT:
 				renderCoherentWithQueue(cam);
-				break;*/
+				break;
 			default:
 				renderCullFrustum(cam);
@@ -48,5 +60,5 @@
 		}	
 		
-//		delete mDistanceQueue;
+		delete mDistanceQueue;
 
 		mFrameId ++;
@@ -55,25 +67,40 @@
 	void OcclusionCullingTerrainSceneTraverser::renderCullFrustum(Camera *cam)
 	{
-		/*while(!mDistanceQueue->empty())
+		AxisAlignedBox box;
+		FrustumPlane plane;
+
+		while(!mDistanceQueue->empty())
 		{
-			SceneNode *node = mDistanceQueue->top();
+			Octree *octree = mDistanceQueue->top();
 			mDistanceQueue->pop();
 	
 			// interesting for visualization purpose
-			node->setNodeVisible(false);
-				
-			if(cam->isVisible(node->_getWorldAABB()))
-			{
+			//TODO: octree->setNodeVisible(false);
+			octree->_getCullBounds(&box);
+
+			//if(cam->isVisible(box, &plane))
+			//{
 				// update node's visited flag 
-				node->setLastVisited(mFrameId);
-				node->setNodeVisible(true);
-				traverseNode(cam, node);
-			}
+				//TODO: octree->setLastVisited(mFrameId);
+				//TODO: octree->setNodeVisible(true);
+				traverseOctree(cam, octree);
+			/*}
 			else
 			{			
 				mNumFrustumCulledNodes ++;
-			}
-		}*/
+			}*/
+		}
 	}	
+	
+	/** Renders the scene with the hierarchical stop and wait algorithm. */
+	void OcclusionCullingTerrainSceneTraverser::renderStopAndWait( Camera *cam )
+	{
+	}
+
+	/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
+	void OcclusionCullingTerrainSceneTraverser::renderCoherentWithQueue( Camera *cam )
+	{
+	}
+	
 	//-----------------------------------------------------------------------
 /*	bool OcclusionCullingTerrainSceneTraverser::isLeaf( SceneNode *node )
@@ -85,3 +112,9 @@
 	{
 	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::renderOctree( Camera *cam, Octree *octree )
+	{
+		setRenderingMode(MODE_RENDER);
+		((OcclusionCullingTerrainSceneManager *)mSceneManager)->_renderOctant(cam, octree);
+	}
 }	
