Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 1271)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 1593)
@@ -520,8 +520,7 @@
 	// Warning: In GL since we can't go higher than the window res
 	mSceneMgr->setShadowTextureSettings(1024, 2);
-
 	mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5));
 
-
+	//////////////77
 	//-- terrain content setup
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h	(revision 1028)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h	(revision 1593)
@@ -13,16 +13,18 @@
 {
 public:
-
+	/** The default constructor taking an entity into account.
+	*/
 	OgreMeshInstance(Entity *ent);
-
+	
 	/** Returns 'mesh' associated with this instance. 
 	*/
-	Entity *GetMesh() const;
+	Entity *GetEntity() const;
 
 	/** See get.
 	*/
-	void SetMesh(Entity *mesh);
+	void SetEntity(Entity *entity);
 
 
+	/////////////////////////////
 	//-- inherited functions from Intersectable
 
@@ -51,5 +53,5 @@
 protected:
 	
-	Entity *mMesh;
+	Entity *mEntity;
 };
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 1276)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 1593)
@@ -16,4 +16,5 @@
 namespace Ogre {
 
+
 /**
 	This class extends the terrain scene manager,
@@ -126,9 +127,9 @@
 	/** Loads / unloads pvs of the view cell to set the visibility in the scene.
 	*/
-	void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
+	void ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
 
 	/** updates pvs in current frame.
 	*/
-	void updatePvs(Camera *cam);
+	void UpdatePvs(Camera *cam);
 
 	/** Sets all objects invisible.
@@ -136,9 +137,14 @@
 	void SetObjectsVisible(const bool visible);
 
-	
+	/** Creates view cells geometry from the loaded view cells.
+	*/
+	void CreateViewCellsGeometry();
+
+
 	//////////////////////////////////////////
 
 	/// the interface to the scene hierarchy.
 	OctreeHierarchyInterface *mHierarchyInterface;
+
 	/// manages all visibility options
 	GtpVisibility::VisibilityManager *mVisibilityManager;
@@ -175,10 +181,9 @@
 	/// the depth pass (no lighting, just filling the depth buffer)
 	Pass *mDepthPass;
+	/// the pass for item buffer setting a color id
 	Pass *mItemBufferPass;
 
-	int mCurrentEntityId;
 	/// flag for passes which should not be deleted from queue during first traversal
 	int mLeavePassesInQueue;
-
 
 	/// if transparent object are considered for item buffer visibility
@@ -190,5 +195,8 @@
 	bool mIsHierarchicalCulling;
 
+	/// do we use preprocessed visibility
 	bool mViewCellsLoaded;
+
+	/// the view cells manager handling the preprocesor stuff
 	GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
 
@@ -210,7 +218,17 @@
 	// normal terrain rendering
 	bool mNormalExecution;
+
+	// helper variable to provide sequential numbering for sub-entities
+	int mCurrentEntityId;
+
+	typedef map<int, MovableObject *> MovableObjectsMap;
+
+	/// hash table for view cells geometry
+    MovableObjectsMap mViewCellsGeometry;
 };
 
-/// Factory for VisibilityOctreeSceneManager
+
+/** Factory for VisibilityOctreeSceneManager.
+*/
 class OcclusionCullingSceneManagerFactory : public SceneManagerFactory
 {
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreTypeConverter.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreTypeConverter.h	(revision 863)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreTypeConverter.h	(revision 1593)
@@ -5,8 +5,11 @@
 #include "AxisAlignedBox3.h"
 #include "Vector3.h"
+//#include "ManualObject.h"
 
 
 namespace Ogre {
- 
+
+class SceneManager;
+
 /**
 	Class which converts preprocessor types to OGRE types
@@ -27,4 +30,8 @@
 	*/
 	static Vector3 ConvertToOgre(const GtpVisibilityPreprocessor::Vector3 &v);
+
+	/** The Ogre object will be created from the mesh.
+	*/
+	static ManualObject *ConvertToOgre(GtpVisibilityPreprocessor::Mesh *mesh, SceneManager *sceneMgr);
 };
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1495)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1593)
@@ -1307,5 +1307,5 @@
 	{
 		OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it);
-		Entity *ent = omi->GetMesh();
+		Entity *ent = omi->GetEntity();
 
 		ent->setVisible(visible);
