Index: /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/scripts/TestKdTree.vcproj
===================================================================
--- /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/scripts/TestKdTree.vcproj	(revision 2130)
+++ /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/scripts/TestKdTree.vcproj	(revision 2183)
@@ -85,5 +85,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GTP_VISIBILITY_MODIFIED_OGRE;USE_VERBOSE_PVS"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE;USE_VERBOSE_PVS"
 				StringPooling="TRUE"
 				MinimalRebuild="TRUE"
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj	(revision 2171)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj	(revision 2183)
@@ -22,5 +22,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;..\..\GtpVisibility\include;..\..\Ogre\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include"
-				PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG;GTP_VISIBILITY_MODIFIED_OGRE"
+				PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -83,5 +83,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;..\..\Ogre\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include"
-				PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
+				PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				RuntimeLibrary="2"
 				RuntimeTypeInfo="FALSE"
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 2171)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 2183)
@@ -1537,6 +1537,11 @@
 	case KC_F5:
 		{
+			unsigned int pixels = 0;
+			mSceneMgr->getOption("VisibleObjects", &pixels);
+
+			std::stringstream d; d << "visible objects: " << pixels;
+			LogManager::getSingleton().logMessage(d.str());
 			const bool fromPoint = false;
-			applyVisibilityQuery(fromPoint, mShiftPressed, mUseItemBuffer);
+			//applyVisibilityQuery(fromPoint, mShiftPressed, mUseItemBuffer);
 			break;
 		}
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 2168)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 2183)
@@ -454,5 +454,5 @@
 	/////////
 	//-- load parameters & scene
-	loadConfig("terrainCulling.cfg");
+	//loadConfig("terrainCulling.cfg");
 	
 	/////////////////////////////////////
@@ -534,7 +534,7 @@
 	{
 		// the objects are generated randomly distributed over the terrain
-		if (1) generateScene(1500, 0); // create robots
+		if (1) generateScene(500, 0); // create robots
 		if (0) generateScene(100, 1); // create trees
-		if (0) generateScene(100, 2); // create ninjas
+		if (1) generateScene(1000, 2); // create ninjas
 	}
 }
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2130)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2183)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -73,5 +73,5 @@
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1;USE_VERBOSE_PVS"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE;USE_VERBOSE_PVS"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2100)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2183)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include;..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;GTP_VISIBILITY_MODIFIED_OGRE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 1267)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 2183)
@@ -20,5 +20,5 @@
 }
 //-----------------------------------------------------------------------
-bool VisibilityEnvironment::LoadEnvironment(string filename)
+bool VisibilityEnvironment::LoadEnvironment(std::string filename)
 {		
 	//-- parse environment
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h	(revision 2115)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h	(revision 2183)
@@ -52,5 +52,5 @@
 						   GtpVisibilityPreprocessor::Vector3 &normal);
 
-	ostream &Describe(ostream &s);
+	std::ostream &Describe(std::ostream &s);
 	
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2171)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2183)
@@ -13,4 +13,5 @@
 #include "Containers.h"
 #include "ViewCellsManager.h"
+#include "VisibilityInfo.h"
 
 
@@ -20,4 +21,5 @@
 
 class ObjReader;
+
 
 namespace Ogre {
@@ -126,4 +128,6 @@
 	void RenderDepthForQuery(Camera* camera, Viewport* vp);
 
+	void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
+
 protected:
 	
@@ -191,4 +195,7 @@
 								const bool fromPoint,
 								const bool nodeVisibility);	
+
+	void AddVisibleMeshGeometryToQueue(const GtpVisibility::MeshInfoContainer &visibleGeometry, Camera *cam);
+	void AddVisibleNodeGeometryToQueue(const GtpVisibility::NodeInfoContainer &visibleNodes, Camera *cam);
 
 	//////////////////////////////////////////
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp	(revision 2115)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp	(revision 2183)
@@ -74,5 +74,5 @@
 	}
 
-	ostream &OgreMeshInstance::Describe(ostream &s)
+	std::ostream &OgreMeshInstance::Describe(std::ostream &s)
 	{
 		s << mEntity;
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2171)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2183)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\Preprocessing\src\Timer"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -90,5 +90,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\Preprocessing\src\Timer;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -320,5 +320,5 @@
 				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\Release&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\Release&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;&quot;$(OGRE_PATH)\Dependencies\lib\Release&quot;;..\..\..\Preprocessing\lib\Release;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;&quot;$(CG_LIB_PATH)&quot;;..\..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\Lib\Vis\Preprocessing\MultiLevelRayTracing\RTWorld\Release;..\..\..\..\..\Lib\Vis\Preprocessing\MultiLevelRayTracing\RTScene\Release;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\Release;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\lib\Release"
 				ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def"
