Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 1616)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 1816)
@@ -104,5 +104,5 @@
 	*/
 #if 1
-	virtual void setWorldGeometry( DataStreamPtr& stream, const String& typeName );
+	virtual void setWorldGeometry(DataStreamPtr& stream, const String& typeName);
 #endif
 	
@@ -141,4 +141,12 @@
 	void CreateViewCellsGeometry();
 	void VisualizeViewCells(const bool visualize);
+
+	bool LoadSceneIV(const String &filename, 
+					 SceneNode *root, 
+					 const int index);
+
+	bool LoadScene(const String &filename);
+
+	void loadConfig(DataStreamPtr& stream);
 
 	//////////////////////////////////////////
@@ -231,4 +239,6 @@
 
 	bool mViewCellsGeometryLoaded;
+
+	bool mShowTerrain;
 };
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1595)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1816)
@@ -1333,24 +1333,28 @@
 void KdTreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 
 													const bool load)
-{	// NOTE: should not happen, rather apply view cell representing unbounded space then
+{	
 	if (!vc) 
 	{	
 		// set everything visible for savety
+
+		// NOTE: should not happen, rather apply view cell 
+		// representing unbounded space then
 		SetObjectsVisible(true);
-
 		return;
 	}
 
-	GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit,
-		oit_end = vc->GetPvs().mEntries.end();
-
-	//-- PVS of view cell
-	for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
-	{
-		if (!(*oit).first) continue;
-
-		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first);
-		omi->GetEntity()->setVisible(load);
-		//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
+	//////////
+	//-- set PVS of view cell visible
+	GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator();
+
+	while (pit.HasMoreEntries())
+	{		
+		GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next();
+
+		if (entry.mObject)
+		{
+			OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(entry.mObject);
+			omi->GetEntity()->setVisible(load);
+		}
 	}
 }
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp	(revision 1595)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp	(revision 1816)
@@ -1336,24 +1336,28 @@
 void BvHierarchySceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 
 													const bool load)
-{	// NOTE: should not happen, rather apply view cell 
-	// representing unbounded space then
+{	
 	if (!vc) 
-	{	// set everything visible for savety
+	{	
+		// set everything visible for savety
+
+		// NOTE: should not happen, rather apply view cell 
+		// representing unbounded space then
 		SetObjectsVisible(true);
 		return;
 	}
 
-	GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit,
-		oit_end = vc->GetPvs().mEntries.end();
-
-	//////////////
-	//-- PVS of view cell
-	for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
-	{
-		if (!(*oit).first) continue;
-
-		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>((*oit).first);
-		omi->GetEntity()->setVisible(load);
-		//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
+	//////////
+	//-- set PVS of view cell visible
+	GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator();
+
+	while (pit.HasMoreEntries())
+	{		
+		GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next();
+
+		if (entry.mObject)
+		{
+			OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(entry.mObject);
+			omi->GetEntity()->setVisible(load);
+		}
 	}
 }
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 1676)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 1816)
@@ -89,5 +89,5 @@
 				OptimizeForProcessor="0"
 				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"
+				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"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
 				StringPooling="TRUE"
@@ -105,10 +105,10 @@
 				Name="VCLinkerTool"
 				IgnoreImportLibrary="TRUE"
-				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib glew32.lib glew32s.lib"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib glew32.lib glew32s.lib IVReader.lib"
 				OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll"
 				Version="0.99"
 				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"
-				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Zlib\lib;&quot;..\..\lib\$(ConfigurationName)&quot;"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Zlib\lib;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;"
 				ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def"
 				GenerateDebugInformation="TRUE"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1676)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1816)
@@ -22,4 +22,6 @@
 #include <OgreManualObject.h>
 #include "IntersectableWrapper.h"
