Index: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj	(revision 657)
+++ GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj	(revision 866)
@@ -73,5 +73,5 @@
 			<Tool
 				Name="VCCLCompilerTool"
-				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"
+				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"
 				RuntimeLibrary="2"
@@ -85,8 +85,8 @@
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="OGREMain.LIB CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib"
+				AdditionalDependencies="OGREMain.LIB CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib IVReader.lib"
 				OutputFile="$(OGRE_PATH)/Samples/Common/bin/Release/TestCullingTerrain.exe"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\Ogre\lib\$(ConfigurationName)&quot;;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\lib;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)&quot;"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\Ogre\lib\$(ConfigurationName)&quot;;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\lib;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;"
 				GenerateDebugInformation="TRUE"
 				SubSystem="2"
Index: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 724)
+++ GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 866)
@@ -207,6 +207,13 @@
 	}
 
+	// larger magnification for terrain
+	if (TestCullingTerrainApplication::msShowHillyTerrain)
+		mVizScale = 25;
+	else
+		mVizScale = 1;
+
 	// the scale factor for the visualized bounding boxes
 	mSceneMgr->setOption("NodeVizScale", &mVizScale);
+	
 
 	// set culling algorithm type
@@ -478,5 +485,13 @@
 
 		// clamp camera so we always walk along the terrain
-		mApplication->Clamp2Terrain(mCamNode, 5);
+		if (TestCullingTerrainApplication::msShowHillyTerrain)
+		{
+			mApplication->Clamp2Terrain(mCamNode, 5);
+		}
+		else
+		{
+			mApplication->Clamp2FloorPlane();
+		}
+
 		break;
 
Index: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 723)
+++ GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp	(revision 866)
@@ -7,5 +7,5 @@
 
 #include <Ogre.h>
-
+#include <direct.h> // for getcwd
 //#include "OgreReferenceAppLayer.h"
 //#include "OgreRefAppWorld.h"
@@ -13,11 +13,15 @@
 #include "TerrainFrameListener.h"
 
+#include "IVReader.h"
+
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 
-/**********************************************/
-/*             EntityState implementation     */
-/**********************************************/
+bool TestCullingTerrainApplication::msShowHillyTerrain = false;
+
+/******************************************************/
+/*             EntityState implementation             */
+/******************************************************/
 
 
@@ -159,4 +163,5 @@
 	OGRE_DELETE(mTerrainContentGenerator);
 	OGRE_DELETE(mRayQueryExecutor);
+	OGRE_DELETE(mIVReader);
 
 	deleteEntityStates();	
@@ -183,7 +188,15 @@
 	*	because then the camera is displayed correctly in the visualization
 	*/
-	mCamNode = mSceneMgr->getRootSceneNode()->
+	if (msShowHillyTerrain)
+	{
+		mCamNode = mSceneMgr->getRootSceneNode()->
 		createChildSceneNode("CamNode1", Vector3(707, 5000, 528));
-	//mCamera->setPosition(707, 5000, 528);
+	}
+	else
+	{
+		mCamNode = mSceneMgr->getRootSceneNode()->
+			createChildSceneNode("CamNode1", Vector3(0, -100, -200));
+	}
+
 	mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));
 	mCamNode->attachObject(mCamera);
@@ -225,6 +238,122 @@
 }
 //-----------------------------------------------------------------------