-				GenerateDebugInformation="FALSE"
+				GenerateDebugInformation="TRUE"
 				SubSystem="2"
 				OptimizeReferences="2"
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2176)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2183)
@@ -25,4 +25,6 @@
 #include "ObjReader.h"
 #include "OgreOcclusionQueriesQueryManager.h"
+#include "VisibilityInfo.h"
+#include "Preprocessor.h"
 
 
@@ -706,25 +708,22 @@
 
 	// standard rendering in first pass
-	if (!mNormalExecution && mUseDepthPass)
+	// hierarchical culling interleaves identification 
+	// and rendering of objects in _renderVisibibleObjects
+
+	// for the shadow pass we use only standard rendering
+	// because shadows have low occlusion anyway
+	if ((mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
+		 mIlluminationStage == IRS_RENDER_TO_TEXTURE) ||
+		mNormalExecution)
+	{
+		OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
+	}
+	else if (mUseDepthPass)
 	{
 		RenderDepthPass();
 	}
-	else
-	{
-		// hierarchical culling interleaves identification 
-		// and rendering of objects in _renderVisibibleObjects
-
-		// for the shadow pass we use only standard rendering
-		// because shadows have low occlusion anyway
-		if ((mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
-			 mIlluminationStage == IRS_RENDER_TO_TEXTURE) ||
-			mNormalExecution)
-		{
-			OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
-		}
-
-		// only shadow casters will be rendered in shadow texture pass
-		//if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
-	}
+	
+	// only shadow casters will be rendered in shadow texture pass
+	//if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
 }
 //-----------------------------------------------------------------------
@@ -1087,5 +1086,5 @@
 			return false;
 
-		const bool fromPoint = true;
+		const bool fromPoint = false;
 		const bool nodeVisibility = true;
 		
@@ -1397,5 +1396,5 @@
 	
 	// possible two cameras (one for culling, one for rendering)
-	mHierarchyInterface->InitTraversal(mCameraInProgress, 
+	mHierarchyInterface->InitTraversal(cam, 
 									   mCullCamera ? getCamera("CullCamera") : NULL,
 									   mLeavePassesInQueue);
@@ -2311,4 +2310,131 @@
 }
 //-----------------------------------------------------------------------
