Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 1268)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 1271)
@@ -83,4 +83,6 @@
 // if we are recording a demo
 static const bool DEMO_HACK = false;
+
+//using namespace GtpVisibility;
 
 //-----------------------------------------------------------------------
@@ -109,10 +111,5 @@
 mVisibilityThreshold(0),
 mAssumedVisibility(0),
-#if 1
 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),
-#else
-mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING),
-//mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING),
-#endif
 mNodeVizMode(NODEVIZ_NONE),
 mVizCameraHeight(Real(4000.0)),
@@ -181,4 +178,5 @@
 	mRayQueryExecutor = new RayQueryExecutor(mSceneMgr);
 	
+
 	//-- overlays
 	
@@ -217,16 +215,9 @@
 	}
 
-	// loading overlay
-
+	// loading view cells overlay
 	mLoadingOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/LoadingOverlay");
 	mMyLoadingInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Loading/MyLoadingInfo");
 	mMyLoadingInfo->setCaption("loading view cells ...");
-	
-	/*const int top = 10;
-		mMyStatsAlgorithmInfo->setTop(top);
-
-		char str[100]; sprintf(str,": %d", 0);
-		mMyStatsFpsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/MyFpsInfo");
-		mMyStatsFpsInfo->setCaption(str);*/
+
 
 	mLoadingOverlay->hide();
@@ -241,6 +232,6 @@
 	mSceneMgr->setOption("NodeVizScale", &mVizScale);
 		
-	//-- set culling algorithm type
-	setAlgorithm(mCurrentAlgorithm);
+	//-- set the current culling algorithm type
+	setAlgorithm(mApplication->mAlgorithm);
 
 	// set scene manager options
@@ -253,5 +244,5 @@
 	mSceneMgr->setOption("PrepareVisualization", &mShowVisualization);
 	
-	setObjectType(mCurrentObjectType);
+	applyObjectType();
 
 	// initialise timer
@@ -983,8 +974,8 @@
 	mCurrentAlgorithm = (mCurrentAlgorithm + 1) % 
 		GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS;
-	setAlgorithm(mCurrentAlgorithm);
-}
-//-----------------------------------------------------------------------
-void TerrainFrameListener::setObjectType(int objectType)
+	applyCurrentAlgorithm();
+}
+//-----------------------------------------------------------------------
+void TerrainFrameListener::applyObjectType()
 {
 	if (mCurrentObjectType >= 3) // TODO: define a constant
@@ -999,5 +990,5 @@
 }
 //-----------------------------------------------------------------------
-void TerrainFrameListener::setAlgorithm(int algorithm)
+void TerrainFrameListener::applyCurrentAlgorithm()
 {
 	mAlgorithmInfo->setCaption(": " + msAlgorithmCaptions[mCurrentAlgorithm]);
@@ -1184,5 +1175,5 @@
 //-----------------------------------------------------------------------
 void TerrainFrameListener::toggleUseViewCells()
-{LogManager::getSingleton().logMessage("here52");
+{
 	// HACK: no view cells for hilly terrain
 	if (mApplication->msShowHillyTerrain)
@@ -1409,5 +1400,6 @@
 	
 	case KC_F7:
-		setObjectType(++ mCurrentObjectType);
+		++ mCurrentObjectType;
+		applyObjectType();
 		break;
 	#endif
@@ -1849,5 +1841,5 @@
 	int top = border_height + 25;
 
-	String ext = "Example/Visibility/Query/";
+	const String ext = "Example/Visibility/Query/";
 	    
 	initOverlayElement(&mQueryTypeInfo , ext, "QueryType", top,	": 0"); top += vert_space;
@@ -1867,2 +1859,8 @@
 	queryPanel->setHeight(top + border_height);
 }
+//-----------------------------------------------------------------------
+void TerrainFrameListener::setAlgorithm(const int algorithm)
+{
+	mCurrentAlgorithm = algorithm;
+	applyCurrentAlgorithm();
+}
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 1268)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 1271)
@@ -25,4 +25,5 @@
 
 
+//using namespace GtpVisibility;
 
 /*************************************************************/
@@ -165,5 +166,6 @@
 mIVReader(NULL),
 mFilename("terrain"),
