Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2254)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2255)
@@ -191,8 +191,8 @@
 	void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays);
 
-	int FindExactVisibleObjects(Camera *camera,
-								Viewport* vp,
-								const bool fromPoint,
-								const bool nodeVisibility);	
+	int QueryVisibleObjectsExact(Camera *camera,
+								 Viewport* vp,
+								 const bool fromPoint,
+								 const bool nodeVisibility);	
 
 	void AddVisibleMeshGeometryToQueue(const GtpVisibility::MeshInfoContainer &visibleGeometry, 
@@ -299,4 +299,8 @@
 	int mCurrentFrame;
 
+	int mQueryMode;
+	
+	enum {EXACT_QUERIES, NODE_QUERIES, APPROXIMATE_QUERIES};
+
 	ObjReader *mObjReader;
 
@@ -305,7 +309,5 @@
 	bool mUseFromPointQueries;
 
-	bool mUseExactQueries;
-	
-	bool mUseDepthPassForQueries;
+	bool mResetMaterialForQueries;
 };
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionQueriesQueryManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionQueriesQueryManager.h	(revision 2171)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionQueriesQueryManager.h	(revision 2255)
@@ -15,6 +15,8 @@
 		on different hierarchy types, while reusing the implementation of the query methods.
     */
-	OcclusionQueriesQueryManager(GtpVisibility::HierarchyInterface *hierarchyInterface, Viewport *vp,
-								 int queryModes, int itemBufferMode);
+	OcclusionQueriesQueryManager(GtpVisibility::HierarchyInterface *hierarchyInterface, 
+								 Viewport *vp,
+								 int queryModes, 
+								 int itemBufferMode);
     
     void ComputeCameraVisibility(const Camera &camera,
@@ -22,5 +24,6 @@
 								 GtpVisibility::MeshInfoContainer *visibleGeometry,
 								 GtpVisibility::PatchInfoContainer *visiblePatches,
-								 bool relativeVisibility = false);
+								 const bool relativeVisibility,
+								 const bool approximateVisibility);
     
     /** 
@@ -32,5 +35,6 @@
 									GtpVisibility::MeshInfoContainer *visibleGeometry,
 									GtpVisibility::PatchInfoContainer *visiblePatches,
-									bool relativeVisibility = false);
+									const bool relativeVisibility,
+									const bool approximateVisibility);
     
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformQueryManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformQueryManager.h	(revision 925)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformQueryManager.h	(revision 2255)
@@ -18,5 +18,6 @@
     */
 	PlatformQueryManager(GtpVisibility::HierarchyInterface *hierarchyInterface, 
-		                 Viewport *vp, int queryModes);
+		                 Viewport *vp, 
+						 int queryModes);
     
     /** 
@@ -25,14 +26,16 @@
     */
     void ComputeFromPointVisibility(const Vector3 &point,
-			       GtpVisibility::NodeInfoContainer *visibleNodes,
-			       GtpVisibility::MeshInfoContainer *visibleGeometry,
-				   GtpVisibility::PatchInfoContainer *visiblePatches,
-			       bool relativeVisibility = false);
+									GtpVisibility::NodeInfoContainer *visibleNodes,
+									GtpVisibility::MeshInfoContainer *visibleGeometry,
+									GtpVisibility::PatchInfoContainer *visiblePatches,
+									const bool relativeVisibility,
+									const bool approximateVisibility);
   
 	void ComputeCameraVisibility(const Camera &camera,
-			       GtpVisibility::NodeInfoContainer *visibleNodes,
-			       GtpVisibility::MeshInfoContainer *visibleGeometry,
-				   GtpVisibility::PatchInfoContainer *visiblePatches,
-			       bool relativeVisibility = false);
+								 GtpVisibility::NodeInfoContainer *visibleNodes,
+								 GtpVisibility::MeshInfoContainer *visibleGeometry,
+								 GtpVisibility::PatchInfoContainer *visiblePatches,
+								 const bool relativeVisibility,
+								 const bool approximateVisibility);
   
 	bool ShootRay(const Ray &ray, std::vector<Mesh *> *visibleMeshes, bool isGlobalLine = false);  
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp	(revision 2184)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp	(revision 2255)
@@ -33,5 +33,6 @@
 					GtpVisibility::MeshInfoContainer *visibleGeometry,
 					GtpVisibility::PatchInfoContainer *visiblePatches,
