Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 944)
@@ -32,9 +32,9 @@
 	argv[1] = fname;
 
-	GtpVisibilityPreprocessor::Debug << "here4 loading environment from: " << argv[1] << endl;
+	GtpVisibilityPreprocessor::Debug << "loading environment from: " << argv[1] << endl;
+	return GtpVisibilityPreprocessor::environment->Parse(argc, argv, false);
 */
-		//-- parse environment
+	//-- parse environment
 	return mEnvironment->ReadEnvFile(filename.c_str());
-	//return GtpVisibilityPreprocessor::environment->Parse(argc, argv, false);
 }
 //-----------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 944)
@@ -168,5 +168,5 @@
     }
 	// add bounding boxes of rendered objects
-	if (1)
+	if (0)
 	for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)
 	{
@@ -561,5 +561,4 @@
 		if (mViewCellsLoaded)
 		{
-			LogManager::getSingleton().logMessage("here3");
 			mUseViewCells = *static_cast<const bool *>(val);
 
@@ -1014,5 +1013,5 @@
 		OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it);
 		Entity *ent = omi->GetMesh();
-		LogManager::getSingleton().logMessage("here999");
+		
 		ent->setVisible(visible);
 	}
@@ -1036,5 +1035,5 @@
 	// load the view cells assigning the found objects to the pvss
 	mViewCellsManager = 
-		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, env, &bconverter);
+		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, env, false, &bconverter);
 
 	if (!mViewCellsManager)
@@ -1055,8 +1054,8 @@
 		// set everything visible for savety
 		SetObjectsVisible(true);
-LogManager::getSingleton().logMessage("here7");
+
 		return;
 	}
-		  LogManager::getSingleton().logMessage("here8");
+		
 	GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit,
 			oit_end = vc->GetPvs().mEntries.end();
@@ -1069,5 +1068,5 @@
 		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first);
 		omi->GetMesh()->setVisible(load);
-		GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl;
+		//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
 	}
 }
@@ -1089,5 +1088,5 @@
 
 	mElementaryViewCell = newElementary;
-	LogManager::getSingleton().logMessage("unloading");
+	//LogManager::getSingleton().logMessage("unloading");
 	//-- unload old pvs
 	applyViewCellPvs(mCurrentViewCell, false);
@@ -1110,7 +1109,7 @@
 		viewCell = newElementary;
 	}
-	LogManager::getSingleton().logMessage("loading");
+	//LogManager::getSingleton().logMessage("loading");
 	//-- load new pvs
-	if (0)applyViewCellPvs(viewCell, true);
+	applyViewCellPvs(viewCell, true);
 
 	// store pvs
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformOcclusionQuery.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformOcclusionQuery.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformOcclusionQuery.cpp	(revision 944)
@@ -12,4 +12,5 @@
 PlatformOcclusionQuery::~PlatformOcclusionQuery()
 {
+	// hardwareocclusion query is deleted by Ogre
 	//delete mHardwareOcclusionQuery;
 }
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp	(revision 944)
@@ -54,4 +54,5 @@
 {
 	Octree *octree = static_cast<Octree *>(node);
+
 	// HACK: if there are subtrees, they are empty => we are not interested in them
 	return octree->numNodes() == (int)octree->mNodes.size();
@@ -70,6 +71,9 @@
 	const Vector3 pos = (bmax - bmin) * 0.5 + bmin;
 	
+/*	std::stringstream d; 
+	d << "a: " << (mCameraPosition - pos).squaredLength() 
+	  << " b: " << (mCullCamera->getDerivedPosition() - pos).squaredLength();
+	LogManager::getSingleton().logMessage(d.str());*/
 	return (mCameraPosition - pos).squaredLength();
-	//return (mCullCamera->getDerivedPosition() - pos).squaredLength();
 }
 //-----------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBoundingBoxConverter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBoundingBoxConverter.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBoundingBoxConverter.cpp	(revision 944)
@@ -19,12 +19,12 @@
 	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::
 		const_iterator iit, iit_end = iboxes.end();
-std::stringstream d; d << "here75557\n";
-   LogManager::getSingleton().logMessage(d.str());
+
+  
 	for (iit = iboxes.begin(); iit != iit_end; ++ iit)
 	{
 		const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second;
 		const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box);
-std::stringstream d; d << "here77\n";
-   LogManager::getSingleton().logMessage(d.str());
+
+   
 		Entity *ent = FindCorrespondingObject(currentBox);
 
@@ -53,6 +53,5 @@
 	AxisAlignedBox mybox = EnlargeBox(box);
 	//AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000));
-	std::stringstream d; d << "here3 idenbtiy 8888\n";
-	LogManager::getSingleton().logMessage(d.str());
+	
 	//-- get intersecting scene nodes
 	mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 942)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env	(revision 944)
@@ -259,5 +259,5 @@
 #	filename ../data/vienna/viewcells-large-sel.x3d
 #	filename ../scripts/viewcells_vienna.xml
-	filename D:/svn/gametools/GTP/trunk/Lib/Vis/Preprocessing/scripts/vienna_visibility.xml
+	filename D:/svn/gametools/GTP/trunk/Lib/Vis/Preprocessing/scripts/vienna-visibility.xml
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells	(revision 942)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells	(revision 944)
@@ -42,5 +42,5 @@
 -view_cells_evaluation_samples_per_pass=1000000 \
 -vsp_bsp_node_queue_type=2 \
--view_cells_filename=$LOG_PREFIX/vienna-visibility.xml
+-view_cells_filename=$LOG_PREFIX-visibility.xml
 
 mv debug.log $LOG_PREFIX-$METHOD-debug.log
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 938)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 944)
@@ -432,4 +432,5 @@
 										   ObjectContainer *objects, 
 										   Environment *env,
+										   const bool finalizeViewCells,
 										   BoundingBoxConverter *bconverter = NULL);
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 944)
@@ -356,5 +356,5 @@
 	{
 		environment->GetStringValue("ViewCells.filename", buf);
-		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, environment);
+		mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, environment, true);
 	}
 	else
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 944)
@@ -126,5 +126,5 @@
 	// go one up in the tree
 	if (mCurrentBspNode->GetParent())
-	{	Debug << "]";
+	{	cout << "]";
 		mCurrentBspNode = mCurrentBspNode->GetParent();
 	}
@@ -136,5 +136,5 @@
 	// go one up in the tree
 	if (mCurrentViewCell->GetParent())
-	{	Debug << "]";
+	{	cout << "]";
 		mCurrentViewCell = mCurrentViewCell->GetParent();
 	}
@@ -159,6 +159,11 @@
 	// all bounding boxes gathered in this step => 
 	// associate object ids with bounding boxes
+	long startTime = GetTime();
+	
 	if (mBoundingBoxConverter)
 		mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects);
+
+	Debug << "\nconverted bounding boxes to objects in"
+		  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 }
 
@@ -190,5 +195,5 @@
 	if (element == "Interior") 
 	{
-		Debug << "[";
+		cout << "[";
 		StartBspInterior(attributes);
 	}
@@ -196,6 +201,5 @@
 	if (element == "Leaf") 
 	{
-		Debug << "l";
-		Debug << "leaf" << endl;
+		cout << "l";
 		StartBspLeaf(attributes);
 	}
@@ -212,5 +216,5 @@
 	if (element == "ViewCells")
 	{
-		Debug << "parsing view cells" << endl;
+		cout << "parsing view cells" << endl;
 		mParseViewCells = true;
 	}
@@ -218,5 +222,5 @@
 	if (element == "Hierarchy")
 	{
-		Debug << "parsing spatial hierarchy" << endl;
+		cout << "parsing spatial hierarchy" << endl;
 		mParseViewCells = false;
 		StartHierarchy(attributes);
@@ -226,5 +230,5 @@
 	if (element == "ViewSpaceBox")
 	{
-		Debug << "v";
+		cout << "v";
 		StartViewSpaceBox(attributes);
 	}
@@ -233,5 +237,5 @@
 	if (element == "BoundingBox")
 	{
-		Debug << "b";
+		cout << "b";
 		StartBoundingBox(attributes);
 	}
@@ -259,5 +263,5 @@
 		if (element == "Interior") 
 		{
-			Debug << "[";
+			cout << "[";
 			StartViewCellInterior(attributes);
 		}
@@ -265,5 +269,5 @@
 		if (element == "Leaf") 
 		{
-			Debug << "l";
+			cout << "l";
 			StartViewCellLeaf(attributes);
 		}
@@ -399,5 +403,5 @@
 	mViewSpaceBox = AxisAlignedBox3(bmin, bmax);
 
-	Debug << "view space box: " << mViewSpaceBox << endl;
+	Debug << "\nview space box: " << mViewSpaceBox << endl;
 }
 
@@ -437,5 +441,5 @@
 	mIBoundingBoxes.push_back(IndexedBoundingBox(id, box));
 
-	Debug << "view space box: " << mViewSpaceBox << endl;
+	//Debug << "bbox: " << box << endl;
 }
 
@@ -624,9 +628,9 @@
 
 		mVspBspTree->mBox = mViewSpaceBox;
-		Debug << "creating vsp bsp view cells manager" << endl;
 	}
 	else if (strcmp(name, "vspKdTree") == 0)
 	{
 		// TODO
+		Debug << "view cell type: VspKd" << endl;
 		mVspKdTree = new VspKdTree();	
 		mViewCellsManager = new VspKdViewCellsManager(mVspKdTree, mEnvironment);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 938)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 944)
@@ -1861,5 +1861,7 @@
 
 
-bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects)
+bool ViewCellsManager::ExportViewCells(const string filename, 
+									   const bool exportPvs, 
+									   const ObjectContainer &objects)
 {
 	return false;
@@ -1880,4 +1882,5 @@
 	// active view cells
 	ViewCellContainer::const_iterator it, it_end = mViewCells.end();
+
 	for (it = mViewCells.begin(); it != it_end; ++ it)
 	{
@@ -4727,5 +4730,7 @@
 												  ObjectContainer *objects,
 												  Environment *env,
+												  const bool finalizeViewCells,
 												  BoundingBoxConverter *bconverter)
+												 
 {
 	ViewCellsParser parser;
@@ -4733,9 +4738,8 @@
 	ViewCellsManager *vm = NULL;
 
-	Debug << "here23 filename: " << filename << endl;
-	//BoundingBoxConverter bconverter;
-
 	if (parser.ParseFile(filename, &vm, objects, bconverter, env))
-	{Debug << "here25 filename: " << filename << endl;
+	{
+		long startTime = GetTime();
+
 		//vm->PrepareLoadedViewCells();
 		vm->ResetViewCells();
@@ -4745,8 +4749,12 @@
 
 		// create the meshes and compute volumes
-		vm->FinalizeViewCells(true);
-
-		vm->mViewCellsTree->AssignRandomColors();
-		Debug << (int)vm->mViewCells.size() << " view cells loaded" << endl;
+		if (finalizeViewCells)
+		{
+			vm->FinalizeViewCells(true);
+			vm->mViewCellsTree->AssignRandomColors();
+		}
+
+		Debug << (int)vm->mViewCells.size() << " view cells loaded in "
+			  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 	}
 	else
@@ -4785,5 +4793,7 @@
 
 	//-- export the view cells and the pvs
-	stream << "<ViewCells>" << endl;
+	const int numViewCells = mCurrentViewCellsStats.viewCells;
+
+	stream << "<ViewCells number=\"" << numViewCells << "\" />" << endl;
 	
 	mViewCellsTree->Export(stream, exportPvs);
Index: GTP/trunk/Lib/Vis/README_ONLINE_MODULE.txt
===================================================================
--- GTP/trunk/Lib/Vis/README_ONLINE_MODULE.txt	(revision 902)
+++ GTP/trunk/Lib/Vis/README_ONLINE_MODULE.txt	(revision 944)
@@ -4,50 +4,58 @@
 ONLINE VISIBILITY (CHC + VIEW CELLS)
 
-1) Requirements: 
-   WindowsXP
-   svn
+1) 
+
+Requirements: 
+
+WindowsXP
+svn
 
 2) check out gametools repository
-   in the following it is assumed that your repository is located in d:\svn\gametools (not required, just replace your path)
+   
+in the following it is assumed that your repository is located in d:\svn\gametools (not required, just replace your path)
 
-3) add following environment variables:
+3) 
 
-   OGRE_PATH: points to directory where ogre.sln is located (i.e., the
+add following environment variables:
+
+OGRE_PATH: points to directory where ogre.sln is located (i.e., the
 directory OGRE), e.g. D:\svn\gametools\OGRE\trunk\ogrenew
 
-4) copy the ogre_dependencies and ogre_changes_12 into the ogrenew directory
+4) 
+
+copy the directories 
+
+D:\svn\gametools\OGRE\trunk\ogre_dependencies 
+D:\svn\gametools\OGRE\trunk\ogre_changes\Ogre1.2 
+
+into the ogrenew directory. 
+
+Further copy the files
+
+D:\svn\gametools\OGRE\trunk\resources\terrain.cfg
+D:\svn\gametools\OGRE\trunk\resources\terrainCulling.cfg into the 
+
+D:\svn\gametools\OGRE\trunk\ogrenew\Samples\Common\bin\Release
+
+directory. 
+
+The absolute filenames in terrainCulling.cfg must be
+changed accordingly
+
+5) add following directories to 
+
+D:\svn\gametools\OGRE\trunk\ogrenew\Samples\Common\bin\Release\resources.cfg
+
+FileSystem=d:/svn/gametools/OGRE/trunk/resources/materials/textures
+FileSystem=d:/svn/gametools/OGRE/trunk/resources/materials/scripts
+FileSystem=d:/svn/gametools/OGRE/trunk/resources/overlays
+FileSystem=d:/svn/gametools/OGRE/trunk/resources/models
+FileSystem=d:/svn/gametools/OGRE/trunk/resources/models/trees
+
 
 5) Set preprocessor flag GTP_VISIBILITY_MODIFIED_OGRE to the example projects you want to use
 
-5) open scripts GTP\trunk\Lib\Vis\shared\GtpVisibility.sln and build all
+6) open scripts GTP\trunk\Lib\Vis\shared\GtpVisibility.sln and build all
 
 
-6) start TerrainExampleApplication for testing
-
-
-
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-FOR USING THE PREPROCESSED VIEW CELLS:
-
-the same as above, before step 6) change in the code: 
-
-in 
-
-D:\svn\gametools\GTP\trunk\App\Demos\Vis\HillyTerrain\OGRE\TestCullingTerrainApplication.cpp
-
-replace 
-
-bool TestCullingTerrainApplication::msShowHillyTerrain = true;
-
-with 
-
-bool TestCullingTerrainApplication::msShowHillyTerrain = false;
-
-
-Then the vienna model is loaded together with the view cells. The
-usage of the view cells is toggled using key "V".
+7) start TerrainExampleApplication for testing