-mEnvironmentFilename("generate_viewcells.env")
+mViewCellsFilename(""),
+mAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
 {
 }
@@ -191,14 +193,10 @@
 
 	
-	/*val = config.getSetting("ViewCells");
+	val = config.getSetting("ViewCells");
+
 	if (!val.empty())
-	{	 mViewCellsFilename = val.c_str();}*/
-
-	val = config.getSetting("VisibilityEnvironment");
-
-	if (!val.empty())
-	{
-		 mEnvironmentFilename = val.c_str();
-		 std::stringstream d; d << "loading environment from file: " << mEnvironmentFilename;
+	{
+		 mViewCellsFilename = val.c_str();
+		 std::stringstream d; d << "view cells file name: " << mViewCellsFilename;
 		 LogManager::getSingleton().logMessage(d.str());
 	}
@@ -222,40 +220,34 @@
 
 
+	val = config.getSetting("OnlineCullingAlgorithm");
+
+	if (!val.empty())
+	{
+		 if (val == "CHC")
+		 {
+			 mAlgorithm = 
+				 GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING;
+		 }
+		 else if (val == "SWC")
+		 {
+			 mAlgorithm = 
+				 GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING;
+		 }
+		 else if (val == "VFC")
+		 {
+			 mAlgorithm = 
+				 GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING;
+		 }
+	}
+
 	/////////////////////////
 	// setup scene
 
 	//-- load the scene from specified file
-LogManager::getSingleton().logMessage("here5112");
 	if (!LoadScene(mFilename))
-		LogManager::getSingleton().logMessage("error loading scene");
-
-LogManager::getSingleton().logMessage("here6");
-	GtpVisibility::VisibilityManager *mVisManager = NULL;
-
-	//-- load the environment from file
-	if (mSceneMgr->getOption("VisibilityManager", &mVisManager))
-	{
-		LogManager::getSingleton().logMessage("here7");
-		GtpVisibility::VisibilityEnvironment *visEnv = mVisManager->GetVisibilityEnvironment();
-		LogManager::getSingleton().logMessage("here7.04");
-		if (!visEnv->LoadEnvironment(mEnvironmentFilename))
-		{LogManager::getSingleton().logMessage("here7.l2");
-			std::stringstream d; d << "failed loading environment from " << mEnvironmentFilename;
-			LogManager::getSingleton().logMessage(d.str());
-		}
-		else //-- load environment options
-		{LogManager::getSingleton().logMessage("here8");
-			//-- get view cells file name, load view cells only on demand
-			mViewCellsFilename = visEnv->getViewCellsFileName();
-
-			std::stringstream d; d << "view cells file name: " << mViewCellsFilename;
-			LogManager::getSingleton().logMessage(d.str());
-		}
-	}
-	else
-	{
-		LogManager::getSingleton().logMessage("error: no visibility scenemanager available");
-	}
-LogManager::getSingleton().logMessage("here9");
+	{
+    	LogManager::getSingleton().logMessage("error loading scene");
+	}
+	
 	// set camera position accordingly
 	mCamNode->setPosition(v);
@@ -477,5 +469,6 @@
 	mSunLight->setCastShadows(true);
 
-	// set light angle not too small over the surface, otherwise shadows textures will be broken
+	// set light angle not too small over the surface, 
+	// otherwise shadows textures will be broken
 	Vector3 dir(0.5, 1, 0.5);
 	dir.normalise();
@@ -490,9 +483,10 @@
 	ColourValue fadeColour(0.93, 0.86, 0.76);
 	mWindow->getViewport(0)->setBackgroundColour(fadeColour);
-	//mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000);
+	//mSceneMgr->setFog(FOG_LINEAR, fadeColour, .001, 500, 1000);
 	
 	// Create a skybox
 	mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true);
 	
+	// terrain creation
 	if (msShowHillyTerrain)
 	{
@@ -505,6 +499,5 @@
 	
 
-	//-- CEGUI setup
-	setupGui();
+	setupGui(); //-- CEGUI setup
 
 	// occluder plane to test visibility
@@ -530,8 +523,8 @@
 	mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5));
 
+
 	//-- terrain content setup
 
-	// HACK: necessary to call once before the content creation for
-	// terrain initialisation
+	// HACK: necessary to call once here for terrain initialisation
 	mSceneMgr->_renderScene(mCamera, mWindow->getViewport(0), true);
 