@@ -1351,5 +1351,5 @@
 
 		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first);
-		omi->GetMesh()->setVisible(load);
+		omi->GetEntity()->setVisible(load);
 		//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
 	}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreTypeConverter.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreTypeConverter.cpp	(revision 863)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreTypeConverter.cpp	(revision 1593)
@@ -1,3 +1,6 @@
 #include "OgreTypeConverter.h"
+#include "Mesh.h"
+#include <OgreManualObject.h>
+#include <OgreSceneManager.h>
 
 
@@ -13,9 +16,11 @@
 }
 
+
 GtpVisibilityPreprocessor::Vector3 OgreTypeConverter::ConvertFromOgre(const Vector3 &v)
 {
     return GtpVisibilityPreprocessor::Vector3(v.x, v.y, v.z);
 }
-	
+
+
 AxisAlignedBox OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::AxisAlignedBox3 &box)
 {
@@ -26,7 +31,53 @@
 }
 
+
 Vector3 OgreTypeConverter::ConvertToOgre(const GtpVisibilityPreprocessor::Vector3 &v)
 {
 	return Vector3(v.getX(), v.getY(), v.getZ());
 }
+
+
+ManualObject *OgreTypeConverter::ConvertToOgre(GtpVisibilityPreprocessor::Mesh *mesh, SceneManager *sceneMgr)
+{
+	char name[100];
+	sprintf(name, "mesh%04d", mesh->GetId());
+
+	ManualObject* manual = sceneMgr->createManualObject(name);
+	manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP);
+	
+	// create vertices
+	GtpVisibilityPreprocessor::VertexContainer::const_iterator vit, 
+		vit_end = mesh->mVertices.end();
+
+	for (vit = mesh->mVertices.begin(); vit != vit_end; ++ vit)
+	{
+		const GtpVisibilityPreprocessor::Vector3 vtx = *vit;
+		manual->position(vtx.x, vtx.y, vtx.z);
+	}
+
+	// create faces indices
+	GtpVisibilityPreprocessor::FaceContainer::const_iterator fit, fit_end = mesh->mFaces.end();
+
+	for (fit = mesh->mFaces.begin(); fit != fit_end; ++ fit)
+	{
+		GtpVisibilityPreprocessor::Face *face = *fit;
+		GtpVisibilityPreprocessor::VertexIndexContainer::const_iterator 
+			iit, iit_end = face->mVertexIndices.end();
+		//GtpVisibilityPreprocessor::VertexIndexContainer::const_reverse_iterator 
+		//	iit, iit_end = face->mVertexIndices.rend();
+
+		for (iit = face->mVertexIndices.begin(); iit != iit_end; ++ iit)
+		{
+			const int index = *iit;
+			manual->index(index);
+		}
+	}
+
+	manual->end();
+	//mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
+
+	return manual;
 }
+
+
+}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp	(revision 1344)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp	(revision 1593)
@@ -1696,6 +1696,8 @@
 
 	if (showBoxes)
+	{
 		if (mLevel == mOwner->getHiLiteLevel() || mOwner->getShowAllBoxes())
 			queue->addRenderable(getWireBoundingBox());
+	}
 }
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp	(revision 1320)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp	(revision 1593)
@@ -1307,5 +1307,5 @@
 	{
 		OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it);
-		Entity *ent = omi->GetMesh();
+		Entity *ent = omi->GetEntity();
 
 		ent->setVisible(visible);
@@ -1354,5 +1354,5 @@
 
 		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first);
-		omi->GetMesh()->setVisible(load);
+		omi->GetEntity()->setVisible(load);
 		//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
 	}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp	(revision 1028)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp	(revision 1593)
@@ -6,21 +6,21 @@
 
 	OgreMeshInstance::OgreMeshInstance(Entity *ent):
-	GtpVisibilityPreprocessor::Intersectable(), mMesh(ent)
+	GtpVisibilityPreprocessor::Intersectable(), mEntity(ent)
 	{
 	}
 
-	void OgreMeshInstance::SetMesh(Entity *mesh)
+	void OgreMeshInstance::SetEntity(Entity *entity)
 	{
-		mMesh = mesh;
+		mEntity = entity;
 	}
 