+#include "IVReader.h"
+
 
 namespace Ogre {
@@ -54,7 +56,9 @@
 mNormalExecution(false),
 mShowViewCells(false),
-mViewCellsGeometryLoaded(false)
-{
-	Ogre::LogManager::getSingleton().logMessage("creating occlusion culling scene manager");
+mViewCellsGeometryLoaded(false),
+mShowTerrain(false)
+{
+	Ogre::LogManager::getSingleton().
+		logMessage("creating occlusion culling scene manager");
 
 	mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
@@ -126,5 +130,6 @@
 //-------------------------------------------------------------------------
 #if 1
-void OcclusionCullingSceneManager::setWorldGeometry( DataStreamPtr& stream, const String& typeName )
+void OcclusionCullingSceneManager::setWorldGeometry(DataStreamPtr& stream, 
+													const String& typeName)
 {
     // Clear out any existing world resources (if not default)
@@ -141,20 +146,90 @@
     // Load the configuration
     loadConfig(stream);
-	initLevelIndexes();
-
-    // Resize the octree, allow for 1 page for now
-    float max_x = mOptions.scale.x * mOptions.pageSize;
-    float max_y = mOptions.scale.y;
-    float max_z = mOptions.scale.z * mOptions.pageSize;
-
-	float maxAxis = std::max(max_x, max_y);
-	maxAxis = std::max(maxAxis, max_z);
-	resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) );
+
+	if (mShowTerrain)
+	{
+		initLevelIndexes();
+
+		// Resize the octree, allow for 1 page for now
+		float max_x = mOptions.scale.x * mOptions.pageSize;
+		float max_y = mOptions.scale.y;
+		float max_z = mOptions.scale.z * mOptions.pageSize;
+
+		float maxAxis = std::max(max_x, max_y);
+		maxAxis = std::max(maxAxis, max_z);
+		resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) );
     
-    setupTerrainMaterial();
-    setupTerrainPages();
-
+		setupTerrainMaterial();
+		setupTerrainPages();
+	}
  }
 #endif
+//-------------------------------------------------------------------------
+void OcclusionCullingSceneManager::loadConfig(DataStreamPtr& stream)
+{
+	/* Set up the options */
+	ConfigFile config;
+	String val;
+
+	config.load(stream);
+
+	std::stringstream d; 
+	//d << "reading the config file from: " << filename;
+	//LogManager::getSingleton().logMessage(d.str());
+
+	val = config.getSetting("Scene");
+
+    if (!val.empty())
+	{
+		 string filename = val.c_str();
+		 LoadScene(filename);
+	}
+
+	val = config.getSetting("ViewCells");
+
+	if (!val.empty())
+	{
+		 string viewCellsFilename = val.c_str();
+		 std::stringstream d; d << "view cells file name: " << viewCellsFilename;
+		 LogManager::getSingleton().logMessage(d.str());
+
+		 mViewCellsLoaded = LoadViewCells(viewCellsFilename);
+	}
+	
+	val = config.getSetting("OnlineCullingAlgorithm");
+		
+	if (!val.empty())
+	{
+		GtpVisibility::VisibilityEnvironment::CullingManagerType algorithm;
+
+		if (val == "CHC")
+		{
+			algorithm = 
+				GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING;
+		}
+		else if (val == "SWC")
+		{
+			 algorithm = 
+				 GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING;
+		 }
+		 else if (val == "VFC")
+		 {
+			 algorithm = 
+				 GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING;
+		 }
+		 else // default rendering
+		 {
+			 algorithm = 
+				 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS;
+		 }
+
+		 mVisibilityManager->SetCullingManager(algorithm);
+	}
+
+	if (mShowTerrain)
+	{
+		TerrainSceneManager::loadConfig(stream);
+	}
+}
 //-----------------------------------------------------------------------
 void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam)
@@ -192,4 +267,5 @@
 
 				MovableMap::iterator fit = mViewCellsGeometry.find(id);
+
 				if ((fit != mViewCellsGeometry.end()) && (*fit).second)
 					(*fit).second->_updateRenderQueue(getRenderQueue());
@@ -207,19 +283,24 @@
 		}
 		