@@ -634,6 +627,14 @@
 void TestCullingTerrainApplication::createFrameListener()
 {
-	mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr, 
-		mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight, this);
+	mTerrainFrameListener = 
+		new TerrainFrameListener(mWindow, 
+								 mCamera, 
+								 mSceneMgr, 
+								 mGUIRenderer, 
+								 mTerrainContentGenerator, 
+								 mVizCamera, 
+								 mCamNode, 
+								 mSunLight, 
+								 this);
 	
 	mRoot->addFrameListener(mTerrainFrameListener);
@@ -655,12 +656,12 @@
 	if (msShowHillyTerrain)
 	{
+		mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");
 		//mSceneMgr = mRoot->createSceneManager("TerrainSceneManager");
-		mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");
 		//mSceneMgr = mRoot->createSceneManager("KdTreeSceneManager");
 	}
 	else
 	{	
+		mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");
 		//mSceneMgr = mRoot->createSceneManager("OctreeSceneManager");
-		mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");
 		//mSceneMgr = mRoot->createSceneManager("KdTreeSceneManager");
 	}
@@ -741,5 +742,4 @@
 	return (int)filenames.size();
 }
-
 //-----------------------------------------------------------------------
 bool TestCullingTerrainApplication::LoadScene(const String &filename)
@@ -757,5 +757,5 @@
 	vector<string>::const_iterator fit, fit_end = filenames.end();
 	int i = 0;
-	// root for different files
+
 	for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i)
 	{
@@ -764,8 +764,4 @@
 		if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl"))
 		{
-			// hack: set postion manually for vienna
-			//mCamNode->setPosition(Vector3(830, 300, -540));
-			//mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));
-
 			// load iv files
 			if (!LoadSceneIV(fn, mSceneMgr->getRootSceneNode(), i))
@@ -773,7 +769,6 @@
 				// terrain hack
 				msShowHillyTerrain = true;
-				LogManager::getSingleton().logMessage("error loading scene. loading terrain instead");
+				LogManager::getSingleton().logMessage("error loading scene => load terrain");
 			}
-			LogManager::getSingleton().logMessage("here521");
 		}
 		else if (strstr(filename.c_str(), ".dae"))
@@ -793,17 +788,4 @@
 	}
 	
-
-	/*
-	if (result) 
-	{
-		int intersectables, faces;
-
-	  std::stringstream d;
-	  d << filename << " parsed successfully.\n"
-		<< "#NUM_OBJECTS (Total numner of objects)\n" << intersectables << "\n"
-		<< "#NUM_FACES (Total numner of faces)\n" << faces << "\n";
-	}
-	*/
-	
 	return result;
 }
@@ -847,5 +829,4 @@
     mSceneMgr->setOption("PrepareVisualization", &showViz);
 	mSceneMgr->setOption("SkyBoxEnabled", &nShowViz);
-	//mSceneMgr->setOption("SkyPlaneEnabled", &showViz);
 	
 	RenderTargetListener::preViewportUpdate(evt);
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h	(revision 945)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h	(revision 1271)
@@ -164,5 +164,5 @@
    void setCurrentFrameInfo(Real timeElapsed);
 
-   void setAlgorithm(int algorithm);
+   void applyCurrentAlgorithm();
 
    void moveCamera();
@@ -244,5 +244,8 @@
 	/** Sets the type of the objects generated in the scene.
 	*/
-	void setObjectType(int objectType);
+	void applyObjectType();
+
+	void setAlgorithm(const int algorithm);
+
 
 	static String msAlgorithmCaptions[];
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h	(revision 1003)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h	(revision 1271)
@@ -137,8 +137,8 @@
 	*/
 	void loadConfig(const String& filename);
-	
+
+
 	/// if hilly terrain should be loaded
 	static bool msShowHillyTerrain;
-
 
 	String mFilename;
@@ -146,4 +146,7 @@
 	/// name of the visibility environment file
 	String mEnvironmentFilename;
+	
+	int mAlgorithm;
+
 
 protected:
@@ -192,6 +195,5 @@
 	
 	StaticGeometry *mStaticGeometry;
-
-	
+    
 
 private:
