Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h	(revision 1173)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h	(revision 1177)
@@ -429,8 +429,9 @@
 		enum RenderMethod
 		{
-			KDRM_RECURSE,
-			KDRM_STACK,
-			KDRM_SAW,
-			KDRM_CHC
+			KDRM_INTERNAL,
+			KDRM_GTP_VFC,
+			KDRM_GTP_SWC,
+			KDRM_GTP_CHC
+
 		};
 
@@ -488,7 +489,4 @@
 		void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, 
 			Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes);
-		// stack based rendering function
-		void stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame, 
-			Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes);
 
 		// the root node of the kdtree
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h	(revision 1175)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h	(revision 1177)
@@ -32,6 +32,11 @@
 		virtual const String& getTypeName(void) const;
 
+		/** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode
+		*/
 		virtual SceneNode* createSceneNode(void);
+		/** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode
+		*/
 		virtual SceneNode* createSceneNode(const String& name);
+
 		/** Override from SceneManager so that sub entities can be assigned an id for item buffer.
 		*/
@@ -42,8 +47,15 @@
 		virtual void _updateNode(KdTreeSceneNode *node); // TODO: 
 
-		//virtual void _updateSceneGraph(Camera* cam);
+		/** Override from scene manager to st up culling manager
+		*/
+		virtual void _updateSceneGraph(Camera* cam);
+		/** Override from Scenemanager, employ kd-tree based culling
+			or CHC
+		*/
 		virtual void _findVisibleObjects(Camera *cam, bool onlyShadowCasters);
 		//virtual void _renderVisibleObjects();
 
+		/** Render a list of scenenodes
+		*/
 		virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam,
 			bool onlyShadowCasters, int leavePassesInQueue);
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1175)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1177)
@@ -14,4 +14,5 @@
 #include "OgreKdTree.h"
 #include "OgreVisibilityOptionsManager.h"
+#include <VisibilityEnvironment.h>
 
 #include <OgreLogManager.h>
@@ -31,5 +32,5 @@
 #endif
 		mBuildMethod(KdTree::KDBM_PRIORITYQUEUE),
-		mRenderMethod(KdTree::KDRM_RECURSE),
+		mRenderMethod(KdTree::KDRM_INTERNAL),
 		mLeavePassesInQueue(0),
 		mCurrentEntityId(1)
@@ -164,28 +165,55 @@
 		{
 			String rm = *static_cast<const String *>(pValue);
-			if (rm == "Recursive")
-			{
-				mRenderMethod = KdTree::KDRM_RECURSE;
-				return true;
-			}
-			else if (rm == "Stack")
-			{
-				mRenderMethod = KdTree::KDRM_STACK;
-				return true;
-			}
-			else if (rm == "StopAndWait")
-			{
-				mRenderMethod = KdTree::KDRM_SAW;
-				return true;
+			if (rm == "INT")
+			{
+				mRenderMethod = KdTree::KDRM_INTERNAL;
+				return true;
+			}
+			else if (rm == "VFC")
+			{
+				mRenderMethod = KdTree::KDRM_GTP_VFC;
+				int cmt = GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING;
+				return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface)
+					.setOption("Algorithm", &cmt);
+			}
+			else if (rm == "SWC")
+			{
+				mRenderMethod = KdTree::KDRM_GTP_SWC;
+				int cmt = GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING;
+				return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface)
+					.setOption("Algorithm", &cmt);
 			}
 			else if (rm == "CHC")
 			{
-				mRenderMethod = KdTree::KDRM_CHC;
-				return true;
-			}
-			else
-			{
-				return false;
-			}
+				mRenderMethod = KdTree::KDRM_GTP_CHC;
+				int cmt = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING;
+				return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface)
+					.setOption("Algorithm", &cmt);
+			}
+			else
+			{
+				return false;
+			}
+		}
+		// little hack in case someone uses "Algorithm" option from VisOptMan directly
+		else if (strKey == "Algorithm")
+		{
+			bool success = VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface)
+				.setOption(strKey, pValue);
+			// change setting only if change in VisOptMan was successful
+			if (success)
+			{
+				int val = *static_cast<const int *>(pValue);
+				if (val == GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING)
+					mRenderMethod = KdTree::KDRM_GTP_VFC;
+				else if (val == GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING)
+					mRenderMethod = KdTree::KDRM_GTP_SWC;
+				else if (val == GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
+					mRenderMethod = KdTree::KDRM_GTP_CHC;
+				// default, should never happen
+				else
+					mRenderMethod = KdTree::KDRM_INTERNAL;
+			}
+			return success;
 		}
 		else if (strKey == "ShowKdTree")
@@ -243,19 +271,23 @@
 		else if (strKey == "RenderMethod")
 		{
-			if (mRenderMethod == KdTree::KDRM_RECURSE)
-			{
-				*static_cast<String *>(pDestValue) = "Recursive";
-			}
-			else if (mRenderMethod == KdTree::KDRM_STACK)
-			{
-				*static_cast<String *>(pDestValue) = "Stack";
-			}
-			else if (mRenderMethod == KdTree::KDRM_SAW)
-			{
-				*static_cast<String *>(pDestValue) = "StopAndWait";
-			}
-			else if (mRenderMethod == KdTree::KDRM_CHC)
-			{
-				*static_cast<String *>(pDestValue) = "CHC";
+			if (mRenderMethod == KdTree::KDRM_INTERNAL)
+			{
+				*static_cast<String *>(pDestValue) = "INT";
+			}
+			else if (mRenderMethod == KdTree::KDRM_GTP_VFC)
+			{
+					*static_cast<String *>(pDestValue) = "VFC";
+			}
+			else if (mRenderMethod == KdTree::KDRM_GTP_SWC)
+			{
+					*static_cast<String *>(pDestValue) = "SWC";
+			}
+			else if (mRenderMethod == KdTree::KDRM_GTP_CHC)
+			{
+					*static_cast<String *>(pDestValue) = "CHC";
+			}
+			else
+			{
+				return false;
 			}
 			return true;
@@ -343,5 +375,5 @@
 	{
 		Entity *ent = SceneManager::createEntity(entityName, meshName);
-
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
 		for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)
 		{
@@ -351,5 +383,5 @@
 		// increase counter of entity id values
 		++ mCurrentEntityId;
-
+#endif
 		return ent;
 	}
@@ -398,4 +430,12 @@
 	}
 
+	void KdTreeSceneManager::_updateSceneGraph(Camera* cam)
+	{
+		mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
+		mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
+
+		SceneManager::_updateSceneGraph(cam);
+	}
+
 	void KdTreeSceneManager::_findVisibleObjects(Camera *cam, bool onlyShadowCasters)
 	{
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp	(revision 1173)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp	(revision 1177)
@@ -1278,14 +1278,6 @@
 		if (mKdRoot)
 		{
-			//if (renderMethod == KdTree::KDRM_STACK)
-			//{
-			//	stackQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 
-			//		cam, queue, onlyShadowCasters, showBoxes);
-			//}
-			//else
-			//{
-				recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(),
-					cam, queue, onlyShadowCasters, showBoxes);
-			//}
+			recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(),
+				cam, queue, onlyShadowCasters, showBoxes);
 		}
 	}
@@ -1343,67 +1335,4 @@
 	}
 
-	void KdTree::stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame, Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes)
-	{
-		static NodeStack nodestack;
-		if (!nodestack.empty()) OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-			"Stuff left in stack from previos frame", "KdTree::stackQueueVisibleObjects");
-
-		nodestack.push(root);
-
-		while (!nodestack.empty())
-		{
-			KdTree::Node * node = nodestack.top();
-			nodestack.pop();
-
-			// test visibility
-			if (cam->isVisible(node->mAABB))
-			{
-	#ifdef KDTREE_DEBUG
-				WireBoundingBox * wbb = 0;
-				if (showBoxes)
-					wbb = node->getWireBoundingBox();
-	#endif
-
-				if (node->isLeaf())
-				{
-					KdTree::Leaf * leaf = KDLEAFPTR_CAST(node);
-					KdRenderableList::iterator it  = leaf->mKdRenderables.begin();
-					KdRenderableList::iterator end = leaf->mKdRenderables.end();
-					while (it != end)
-					{			
-						if (!(*it)->isQueued(currentFrame, cam))
-						{
-							(*it)->queueObjects(cam, queue, onlyShadowCasters);
-						}
-						it++;
-					}
-	#ifdef KDTREE_DEBUG
-					if (wbb)
-						queue->addRenderable(wbb);
-	#else
-					if (showBoxes)
-						queue->addRenderable(leaf->getWireBoundingBox());
-	#endif
-				}
-				else
-				{
-					KdTree::Branch * branch = KDBRANCHPTR_CAST(node);
-	#ifdef KDTREE_DEBUG
-					if (wbb)
-						queue->addRenderable(wbb);
-	#else
-					if (showBoxes)
-						queue->addRenderable(branch->getWireBoundingBox());
-	#endif
-
-					if (branch->mLeft)
-						nodestack.push(branch->mLeft);
-					if (branch->mRight)
-						nodestack.push(branch->mRight);
-				}
-			}
-		}
-	}
-
 	void KdTree::dump()
 	{
