Index: /trunk/VUT/GtpVisibility/include/VisibilityManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/VisibilityManager.h	(revision 92)
+++ /trunk/VUT/GtpVisibility/include/VisibilityManager.h	(revision 114)
@@ -52,13 +52,17 @@
 	void SetVisibilityCullingThreshold(unsigned int threshold);
 
+	/** Determines if optimization for coherent hierarchical culling is used.
+	*/
+	void SetUseChcOptimization(bool useOptimization);
+
 protected:
 	
-  CullingManager *mCullingManager;
-  QueryManager *mQueryManager;
-  PreprocessingManager *mPreprocessingManager;
-  VisibilityEnvironment *mVisibilityEnvironment;
-  VisibilityEnvironment::CullingManagerType mCullingManagerType;
+	CullingManager *mCullingManager;
+	QueryManager *mQueryManager;
+	PreprocessingManager *mPreprocessingManager;
+	VisibilityEnvironment *mVisibilityEnvironment;
+	VisibilityEnvironment::CullingManagerType mCullingManagerType;
 
-  unsigned int mVisibilityThreshold;
+	unsigned int mVisibilityThreshold;
 
 };
Index: /trunk/VUT/GtpVisibility/include/CullingManager.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/CullingManager.h	(revision 112)
+++ /trunk/VUT/GtpVisibility/include/CullingManager.h	(revision 114)
@@ -43,5 +43,4 @@
 	/** basic initializations on beginning of each frame, e.g., 
 		resets statistics.
-		@param visualizeCulledNodes 
 	*/
 	void InitFrame(bool visualizeCulledNodes);
Index: /trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 107)
+++ /trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 114)
@@ -51,8 +51,13 @@
 			mCullingManager = new FrustumCullingManager();
 			break;
+
 		default:
 			mCullingManager = new StopAndWaitCullingManager();
 			break;
+
 		}
+
+		// -- set threshold
+		mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);		
 	}
 }
Index: /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 113)
+++ /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 114)
@@ -23,5 +23,5 @@
 		{//if (mHierarchyInterface->mIsShadowPass)
 			mNumFrustumCulledNodes ++;
-			if(mVisualizeCulledNodes)
+			if (mVisualizeCulledNodes)
 			{
 				mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
@@ -52,5 +52,5 @@
 			{	//if (mHierarchyInterface->mIsShadowPass)
 				mNumQueryCulledNodes ++;
-				if(mVisualizeCulledNodes)
+				if (mVisualizeCulledNodes)
 				{
 					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 113)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 114)
@@ -760,10 +760,8 @@
 	mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM;
 
-	bool renderNodesForViz = 
-		(mNodeVizMode == NODEVIZ_RENDER_NODES) || 
-		(mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT);
-	bool renderNodesContentForViz = mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT;
-
-	mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz);
+	//bool renderNodesForViz = (mNodeVizMode == NODEVIZ_RENDER_NODES) || (mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT);
+	bool renderNodesContentForViz = mNodeVizMode == NODEVIZ_RENDER_GEOMETRY;
+
+	//mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz);
 	mSceneMgr->setOption("RenderNodesContentForViz", &renderNodesContentForViz);
 }
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 113)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 114)
@@ -88,6 +88,7 @@
 
 	// visualization modes for scene nodes
-	enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES, 
-		  NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
+	//enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES, 
+	//	  NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
+	enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM};
 
 	void nextAlgorithm();
Index: /trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h
===================================================================
--- /trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h	(revision 75)
+++ /trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h	(revision 114)
@@ -10,5 +10,6 @@
 	
 /**
-	Helper class for setting and getting different visibility options.
+	Helper class for setting and getting different options directly
+	related to visibility culling.
 */
 class VisibilityOptionsManager
Index: /trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
===================================================================
--- /trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 113)
+++ /trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 114)
@@ -52,5 +52,9 @@
 	//writes out stats into the Ogre log file
 	void WriteLog();
-
+	/** Render a set of objects, see renderSingleObject for param definitions 
+		Override so we can handle delayed rendering of transparent objects
+	*/
+	virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 
+            bool doLightIteration, const LightList* manualLightList = 0);
 protected:
 	
@@ -60,7 +64,9 @@
 	bool mUseVisibilityCulling;
 	bool mShowVisualization;
+	bool mRenderTransparentObjects;
 	bool mVisualizeCulledNodes;
 
-	int mRenderNodesForViz;
+	bool mRenderNodesForViz;
+	bool mRenderNodesContentForViz;
 };
 
Index: /trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
===================================================================
--- /trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 113)
+++ /trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 114)
@@ -51,4 +51,9 @@
 	GtpVisibility::VisibilityManager *getVisibilityManager();
 
+	/** Render a set of objects, see renderSingleObject for param definitions 
+		Override so we can handle delayed rendering of transparent objects
+	*/
+	virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 
+            bool doLightIteration, const LightList* manualLightList = 0);
 protected:
 	
@@ -62,7 +67,9 @@
 	bool mUseVisibilityCulling;
 	bool mShowVisualization;
+	bool mRenderTransparentObjects;
+	bool mVisualizeCulledNodes;
+
 	bool mRenderNodesForViz;
 	bool mRenderNodesContentForViz;
-	bool mVisualizeCulledNodes;
 };
 
Index: /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 113)
+++ /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 114)
@@ -21,10 +21,11 @@
 mRenderNodesForViz(false),
 mRenderNodesContentForViz(false),
-mVisualizeCulledNodes(false)
+mVisualizeCulledNodes(false),
+mRenderTransparentObjects(false)
 {
 	mHierarchyInterface = 
 		new OctreeHierarchyInterface(this, mDestRenderSystem);
 
-	//mDisplayNodes = true;
+    //mDisplayNodes = true;
 	//mShowBoundingBoxes = true;
 
@@ -71,8 +72,8 @@
 		{
 			// change node material so it is better suited for visualization
-			MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
+			/*MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
 			nodeMat->setAmbient(1, 1, 0);
 			nodeMat->setLightingEnabled(true);
-			nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
+			nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();*/
 
 			for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
@@ -113,6 +114,4 @@
 	if (!mUseVisibilityCulling || mShowVisualization)
 	{	
-		//mDestRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM);
-		//mDestRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM);
 		TerrainSceneManager::_renderVisibleObjects();
 	
@@ -248,5 +247,4 @@
 	return mVisibilityManager;
 }
-
 //-----------------------------------------------------------------------
 void VisibilityTerrainSceneManager::WriteLog()
@@ -264,5 +262,13 @@
 	LogManager::getSingleton().logMessage(d.str());
 }
-
+//-----------------------------------------------------------------------
+void VisibilityTerrainSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 
+            bool doLightIteration, const LightList* manualLightList)
+{
+	if (mRenderTransparentObjects)
+	{
+		OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);
+	}
+}
 
 } // namespace Ogre
Index: /trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 113)
+++ /trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 114)
@@ -17,5 +17,6 @@
 mShowVisualization(false),
 mRenderNodesForViz(false),
-mVisualizeCulledNodes(false)
+mVisualizeCulledNodes(false),
+mRenderTransparentObjects(false)
 {
 	mHierarchyInterface = 
@@ -92,10 +93,10 @@
 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
 {
-	// if shadow pass => render only shadow casters
+	// only shadow casters will be rendered in shadow texture pass
 	mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
 
 	// does nothing if hierarchical culling is used =>
 	// we interleave identification and rendering of objects 
-	// in _renderVisibibleObjects 
+	// in _renderVisibibleObjects
 	if (!mUseVisibilityCulling)
 	{
@@ -103,16 +104,49 @@
 		return;	
 	}
-	
+
+	//-- show visibile scene nodes and octree bounding boxes from last frame
 	if (mShowVisualization)
     {
+		// add player camera for visualization purpose
+		try {
+			Camera *c;
+			if ((c = getCamera("PlayerCam")) != NULL)
+			{
+				getRenderQueue()->addRenderable(c);
+			}   
+        }
+        catch(...)
+        {
+            // ignore
+        }
 		
-		for ( BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it )
+		if (mRenderNodesForViz || mRenderNodesContentForViz)
+		{
+			// change node material so it is better suited for visualization
+		/*	MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
+			nodeMat->setAmbient(1, 1, 0);
+			nodeMat->setLightingEnabled(true);
+			nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();*/
+
+			for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
+			{
+				if (mRenderNodesForViz)
+				{
+					getRenderQueue()->addRenderable(*it);
+				}
+				if (mRenderNodesContentForViz) 
+				{
+					(*it)->_addToRenderQueue(cam, getRenderQueue(), false);
+				}
+			}
+		}
+		for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)
 		{
 			getRenderQueue()->addRenderable(*it);
 		}
 	}
-
-	mBoxes.clear();
-    mVisible.clear();
+	
+	mVisible.clear();
+    mBoxes.clear();
 }
 //-----------------------------------------------------------------------
@@ -142,5 +176,5 @@
 	if (key == "RenderNodesForViz")
 	{
-		mRenderNodesForViz = (*static_cast<const int *>(val));
+		mRenderNodesForViz = (*static_cast<const bool *>(val));
 		return true;
 	}
@@ -165,4 +199,5 @@
 		return true;
 	}
+
 	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
 		setOption(key, val) || OctreeSceneManager::setOption(key, val);
@@ -200,4 +235,13 @@
 {
 	return mVisibilityManager;
+}
+//-----------------------------------------------------------------------
+void VisibilityOctreeSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 
+            bool doLightIteration, const LightList* manualLightList)
+{
+	if (mRenderTransparentObjects)
+	{
+		OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);
+	}
 }
 //-----------------------------------------------------------------------