-					bool relativeVisibility)
+					const bool relativeVisibility,
+					const bool approximateVisibility)
 {
 	SceneManager *sm =
@@ -87,5 +88,6 @@
 								visibleGeometry, 
 								visiblePatches, 
-			                    relativeVisibility);
+			                    relativeVisibility,
+								approximateVisibility);
 		//mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)	printf("wait");
 
@@ -102,9 +104,10 @@
 //-----------------------------------------------------------------------
 void PlatformQueryManager::ComputeCameraVisibility(
-								const Camera &camera,
-								GtpVisibility::NodeInfoContainer *visibleNodes,
-								GtpVisibility::MeshInfoContainer *visibleGeometry,
-								GtpVisibility::PatchInfoContainer *visiblePatches,
-								bool relativeVisibility)
+									const Camera &camera,
+									GtpVisibility::NodeInfoContainer *visibleNodes,
+									GtpVisibility::MeshInfoContainer *visibleGeometry,
+									GtpVisibility::PatchInfoContainer *visiblePatches,
+									const bool relativeVisibility,
+									const bool approximateVisibility)
 {
 	// we need access to the scene manager and the rendersystem
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2254)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2255)
@@ -53,5 +53,4 @@
 				Name="VCPostBuildEventTool"
 				CommandLine="copy $(OutDir)\$(TargetFileName) $(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)
-copy $(OutDir)\$(TargetFileName) E:\svn\gametools\GTP\trunk\App\Demos\Illum\Ogre\bin\$(ConfigurationName)
 "/>
 			<Tool
@@ -125,5 +124,4 @@
 				Name="VCPostBuildEventTool"
 				CommandLine="copy $(OutDir)\$(TargetFileName) $(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)
-copy $(OutDir)\$(TargetFileName) E:\svn\gametools\GTP\trunk\App\Demos\Illum\Ogre\bin\$(ConfigurationName)
 "/>
 			<Tool
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2254)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2255)
@@ -67,8 +67,8 @@
 mFlushRate(10),
 mCurrentFrame(0),
-mUseVisibilityQueries(false),
+mUseVisibilityQueries(true),
 mUseFromPointQueries(false),
-mUseExactQueries(false),
-mUseDepthPassForQueries(false)
+mQueryMode(NODE_QUERIES),
+mResetMaterialForQueries(false)
 {
 	Ogre::LogManager::getSingleton().
@@ -245,22 +245,24 @@
 	}
 
-	val = config.getSetting("UseExactQueries");
+	val = config.getSetting("QueryObjectsMode");
 
 	if (!val.empty())
 	{
+		if (val == "EXACT")
+			mQueryMode = EXACT_QUERIES;
+		else if (val == "NODE")
+			mQueryMode = NODE_QUERIES;
+		else 
+			mQueryMode = APPROXIMATE_QUERIES;
+	}
+
+	val = config.getSetting("ResetMaterialForQueries");
+
+	if (!val.empty())
+	{
 		if (val == "yes")
-			mUseExactQueries = true;
+			mResetMaterialForQueries = true;
 		else
-			mUseExactQueries = false;
-	}
-
-	val = config.getSetting("UseDepthPassForQueries");
-
-	if (!val.empty())
-	{
-		if (val == "yes")
-			mUseDepthPassForQueries = true;
-		else
-			mUseDepthPassForQueries = false;
+			mResetMaterialForQueries = false;
 	}
 
@@ -314,4 +316,5 @@
 			algorithm = 
 				GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING;
+			LogManager::getSingleton().logMessage("Using chc algorithm");
 		}
 		else if (val == "SWC")
@@ -319,4 +322,6 @@
 			 algorithm = 
 				 GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING;
+
+			 LogManager::getSingleton().logMessage("Using stop and wait algorithm");
 		 }
 		 else if (val == "VFC")
@@ -324,4 +329,6 @@
 			 algorithm = 
 				 GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING;
+
+			 LogManager::getSingleton().logMessage("Using frustum culling algorithm");
 		 }
 		 else // default rendering
@@ -331,15 +338,49 @@
 
 			 mNormalExecution = true;
+			 LogManager::getSingleton().logMessage("Using default octree scene manager rendering");
 		 }
 
 		 mVisibilityManager->SetCullingManager(algorithm);
-
-		 stringstream d;
-		 d << "setting algorithm to: " << algorithm;
-		 LogManager::getSingleton().logMessage(d.str());
 	}
 
 	/////////////
 	// terrain options
+
+	if (mUseDepthPass)
+		LogManager::getSingleton().logMessage("using depth pass");
+	else
+		LogManager::getSingleton().logMessage("not using depth pass");
+	
+	if (mExecuteVertexProgramForAllPasses)
+		LogManager::getSingleton().logMessage("executing vertex program for passes");
+	else
+		LogManager::getSingleton().logMessage("not executing vertex program for passes");
+
+	if (mUseVisibilityQueries)
+		LogManager::getSingleton().logMessage("using visibility queries");
+	else
+		LogManager::getSingleton().logMessage("not using visibility queries");
+
+	if (mUseFromPointQueries)
+		LogManager::getSingleton().logMessage("using from point queries");
+	else
+		LogManager::getSingleton().logMessage("not using from point queries");
+
+	if (mQueryMode == EXACT_QUERIES)
+		LogManager::getSingleton().logMessage("using exact queries");
+	else if (mQueryMode == NODE_QUERIES)
+		LogManager::getSingleton().logMessage("using node queries");
+	else if (mQueryMode == APPROXIMATE_QUERIES)
+		LogManager::getSingleton().logMessage("using approximate queries");
+
+	if (mResetMaterialForQueries)
+		LogManager::getSingleton().logMessage("resetting material for queries");
+	else
+		LogManager::getSingleton().logMessage("resetting material for queries");
+
+	if (mDeleteQueueAfterRendering)
+		LogManager::getSingleton().logMessage("flushing queue after some frames");
+	else
+		LogManager::getSingleton().logMessage("not flushing queue after some frames");
 
 	if (!mShowTerrain)
@@ -449,39 +490,5 @@
 	selectPageSource(pageSourceName, optlist);
 
-	if (mUseDepthPass)
-		LogManager::getSingleton().logMessage("using depth");
-	else
-		LogManager::getSingleton().logMessage("not using depth");
-	
-	if (mExecuteVertexProgramForAllPasses)
-		LogManager::getSingleton().logMessage("executing vertex program for passes");
-	else
-		LogManager::getSingleton().logMessage("not executing vertex program for passes");
-
-	if (mUseVisibilityQueries)
-		LogManager::getSingleton().logMessage("using visibility queries");
-	else
-		LogManager::getSingleton().logMessage("not using visibility queries");
-
-	if (mUseFromPointQueries)
-		LogManager::getSingleton().logMessage("using from point queries");
-	else
-		LogManager::getSingleton().logMessage("not using from point queries");
-
-	if (mUseExactQueries)
-		LogManager::getSingleton().logMessage("using exact queries");
-	else
-		LogManager::getSingleton().logMessage("not using exact queries");
-
-	if (mUseDepthPassForQueries)
-		LogManager::getSingleton().logMessage("using depth pass for queries");
-	else
-		LogManager::getSingleton().logMessage("not using depth pass for queries");
-
-	if (mDeleteQueueAfterRendering)
-		LogManager::getSingleton().logMessage("flushing queue after rendering");
-	else
-		LogManager::getSingleton().logMessage("not flushing queue after rendering");
-
+	
 	LogManager::getSingleton().logMessage("****** OcclusionCullingSceneManager Options Finished ********");
 }
@@ -1126,13 +1133,13 @@
 		return true;
 	}
-	if (key == "UseExactQueries")
-	{
-		mUseExactQueries = *static_cast<const bool *>(val);
-
-		return true;
-	}
-	if (key == "UseDepthPassForQueries")
-	{
-		mUseDepthPassForQueries = *static_cast<const bool *>(val);
+	if (key == "QueryMode")
+	{
+		mQueryMode = *static_cast<const int *>(val);
+
+		return true;
+	}
+	if (key == "ResetMaterialForQueries")
+	{
+		mResetMaterialForQueries = *static_cast<const bool *>(val);
 	}
 	if (key == "UseFromPointQueries")
@@ -1192,4 +1199,5 @@
 		return true;
 	}
+
 	if (key == "VisibleObjects")
 	{ 
@@ -1201,8 +1209,8 @@
 		
 		* static_cast<unsigned int *>(val) = 
-			(unsigned int)FindExactVisibleObjects(mCameraInProgress, 
-												  mCurrentViewport, 
-												  fromPoint, 
-												  nodeVisibility);
+			(unsigned int)QueryVisibleObjectsExact(mCameraInProgress, 
+												   mCurrentViewport, 
+												   fromPoint, 
+												   nodeVisibility);
 		return true;
 	}
@@ -1865,7 +1873,7 @@
 	int i = 0;
 
-	if (filename == "terrain")
-	{
-		LogManager::getSingleton().logMessage("loading terrain");
+	if (filename == "terrain" || filename == "")
+	{
+		LogManager::getSingleton().logMessage("not loading scene");
 
 		// terrain hack
@@ -2203,11 +2211,12 @@
 }
 //-----------------------------------------------------------------------
-int OcclusionCullingSceneManager::FindExactVisibleObjects(Camera *camera,
-														  Viewport* vp,
-														  const bool fromPoint,
-														  const bool nodeVisibility)
+int OcclusionCullingSceneManager::QueryVisibleObjectsExact(Camera *camera,
+														   Viewport* vp,
+														   const bool fromPoint,
+														   const bool nodeVisibility)
 {
 	const int itemBufferMode = 0;
 	const bool relativeVisibility = false;
+	const bool approximateVisibility = false;
 
 	int queryModes = 0;
@@ -2236,5 +2245,6 @@
 												 &visibleGeometry, 
 												 &visiblePatches, 
-												 relativeVisibility);
+												 relativeVisibility,
+												 approximateVisibility);
 	}
 	else
@@ -2244,5 +2254,6 @@
 											  &visibleGeometry, 
 											  &visiblePatches, 
-											  relativeVisibility);
+											  relativeVisibility,
+											  approximateVisibility);
 	}
 		
@@ -2489,5 +2500,5 @@
 	// note:have to disable deph write for nodes!
     bool savedUseDepthPass = mUseDepthPass;
-	if (mUseDepthPassForQueries) mUseDepthPass = true;
+	if (mResetMaterialForQueries) mUseDepthPass = true;
 
 	// lists only used for visualization
@@ -2498,11 +2509,21 @@
 	const int itemBufferMode = 0;
 	const bool relativeVisibility = false;
+	bool approximateVisibility = false;
 
 	int queryModes = 0;
 
-	if (mUseExactQueries)
+	if (mQueryMode != 0)
+	{
+		queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY;
+
+		if (mQueryMode == 2)
+		{
+			approximateVisibility = true;
+		}
+	}
+	else
+	{
 		queryModes |= GtpVisibility::QueryManager::GEOMETRY_VISIBILITY;
-	else
-		queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY;
+	}	
 			
 
@@ -2526,5 +2547,6 @@
 												 &visibleGeometry, 
 												 &visiblePatches, 
-												 relativeVisibility);
+												 relativeVisibility,
+												 approximateVisibility);
 	}
 	else
@@ -2534,5 +2556,6 @@
 											  &visibleGeometry, 
 											  &visiblePatches, 
-											  relativeVisibility);
+											  relativeVisibility,
+											  approximateVisibility);
 	}
 		
@@ -2550,14 +2573,14 @@
 	//-- put items in render queue
 	
-	if (mUseExactQueries)
+	if (mQueryMode != EXACT_QUERIES)
 	{
 		////////////
 		//-- apply queries on geometry level
 
+		AddVisibleNodeGeometryToQueue(visibleNodes, cam);
+	}
+	else
+	{
 		AddVisibleMeshGeometryToQueue(visibleGeometry, cam);
-	}
-	else
-	{
-		AddVisibleNodeGeometryToQueue(visibleNodes, cam);
 	}
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2254)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2255)
@@ -28,5 +28,6 @@
 											GtpVisibility::MeshInfoContainer *visibleGeometry,
 											GtpVisibility::PatchInfoContainer *visiblePatches,
-											bool relativeVisibility)
+											const bool relativeVisibility,
+											const bool approximateVisibility)
 {
 	// we need access to the scene manager and the rendersystem
@@ -37,11 +38,10 @@
 	bool overlayEnabled = mViewport->getOverlaysEnabled();
 
-	///////////
-	//-- render scene with item buffer (i.e., objects with their id as color codes)
-
 	//mItemBufferMode = 0;
-	if (0 && 
-		(mItemBufferMode && mQueryModes) != 0)
-	{
+	if (0 && (mItemBufferMode && mQueryModes) != 0)
+	{
+		///////////
+		//-- render scene with item buffer (ids are used as color codes)
+
 		int savedQueryModes = mQueryModes;
 		mQueryModes = mItemBufferMode;
@@ -51,5 +51,6 @@
 													  visibleGeometry, 
 													  visiblePatches, 
-													  relativeVisibility);
+													  relativeVisibility,
+													  approximateVisibility);
 		
 		// overlays cause false visibility
@@ -175,6 +176,6 @@
 			pfHierarchyInterface->CheckFrustumVisible(*nodeIt, intersects);
 
-			// always push back if intersects
-			if (1 && intersects)
+			// always push back if only checking approximate visibility or intersects
+			if (approximateVisibility || intersects)
 			{
 				// no more information available
@@ -185,5 +186,5 @@
 				queryList[i].push_back(NULL);
 			}
-			else
+			else // issue occlusion query
 			{
 				queryList[i].push_back(mHierarchyInterface->IssueNodeOcclusionQuery(*nodeIt, false));
@@ -200,5 +201,16 @@
 			for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++ geometryIt)
 			{
-				queryList[i].push_back(pfHierarchyInterface->IssueMeshOcclusionQuery(*geometryIt));
+				if (approximateVisibility)
+				{
+					// no more information available
+					const int visPixels = 1;
+					const int projPixels = 1;
+
+					visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt, visPixels, projPixels));
+				}
+				else
+				{
+					queryList[i].push_back(pfHierarchyInterface->IssueMeshOcclusionQuery(*geometryIt));
+				}
 			}
 		}
@@ -211,5 +223,16 @@
 			for (patchIt = patchList.begin(); patchIt != patchIt_end; ++patchIt)
 			{
-				queryList[i].push_back(pfHierarchyInterface->IssuePatchOcclusionQuery(*patchIt));
+				if (approximateVisibility)
+				{
+					// no more information available
+					const int visPixels = 1;
+					const int projPixels = 1;
+
+					visiblePatches->push_back(GtpVisibility::PatchInfo(*patchIt, visPixels, projPixels));
+				}
+				else
+				{
+					queryList[i].push_back(pfHierarchyInterface->IssuePatchOcclusionQuery(*patchIt));
+				}
 			}
 		}
@@ -284,5 +307,6 @@
 								GtpVisibility::MeshInfoContainer *visibleGeometry,
 								GtpVisibility::PatchInfoContainer *visiblePatches,
-								bool relativeVisibility)
+								const bool relativeVisibility,
+								const bool approximateVisibility)
 {
 	PlatformQueryManager::ComputeFromPointVisibility(point, 
@@ -290,5 +314,6 @@
 													 visibleGeometry, 
 													 visiblePatches, 
-													 relativeVisibility);
+													 relativeVisibility,
+													 approximateVisibility);
 
 	// adds up their visibility and removes duplicates 