-		GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator 
-			oit, oit_end = mCurrentViewCell->GetPvs().mEntries.end();
-			
-		for (oit = mCurrentViewCell->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
-		{
-			GtpVisibilityPreprocessor::Intersectable *entry = (*oit).first;
-
-			if (entry->Type() == GtpVisibilityPreprocessor::Intersectable::OBJECTS_INTERSECTABLE)
+
+		//////////
+		//-- set PVS of view cell visible
+
+		GtpVisibilityPreprocessor::ObjectPvsIterator pit = 
+			mCurrentViewCell->GetPvs().GetIterator();
+
+		while (pit.HasMoreEntries())
+		{		
+			GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next();
+			GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject;
+
+			if (obj->Type() == 
+				GtpVisibilityPreprocessor::Intersectable::OBJECTS_INTERSECTABLE)
 			{
-				ObjectsIntersectable *oi = dynamic_cast<ObjectsIntersectable *>(entry);
-				
+				ObjectsIntersectable *oi = dynamic_cast<ObjectsIntersectable *>(obj);
+
 				EntityContainer *entries = oi->GetItem();
-				
 				EntityContainer::const_iterator eit, eit_end = entries->end();
-						
+
 				for (eit = entries->begin(); eit != eit_end; ++ eit)
 				{
@@ -229,48 +310,51 @@
 		}
 
-		for (oit = mCurrentViewCell->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
-		{
-			GtpVisibilityPreprocessor::Intersectable *entry = (*oit).first;
-		
-			switch (entry->Type())
+		pit = mCurrentViewCell->GetPvs().GetIterator();
+
+		while (pit.HasMoreEntries())
+		{		
+			GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next();
+			GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject;
+
+			switch (obj->Type())
 			{	
-				case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE:
+			case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE:
+				{
+					OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(obj);
+					omi->GetEntity()->_updateRenderQueue(getRenderQueue());
+				}
+				break;
+
+			case GtpVisibilityPreprocessor::Intersectable::OBJECTS_INTERSECTABLE:
+				{
+					ObjectsIntersectable *oi = dynamic_cast<ObjectsIntersectable *>(obj);
+
+					EntityContainer *entries = oi->GetItem();
+					EntityContainer::const_iterator eit, eit_end = entries->end();
+
+					for (eit = entries->begin(); eit != eit_end; ++ eit)
 					{
-						OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(entry);
-						omi->GetEntity()->_updateRenderQueue(getRenderQueue());
+						//OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(*eit);
+						Entity *ent = *eit;
+						Any newAny = ent->getUserAny();
+
+						int flt = any_cast<int>(newAny);
+						//std::stringstream d; d << "any: " << flt << " ";
+						//Ogre::LogManager::getSingleton().logMessage(d.str());
+						if (any_cast<int>(newAny) == 0)
+						{
+							ent->setUserAny(Any((int)1));
+							ent->_updateRenderQueue(getRenderQueue());
+						}
+
+						//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
 					}
-					break;
-				case GtpVisibilityPreprocessor::Intersectable::OBJECTS_INTERSECTABLE:
-					{
-						ObjectsIntersectable *oi = dynamic_cast<ObjectsIntersectable *>(entry);
-					
-						EntityContainer *entries = oi->GetItem();
-						EntityContainer::const_iterator eit, eit_end = entries->end();
-						
-						for (eit = entries->begin(); eit != eit_end; ++ eit)
-						{
-							//OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(*eit);
-							Entity *ent = *eit;
-							Any newAny = ent->getUserAny();
-
-							int flt = any_cast<int>(newAny);
-							//std::stringstream d; d << "any: " << flt << " ";
-							//Ogre::LogManager::getSingleton().logMessage(d.str());
-							if (any_cast<int>(newAny) == 0)
-							{
-								ent->setUserAny(Any((int)1));
-								ent->_updateRenderQueue(getRenderQueue());
-							}
-
-							//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
-						}
-					}
-					break;
-				default:
-					break;
+				}
+				break;
+			default:
+				break;
 			}
 		}	
 	}
-
 /*
    if (mRenderNodesForViz || mRenderNodesContentForViz)
@@ -367,8 +451,6 @@
 	}
 	//else if (mIsItemBufferPass) {usedPass = mItemBufferPass;}
-	
 
 	//-- set actual pass here
-
 	const Pass *result = SceneManager::_setPass(usedPass);
 
@@ -673,10 +755,4 @@
 	if (key == "LoadViewCells")
 	{ 
-		if (!mViewCellsLoaded)
-		{
-			String filename(static_cast<const char *>(val));
-			mViewCellsLoaded = LoadViewCells(filename);	
-		}
-
 		return mViewCellsLoaded;
 	}
@@ -742,5 +818,5 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::getOption(const String & key, void *val)
+bool OcclusionCullingSceneManager::getOption(const String &key, void *val)
 {
 	if (key == "NumHierarchyNodes")
@@ -759,4 +835,9 @@
 		* static_cast<GtpVisibility::HierarchyInterface **>(val) = 
 			(GtpVisibility::HierarchyInterface *)mHierarchyInterface;
+		return true;
+	}
+	if (key == "ShowTerrain")
+	{
+		* static_cast<bool *>(val) = (bool *)mShowTerrain;
 		return true;
 	}
@@ -922,4 +1003,5 @@
 	}
 
+	///////////
 	//-- TRANSPARENT LOOP: must be handled differently from solids
 
@@ -1237,21 +1319,22 @@
 	}
 		
-	GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit,
-			oit_end = vc->GetPvs().mEntries.end();
+	GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator();
 
 	////////////
 	//-- set PVS of view cell to visible
 
-	for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
-	{
-		GtpVisibilityPreprocessor::Intersectable *entry = (*oit).first;
+	while (pit.HasMoreEntries())
+	{		
+		GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next();
+		GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject;
+
 		// no associated geometry found
-		if (!entry) continue;
-	
-		switch (entry->Type())
+		if (!obj) continue;
+	
+		switch (obj->Type())
 		{
 			case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE:
 				{
-					OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(entry);
+					OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance *>(obj);
 					omi->GetEntity()->setVisible(load);
 					//GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl;
@@ -1262,11 +1345,11 @@
 					//GtpVisibilityPreprocessor::ObjectsIntersectable *oi = 
 					//	dynamic_cast<GtpVisibilityPreprocessor::ObjectsIntersectable *>(entry);
-					ObjectsIntersectable *oi = dynamic_cast<ObjectsIntersectable *>(entry);
+					ObjectsIntersectable *oi = dynamic_cast<ObjectsIntersectable *>(obj);
 
 					//GtpVisibilityPreprocessor::ObjectContainer *entries = oi->GetItem();
 					EntityContainer *entries = oi->GetItem();
 
-					EntityContainer::const_iterator eit,
-						eit_end = entries->end();
+					EntityContainer::const_iterator eit, eit_end = entries->end();
+
 					for (eit = entries->begin(); eit != eit_end; ++ eit)
 					{
@@ -1423,4 +1506,111 @@
 }
 #endif
+// splits strings containing multiple file names
+static int SplitFilenames(const std::string str, std::vector<std::string> &filenames)
+{
+	int pos = 0;
+
+	while(1) 
+	{
+		int npos = (int)str.find(';', pos);
+		
+		if (npos < 0 || npos - pos < 1)
+			break;
+		filenames.push_back(std::string(str, pos, npos - pos));
+		pos = npos + 1;
+	}
+	
+	filenames.push_back(std::string(str, pos, str.size() - pos));
+	return (int)filenames.size();
+}
+//-----------------------------------------------------------------------
+bool OcclusionCullingSceneManager::LoadScene(const String &filename)
+{
+	using namespace std;
+	// use leaf nodes of the original spatial hierarchy as occludees
+	vector<string> filenames;
+	const int files = SplitFilenames(filename, filenames);
+	
+	std::stringstream d;
+	d << "number of input files: " << files << "\n";
+	LogManager::getSingleton().logMessage(d.str());
+
+	bool result = false;
+	vector<string>::const_iterator fit, fit_end = filenames.end();
+	int i = 0;
+
+	if (filename == "terrain")
+	{
+		// terrain hack
+		mShowTerrain = true;
+		LogManager::getSingleton().logMessage("creating terrain");
+		return true;
+	}
+
+	for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i)
+	{
+		const string fn = *fit;
+
+		if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl"))
+		{
+			// load iv files
+			if (!LoadSceneIV(fn, getRootSceneNode(), i))
+			{
+				// terrain hack
+				LogManager::getSingleton().logMessage("error loading file");
+			}
+		}
+			
+		// at least one piece of geometry loaded
+		result = true;
+	}
+	
+	return result;
+}
+//-----------------------------------------------------------------------
+bool OcclusionCullingSceneManager::LoadSceneIV(const String &filename, 
+											   SceneNode *root, 
+											   const int index)
+{
+	IVReader ivReader;
+
+	Timer *timer = PlatformManager::getSingleton().createTimer();
+	timer->reset();
+
+	if (1)
+	{
+		std::string logFilename = "IVLog" + Ogre::StringConverter().toString(index) + ".log";
+		
+		Log *log = LogManager::getSingleton().createLog(logFilename);
+		ivReader.setLog(log);
+	}
+	
+	//viennaNode->translate(Vector3(-300, -300, 0));
+
+	if (ivReader.loadFile(filename.c_str()))
+	{
+		SceneNode *node = root->createChildSceneNode("IVSceneNode" + index);
+
+		ivReader.buildTree(this, node);
+		
+		ivReader.collapse();
+
+		std::stringstream d; 
+		d << "loaded " << filename << " in " << timer->getMilliseconds() * 1e-3 << " secs";
+		LogManager::getSingleton().logMessage(d.str());
+		
+		PlatformManager::getSingleton().destroyTimer(timer);
+
+		//-- bake into static geometry
+		/*if (USE_STATIC_GEOMETRY)
+		{
+			BakeSceneIntoStaticGeometry("staticVienna", "Vienna");
+		}*/
+	
+		return true;
+	}
+
+	return false;
+}
 //-----------------------------------------------------------------------
 const String OcclusionCullingSceneManagerFactory::FACTORY_TYPE_NAME = "OcclusionCullingSceneManager";
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTerrainSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTerrainSceneManager.cpp	(revision 1273)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTerrainSceneManager.cpp	(revision 1816)
@@ -302,6 +302,4 @@
 	// set the page source
 	selectPageSource(pageSourceName, optlist);
-
-
 }
 //-------------------------------------------------------------------------
@@ -514,5 +512,5 @@
 }
 //-------------------------------------------------------------------------
-void KdTerrainSceneManager::setWorldGeometry(DataStreamPtr& stream, const String& typeName )
+void KdTerrainSceneManager::setWorldGeometry(DataStreamPtr& stream, const String& typeName)
 {
 	// Clear out any existing world resources (if not default)