-	Entity *OgreMeshInstance::GetMesh() const
+	Entity *OgreMeshInstance::GetEntity() const
 	{ 
-		return mMesh; 
+		return mEntity; 
 	}
 	
 	GtpVisibilityPreprocessor::AxisAlignedBox3 OgreMeshInstance::GetBox() const
 	{
-		return OgreTypeConverter::ConvertFromOgre(mMesh->getWorldBoundingBox());
+		return OgreTypeConverter::ConvertFromOgre(mEntity->getWorldBoundingBox());
 	}
 
@@ -71,5 +71,5 @@
 	ostream &OgreMeshInstance::Describe(ostream &s)
 	{
-		s << mMesh;
+		s << mEntity;
 		return s;
 	}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1304)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1593)
@@ -20,4 +20,5 @@
 #include "common.h"
 #include "OgreBoundingBoxConverter.h"
+#include <OgreManualObject.h>
 
 
@@ -173,5 +174,13 @@
 		getRenderQueue()->addRenderable(*it);
 	}
-	
+
+	MovableObjectsMap::const_iterator mit, mit_end = mViewCellsGeometry.end();
+/*
+	for (mit = mViewCellsGeometry.begin(); mit != mit_end; ++ mit)
+	{
+		(*mit).second->_updateRenderQueue(getRenderQueue());
+	}
+*/	
+
 	if (mRenderNodesForViz || mRenderNodesContentForViz)
 	{
@@ -198,4 +207,5 @@
 				//(*it)->_addBoundingBoxToQueue(getRenderQueue());
 			}
+
 			// add renderables itself
 			if (mRenderNodesContentForViz) 
@@ -292,8 +302,9 @@
 	}
 
-
-	//-- show visible scene nodes and octree bounding boxes from last frame
 	if (mShowVisualization)
     {
+		//////////////
+		//-- show visible scene nodes and octree bounding boxes from last frame
+
 		PrepareVisualization(cam);
 	}
@@ -314,10 +325,9 @@
 		if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
 
-
+		///////////
 		//-- apply view cell pvs
-		updatePvs(cam);
-	}
-	
-	
+		UpdatePvs(cam);
+	}
+		
 	// lists only used for visualization
 	mVisible.clear();
@@ -329,4 +339,5 @@
 	if (mNormalExecution)
 	{
+		// the standard octree rendering mode
 		OctreeSceneManager::_renderVisibleObjects();
 		return;
@@ -339,5 +350,7 @@
 	ColourValue savedAmbient = mAmbientLight;
 
-	//-- apply standard rendering for some modes (e.g., visualization, shadow pass)
+	////////////////////
+	//-- apply standard rendering for some modes 
+	//-- (e.g., the visualization mode, the shadow pass)
 
 	if (mShowVisualization ||
@@ -363,16 +376,18 @@
 		mDestRenderSystem -> setLightingEnabled(false);
 
-		// don't render backgrounds for item buffer
 		if (mUseItemBuffer)
 		{
+			// don't render backgrounds for item buffer
 			clearSpecialCaseRenderQueues();
 			getRenderQueue()->clear();
 		}
 
+		////////////////////
 		//-- hierarchical culling
+
 		// the objects of different layers (e.g., background, scene, 
 		// overlay) must be identified and rendered one after another
 
-		//-- render all early skies
+		// first render all early skies
 		clearSpecialCaseRenderQueues();
 		addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
@@ -387,5 +402,7 @@
 #endif
 
+		///////////////////
 		//-- prepare queue for visible objects (i.e., all but overlay and skies late)
+
 		clearSpecialCaseRenderQueues();
 		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE);
@@ -394,5 +411,4 @@
 		// exclude this queues from hierarchical rendering
 		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-
 
 		// set all necessary parameters for 
@@ -416,4 +432,5 @@
 #endif
 
+		/////////////
 		//-- reset parameters needed for special rendering
 		
@@ -425,7 +442,7 @@
 		mLeavePassesInQueue = 0;
 		
-		// add visible nodes found by the visibility culling algorithm
-		if (mUseDepthPass)
-		{
+		if (mUseDepthPass) // the shaded geometry is rendered in a second pass
+		{
+			// add visible nodes found by the visibility culling algorithm
 			NodeList::const_iterator it, it_end = mVisible.end();
 
@@ -436,4 +453,6 @@
 			}
 		}
+
+		/////////////
 		//-- now we can render all remaining queue objects
 		//-- used for depth pass, transparents, overlay
@@ -453,8 +472,11 @@
 	getRenderQueue()->clear(mDeleteQueueAfterRendering);
 
-	//if (!mDeleteQueueAfterRendering)
-	//	getRenderQueue()->clear(true); // finally clear render queue
-	//else
-	//	OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...
+	if (0)
+	{
+		if (!mDeleteQueueAfterRendering)
+			getRenderQueue()->clear(true); // finally clear render queue
+		else
+			OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...
+	}
 
 	if (0) WriteLog(); // write out stats
@@ -573,5 +595,7 @@
 
 			if (mUseViewCells)
+			{
 				mCurrentViewCell = mViewCellsManager->GenerateViewCell();
+			}
 
 			mElementaryViewCell = NULL;
@@ -683,10 +707,10 @@
         renderObjects(pPriorityGrp->getSolidsBasic(), om, true);
 
-		// for correct rendering, transparents must be rendered after hierarchical culling
-		// => do nothing
-
-        // Do transparents (always descending)
-		if (mNormalExecution || !mSkipTransparents)
-		{
+		// for correct rendering, transparents must be rendered 
+		// after hierarchical culling => don't render them now
+
+        if (mNormalExecution || !mSkipTransparents)
+		{
+			// Do transparents (always descending)
 			renderObjects(pPriorityGrp->getTransparents(), 
 			QueuedRenderableCollection::OM_SORT_DESCENDING, true);
@@ -694,5 +718,5 @@
 
 
-    }// for each priority
+    } // for each priority
 }
 
@@ -770,8 +794,8 @@
 			if (0)
 			{
-			std::stringstream d; d << "itembuffer, pass name: " << 
-				ipass->first->getParent()->getParent()->getName();
-				
-			LogManager::getSingleton().logMessage(d.str());
+				std::stringstream d; d << "itembuffer, pass name: " << 
+					ipass->first->getParent()->getParent()->getName();
+
+				LogManager::getSingleton().logMessage(d.str());
 			}
 			
@@ -1023,5 +1047,5 @@
 	{
 		OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it);
-		Entity *ent = omi->GetMesh();
+		Entity *ent = omi->GetEntity();
 		
 		ent->setVisible(visible);
@@ -1034,6 +1058,4 @@
 	SetObjectsVisible(false);
 	
-	const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName();
-
 	// converter between view cell ids and Ogre entites 
 	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes;
@@ -1041,18 +1063,24 @@
 
 	// load the view cells assigning the found objects to the pvss
+	const bool finalizeViewCells = true;
 	mViewCellsManager = 
-		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, false, &bconverter);
+		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, true, &bconverter);
+
+	if (finalizeViewCells)
+	{
+		CreateViewCellsGeometry();
+	}
 
 	return (mViewCellsManager != NULL);
 }
 //-------------------------------------------------------------------------
-void OcclusionCullingSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 
+void OcclusionCullingSceneManager::ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 
 													const bool load)
-{	// NOTE: should not happen, rather apply view cell representing unbounded space then
+{	// NOTE: should not encounter NULL view cell, 
+	// rather apply view cell representing unbounded space then
 	if (!vc) 
 	{	
-		// set everything visible for savety
+		// if no there is no view cell, set everything visible
 		SetObjectsVisible(true);
-
 		return;
 	}
@@ -1061,5 +1089,7 @@
 			oit_end = vc->GetPvs().mEntries.end();
 
-	//-- PVS of view cell
+	////////////
+	//-- set PVS of view cell to visible
+
 	for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
 	{
@@ -1067,10 +1097,10 @@
 
 		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first);
-		omi->GetMesh()->setVisible(load);
+		omi->GetEntity()->setVisible(load);
 		//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
 	}
 }
 //-------------------------------------------------------------------------
-void OcclusionCullingSceneManager::updatePvs(Camera *cam)
+void OcclusionCullingSceneManager::UpdatePvs(Camera *cam)
 {
 	if (!(mViewCellsLoaded && mUseViewCells))
@@ -1088,17 +1118,35 @@
 
 	mElementaryViewCell = newElementary;
-	//LogManager::getSingleton().logMessage("unloading");
+	LogManager::getSingleton().logMessage("unloading");
+	
+		std::stringstream d;
+		d << "here2 " << mViewCellsGeometry.size();
+		LogManager::getSingleton().logMessage(d.str());
+
+	//////////////
 	//-- unload old pvs
-	applyViewCellPvs(mCurrentViewCell, false);
-
-
-	//-- the new view cell
-		
+
+	ApplyViewCellPvs(mCurrentViewCell, false);
+
+	// set old view cell geometry to invisible
+    if (mCurrentViewCell && mCurrentViewCell->GetMesh())
+	{
+		const int id = mCurrentViewCell->GetId();
+		
+		std::stringstream str;
+		str << "id : " << id << " of " << mViewCellsGeometry.size();
+		LogManager::getSingleton().logMessage(str.str());
+
+		mViewCellsGeometry[id]->setVisible(false);
+	}
+
+	// the new view cell
 	GtpVisibilityPreprocessor::ViewCell *viewCell;
-
 		
 	if (mUseVisibilityFilter)
-	{
+	{	
+		////////////
 		//-- compute new filtered cell
+
 		GtpVisibilityPreprocessor::PrVs prvs;
 		mViewCellsManager->GetPrVS(viewPoint, prvs, 5);
@@ -1107,17 +1155,62 @@
 	else
 	{
-		viewCell = newElementary;
-	}
-	//LogManager::getSingleton().logMessage("loading");
+		viewCell = newElementary;LogManager::getSingleton().logMessage("here55");
+	}
+
+	///////////////
 	//-- load new pvs
-	applyViewCellPvs(viewCell, true);
+
+	// set new view cell geometry to invisible
+	if (viewCell && viewCell->GetMesh())
+	{
+		const int id = viewCell->GetId();
+		
+		std::stringstream str;
+		str << "id : " << id << " of " << mViewCellsGeometry.size();
+		LogManager::getSingleton().logMessage(str.str());
+
+		mViewCellsGeometry[id]->setVisible(false);
+	}
+
+	ApplyViewCellPvs(viewCell, true);
 
 	// store pvs
-	mCurrentViewCell->SetPvs(viewCell->GetPvs());
-
-	// delete merge tree of filtered view cell
-	if (mUseVisibilityFilter)
-		mViewCellsManager->DeleteLocalMergeTree(viewCell);
-}
+	if (viewCell)
+	{
+		mCurrentViewCell->SetPvs(viewCell->GetPvs());
+		mCurrentViewCell->SetMesh(viewCell->GetMesh());
+		mCurrentViewCell->SetId(viewCell->GetId());
+
+		// delete merge tree of filtered view cell
+		if (mUseVisibilityFilter)
+			mViewCellsManager->DeleteLocalMergeTree(viewCell);
+	}
+}
+//-------------------------------------------------------------------------
+void OcclusionCullingSceneManager::CreateViewCellsGeometry()
+{
+	LogManager::getSingleton().logMessage("creating view cells geometry");
+
+	GtpVisibilityPreprocessor::ViewCellContainer viewCells = mViewCellsManager->GetViewCells();
+
+	GtpVisibilityPreprocessor::ViewCellContainer::const_iterator it, it_end = viewCells.end();
+	for (it = viewCells.begin(); it != it_end; ++ it)
+	{
+		GtpVisibilityPreprocessor::ViewCell *viewCell = *it;
+
+		std::stringstream str;
+		str << "id : " << viewCell->GetId();
+
+		ManualObject *manual = OgreTypeConverter::ConvertToOgre(viewCell->GetMesh(), this);
+		mViewCellsGeometry[viewCell->GetId()] = manual;
+
+		// attach to scene node
+		getRootSceneNode()->createChildSceneNode()->attachObject(manual);
+		
+		// initialy set to invisible
+		manual->setVisible(false);
+	}
+}
+
 #if 0
 //-------------------------------------------------------------------------
@@ -1135,5 +1228,7 @@
 	// first test for scene node, then for octant (part of the hierarchy)
 	if (!octant->mVisibleChildren)
+	{
 		octant->setVisible(false);
+	}
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1585)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1593)
@@ -432,9 +432,10 @@
 	  cout << "loading view cells from " << buf << endl;
 	  
-	  // $$ does not compile -> commented out
-	  mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL);
+	 mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL);
 	  
 	  if (!mViewCellsManager)
-		return false;
+	  {
+		  return false;
+	  }
 	}
 	else