+void TestCullingTerrainApplication::LoadWorldGeometry()
+{
+	mIVReader = new IVReader();
+
+	// _MAX_PATH is the maximum length allowed for a path
+	char currentPath[_MAX_PATH];
+	// use the function to get the path
+	getcwd(currentPath, _MAX_PATH);
+	std::stringstream d;
+	d << "current path: " << currentPath;
+//E:\ogre_versions\ogre-win32-v1-0-3p1\ogrenew\Samples\Common\bin\Release
+	Ogre::LogManager::getSingleton().logMessage(d.str());
+	//String path = "E:/svn/gametools/trunk/VUT/Ogre/resources/";
+	String path = "E:/svn/gametools/OGRE/trunk/resources/";
+	
+	SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1");
+	SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node2");
+	SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node3");
+	SceneNode *node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node4");
+	SceneNode *node5 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node5");
+	SceneNode *node6 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node6");
+	SceneNode *node7 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node7");
+	SceneNode *node8 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node8");
+	SceneNode *node9 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node9");
+
+
+	node1->translate(Vector3(-500, 0, 750));
+	node2->translate(Vector3(-400, 0, 750));
+	node3->scale(Vector3(100, 100 ,100));
+	node3->pitch(Radian(3 * Math::HALF_PI));
+	node4->translate(Vector3(-100, 0, 0));
+	node5->translate(Vector3(0, 300, 0));
+	
+	node6->scale(Vector3(100, 100 ,100));
+	node6->pitch(Radian(3 * Math::HALF_PI));
+	node6->roll(Radian(Math::HALF_PI));
+	node6->translate(Vector3(0, -100, 0));
+
+	node7->scale(Vector3(100, 100 ,100)); 
+	node7->pitch(Radian(3 * Math::HALF_PI));
+	node7->roll(Radian(Math::HALF_PI));
+	node7->translate(Vector3(100, 0, 0));
+	
+	node8->translate(Vector3(-300, -300, 0));
+
+	Log *log = LogManager::getSingleton().createLog("IVLog.log");
+	mIVReader->setLog(log);
+#if 1
+	String fileName = path + "media\\house_test1.iv";
+
+	if (mIVReader->loadFile(fileName.c_str()))
+	{
+		mIVReader->buildTree(mSceneMgr, node1);
+		mIVReader->buildTree(mSceneMgr, node2);
+	}
+
+	/*if (mIVReader->loadFile("media\\anhk.wrl"))
+	{
+		mIVReader->buildTree(mSceneMgr, node3);
+	}
+	if (mIVReader->loadFile("media\\ant.wrl"))
+	{
+		mIVReader->buildTree(mSceneMgr, node4);
+	}
+	if (mIVReader->loadFile("media\\zepplin0.wrl"))
+	{
+		mIVReader->buildTree(mSceneMgr, node5);
+	}
+	if (mIVReader->loadFile("media\\warbird.wrl"))
+	{
+		mIVReader->buildTree(mSceneMgr, node6);
+	}
+	if (mIVReader->loadFile("media\\z_wing.wrl"))
+	{
+		mIVReader->buildTree(mSceneMgr, node7);
+	}*/
+#else
+	
+	String fileName = path + "media\\city1500_flat_1.iv";
+	
+	if (mIVReader->loadFile(fileName.c_str()))
+	{
+		mIVReader->buildTree(mSceneMgr, node8);
+	}
+
+	fileName = path + "media\\roofs_1500.iv";
+	if (mIVReader->loadFile(fileName.c_str()))
+	{
+		mIVReader->buildTree(mSceneMgr, node8);
+	}
+
+	fileName = path + "media\\CityRoads60.iv";
+	if (mIVReader->loadFile(fileName.c_str()))
+	{
+		mIVReader->buildTree(mSceneMgr, node8);
+	}
+
+	fileName = path + "media\\CityPlane60.iv";
+    if (mIVReader->loadFile(fileName.c_str()))
+	{
+		mIVReader->buildTree(mSceneMgr, node8);
+	}
+	
+	fileName = path + "media\\test.iv";
+	if (mIVReader->loadFile(fileName.c_str()))
+	{
+		mIVReader->buildTree(mSceneMgr, node9);
+	}
+#endif
+	mIVReader->collapse();
+}
+
+//-----------------------------------------------------------------------
 void TestCullingTerrainApplication::createScene()
 {
+	if (!msShowHillyTerrain)
+		LoadWorldGeometry();
+
 	// Set ambient light
 	mAmbientLight = ColourValue(0.5, 0.5, 0.5);
@@ -258,9 +387,12 @@
 	mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true);
 	
-	std::string terrain_cfg("terrain.cfg");
+	if (msShowHillyTerrain)
+	{
+		std::string terrain_cfg("terrain.cfg");
 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
-	terrain_cfg = mResourcePath + terrain_cfg;
+		terrain_cfg = mResourcePath + terrain_cfg;
 #endif
-	mSceneMgr->setWorldGeometry(terrain_cfg);
+		mSceneMgr->setWorldGeometry(terrain_cfg);
+	}
 	
 
@@ -278,5 +410,5 @@
 	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);	*/
 
-	// Use 512x512 texture in GL since we can't go higher than the window res
+	// Warning: In GL since we can't go higher than the window res
 	mSceneMgr->setShadowTextureSettings(1024, 2);
 
@@ -298,6 +430,7 @@
 	mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr);
 	
+	
 	// if no objects in file, we generate new objects
-	if (!mTerrainContentGenerator->LoadObjects("objects.out"))
+	if (msShowHillyTerrain && !mTerrainContentGenerator->LoadObjects("objects.out"))
 	{
 		// the objects are generated randomly distributed over the terrain
@@ -388,5 +521,13 @@
 void TestCullingTerrainApplication::chooseSceneManager()
 {
-	mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);
+	if (msShowHillyTerrain)
+	{
+		// Terrain scene manager
+		mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);
+	}
+	else
+	{	// octree scene manager
+		mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
+	}
 }
 //-----------------------------------------------------------------------
@@ -407,8 +548,47 @@
 }
 
-
-/**************************************************************/
-/*      VisualizationRenderTargetListener implementation      */
-/**************************************************************/
+//-----------------------------------------------------------------------
+bool TestCullingTerrainApplication::Clamp2FloorPlane()
+{
+    // clamp to floor plane
+	RaySceneQuery *raySceneQuery = mSceneMgr->createRayQuery(
+		Ray(mCamNode->getPosition(), Vector3::NEGATIVE_UNIT_Y));
+
+	RaySceneQueryResult& qryResult = raySceneQuery->execute();
+    
+	RaySceneQueryResult::iterator rit = qryResult.begin();
+ 
+	while (rit != qryResult.end() && rit->movable)
+	{
+		if (rit->movable->getName() != "PlayerCam")
+		{
+			mCamNode->setPosition(mCamNode->getPosition().x,
+				rit->movable->getWorldBoundingBox().getCenter().y + 2, 
+				mCamNode->getPosition().z);
+	
+			/*std::stringstream d;
+			d << "World: " << it->movable->getWorldBoundingBox().getCenter().y <<
+			", Object: " << it->movable->getBoundingBox().getCenter().y <<
+			", Camera: " << mCamera->getDerivedPosition();
+
+			LogManager::getSingleton().logMessage(d.str());*/
+
+			return true;
+		}
+
+		++ rit;
+	}
+    
+	OGRE_DELETE(raySceneQuery);
+	return false;
+}
+
+
+
+/**********************************************************************/
+/*            VisualizationRenderTargetListener implementation        */
+/**********************************************************************/
+
+
 //-----------------------------------------------------------------------
 VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr)
Index: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h
===================================================================
--- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h	(revision 723)
+++ GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h	(revision 866)
@@ -15,4 +15,5 @@
 #define VIZ_VIEWPORT_Z_ORDER 10
 
+class IVReader;
 
 //-- constants for animation
@@ -119,4 +120,15 @@
 	bool Clamp2Terrain(SceneNode *node, int terrainOffs);
 
+	/** Clamps camera to floor plane: used for vienna set.
+	*/
+	bool Clamp2FloorPlane();
+
+	/** Loads world geometry.
+	*/
+	void LoadWorldGeometry();
+
+	// if hilly terrain should be loaded
+	static bool msShowHillyTerrain;
+
 protected:
 
@@ -158,4 +170,6 @@
 	Vector3 mTerrainMaxPos;
 
+	IVReader *mIVReader;
+
 private:
 	void chooseSceneManager(void);