+void OcclusionCullingSceneManager::AddVisibleMeshGeometryToQueue(const GtpVisibility::MeshInfoContainer &visibleGeometry,
+																 Camera *cam)
+{
+	GtpVisibility::MeshInfoContainer::const_iterator geomIt, geomIt_end = visibleGeometry.end();
+
+	for (geomIt = visibleGeometry.begin(); geomIt != geomIt_end; ++geomIt)
+	{
+		MovableObject *mo = (*geomIt).GetSource();
+
+		// add if not 0
+		if (!(*geomIt).GetVisiblePixels())
+			continue;
+
+		mo->_notifyCurrentCamera(cam);
+
+		if (mo->isVisible())
+		{
+			mo->_updateRenderQueue(getRenderQueue());
+		}
+	}
+}
+//-----------------------------------------------------------------------
+void OcclusionCullingSceneManager::AddVisibleNodeGeometryToQueue(const GtpVisibility::NodeInfoContainer &visibleNodes,
+																 Camera *cam)
+{
+	////////////////
+	//-- apply queries on node level
+
+	GtpVisibility::NodeInfoContainer::const_iterator nodesIt, nodesIt_end = visibleNodes.end();
+
+	for (nodesIt = visibleNodes.begin(); nodesIt != nodesIt_end; ++ nodesIt)
+	{
+		if (!(*nodesIt).GetVisiblePixels())
+			continue;
+
+		Octree *octree = static_cast<Octree *>((*nodesIt).GetSource());
+
+		NodeList::iterator nIt, nIt_end = octree->mNodes.end();
+
+		for (nIt = octree->mNodes.begin(); nIt != nIt_end; ++ nIt)
+		{
+			(*nIt)->_addToRenderQueue(cam, getRenderQueue(), false);
+		}
+	}
+}
+//-----------------------------------------------------------------------
+void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam,
+													   bool onlyShadowCasters)										 
+{
+	// lists only used for visualization
+	mVisible.clear();
+	mBoxes.clear();
+
+	const bool fromPoint = false;
+	const bool nodeVisibility = false;
+
+	const int itemBufferMode = 0;
+	const bool relativeVisibility = false;
+
+	int queryModes = 0;
+
+	if (nodeVisibility)
+		queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY;
+	else
+		queryModes |= GtpVisibility::QueryManager::GEOMETRY_VISIBILITY;
+
+	OcclusionQueriesQueryManager *queryManager = 
+		new OcclusionQueriesQueryManager(mHierarchyInterface,
+										 mCurrentViewport,
+										 queryModes, 
+										 itemBufferMode);
+
+	mVisibilityManager->SetQueryManager(queryManager);
+
+	GtpVisibility::NodeInfoContainer visibleNodes;
+	GtpVisibility::MeshInfoContainer visibleGeometry;
+	GtpVisibility::PatchInfoContainer visiblePatches;
+
+	if (fromPoint)
+	{
+		queryManager->ComputeFromPointVisibility(cam->getDerivedPosition(), 
+												 &visibleNodes, 
+												 &visibleGeometry, 
+												 &visiblePatches, 
+												 relativeVisibility);
+	}
+	else
+	{
+		queryManager->ComputeCameraVisibility(*cam,
+											  &visibleNodes, 
+											  &visibleGeometry, 
+											  &visiblePatches, 
+											  relativeVisibility);
+	}
+		
+	if (0)
+	{
+		std::stringstream d; 
+		d << "Query mode: " << queryModes 
+		  << " visible nodes: " << (int)visibleNodes.size() 
+		  << " visible geometry: " << (int)visibleGeometry.size();
+
+		LogManager::getSingleton().logMessage(d.str());
+	}
+
+	///////////////////////
+	//-- put items in render queue
+	//////////
+
+	//getRenderQueue()->clear();
+
+	//////////////////////
+	//-- apply queries on geometry level
+
+	if (!nodeVisibility)
+	{
+		AddVisibleMeshGeometryToQueue(visibleGeometry, cam);
+	}
+	else
+	{
+		AddVisibleNodeGeometryToQueue(visibleNodes, cam);
+	}
+		
+	delete queryManager;
+}
+
+//-----------------------------------------------------------------------
 void OcclusionCullingSceneManagerFactory::destroyInstance(SceneManager* instance)
 {
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2171)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2183)
@@ -168,8 +168,25 @@
 	{
 		//-- queries for hierarchy nodes
-		for (nodeIt = nodeList.begin(); nodeIt != nodeIt_end; ++nodeIt)		
+		for (nodeIt = nodeList.begin(); nodeIt != nodeIt_end; ++ nodeIt)		
 		{
 			// TODO: DELETE QUERIES FROM PREVIOUS RENDER
-			queryList[i].push_back(mHierarchyInterface->IssueNodeOcclusionQuery(*nodeIt, false));
+			bool intersects = false;
+
+			pfHierarchyInterface->CheckFrustumVisible(*nodeIt, intersects);
+
+			// always push back if intersects
+			if (1 && intersects)
+			{
+				// no more information available
+				const int visPixels = 1;
+				const int projPixels = 1;
+
+				visibleNodes->push_back(GtpVisibility::NodeInfo(*nodeIt, visPixels, projPixels));
+				queryList[i].push_back(NULL);
+			}
+			else
+			{
+				queryList[i].push_back(mHierarchyInterface->IssueNodeOcclusionQuery(*nodeIt, false));
+			}
 		}
 
@@ -300,4 +317,12 @@
 	for (nodeIt = nodeList->begin(); nodeIt != nodeList->end(); ++ nodeIt)
 	{
+		if (!(*visQueryIt))
+		{
+			++ visQueryIt;
+			if (relativeVisibility)
+				++ projQueryIt;
+			continue;
+		}
+
 		unsigned int visiblePixels = 0;
 		(*visQueryIt)->GetQueryResult(visiblePixels, true);
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2130)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2183)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include;..\..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -73,5 +73,5 @@
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include;..\..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2172)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2183)
@@ -22,4 +22,5 @@
 #include "InternalRayCaster.h"
 #include "GlobalLinesRenderer.h"
+#include "ObjectsParser.h"
 
 
@@ -27,4 +28,5 @@
 #define SHOW_RAYCAST_TIMING 1
 
+using namespace std;
 
 namespace GtpVisibilityPreprocessor {
@@ -265,5 +267,5 @@
 
 
-bool Preprocessor::LoadBinaryObj(const string filename,
+bool Preprocessor::LoadBinaryObj(const string &filename,
 								 SceneGraphNode *root,
 								 vector<FaceParentInfo> *parents)
@@ -277,12 +279,4 @@
 	cout << "binary obj dump available, loading " << filename.c_str() << endl;
 	
-	// table for vertices
-	VertexContainer vertices; 
-	
-	if (parents)
-		cout << "using face parents" << endl;
-	else
-		cout << "not using face parents" << endl;
-
 	// read in triangle size
 	int numTriangles;
@@ -309,7 +303,5 @@
 		root->mGeometry.push_back(obj);
 		
-		i ++;
-	
-		if (i % 500000 == 499999)
+		if ((i ++) % 500000 == 499999)
 			 cout<<"\r"<<i<<"/"<<numTriangles<<"\r";
 	}
@@ -488,4 +480,5 @@
 	const int files = SplitFilenames(filename, filenames);
 	cout << "number of input files: " << files << endl;
+
 	bool result = false;
 	bool isObj = false;
@@ -547,17 +540,16 @@
 						
 				cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl;
+
 				// only works for triangles
 				if (result && !mLoadMeshes)
 				{
 					cout << "exporting binary obj to " << bnFile << "... " << endl;
+
 					ExportBinaryObj(bnFile, mSceneGraph->GetRoot());
+				
 					cout << "finished" << endl;
 				}
 
 				delete parser;
-			}
-			else if (0)
-			{
-				ExportBinaryObj("../data/test.bn", mSceneGraph->GetRoot());
 			}
 		}
@@ -740,8 +732,28 @@
 	if (mLoadViewCells)
 	{	
+		
+#ifdef USE_BIT_PVS
+		// HACK: for kd pvs, set pvs size to maximal number of kd nodes
+		vector<KdLeaf *> leaves;
+		preprocessor->mKdTree->CollectLeaves(leaves);
+
+		ObjectPvs::SetPvsSize((int)leaves.size());
+#endif
+
 		Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf);
-		cout << "loading view cells from " << buf << endl<<flush;
-
-		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL);
+		cout << "loading objects from " << buf << endl;
+
+		// load objects which will be used as pvs entries
+		ObjectContainer pvsObjects;
+		if (0) LoadObjects(buf, pvsObjects, mObjects);
+
+		const bool finalizeViewCells = true;
+		cout << "loading view cells from " << buf << endl;
+
+		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, 
+															pvsObjects,
+															mObjects, 
+															finalizeViewCells, 
+															NULL);
 
 		cout << "view cells loaded." << endl<<flush;
@@ -1262,5 +1274,5 @@
 	const long t1 = GetTime();
 	
-	if (0 && (int)rays.size() > 10000) {
+	if ((int)rays.size() > 10000) {
 	
 		mRayCaster->SortRays(rays);
@@ -1356,5 +1368,4 @@
 	
 		if ((int)rays.size() > 100000 && i % 100000 == 0)
-			//cout << "here2 " << vssRays.size()<<endl;
 			cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r";
 	}
@@ -1632,3 +1643,29 @@
 
 
-}
+bool Preprocessor::LoadObjects(const string &filename,
+							   ObjectContainer &pvsObjects, 
+							   const ObjectContainer &preprocessorObjects)
+{
+	ObjectsParser parser;
+
+	const bool success = parser.ParseObjects(filename, 
+											 pvsObjects, 
+											 preprocessorObjects);
+
+	if (!success)
+	{
+		Debug << "Error: loading objects failed!" << endl;
+	}
+
+	// hack: no bvh object could be found => take preprocessor objects
+	if (pvsObjects.empty())
+	{
+		Debug << "no objects" << endl;
+		pvsObjects = preprocessorObjects;
+	}
+
+	return success;
+}
+
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2176)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2183)
@@ -263,9 +263,9 @@
 protected:
 
-	bool LoadBinaryObj(const string &filename,
+	bool LoadBinaryObj(const std::string &filename,
 					   SceneGraphNode *root,
-					   vector<FaceParentInfo> *parents);
-
-	bool ExportBinaryObj(const string filename, SceneGraphNode *root);
+					   std::vector<FaceParentInfo> *parents);
+
+	bool ExportBinaryObj(const std::string filename, SceneGraphNode *root);
 
 	void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 2116)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp	(revision 2183)
@@ -283,5 +283,5 @@
 		if (GetArea() < AREA_LIMIT)
 		{
-			Debug << "area too small: " << GetArea() << endl;
+			Debug << "area too small: " << GetArea() << std::endl;
 			return false;
 		}
