Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h	(revision 30)
+++ trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h	(revision 32)
@@ -4,4 +4,5 @@
 #include "OgreSceneNode.h"
 #include "OgreSceneManager.h"
+#include "OgreOcclusionCullingSceneTraverser.h"
 #include "OgrePrerequisites.h"
 #include "OgreSolidHalfBoundingBox.h"
@@ -11,24 +12,5 @@
 
 namespace Ogre {
-	/**
-		This class implements the compare operator for the priority queue.
-		a lower distance has a higher value in the queue
-	*/
-	template <typename T> class myless
-	{
-	public:
-		myless(Camera *cam) { mCamera = cam; }
-		//bool operator() (HierarchyNode *v1, HierarchyNode *v2) const
-		bool operator() (T v1, T v2) const
-		{
-			return v1->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera);
-		}
-	private:
-		Camera *mCamera;
-	};
-
-	typedef pair<SceneNode *, HardwareOcclusionQuery *> query_pair;
-	typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue;
-	typedef queue<query_pair> QueryQueue;
+	
 	/**
 		Class which implements a scene mangager which uses occlusion queries for culling occluded objects
@@ -38,8 +20,6 @@
 	public:
 		OcclusionCullingSceneManager();
-		~OcclusionCullingSceneManager();
+		//~OcclusionCullingSceneManager();
 	
-		enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};
-		
 		/** Overriden from SceneManager. Renders the scene with the specified algorithm
 		/**
@@ -69,57 +49,6 @@
 
 	protected:
-		enum {MODE_QUERY, MODE_RENDER};
-
-		bool isLeaf(SceneNode *node);
-		unsigned int countSceneNodes(SceneNode *node);
-		void renderZPass();
-		void traverseNode(SceneNode *node);
-		/** Renders current node */
-		void render(SceneNode *node);
-		/** Sets rendering mode, e.g. query mode or render mode*/
-		void setRenderingMode(int mode);
-		
-		/** Renders the scene with view frustum culling only. */
-		void renderCullFrustum();
-		/** Renders the scene with the hierarchical stop and wait algorithm. */
-		void renderStopAndWait();
-		/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
-		void renderCoherentWithQueue();
-		/** Issue a occlusion query for this node. */
-		HardwareOcclusionQuery *issueOcclusionQuery(SceneNode *node, bool wasVisible);
-		/** Pulls up the visibility from the child nodes. */
-		void pullUpVisibility(SceneNode *node);
-		/** delete all previously defined occlusion queries */
-		void deleteQueries();
-		/** Renders bounding box of specified node.
-		@param the node which bounding box is to be rendered
-		*/
-		void renderBoundingBox(SceneNode *node);
-		/** Returns one half of the bounding box.
-		@param the half of the bouding box
-		*/
-		SolidHalfBoundingBox *getSolidHalfBoundingBox(int half);
-		
-
-		// we use a priority queue rather than a renderstack
-		PriorityQueue *mDistanceQueue; 
-		
-			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;
+		OcclusionCullingSceneTraverser mSceneTraverser;
+	
 	};
 
Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h	(revision 32)
+++ trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h	(revision 32)
@@ -0,0 +1,140 @@
+#ifndef _OcclusionCullingSceneTraverser_H__
+#define _OcclusionCullingSceneTraverser_H__
+
+#include "OgreSceneNode.h"
+#include "OgreSceneManager.h"
+#include "OgrePrerequisites.h"
+#include "OgreSolidHalfBoundingBox.h"
+#include "OgreCamera.h"
+#include "OgreRenderSystem.h"
+#include <queue>
+
+using namespace std;
+
+namespace Ogre {
+	/**
+		This class implements the compare operator for the priority queue.
+		a lower distance has a higher value in the queue
+	*/
+	template <typename T> class myless
+	{
+	public:
+		myless(Camera *cam) { mCamera = cam; }
+		//bool operator() (HierarchyNode *v1, HierarchyNode *v2) const
+		bool operator() (T v1, T v2) const
+		{
+			return v1->getSquaredViewDepth(mCamera) > v2->getSquaredViewDepth(mCamera);
+		}
+	private:
+		Camera *mCamera;
+	};
+
+	typedef pair<SceneNode *, HardwareOcclusionQuery *> query_pair;
+	typedef priority_queue<SceneNode *, vector<SceneNode *>, myless<vector<SceneNode *>::value_type> > PriorityQueue;
+	typedef queue<query_pair> QueryQueue;
+	/**
+		Class which implements a scene mangager which uses occlusion queries for culling occluded objects
+	*/
+	class OcclusionCullingSceneTraverser
+	{
+	public:
+		OcclusionCullingSceneTraverser();
+		~OcclusionCullingSceneTraverser();
+	
+		enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};
+		
+		/** Overriden from SceneManager. Renders the scene with the specified algorithm
+		/**
+			The algorithm is one of
+			RENDER_CULL_FRUSTUM: renders the scene with view frustum culling only
+			RENDER_STOP_AND_WAIT: renders the scene with the hierarchical stop and wait algorithm
+			RENDER_COHERENT: renders the scene with the coherent hierarchical algorithm
+		*/
+		
+		/** Sets the given option for the SceneTraverser
+			       @remarks
+			Options are:
+			"Algorithm", int *;			
+		*/
+		bool setOption( const String &, const void * );
+		/** Gets the given option for the SceneTraverser.
+	        @remarks
+		    See setOption
+		*/
+		bool getOption( const String &, void * );
+
+		/** Renders current scene 
+		@param cam current camera
+		@param root root of hierarchy */
+		void renderScene(  Camera *cam, SceneNode *root );
+
+		/** Sets the scene manager */
+		void setSceneManager( SceneManager *sm );
+		/** Sets the render system */
+		void setRenderSystem( RenderSystem *rsys );
+
+		void preprocess( void );
+
+	protected:
+		enum {MODE_QUERY, MODE_RENDER};
+		/** returns true if node is leaf of the hierarchy */
+		bool isLeaf( SceneNode *node );
+		//HACK
+		//unsigned int countSceneNodes(SceneNode *node);
+		void traverseNode( Camera *cam, SceneNode *node );
+		/** Renders current scene node 
+		@param cam current camera
+		@param node current scene node to be rendered
+		*/
+		void renderSceneNode( Camera *cam, SceneNode *node);
+		/** Sets rendering mode, e.g. query mode or render mode*/
+		void setRenderingMode( int mode );
+		/** Renders the scene with view frustum culling only. */
+		void renderCullFrustum( Camera *cam );
+		/** Renders the scene with the hierarchical stop and wait algorithm. */
+		void renderStopAndWait( Camera *cam );
+		/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
+		void renderCoherentWithQueue( Camera *cam );
+		/** Issue a occlusion query for this node. */
+		HardwareOcclusionQuery *issueOcclusionQuery( SceneNode *node, bool wasVisible );
+		/** Pulls up the visibility from the child nodes. */
+		void pullUpVisibility( SceneNode *node );
+		/** delete all previously defined occlusion queries */
+		void deleteQueries();
+		/** Renders bounding box of specified node.
+		@param the scene node contained in the bounding box to be rendered
+		*/
+		void renderBoundingBox( SceneNode *node );
+		/** Returns one half of the bounding box.
+		@param the half of the bouding box
+		*/
+		SolidHalfBoundingBox *getSolidHalfBoundingBox( int half );
+
+		// we use a priority queue rather than a renderstack
+		PriorityQueue *mDistanceQueue; 
+		
+		std::vector<HardwareOcclusionQuery *> mOcclusionQueries;
+		// two halfes of a aabb
+		SolidHalfBoundingBox *mHalfBoundingBox[2];	
+
+		int mCurrentAlgorithm;
+
+		unsigned int mFrameId;
+		unsigned int mVisibilityThreshold;
+		
+		SceneManager *mSceneManager;
+		RenderSystem *mRenderSystem;
+
+		int mCurrentTestIdx;
+		int mQueryMode;
+
+		//--- statistics
+		unsigned int mNumSceneNodes;
+		unsigned int mNumTraversedNodes;
+		unsigned int mNumQueryCulledNodes;
+		unsigned int mNumFrustumCulledNodes;
+		unsigned int mNumRenderedGeometry;
+	};
+
+}
+#endif // OCCLUSIONCULLINGSCENEMANAGER_H
Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreTerrainOcclusionCullingSceneManager.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreTerrainOcclusionCullingSceneManager.h	(revision 32)
+++ trunk/VUT/OcclusionCullingSceneManager/include/OgreTerrainOcclusionCullingSceneManager.h	(revision 32)
@@ -0,0 +1,45 @@
+#ifndef _TerrainOcclusionCullingSceneManager_H__
+#define _TerrainOcclusionCullingSceneManager_H__
+
+#include "OgreSceneNode.h"
+#include "OgreTerrainSceneManager.h"
+//#include "OgreOcclusionCullingSceneManager.h"
+#include "OgrePrerequisites.h"
+//#include "OgreSolidHalfBoundingBox.h"
+
+using namespace std;
+
+namespace Ogre {
+	
+	/**
+		Class which implements a scene mangager which uses occlusion queries for culling occluded objects
+	*/
+	class TerrainOcclusionCullingSceneManager: public TerrainSceneManager
+	{
+	public:
+		TerrainOcclusionCullingSceneManager();
+		//~OcclusionCullingSceneManager();
+	
+	/*	void _renderVisibleObjects(void);
+		void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
+		void _updateSceneGraph(Camera* cam);
+*/
+		/** Sets the given option for the SceneManager
+			       @remarks
+			Options are:
+			"Algorithm", int *;			
+		*/
+//		virtual bool setOption( const String &, const void * );
+		/** Gets the given option for the Scene Manager.
+	        @remarks
+		    See setOption
+		*/
+/*		virtual bool getOption( const String &, void * );
+
+		bool getOptionValues( const String & key, StringVector &refValueList );
+		bool getOptionKeys( StringVector &refKeys );*/
+
+	};
+
+}
+#endif // TERRAINOCCLUSIONCULLINGSCENEMANAGER_H
