Index: trunk/VUT/work/IVReader/include/ivreader.h
===================================================================
--- trunk/VUT/work/IVReader/include/ivreader.h	(revision 183)
+++ trunk/VUT/work/IVReader/include/ivreader.h	(revision 187)
@@ -1,4 +1,4 @@
-#ifndef __IVReader_H__
-#define __IVReader_H__
+#ifndef __mIVReader_H__
+#define __mIVReader_H__
 
 
@@ -120,5 +120,5 @@
 		Ogre::Entity *createEntity(Ogre::SceneManager* sceneMgr, std::string name, IVMeshData *mData, Ogre::Vector3 *translation = NULL);
 
-		void buildTree(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *sceneNodeRoot, IVNode *ivRoot, IVMeshData *mData = NULL, Ogre::Material *material = NULL);
+		void buildTree(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *sceneNodeRoot, IVNode *mIVReaderoot, IVMeshData *mData = NULL, Ogre::Material *material = NULL);
 
 		IVDefListNode *defList;
Index: trunk/VUT/work/IVReader/include/ivmeshdata.h
===================================================================
--- trunk/VUT/work/IVReader/include/ivmeshdata.h	(revision 183)
+++ trunk/VUT/work/IVReader/include/ivmeshdata.h	(revision 187)
@@ -5,5 +5,5 @@
 #include <Ogre.h>
 
-enum IVRenderOperationType
+enum mIVReaderenderOperationType
 {
 	IV_ROT_INVALID = -1,
@@ -25,5 +25,5 @@
 		Ogre::Real *vertices, *normals, *texCoords, *indices, *normalIndices, *texCoordIndices;
 		int vcnt, ncnt, tcnt, icnt, nicnt, ticnt;
-		IVRenderOperationType roType;
+		mIVReaderenderOperationType roType;
 		Ogre::AxisAlignedBox *boundingBox;
 
Index: trunk/VUT/work/IVReader/src/ivmanualmeshloader.cpp
===================================================================
--- trunk/VUT/work/IVReader/src/ivmanualmeshloader.cpp	(revision 183)
+++ trunk/VUT/work/IVReader/src/ivmanualmeshloader.cpp	(revision 187)
@@ -1,4 +1,4 @@
 #include "ivmanualmeshloader.h"
-#include "IVReader.h"
+#include "ivreader.h"
 
 IVManualMeshLoader::IVManualMeshLoader()
Index: trunk/VUT/work/IVReader/src/ivreader.cpp
===================================================================
--- trunk/VUT/work/IVReader/src/ivreader.cpp	(revision 183)
+++ trunk/VUT/work/IVReader/src/ivreader.cpp	(revision 187)
@@ -1,3 +1,3 @@
-#include "ivreader.h"
+#include "IVReader.h"
 #include <string>
 #include <stdlib.h>
@@ -571,5 +571,5 @@
 }
 
-void IVReader::buildTree(Ogre::SceneManager* sceneMgr,  Ogre::SceneNode *sceneNodeRoot, IVNode *ivRoot, IVMeshData *mData, Ogre::Material *material)
+void IVReader::buildTree(Ogre::SceneManager* sceneMgr,  Ogre::SceneNode *sceneNodeRoot, IVNode *IVReaderoot, IVMeshData *mData, Ogre::Material *material)
 {
 	using namespace Ogre;
@@ -586,5 +586,5 @@
 	IVType t; int i;
 	
-	IVNode *help = ivRoot->getNextChildNode(true);
+	IVNode *help = IVReaderoot->getNextChildNode(true);
 	while (help != NULL)
 	{	
@@ -766,5 +766,5 @@
 		}
 
-		help = ivRoot->getNextChildNode();
+		help = IVReaderoot->getNextChildNode();
 	}
 	if (meshDataCreated) if (mData != NULL) delete mData;
Index: trunk/VUT/work/IVReader/src/ivnode.cpp
===================================================================
--- trunk/VUT/work/IVReader/src/ivnode.cpp	(revision 183)
+++ trunk/VUT/work/IVReader/src/ivnode.cpp	(revision 187)
@@ -1,4 +1,4 @@
 #include "ivnode.h"
-#include "IVReader.h"
+#include "ivreader.h"
 
 IVField::IVField()
Index: trunk/VUT/work/IVReader/src/ivmeshdata.cpp
===================================================================
--- trunk/VUT/work/IVReader/src/ivmeshdata.cpp	(revision 183)
+++ trunk/VUT/work/IVReader/src/ivmeshdata.cpp	(revision 187)
@@ -1,4 +1,4 @@
 #include "ivmeshdata.h"
-#include "IVReader.h"
+#include "ivreader.h"
 
 
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj	(revision 136)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj	(revision 187)
@@ -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)\ReferenceApplication\ReferenceAppLayer\include&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;..\..\Ogre\include;..\..\GtpVisibility\include;..\include;..\TestCulling"
+				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;..\..\GtpVisibility\include;..\include"
 				PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE"
 				RuntimeLibrary="2"
@@ -88,5 +88,5 @@
 				OutputFile="$(OGRE_PATH)/Samples/Common/bin/Release/TestCullingTerrain.exe"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\bin\$(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;$(GAMETOOLS_PATH)\trunk\VUT\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;$(GAMETOOLS_PATH)\trunk\VUT\Ogre\lib\$(ConfigurationName)&quot;"
 				GenerateDebugInformation="TRUE"
 				SubSystem="2"
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 183)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 187)
@@ -169,11 +169,6 @@
 
 	// set scene manager options
-	mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves);
-
-	// apply delayed rendering (i.e., transparents after hierarchical culling pass)
-	// only if optimization is not used 
-	bool delayRenderTransparents = !mTestGeometryForVisibleLeaves;
-
-	mSceneMgr->setOption("DelayRenderTransparents", &delayRenderTransparents);
+	setTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves);
+
 	mSceneMgr->setOption("UseDepthPass", &mUseDepthPass);
 	
@@ -190,12 +185,7 @@
 TerrainFrameListener::~TerrainFrameListener()
 {
-	delete mRayQueryExecutor;
-	delete mEventProcessor;
-
-	if (mQueryManager)
-	{
-		delete mQueryManager;
-		mQueryManager = NULL;
-	}
+	OGRE_DELETE(mRayQueryExecutor);
+	OGRE_DELETE(mEventProcessor);
+	OGRE_DELETE(mQueryManager);
 }
 //-----------------------------------------------------------------------
@@ -858,7 +848,6 @@
 }
 //-----------------------------------------------------------------------
-void TerrainFrameListener::toggleTestGeometryForVisibleLeaves()
-{
-	mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves;
+void TerrainFrameListener::setTestGeometryForVisibleLeaves(bool testGeometryForVisibleLeaves)
+{
 	mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves);
 	
@@ -1005,5 +994,6 @@
 		break;
 	case KC_G:
-		toggleTestGeometryForVisibleLeaves();
+		mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves;
+		setTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves);
 		break;
 	case KC_T:
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 175)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 187)
@@ -227,4 +227,7 @@
 void TestCullingTerrainApplication::createScene()
 {
+	Real scale = 3;
+	mSceneMgr->setOption("NodeVizScale", &scale);
+
 	// Set ambient light
 	mAmbientLight = ColourValue(0.5 , 0.5, 0.5);
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 174)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 187)
@@ -119,5 +119,5 @@
     void changeThreshold(int incr);
 	void changeAssumedVisibility(int incr);
-	void toggleTestGeometryForVisibleLeaves();
+	void setTestGeometryForVisibleLeaves(bool testGeometryForVisibleLeaves);
 	void toggleShowOctree();
 	void toggleUseDepthPass();
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeNode.h
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeNode.h	(revision 187)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeNode.h	(revision 187)
@@ -0,0 +1,146 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+(Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+/***************************************************************************
+octreenode.h  -  description
+-------------------
+begin                : Fri Sep 27 2002
+copyright            : (C) 2002 by Jon Anderson
+email                : janders@users.sf.net
+
+Enhancements 2003 - 2004 (C) The OGRE Team
+***************************************************************************/
+
+#ifndef OCTREENODE_H
+#define OCTREENODE_H
+
+#include <OgreSceneNode.h>
+
+#include <OgreOctreeSceneManager.h>
+
+namespace Ogre
+{
+
+/** Specialized SceneNode that is customized for working within an Octree. Each node
+* maintains it's own bounding box, rather than merging it with all the children.
+*
+*/
+
+class _OgreTerrainExport OctreeNode : public SceneNode
+{
+public:
+    /** Standard constructor */
+    OctreeNode( SceneManager* creator );
+    /** Standard constructor */
+    OctreeNode( SceneManager* creator, const String& name );
+    /** Standard destructor */
+    ~OctreeNode();
+
+    /** Overridden from Node to remove any reference to octants */
+    Node * removeChild( unsigned short index );
+    
+    /** Overridden from Node to remove any reference to octants */
+    Node * removeChild( const String & name );
+
+    /** Overridden from Node to remove any reference to octants */
+    Node * removeChild( Node* child);
+
+    /** Returns the Octree in which this OctreeNode resides
+    */
+    Octree * getOctant()
+    {
+        return mOctant;
+    };
+
+    /** Sets the Octree in which this OctreeNode resides
+    */
+    void setOctant( Octree *o )
+    {
+        mOctant = o;
+    };
+
+    /** Determines if the center of this node is within the given box
+    */
+    bool _isIn( AxisAlignedBox &box );
+
+    /** Adds all the attached scenenodes to the render queue
+    */
+    virtual void _addToRenderQueue( Camera* cam, RenderQueue * q, bool onlyShadowCasters );
+
+    /** Sets up the LegacyRenderOperation for rendering this scene node as geometry.
+    @remarks
+    This will render the scenenode as a bounding box.
+    */
+    virtual void getRenderOperation( RenderOperation& op );
+
+    /** Returns the local bounding box of this OctreeNode.
+    @remarks
+    This is used to render the bounding box, rather then the global.
+    */
+    AxisAlignedBox & _getLocalAABB()
+    {
+        return mLocalAABB;
+    };
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+	/// scale for node visualization
+	static void setVizScale(Real scale);
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
+protected:
+
+    /** Internal method for updating the bounds for this OctreeNode.
+    @remarks
+    This method determines the bounds solely from the attached objects, not
+    any children. If the node has changed it's bounds, it is removed from its
+    current octree, and reinserted into the tree.
+    */
+    void _updateBounds( void );
+
+    void _removeNodeAndChildren( );
+
+    ///local bounding box
+    AxisAlignedBox mLocalAABB;
+
+    ///Octree this node is attached to.
+    Octree *mOctant;
+
+    ///preallocated corners for rendering
+    Real mCorners[ 24 ];
+    ///shared colors for rendering
+    static unsigned long mColors[ 8 ];
+    ///shared indexes for rendering
+    static unsigned short mIndexes[ 24 ];
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+	// scale for node visualization
+	static Real msVizScale;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
+};
+
+}
+
+
+#endif
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeNode.cpp
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeNode.cpp	(revision 183)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeNode.cpp	(revision 187)
@@ -46,4 +46,8 @@
 unsigned long green = 0xFFFFFFFF;
 
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+Real OctreeNode::msVizScale = 1;
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+
 unsigned short OctreeNode::mIndexes[ 24 ] = {0, 1, 1, 2, 2, 3, 3, 0,       //back
         0, 6, 6, 5, 5, 1,             //left
@@ -187,7 +191,10 @@
 	}
 
+	//LogManager::getSingleton().logMessage("hagaaggaagag");
 	AxisAlignedBox box = mLocalAABB;
+	
 	// HACK: scale should not be done here
-	box.scale(Vector3(3, 3, 3));
+	box.scale(Vector3(msVizScale, msVizScale, msVizScale));
+
 	mWireBoundingBox->setupBoundingBox(box);
 	mWireBoundingBox->getRenderOperation(rend);
@@ -224,3 +231,10 @@
 
 }
-}
+
+#ifdef GTP_VISIBILITY_MODIFIED_OGRE
+void OctreeNode::setVizScale(Real scale)
+{
+	msVizScale = scale;
+}
+#endif // GTP_VISIBILITY_MODIFIED_OGRE
+}
Index: trunk/VUT/work/iv/IVFrameListener.cpp
===================================================================
--- trunk/VUT/work/iv/IVFrameListener.cpp	(revision 187)
+++ trunk/VUT/work/iv/IVFrameListener.cpp	(revision 187)
@@ -0,0 +1,1164 @@
+#include <OgreNoMemoryMacros.h>
+#include <CEGUI/CEGUI.h>
+#include <../CEGUIRenderer/include/OgreCEGUIRenderer.h>
+#include <../CEGUIRenderer/include/OgreCEGUIResourceProvider.h>
+#include <../CEGUIRenderer/include/OgreCEGUITexture.h>
+#include <OgreMemoryMacros.h>
+#include "IVFrameListener.h"
+#include "OgreVisibilityOctreeSceneManager.h"
+#include "VisibilityInfo.h"
+#include "TestCullingIVApplication.h"
+
+
+//-- captions for overlays
+String IVFrameListener::msAlgorithmCaptions[] = 
+{
+	"Coherent Hierarchical Culling",
+	"View Frustum Culling", 
+	"Stop and Wait Culling"
+};
+
+
+// output file for frame info
+const char* frames_out_filename = "frame.out";
+// output file for object positions / orientations
+const char* objects_out_filename = "objects.out";
+
+
+//-----------------------------------------------------------------------
+IVFrameListener::IVFrameListener(RenderWindow* win, Camera* cam, 
+									   SceneManager *sceneManager, 
+									   CEGUI::Renderer *renderer,
+									   Camera *vizCamera,
+									   SceneNode *camNode,
+									   Light *sunLight,
+									   TestCullingIVApplication *app): 
+mCamera(cam),
+mWindow(win),
+mNumScreenShots(0),
+mTimeDelay(0),
+mSceneDetailIndex(0),
+mMoveScale(0.0f),
+mRotScale(0.0f),
+mTranslateVector(Vector3::ZERO),
+mAniso(1),
+mFiltering(TFO_BILINEAR), 
+mGUIRenderer(renderer), 
+mSceneMgr(sceneManager),
+mVisibilityThreshold(0),
+mAssumedVisibility(0),
+mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),
+mNodeVizMode(NODEVIZ_NONE),
+mVizCameraHeight(Real(2500.0)),
+mCamNode(camNode),
+mAppState(WALKTHROUGH),
+mCurrentFrame(0),
+mReplayTimeElapsed(0),
+mRotateSpeed(72),
+mVizCamera(vizCamera),
+mStatsOn(true),
+mShutdownRequested(false), 
+mLMouseDown(false),
+mRMouseDown(false),
+mShowOctree(false),
+mUseDepthPass(false),
+mTestGeometryForVisibleLeaves(false),
+mShowVisualization(false),
+mCullCamera(false),
+mRecord(false),
+mShowShadows(false),
+mShowHelp(false),
+mDisplayCameraDetails(false),
+mVisualizeCulledNodes(false),
+mSunLight(sunLight),
+mShiftPressed(false),
+mShowQueryStats(false),
+mVisibilityManager(NULL),
+mDelayedQueriesIssued(0.0),
+mDelayedTraversedNodes(0.0),
+mApplication(app),
+mMoveSpeed(15)
+{
+	mRaySceneQuery = mSceneMgr->createRayQuery(
+        Ray(mCamNode->getPosition(), Vector3::NEGATIVE_UNIT_Y));
+
+	//mInputDevice = PlatformManager::getSingleton().createInputReader();
+	//mInputDevice->initialise(win, true, true);
+
+	mEventProcessor = new EventProcessor();
+	
+	mEventProcessor->initialise(win);
+	mEventProcessor->startProcessingEvents();
+	mEventProcessor->addMouseListener(this);
+	mEventProcessor->addMouseMotionListener(this);
+	mEventProcessor->addKeyListener(this);
+
+	mInputDevice = mEventProcessor->getInputReader();	
+
+	//-- overlays
+	mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
+	mHelpOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/HelpOverlay"); 
+	mQueryOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/QueryOverlay"); 
+	mCullStatsOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/CullStatsOverlay"); 
+
+	initVisStatsOverlay(); // visibility stats overlay
+	initHelpOverlay(); // help overlay
+	initQueryOverlay(); // visibility query stats overlay
+
+	// show stats overlays
+	showStats(true);
+	
+	// set culling algorithm type
+	setAlgorithm(mCurrentAlgorithm);
+
+	// set scene manager options
+	mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves);
+
+	// apply delayed rendering (i.e., transparents after hierarchical culling pass)
+	// only if optimization is not used 
+	bool delayRenderTransparents = !mTestGeometryForVisibleLeaves;
+
+	mSceneMgr->setOption("DelayRenderTransparents", &delayRenderTransparents);
+	mSceneMgr->setOption("UseDepthPass", &mUseDepthPass);
+	
+	mSceneMgr->setOption("ShowOctree", &mShowOctree);
+	mSceneMgr->setOption("CullCamera", &mCullCamera);
+	mSceneMgr->setOption("PrepareVisualization", &mShowVisualization);
+
+	// reset statistics
+	resetStats();
+} 
+//-----------------------------------------------------------------------
+IVFrameListener::~IVFrameListener()
+{
+	OGRE_DELETE(mEventProcessor);
+	OGRE_DELETE(mRaySceneQuery);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::mouseMoved(MouseEvent *e)
+{
+	// Update CEGUI with the mouse motion
+    CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * 
+		mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight());
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::mousePressed(MouseEvent* e)
+{
+     // Left mouse button down
+     if (e->getButtonID() & InputEvent::BUTTON0_MASK)
+     {
+		 CEGUI::MouseCursor::getSingleton().hide();
+		
+         mLMouseDown = true; 
+     }
+     // Right mouse button down
+     else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
+     {
+         CEGUI::MouseCursor::getSingleton().hide();
+         mRMouseDown = true;
+     }
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::mouseDragDropped(MouseEvent* e)
+{
+	// Left mouse button up
+    if (e->getButtonID() & InputEvent::BUTTON0_MASK)
+    {
+		CEGUI::MouseCursor::getSingleton().show();
+		
+	    mLMouseDown = false;
+    }
+    // Right mouse button up
+    else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
+    {
+        CEGUI::MouseCursor::getSingleton().show();
+
+		mRMouseDown = false;
+    }
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::mouseReleased(MouseEvent* e)
+{
+    // Left mouse button up
+    if (e->getButtonID() & InputEvent::BUTTON0_MASK)
+    {
+		CEGUI::MouseCursor::getSingleton().show();
+		
+	    mLMouseDown = false;
+    }
+    // Right mouse button up
+    else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
+    {
+        CEGUI::MouseCursor::getSingleton().show(); 
+
+        mRMouseDown = false;
+    }
+} 
+//-----------------------------------------------------------------------
+void IVFrameListener::mouseDragged(MouseEvent *e)
+ {
+	 // If we are dragging the left mouse button.	 	 
+	 if (mLMouseDown)
+     {
+     }
+	 // If we are dragging the right mouse button.
+	 if (mRMouseDown)
+	 {
+		 mCamNode->yaw(-e->getRelX() * mRotateSpeed);
+		 mCamNode->pitch(-e->getRelY() * mRotateSpeed);
+	 }
+}
+//-----------------------------------------------------------------------
+bool IVFrameListener::frameStarted(const FrameEvent &evt)
+{
+	if (mWindow->isClosed())
+	{
+        return false;
+	}
+
+	if (mDisplayCameraDetails)  // Print camera details
+    {       
+        mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + 
+			" " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation()));
+    }
+
+	//-- setup what is needed for immediate mouse/key movement
+	if (mTimeDelay >= 0) 
+	{
+		mTimeDelay -= evt.timeSinceLastFrame;
+	}
+	
+	// If this is the first frame, pick a speed
+	if (evt.timeSinceLastFrame == 0)
+	{
+		mMoveScale = 1;
+		mRotScale = 0.1;
+	}
+	// Otherwise scale movement units by time passed since last frame
+	else
+	{
+		// Move about 100 units per second,
+		mMoveScale = mMoveSpeed * evt.timeSinceLastFrame;
+		// Take about 10 seconds for full rotation
+		mRotScale = mRotateSpeed * evt.timeSinceLastFrame;
+	}
+
+	mRotX = 0;
+	mRotY = 0;
+	mTranslateVector = Vector3::ZERO;
+
+	if (!processUnbufferedKeyInput(evt))
+	{
+		return false;
+	}
+/*	if (!processUnbufferedMouseInput(evt))
+	{	return false;	}*/
+
+	// --- set parameters for visualization
+	if (mShowVisualization)
+	{
+		// important for visualization => draw octree bounding boxes
+		mSceneMgr->setOption("ShowOctree", &mShowVisualization);
+		
+		// ---- setup visualization camera
+
+		mVizCamera->setPosition(0, 0, 0);
+		mVizCamera->setOrientation(Quaternion::IDENTITY);
+
+		Vector3 camPos = mCamNode->getPosition();
+		mVizCamera->setPosition(camPos.x, mVizCameraHeight, camPos.z);
+
+		// point down -Z axis
+		mVizCamera->pitch(Radian(Degree(270.0)));
+
+		// rotation arounnd X axis
+		mVizCamera->yaw(Math::ATan2(-mCamera->getDerivedDirection().x, 
+			-mCamera->getDerivedDirection().z));
+		
+		// move by a constant so view plane is on bottom of viewport
+		mVizCamera->moveRelative(Vector3(0, 800, 0));
+	}
+
+	//-- set application state
+	switch (mAppState)
+	{
+	case REPLAY:
+		setCurrentFrameInfo(evt.timeSinceLastFrame);
+		break;
+	case WALKTHROUGH:
+		//-- if we are recording camera status per frame
+		if (mRecord)
+		{
+			addFrameInfo(mCamNode, evt.timeSinceLastFrame);
+			// print recording message
+			mWindow->setDebugText("Recording frame " + 
+				StringConverter::toString(mFrameInfo.size() - 1));
+		}	
+	
+		// move camera according to input
+		moveCamera();
+
+		// clamp camera so we always walk along the floor plane
+		Clamp2Floor();
+
+		break;
+
+	default:
+		break;
+	};	
+
+	return true;
+}
+//-----------------------------------------------------------------------
+bool IVFrameListener::Clamp2Floor()
+{
+	// clamp to floor plane
+	Ray updateRay;
+    updateRay.setOrigin(Vector3(mCamNode->getPosition().x, mCamNode->getPosition().y /*+ 2*/, 
+		mCamNode->getPosition().z));
+	//updateRay.setOrigin(Vector3(0, 100, -200));
+	updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y);
+    mRaySceneQuery->setRay(updateRay);
+
+	RaySceneQueryResult& qryResult = mRaySceneQuery->execute();
+    
+	RaySceneQueryResult::iterator it = qryResult.begin();
+ 
+	while (it != qryResult.end() && it->movable)
+	{
+		if (it->movable->getName() != "PlayerCam")
+		{
+			mCamNode->setPosition(mCamNode->getPosition().x, 
+				it->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;
+		}
+		++ it;
+	}
+	return false;
+}
+//-----------------------------------------------------------------------
+bool IVFrameListener::frameEnded(const FrameEvent& evt)
+{
+	if (mShutdownRequested)
+		return false;
+
+    updateStats();
+
+	//-- IMPORTANT
+	mSceneMgr->endFrame();
+
+	if (mTimeDelay <= 0) // approx. one second
+		mTimeDelay = 1.0;
+
+	return true;
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::moveCamera()
+{
+	// move node rather than camera so orientation is right in the visualization
+	mCamNode->yaw(mRotX);
+	mCamNode->pitch(mRotY);
+	mCamNode->translate(mCamNode->getLocalAxes(), mTranslateVector);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::writeFrames()
+{
+	std::ofstream ofstr(frames_out_filename);
+	
+	std::vector<frame_info>::const_iterator it, it_end;
+
+	it_end = mFrameInfo.end();
+	for (it = mFrameInfo.begin(); it < it_end; ++it)
+	{
+		ofstr << StringConverter::toString((*it).position) << " " 
+			  << StringConverter::toString((*it).orientation) << " "
+			  << StringConverter::toString((*it).timeElapsed) << "\n";
+	}
+	ofstr.close();
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::loadFrames()
+{
+	std::ifstream ifstr(frames_out_filename);
+	char line[256];
+	frame_info info;
+
+	// reset current values
+	mFrameInfo.clear();
+	mCurrentFrame = 0;
+	
+	while (!ifstr.eof()) 
+	{
+		ifstr.getline(line, 256);
+		sscanf(line, "%f %f %f %f %f %f %f %f", &info.position.x, &info.position.y, &info.position.z,
+			   &info.orientation.w, &info.orientation.x, &info.orientation.y, &info.orientation.z,
+			   &info.timeElapsed);
+		
+		mFrameInfo.push_back(info);
+	}
+	ifstr.close();
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::nextAppState()
+{
+	mCurrentFrame = 0;
+
+	// if last state was replay state
+	if (mAppState == REPLAY)
+	{
+		// reset debug text and write frame info to file
+		mWindow->setDebugText("");
+		writeFrames();
+		
+		float avgFps = (float)mAvgFps / (float)mFrameCount;
+
+		//-- write out stats for recorded walkthrough
+		std::stringstream d;
+		d << "Algorithm: " << msAlgorithmCaptions[mCurrentAlgorithm] << "\n"
+		  //<< "avg. FPS: " << mWindow->getAverageFPS() << "\n"
+		  << "avg. FPS: " << avgFps << "\n"
+		  << "best FPS: " << mWindow->getBestFPS() << "\n"
+		  << "worst FPS: " << mWindow->getWorstFPS() << "\n"
+		  << "best frame time: " <<	mWindow->getBestFrameTime() << "\n"
+		  << "worst frame time: " << mWindow->getWorstFrameTime();
+ 		
+		LogManager::getSingleton().logMessage(d.str());
+	}
+	
+	//-- set the next státe
+	mAppState = (mAppState + 1) % STATE_NUM;
+
+	// replay recorded walkthrough
+	if (mAppState == REPLAY)
+	{
+		// no recording during replay
+		mRecord = false;
+
+		// load recorded walkthrough
+		if (mFrameInfo.size() == 0)
+		{
+			loadFrames();
+		}
+
+		// if there are no recorded frames => set next state
+		if (mFrameInfo.size() == 0) 
+		{
+			nextAppState();
+		}
+		else
+		{
+			mWindow->setDebugText("Replay");
+			
+			// reset, because we measure fps stats during walkthrough (warning: average fps broken)
+			mWindow->resetStatistics();
+			resetStats();
+
+			//-- initialise frame data
+			mReplayTimeElapsed = 0;
+
+			mCamNode->setPosition(mFrameInfo[0].position);
+			mCamNode->setOrientation(mFrameInfo[0].orientation);
+		}
+	}
+
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleRecord()
+{
+	mRecord = !mRecord;
+
+	// clear previous camera path
+	if (mRecord)
+		mFrameInfo.clear();
+	else
+		mWindow->setDebugText("");
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::changeThreshold(int incr)
+{
+	mVisibilityThreshold += incr; 
+	if(mVisibilityThreshold < 0) mVisibilityThreshold = 0;
+	
+	char str[100]; sprintf(str,": %d", mVisibilityThreshold);
+
+	mSceneMgr->setOption("Threshold", &mVisibilityThreshold); 
+	mThresholdInfo->setCaption(str);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::changeAssumedVisibility(int incr)
+{
+	mAssumedVisibility += incr; 
+	if(mAssumedVisibility < 0) mAssumedVisibility = 0;
+	
+	char str[100]; sprintf(str,": %d", mAssumedVisibility);
+
+	mSceneMgr->setOption("AssumedVisibility", &mAssumedVisibility); 
+	mAssumedVisibilityInfo->setCaption(str);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::zoomVizCamera(int zoom)
+{
+	mVizCameraHeight += zoom; 
+	if(mVizCameraHeight < 0) mVizCameraHeight = 0;
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::nextAlgorithm()
+{
+	mCurrentAlgorithm = (mCurrentAlgorithm + 1) % 
+		(GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS - 1);
+	setAlgorithm(mCurrentAlgorithm);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::setAlgorithm(int algorithm)
+{
+	mAlgorithmInfo->setCaption(": " + msAlgorithmCaptions[mCurrentAlgorithm]);
+	mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::resetStats()
+{
+	mAvgFps = 0;
+	mFrameCount = 0;
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::updateStats()
+{
+	unsigned int opt = 0;
+	char str[100];
+	
+	static String currFpsString = "Current FPS: ";
+	static String avgFpsString = "Average FPS: ";
+	static String bestFpsString = "Best FPS: ";
+	static String worstFpsString = "Worst FPS: ";
+	static String trisString = "Triangle Count: ";
+
+	// HACK: compute average fps ourselfs, because ogre avg. fps is wrong
+	// TODO: update only once per second
+	mAvgFps += mWindow->getStatistics().lastFPS;
+	++ mFrameCount;
+	
+	float avgFps = (float)mAvgFps / (float)mFrameCount;
+    
+	// update stats when necessary
+    try 
+	{
+		OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
+		OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
+		OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
+		OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
+
+		const RenderTarget::FrameStats& stats = mWindow->getStatistics();
+
+		//guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
+		if (mTimeDelay < 0) // only update once per second
+		{		
+			guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps) + " ms");
+		}
+
+		guiCurr->setCaption(currFpsString + StringConverter::toString(stats.lastFPS));
+		guiBest->setCaption(bestFpsString + StringConverter::toString(stats.bestFPS)
+			+" "+StringConverter::toString(stats.bestFrameTime) + " ms");
+		guiWorst->setCaption(worstFpsString + StringConverter::toString(stats.worstFPS)
+			+" "+StringConverter::toString(stats.worstFrameTime) + " ms");
+
+		OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
+        guiTris->setCaption(trisString + StringConverter::toString(stats.triangleCount));
+
+		OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
+		guiDbg->setCaption(mWindow->getDebugText());
+
+		//-- culling stats
+		mSceneMgr->getOption("NumFrustumCulledNodes", &opt); sprintf(str,": %d", opt); 
+		mFrustumCulledNodesInfo->setCaption(str);
+
+		mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt); 
+		mQueryCulledNodesInfo->setCaption(str);
+	
+		mSceneMgr->getOption("NumHierarchyNodes", &opt); sprintf(str,": %d", opt); 
+		mHierarchyNodesInfo->setCaption(str);
+
+		mSceneMgr->getOption("NumRenderedNodes", &opt); sprintf(str,": %d", opt); 
+		mRenderedNodesInfo->setCaption(str);
+
+	//	sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount()); 
+	//	mObjectsCountInfo->setCaption(str);
+
+		// take old value into account in order to create no sudden changes
+		mSceneMgr->getOption("NumQueriesIssued", &opt); 
+		mDelayedQueriesIssued = mDelayedQueriesIssued * 0.8 + (float)opt * 0.2;
+		sprintf(str,": %d", (int)mDelayedQueriesIssued); 
+		mQueriesIssuedInfo->setCaption(str);
+
+		mSceneMgr->getOption("NumTraversedNodes", &opt); 
+		mDelayedTraversedNodes = mDelayedTraversedNodes * 0.8 + (float)opt * 0.2;
+		sprintf(str,": %d", (int)mDelayedTraversedNodes); 
+		mTraversedNodesInfo->setCaption(str);
+
+	}
+	catch (...)
+	{
+		// ignore
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleTestGeometryForVisibleLeaves()
+{
+	mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves;
+	mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves);
+	
+	/* disable optimization which tests geometry instead of aabb
+	 * for "delayed" rendering of transparents (i.e., render transparents after all the solids)
+	 * because otherwise visible transparents could be skipped
+	 */
+	bool delayedRendering = !mTestGeometryForVisibleLeaves;
+
+	mSceneMgr->setOption("DelayRenderTransparents", &delayedRendering);
+
+	if (mTestGeometryForVisibleLeaves)
+	{
+		mTestGeometryForVisibleLeavesInfo->setCaption(": true");
+	}
+	else
+	{
+		mTestGeometryForVisibleLeavesInfo->setCaption(": false");
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleShowOctree()
+{
+	mShowOctree = !mShowOctree;
+
+	mSceneMgr->setOption("ShowOctree", &mShowOctree);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleUseDepthPass()
+{
+	mUseDepthPass = !mUseDepthPass;
+
+	mSceneMgr->setOption("UseDepthPass", &mUseDepthPass);
+	
+	if (mUseDepthPass)
+	{
+		mUseDepthPassInfo->setCaption(": true");
+	}
+	else
+	{
+		mUseDepthPassInfo->setCaption(": false");
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleShowViz()
+{
+	mVisualizeCulledNodes = mShowVisualization = !mShowVisualization;
+	
+	// create viewport with priority VIZ_VIEWPORT_Z_ORDER: 
+	// will be rendered over standard viewport
+	if (mShowVisualization)
+	{	
+		Viewport *vizvp = mWindow->addViewport(mVizCamera, 
+			VIZ_VIEWPORT_Z_ORDER, 0.6, 0.6, 0.4, 0.4); 
+				
+		vizvp->setBackgroundColour(ColourValue(0.0, 0.3, 0.2, 1));
+
+		vizvp->setOverlaysEnabled(false);
+		// Alter the camera aspect ratio to match the viewport
+        mVizCamera->setAspectRatio(Real(vizvp->getActualWidth()) / 
+								   Real(vizvp->getActualHeight()));
+		
+		mSceneMgr->setOption("VisualizeCulledNodes", &mVisualizeCulledNodes);
+	}
+	else
+	{
+		// remove visualization viewport
+		mWindow->removeViewport(VIZ_VIEWPORT_Z_ORDER);
+
+		// octree bounding boxes are shown for visualization purpose, reset now
+		mSceneMgr->setOption("ShowOctree", &mShowOctree);
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleShowShadows()
+{
+	mShowShadows = !mShowShadows;
+
+	mSunLight->setCastShadows(mShowShadows);
+
+	if (mShowShadows)
+	{
+		mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
+		//mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_MODULATIVE);
+		//mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);		
+	}
+	else
+	{
+		mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
+	}
+
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::nextNodeVizMode()
+{
+	mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM;
+
+	bool renderNodesForViz = (mNodeVizMode == NODEVIZ_RENDER_NODES) || 
+		(mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT);
+	bool renderNodesContentForViz = (mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT);
+	//bool renderNodesContentForViz = mNodeVizMode == NODEVIZ_RENDER_GEOMETRY;
+
+	mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz);
+	mSceneMgr->setOption("RenderNodesContentForViz", &renderNodesContentForViz);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::keyPressed(KeyEvent* e)
+{
+	// hide exact visibility query overlay
+	if (mShowQueryStats)
+	{
+		mQueryOverlay->hide();
+		mShowQueryStats = false;
+	}
+
+	switch(e->getKey())
+	{
+	case KC_ESCAPE:
+		mShutdownRequested = true;
+		e->consume();
+		return;
+
+	case KC_SPACE:
+		nextAlgorithm();
+		break;
+	
+    case KC_F:
+		nextFilter();
+		break;
+	case KC_R:
+		nextSceneDetailLevel();
+		break;
+	case KC_P:
+		toggleDisplayCameraDetails();
+		break;
+	case KC_G:
+		toggleTestGeometryForVisibleLeaves();
+		break;
+	case KC_T:
+		toggleShowOctree();
+		break;
+	case KC_X:
+		toggleUseDepthPass();
+		break;
+	case KC_S:
+		toggleShowShadows();
+		break;
+	case KC_SUBTRACT:
+		changeThreshold(-10);
+		break;
+	case KC_ADD:
+		changeThreshold(10);
+		break;
+
+	//-- visualization
+	case KC_1:
+		toggleShowViz();
+		break;
+	case KC_2:
+		nextNodeVizMode();
+		break;
+
+	case KC_F1:
+		toggleShowHelp();
+		break;
+	case KC_F2:
+		toggleShowStats();
+		break;
+	case KC_F3:
+		nextAppState();
+		break;
+	case KC_F4:
+		toggleRecord();
+		break;
+
+	case KC_F11:
+		takeScreenshot();
+		break;
+
+	case KC_8:
+		changeAssumedVisibility(-1);
+		break;
+	case KC_9:
+		changeAssumedVisibility(1);
+		break;
+	case KC_LSHIFT:
+		mShiftPressed = true;
+		break;
+
+	default:
+		break;
+	}
+
+	CEGUI::System::getSingleton().injectKeyDown(e->getKey());
+	CEGUI::System::getSingleton().injectChar(e->getKeyChar());
+	e->consume();
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::keyReleased(KeyEvent* e)
+{
+	if (e->getKey() == KC_LSHIFT)
+	{
+		mShiftPressed = false;
+	}
+	
+	CEGUI::System::getSingleton().injectKeyUp(e->getKey());
+	e->consume();
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::keyClicked(KeyEvent* e) 
+{
+	// Do nothing
+	e->consume();
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::addFrameInfo(SceneNode *camNode, Real timeElapsed)
+{
+	frame_info info;
+	info.orientation = mCamNode->getOrientation();
+	info.position = mCamNode->getPosition();
+	info.timeElapsed = timeElapsed;
+
+	mFrameInfo.push_back(info);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::setCurrentFrameInfo(Real timeElapsed)
+{
+	//-- find current frame relative to elapsed frame time		
+	mReplayTimeElapsed -= timeElapsed;
+
+	while ((mReplayTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1))
+	{
+		mReplayTimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed;
+	}
+
+	frame_info new_frame = mFrameInfo[mCurrentFrame];
+	frame_info old_frame = mFrameInfo[mCurrentFrame - 1];
+		
+	//-- interpolate frames
+	Real factor = 1;
+
+	if (old_frame.timeElapsed > 0)
+	{
+		factor = mReplayTimeElapsed / old_frame.timeElapsed;
+	}
+
+	Vector3 camPos = old_frame.position + factor 
+		* (new_frame.position - old_frame.position);
+	Quaternion camOrienation = Quaternion::Slerp(factor, old_frame.orientation, 
+		new_frame.orientation, true);
+
+	mCamNode->setPosition(camPos);
+	mCamNode->setOrientation(camOrienation);
+	
+	// stop replay after a full walkthrough
+	if (mCurrentFrame == (int)mFrameInfo.size() - 1)
+	{
+		nextAppState();
+	}
+}
+//-----------------------------------------------------------------------    
+bool IVFrameListener::processUnbufferedKeyInput(const FrameEvent& evt)
+{
+	bool cursorPressed = false;
+	
+	/* Move camera forward by keypress. */
+    if (mInputDevice->isKeyDown(KC_UP))
+	{
+		mTranslateVector.z = -mMoveScale;
+		cursorPressed = true;
+	}
+    /* Move camera backward by keypress. */
+    if (mInputDevice->isKeyDown(KC_DOWN))
+    {
+		mTranslateVector.z = mMoveScale;
+		cursorPressed = true;
+    }
+
+    if (mInputDevice->isKeyDown(KC_RIGHT))
+    {
+        //mCamNode->yaw(-mRotScale);
+		mRotX = -mRotScale;
+		cursorPressed = true;
+    }
+	
+    if (mInputDevice->isKeyDown(KC_LEFT))
+    {
+		mRotX = mRotScale;
+        //mCamNode->yaw(mRotScale);
+		cursorPressed = true;
+    }
+	// visualization camera
+	if (mInputDevice->isKeyDown(KC_3))
+	{
+		zoomVizCamera(50);
+	}
+	if (mInputDevice->isKeyDown(KC_4))
+	{
+		zoomVizCamera(-50);
+	}
+
+	// show the results
+	if (cursorPressed && mShowQueryStats)
+	{
+		mQueryOverlay->hide();
+		mShowQueryStats = false;
+	}
+
+    // Return true to continue rendering
+    return true;
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::nextFilter()
+{
+	switch (mFiltering)
+	{
+	case TFO_BILINEAR:
+		mFiltering = TFO_TRILINEAR;
+		mAniso = 1;
+		break;
+	case TFO_TRILINEAR:
+		mFiltering = TFO_ANISOTROPIC;
+		mAniso = 8;
+		break;
+	case TFO_ANISOTROPIC:
+		mFiltering = TFO_BILINEAR;
+		mAniso = 1;
+		break;
+	default:
+		break;
+	}
+
+    MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering);
+    MaterialManager::getSingleton().setDefaultAnisotropy(mAniso);
+
+	// reload stats
+    showStats(mStatsOn);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::nextSceneDetailLevel()
+{
+	mSceneDetailIndex = (mSceneDetailIndex + 1) % 3;
+	switch (mSceneDetailIndex) 
+	{
+		case 0: 
+			mCamera->setDetailLevel(SDL_SOLID); 
+			break;
+		case 1: 
+			mCamera->setDetailLevel(SDL_WIREFRAME); 
+			break;
+		case 2: 
+			mCamera->setDetailLevel(SDL_POINTS); 
+			break;
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::takeScreenshot()
+{
+	char tmp[20];
+	sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots);
+    mWindow->writeContentsToFile(tmp);
+    mWindow->setDebugText(String("Wrote ") + tmp);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleDisplayCameraDetails()
+{
+	mDisplayCameraDetails = !mDisplayCameraDetails;
+        
+    if (!mDisplayCameraDetails)
+	{
+		mWindow->setDebugText("");
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::showStats(bool show)
+{
+	if (mDebugOverlay && mCullStatsOverlay)
+	{
+		if (show)
+		{
+			mDebugOverlay->show();
+			mCullStatsOverlay->show();
+		}
+		else
+		{
+			mDebugOverlay->hide();
+			mCullStatsOverlay->hide();
+		}
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleShowStats()
+{
+	mStatsOn = !mStatsOn;
+
+	showStats(mStatsOn);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::toggleShowHelp()
+{
+	mShowHelp = !mShowHelp;
+
+	if (mShowHelp)
+	{
+		mHelpOverlay->show();
+	}
+	else
+	{
+		mHelpOverlay->hide();
+	}
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::initOverlayElement(OverlayElement **elInfo, String ext, 
+											  String name, int top, String caption)
+{
+	OverlayElement *el = 
+		OverlayManager::getSingleton().getOverlayElement(ext + name);
+
+	(*elInfo) = OverlayManager::getSingleton().getOverlayElement(ext + name + "Info");
+	(*elInfo)->setCaption(caption);
+
+	el->setTop(top);
+	(*elInfo)->setTop(top);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::initHelpOverlayElement(String name, int top)
+{
+	OverlayElement *el = OverlayManager::getSingleton().getOverlayElement(
+		"Example/Visibility/Help/" + name);
+
+	el->setTop(top);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::initHelpOverlay()
+{
+	const int vert_space = 15;
+	int top = 30;
+
+	initHelpOverlayElement("ShowHelp", top); top += vert_space;
+	initHelpOverlayElement("Stats", top); top += vert_space;
+	initHelpOverlayElement("AppState", top); top += vert_space;
+	initHelpOverlayElement("Recorded", top); top += vert_space;
+	initHelpOverlayElement("Animation", top); top += vert_space;
+	initHelpOverlayElement("Screenshots", top); top += vert_space;
+	initHelpOverlayElement("WriteOut", top); top += vert_space;
+
+	top +=vert_space;
+	initHelpOverlayElement("SceneDetail", top); top += vert_space;
+	initHelpOverlayElement("DisplayCameraDetails", top); top += vert_space;
+	initHelpOverlayElement("DisplayOctree", top); top += vert_space;
+	initHelpOverlayElement("UseShadows", top); top += vert_space;
+	initHelpOverlayElement("Filter", top); top += vert_space;
+
+	//-- visualization
+	top += vert_space;
+	initHelpOverlayElement("VizSection", top); top += vert_space;
+	initHelpOverlayElement("Viz", top); top += vert_space;
+	initHelpOverlayElement("NextVizMode", top); top += vert_space;
+	initHelpOverlayElement("ZoomViz", top); top += vert_space;
+
+
+	//-- visibility queries
+	top += vert_space;
+	initHelpOverlayElement("VisQuery", top); top += vert_space;
+	initHelpOverlayElement("FromCameraQuery", top); top += vert_space;
+	initHelpOverlayElement("FromPointQuery", top); top += vert_space;
+	initHelpOverlayElement("QueryType", top); top += vert_space;
+	initHelpOverlayElement("QueryTarget", top); top += vert_space;
+
+	//-- object generation
+	top += vert_space;
+	initHelpOverlayElement("SceneObjects", top); top += vert_space;
+	initHelpOverlayElement("GenerateObjects", top); top += vert_space;
+	initHelpOverlayElement("RemoveObjects", top); top += vert_space;
+	initHelpOverlayElement("DropObject", top); top += vert_space;
+
+	OverlayElement *helpPanel = OverlayManager::getSingleton().getOverlayElement(
+		"Example/Visibility/Help/HelpPanel");
+
+	helpPanel->setHeight(top + 10);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::initVisStatsOverlay()
+{
+	const int border_height = 10;
+	const int vert_space = 15;
+
+	//-- visibility culling stats overlay
+	int top = border_height;
+
+	String ext = "Example/Visibility/";
+	
+	initOverlayElement(&mAlgorithmInfo, ext, "Algorithm", top,
+		": " + msAlgorithmCaptions[mCurrentAlgorithm]); top += vert_space;
+
+	initOverlayElement(&mThresholdInfo, ext, "Threshold", top, ": 0"); top += vert_space;
+	initOverlayElement(&mTestGeometryForVisibleLeavesInfo, ext, 
+		"TestGeometryForVisibleLeaves", top, ": true"); top += vert_space;
+	initOverlayElement(&mUseDepthPassInfo, ext, "UseDepthPass", top, ": false"); top += vert_space;
+	initOverlayElement(&mAssumedVisibilityInfo, ext, "AssumedVisibility", top, ": 0"); top += vert_space;
+	initOverlayElement(&mCurrentObjectTypeInfo, ext, "CurrentObjectType", top, ": "); top += vert_space;
+	//initOverlayElement(&mHelpInfo, ext, "Help", top, ": "); top += vert_space;
+
+	OverlayElement *optionsPanel = OverlayManager::getSingleton().
+		getOverlayElement("Example/Visibility/VisibilityPanel");
+
+	optionsPanel->setHeight(top + border_height);
+
+	top = border_height;
+	//ext = "Example/Visibility/";
+	initOverlayElement(&mFrustumCulledNodesInfo, ext, "FrustumCulledNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mQueryCulledNodesInfo, ext, "QueryCulledNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mTraversedNodesInfo, ext, "TraversedNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mHierarchyNodesInfo, ext, "HierarchyNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mRenderedNodesInfo, ext, "RenderedNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mObjectsCountInfo, ext, "ObjectsCount", top, ": 0"); top += vert_space;
+	initOverlayElement(&mQueriesIssuedInfo, ext, "QueriesIssued", top, ": 0"); top += vert_space;
+
+	OverlayElement *visPanel = OverlayManager::getSingleton().
+		getOverlayElement("Example/Visibility/VisibilityStatsPanel");
+
+	visPanel->setHeight(top + border_height);
+}
+//-----------------------------------------------------------------------
+void IVFrameListener::initQueryOverlay()
+{
+	const int border_height = 10;
+	const int vert_space = 15;
+
+	//-- visibility culling stats overlay
+	int top = border_height + 25;
+
+	String ext = "Example/Visibility/Query/";
+	    
+	initOverlayElement(&mQueryTypeInfo , ext, "QueryType", top,	": 0"); top += vert_space;
+	
+	initOverlayElement(&mQueryVisibleNodesInfo , ext, "VisibleNodes", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryVisibleGeometryInfo , ext, "VisibleGeometry", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryVisiblePatchInfo , ext, "VisiblePatches", top,	": 0"); top += vert_space;
+	
+	initOverlayElement(&mQueryNodeVisibilityInfo , ext, "NodeVisibility", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryGeometryVisibilityInfo , ext, "GeometryVisibility", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryPatchVisibilityInfo , ext, "PatchVisibility", top,	": 0"); top += vert_space;
+
+
+	OverlayElement *queryPanel = OverlayManager::getSingleton().
+		getOverlayElement("Example/Visibility/Query/QueryPanel");
+
+	queryPanel->setHeight(top + border_height);
+}
Index: trunk/VUT/work/iv/TestCullingIVApplication.cpp
===================================================================
--- trunk/VUT/work/iv/TestCullingIVApplication.cpp	(revision 187)
+++ trunk/VUT/work/iv/TestCullingIVApplication.cpp	(revision 187)
@@ -0,0 +1,317 @@
+#include <OgreNoMemoryMacros.h>
+#include <CEGUI/CEGUI.h>
+#include <../CEGUIRenderer/include/OgreCEGUIRenderer.h>
+#include <../CEGUIRenderer/include/OgreCEGUIResourceProvider.h>
+#include <../CEGUIRenderer/include/OgreCEGUITexture.h>
+#include <OgreMemoryMacros.h>
+
+#include <Ogre.h>
+
+//#include "OgreReferenceAppLayer.h"
+//#include "OgreRefAppWorld.h"
+#include "TestCullingIVApplication.h"
+#include "IVFrameListener.h"
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+
+/*********************************************************/
+/*        TestCullingIVApplication implementation        */
+/*********************************************************/
+
+//-----------------------------------------------------------------------
+TestCullingIVApplication::TestCullingIVApplication()
+{
+	mIVReader = new IVReader();
+}
+//-----------------------------------------------------------------------
+TestCullingIVApplication::~TestCullingIVApplication()
+{
+	OGRE_DELETE(mIVReader);
+}
+//-----------------------------------------------------------------------
+void TestCullingIVApplication::createCamera()
+{
+	// create the camera
+	mCamera = mSceneMgr->createCamera("PlayerCam");
+	// Look back along -Z
+    mCamera->lookAt(Vector3(0, 0, -300));
+	
+	/** set a nice viewpoint
+	*	we use a camera node here and apply all transformations on it instead
+	*	of applying all transformations directly to the camera
+	*	because then the camera is displayed correctly in the visualization
+	*/
+	mCamNode = mSceneMgr->getRootSceneNode()->
+		createChildSceneNode("CamNode1", Vector3(0, -100, -200));
+
+	mCamNode->attachObject(mCamera);
+	//mCamNode->lookAt(Vector3(0, 0, -300), Node::TS_WORLD); 
+	//mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));
+
+	//-- create visualization camera
+	mVizCamera = mSceneMgr->createCamera("VizCam");
+	mVizCamera->setPosition(mCamNode->getPosition());
+
+	mVizCamera->setNearClipDistance(1);
+	mCamera->setNearClipDistance(1);
+
+	// infinite far plane?
+	if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
+	{
+		mVizCamera->setFarClipDistance(0);
+		mCamera->setFarClipDistance(0);
+	}
+	else
+	{
+		 mVizCamera->setFarClipDistance(20000);
+		 mCamera->setFarClipDistance(20000);
+	}	
+}
+
+//-----------------------------------------------------------------------
+bool TestCullingIVApplication::setup()
+{
+	bool carryOn = ExampleApplication::setup();
+
+	if (carryOn)
+		createRenderTargetListener();
+
+	return carryOn;
+}
+//-----------------------------------------------------------------------
+void TestCullingIVApplication::createRenderTargetListener()
+{
+	mWindow->addListener(new VisualizationRenderTargetListener(mSceneMgr));
+}
+//-----------------------------------------------------------------------
+void TestCullingIVApplication::createScene()
+{
+	Real scale = 1;
+	mSceneMgr->setOption("NodeVizScale", &scale);
+
+	String path = "E:/gametools/trunk/VUT/Ogre/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 (mIVReader->loadFile("media\\house_test1.iv"))
+	{
+		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);
+	}*/
+
+	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);
+	}
+
+	mIVReader->collapse();
+
+	
+	// Set ambient light
+	mAmbientLight = ColourValue(0.5 , 0.5, 0.5);
+	mSceneMgr->setAmbientLight(mAmbientLight);
+	
+	//-- create light
+	mSunLight = mSceneMgr->createLight("SunLight");
+	mSunLight->setType(Light::LT_DIRECTIONAL);
+	//mSunLight->setType(Light::LT_SPOTLIGHT);
+	//mSunLight->setSpotlightRange(Degree(30), Degree(50));
+
+    mSunLight->setPosition(707, 2000, 500);
+	mSunLight->setCastShadows(true);
+
+	// set light angle not too small over the surface, otherwise shadows textures will be broken
+	Vector3 dir(0.5, 1, 0.5);
+	dir.normalise();
+	mSunLight->setDirection(dir);
+	//mSunLight->setDirection(Vector3::NEGATIVE_UNIT_Y);
+	mSunLight->setDiffuseColour(1, 1, 1);
+	mSunLight->setSpecularColour(1, 1, 1);
+
+	// -- Fog
+	// NB it's VERY important to set this before calling setWorldGeometry 
+	// because the vertex program picked will be different
+	ColourValue fadeColour(0.93, 0.86, 0.76);
+	mWindow->getViewport(0)->setBackgroundColour(fadeColour);
+	//mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000);
+	
+	// Create a skybox
+	mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true);
+	
+	
+	//-- CEGUI setup
+	setupGui();
+
+	// Use 512x512 texture in GL since we can't go higher than the window res
+	mSceneMgr->setShadowTextureSettings(512, 2);
+
+	mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5));
+}
+//-----------------------------------------------------------------------
+void TestCullingIVApplication::setupGui()
+{
+	 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, 
+		 false, 3000, ST_EXTERIOR_CLOSE);
+     mGUISystem = new CEGUI::System(mGUIRenderer);
+
+	 // Mouse
+     CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
+     CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
+	 mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", 
+									   (CEGUI::utf8*)"MouseArrow");
+
+	 CEGUI::MouseCursor::getSingleton().show();
+}
+//-----------------------------------------------------------------------
+void TestCullingIVApplication::createFrameListener()
+{
+	mIVFrameListener = new IVFrameListener(mWindow, mCamera, mSceneMgr, 
+		mGUIRenderer, mVizCamera, mCamNode, mSunLight, this);
+	
+	mRoot->addFrameListener(mIVFrameListener);
+}
+//-----------------------------------------------------------------------
+void TestCullingIVApplication::chooseSceneManager()
+{
+	mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
+}
+
+
+
+/**************************************************************/
+/*      VisualizationRenderTargetListener implementation      */
+/**************************************************************/
+
+//-----------------------------------------------------------------------
+VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr)
+:RenderTargetListener(), mSceneMgr(sceneMgr)
+{
+}
+//-----------------------------------------------------------------------
+void VisualizationRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt)
+{
+	// visualization viewport
+	const bool showViz = evt.source->getZOrder() == VIZ_VIEWPORT_Z_ORDER;
+	const bool nShowViz = !showViz;
+
+	mSavedShadowTechnique = mSceneMgr->getShadowTechnique();
+	mSavedAmbientLight = mSceneMgr->getAmbientLight();
+
+	// -- ambient light must be full for visualization, shadows disabled
+    if (showViz)
+	{
+		mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));
+		mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
+	}
+	
+    mSceneMgr->setOption("PrepareVisualization", &showViz);
+	mSceneMgr->setOption("SkyBoxEnabled", &nShowViz);
+	//mSceneMgr->setOption("SkyPlaneEnabled", &showViz);
+	
+	RenderTargetListener::preViewportUpdate(evt);
+}
+//-----------------------------------------------------------------------
+void VisualizationRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt)
+{
+	// reset values
+	mSceneMgr->setShadowTechnique(mSavedShadowTechnique);
+	mSceneMgr->setAmbientLight(mSavedAmbientLight);
+	
+	RenderTargetListener::postRenderTargetUpdate(evt);
+}
+//-----------------------------------------------------------------------
+INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
+{
+    // Create application object
+    TestCullingIVApplication app;
+
+	try 
+	{
+        app.go();
+    } 
+	catch( Ogre::Exception& e ) 
+	{
+        MessageBox( NULL, e.getFullDescription().c_str(), 
+			"An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
+    }	
+
+    return 0;
+}
Index: trunk/VUT/work/iv/Demo_IV.vcproj
===================================================================
--- trunk/VUT/work/iv/Demo_IV.vcproj	(revision 187)
+++ trunk/VUT/work/iv/Demo_IV.vcproj	(revision 187)
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="Demo_IV"
+	ProjectGUID="{640481BA-D8FE-41ED-B2F2-9844A8CA1E40}"
+	SccProjectName=""
+	SccLocalPath="">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\..\bin\$(ConfigurationName)"
+			IntermediateDirectory=".\..\obj\$(ConfigurationName)"
+			ConfigurationType="1"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="FALSE"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\IVReader\include;&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;..\..\GtpVisibility\include;..\include"
+				PreprocessorDefinitions="NDEBUG;_WINDOWS;WIN32;GTP_VISIBILITY_MODIFIED_OGRE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=""
+				AssemblerListingLocation=".\..\obj\Release/"
+				ObjectFile=".\..\obj\Release/"
+				ProgramDataBaseFileName=".\..\obj\Release/"
+				BrowseInformation="1"
+				BrowseInformationFile=".\..\obj\Release/"
+				WarningLevel="3"
+				SuppressStartupBanner="TRUE"
+				DebugInformationFormat="3"
+				CompileAs="0"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				IgnoreImportLibrary="TRUE"
+				AdditionalDependencies="OGREMain.LIB CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib IVReader.lib"
+				OutputFile="$(OGRE_PATH)/Samples/Common/bin/Release/Demo_IV.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="TRUE"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)&quot;;&quot;..\IVReader\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(GAMETOOLS_PATH)\trunk\VUT\Ogre\lib\$(ConfigurationName)&quot;"
+				ProgramDatabaseFile=".\..\bin\Release/Demo_IV.pdb"
+				SubSystem="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="TRUE"
+				SuppressStartupBanner="TRUE"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\bin\Release/Demo_IV.tlb"
+				HeaderFileName=""/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2057"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\..\bin\Debug"
+			IntermediateDirectory=".\..\obj\Debug"
+			ConfigurationType="1"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="FALSE"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/Zm500 "
+				Optimization="0"
+				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;"
+				PreprocessorDefinitions="_WINDOWS;_DEBUG;WIN32;GTP_VISIBILITY_MODIFIED_OGRE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				PrecompiledHeaderFile=".\..\obj\Debug/Demo_IV.pch"
+				AssemblerListingLocation=".\..\obj\Debug/"
+				ObjectFile=".\..\obj\Debug/"
+				ProgramDataBaseFileName=".\..\obj\Debug/"
+				WarningLevel="3"
+				SuppressStartupBanner="TRUE"
+				DebugInformationFormat="4"
+				CompileAs="0"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				IgnoreImportLibrary="TRUE"
+				AdditionalDependencies="odbc32.lib odbccp32.lib OgreMain_d.lib"
+				OutputFile="$(OGRE_PATH)/Samples/Common/bin/Debug/Demo_IV.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="TRUE"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)&quot;"
+				IgnoreDefaultLibraryNames="LIBCMT"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile=".\..\bin\Debug/Demo_IV.pdb"
+				SubSystem="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="TRUE"
+				SuppressStartupBanner="TRUE"
+				TargetEnvironment="1"
+				TypeLibraryName=".\..\bin\Debug/Demo_IV.tlb"
+				HeaderFileName=""/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2057"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+			<File
+				RelativePath=".\IVFrameListener.cpp">
+			</File>
+			<File
+				RelativePath=".\TestCullingIVApplication.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl">
+			<File
+				RelativePath=".\IVFrameListener.h">
+			</File>
+			<File
+				RelativePath=".\TestCullingIVApplication.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: trunk/VUT/work/iv/IVFrameListener.h
===================================================================
--- trunk/VUT/work/iv/IVFrameListener.h	(revision 187)
+++ trunk/VUT/work/iv/IVFrameListener.h	(revision 187)
@@ -0,0 +1,252 @@
+#ifndef _IVFrameListener_H__
+#define _IVFrameListener_H__
+
+#include "CEGUIForwardRefs.h"
+#include <Ogre.h>
+#include <OgreKeyEvent.h>
+#include <OgreEventListeners.h>
+#include <OgreStringConverter.h>
+#include <OgreException.h>
+#include "VisibilityEnvironment.h"
+#include "VisibilityManager.h"
+
+
+
+class TestCullingIVApplication;
+
+
+using namespace Ogre;
+
+
+/** Frame listener specialised for terrains.
+*/
+class IVFrameListener: public FrameListener, public MouseListener, 
+							public MouseMotionListener, public KeyListener
+{
+public:
+
+	IVFrameListener(RenderWindow* win, 
+						Camera* cam, 
+						SceneManager *sceneManager, 
+						CEGUI::Renderer *renderer, 
+						Camera *vizCamera,
+						SceneNode *camNode, 
+						Light *sunLight,
+						TestCullingIVApplication *app);
+
+	~IVFrameListener();
+
+
+	bool frameStarted(const FrameEvent& evt);
+	bool frameEnded(const FrameEvent& evt);
+   //bool processUnbufferedKeyInput(const FrameEvent& evt);
+    
+
+	/* MouseListener callbacks. */
+	virtual void mouseClicked(MouseEvent* e) { }
+	virtual void mouseEntered(MouseEvent* e) { }
+	virtual void mouseExited(MouseEvent* e)  { }
+
+	// This is when the mouse button goes DOWN.
+	void mousePressed(MouseEvent* e);
+
+	// This is when the mouse button is let UP.
+	void mouseReleased(MouseEvent* e);
+
+	/* MouseMotionListener callbacks */
+	void mouseMoved(MouseEvent *e);
+
+	// This is when the mouse is clicked, held and dragged.
+	void mouseDragged(MouseEvent *e);
+
+	void mouseDragDropped(MouseEvent *e);
+	void keyPressed(KeyEvent* e);
+
+	void keyReleased(KeyEvent* e);
+	void keyClicked(KeyEvent* e);
+
+	/** The information about camera position and orienation per frame.
+	*/
+	typedef struct
+	{
+		Vector3 position;
+		Quaternion orientation;
+		Real timeElapsed;
+	} frame_info;
+
+	enum  {WALKTHROUGH, REPLAY, STATE_NUM};
+
+	// visualization modes for scene nodes
+	enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES, NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
+	//enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM};
+
+	void zoomVizCamera(int zoom);
+
+	void addFrameInfo(SceneNode *camNode, Real timeElapsed);
+	void setCurrentFrameInfo(Real timeElapsed);
+
+	void setAlgorithm(int algorithm);
+
+	void moveCamera();
+
+	void writeFrames();
+	void loadFrames();
+
+	bool processUnbufferedKeyInput(const FrameEvent& evt);
+	bool processUnbufferedMouseInput(const FrameEvent& evt);
+
+	void showStats(bool show);
+
+	void updateStats();
+	void toggleShowHelp();
+	void toggleShowStats();
+
+	void toggleShowShadows();
+	void toggleDisplayCameraDetails();
+	void takeScreenshot();
+	void nextSceneDetailLevel();
+	void nextFilter();
+	void nextAlgorithm();
+	void nextNodeVizMode();
+	void nextAppState();
+	void changeThreshold(int incr);
+	void changeAssumedVisibility(int incr);
+	void toggleTestGeometryForVisibleLeaves();
+	void toggleShowOctree();
+	void toggleUseDepthPass();
+	void toggleShowViz();
+	void toggleRecord();
+
+	bool Clamp2Floor();
+
+	static String msAlgorithmCaptions[];
+		
+	protected:
+
+	void initHelpOverlayElement(String name, int top);
+	void initOverlayElement(OverlayElement **elInfo, String ext, String name, 
+							int top, String caption);
+
+	//-- initialise overlays
+	void initHelpOverlay();
+	void initVisStatsOverlay();
+	void initQueryOverlay();
+
+	void resetStats();
+
+	SceneManager *mSceneMgr;           // A pointer to the scene manager
+
+	CEGUI::Renderer *mGUIRenderer;     // cegui renderer
+
+	int mCurrentAlgorithm;
+	int mVisibilityThreshold;
+	int mAssumedVisibility;
+	// the current frame number
+	int mCurrentFrame;
+	// the current application state
+	int mAppState;
+	// visualization mode
+	int mNodeVizMode;
+
+
+	OverlayElement *mAlgorithmInfo;
+	OverlayElement *mThresholdInfo;
+	OverlayElement *mAssumedVisibilityInfo;
+	OverlayElement *mFrustumCulledNodesInfo;
+	OverlayElement *mQueryCulledNodesInfo;
+	OverlayElement *mTraversedNodesInfo;
+	OverlayElement *mHierarchyNodesInfo;
+	OverlayElement *mTestGeometryForVisibleLeavesInfo;
+	OverlayElement *mUseDepthPassInfo;
+	OverlayElement *mRenderedNodesInfo;
+	OverlayElement *mObjectsCountInfo;
+	OverlayElement *mQueriesIssuedInfo;
+	OverlayElement *mDelayedQueriesIssuedInfo;
+	OverlayElement *mDelayedTraversedNodesInfo;
+	OverlayElement *mCurrentObjectTypeInfo;
+
+	OverlayElement *mQueryTypeInfo;
+	OverlayElement *mQueryVisibleNodesInfo;
+	OverlayElement *mQueryVisibleGeometryInfo;
+	OverlayElement *mQueryVisiblePatchInfo;
+
+	OverlayElement *mQueryVisiblityInfo;
+	OverlayElement *mQueryNodeVisibilityInfo;
+	OverlayElement *mQueryGeometryVisibilityInfo;
+	OverlayElement *mQueryPatchVisibilityInfo;
+	//OverlayElement *mHelpInfo;
+	
+	bool mTestGeometryForVisibleLeaves;
+	bool mShowOctree;
+	bool mUseDepthPass;
+	bool mShowVisualization;
+	bool mCullCamera;
+	bool mRecord;
+	bool mShowShadows;
+	bool mVisualizeCulledNodes;
+	bool mShowHelp;
+	bool mStatsOn;
+	bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
+	bool mShutdownRequested;
+	bool mDisplayCameraDetails;
+	bool mUseItemBuffer;
+	bool mUseAnimation;
+
+	int mItemBufferMode;
+
+	Real mVizCameraHeight;
+
+	Camera *mVizCamera;
+	SceneNode *mCamNode;
+
+	std::vector<frame_info> mFrameInfo;
+		
+	Real mReplayTimeElapsed;
+	//EventProcessor* mEventProcessor;
+	InputReader* mInputDevice;
+	Camera* mCamera;
+
+	Vector3 mTranslateVector;
+	RenderWindow* mWindow;
+
+	unsigned int mNumScreenShots;
+	int mSceneDetailIndex;
+	int mAniso;
+
+	float mMoveScale;
+	Real mMoveSpeed;
+	Degree mRotScale;
+
+	// just to stop toggles flipping too fast
+	Real mTimeDelay;
+	Radian mRotX, mRotY;
+	TextureFilterOptions mFiltering;
+
+	Degree mRotateSpeed;
+
+	Overlay* mDebugOverlay;
+	Overlay* mHelpOverlay;
+	Overlay* mCullStatsOverlay;
+	Overlay* mQueryOverlay;
+
+	Light *mSunLight;
+	GtpVisibility::VisibilityManager *mVisibilityManager;
+	EventProcessor* mEventProcessor;
+
+	bool mShiftPressed;
+	bool mShowQueryStats;
+
+	unsigned long mAvgFps;
+	unsigned long mFrameCount;
+
+	//bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
+	
+	float mDelayedQueriesIssued;
+	float mDelayedTraversedNodes;
+
+	TestCullingIVApplication *mApplication;
+	RaySceneQuery *mRaySceneQuery;
+};
+
+
+#endif //_IVFrameListener_H__
Index: trunk/VUT/work/iv/TestCullingIVApplication.h
===================================================================
--- trunk/VUT/work/iv/TestCullingIVApplication.h	(revision 187)
+++ trunk/VUT/work/iv/TestCullingIVApplication.h	(revision 187)
@@ -0,0 +1,78 @@
+#ifndef _TestCullingIVApplication_H__
+#define _TestCullingIVApplication_H__
+
+#include "CEGUIForwardRefs.h"
+#include <OgreRenderTargetListener.h>
+#include "ExampleApplication.h"
+
+#include "ivreader.h"
+#include "IVFrameListener.h"
+
+
+// z order index of visualizaion viewport
+#define VIZ_VIEWPORT_Z_ORDER 10
+
+
+/** Rendertarget listener which shows a visualization.
+*/
+class VisualizationRenderTargetListener: public RenderTargetListener
+{
+public:
+	VisualizationRenderTargetListener(SceneManager *sceneMgr);
+
+protected:
+	void preViewportUpdate (const RenderTargetViewportEvent &evt);
+	void postRenderTargetUpdate (const RenderTargetEvent &evt);
+
+	SceneManager *mSceneMgr;
+	
+	ShadowTechnique mSavedShadowTechnique;
+	ColourValue mSavedAmbientLight;
+};
+
+
+class TestCullingIVApplication: public ExampleApplication
+{
+public:
+	TestCullingIVApplication();
+	~TestCullingIVApplication();
+
+	/** Generates a scene using num entities of a type. 
+		@param num the number of objects
+		@parma objectType the type of objects
+	*/
+	void generateScene(int num, int objectType);
+
+
+protected:
+
+	//-- inherited from ExampleApplication
+	bool setup();
+	void createScene();
+	void createFrameListener();
+	void createCamera();
+	//void createViewports();
+	
+	virtual void createRenderTargetListener();
+
+	/** cegui setup 
+	*/
+	void setupGui();
+
+	CEGUI::OgreCEGUIRenderer *mGUIRenderer;
+	CEGUI::System *mGUISystem;
+
+	Camera *mVizCamera;
+	SceneNode *mCamNode;
+	Light *mSunLight;
+
+	ColourValue mAmbientLight;
+
+	IVReader *mIVReader;
+	IVFrameListener *mIVFrameListener;
+
+private:
+	void chooseSceneManager(void);
+};
+
+#endif // TestCullingIVApplication
Index: trunk/VUT/work/iv/Demo_IV.dsp
===================================================================
--- trunk/VUT/work/iv/Demo_IV.dsp	(revision 187)
+++ trunk/VUT/work/iv/Demo_IV.dsp	(revision 187)
@@ -0,0 +1,141 @@
+# Microsoft Developer Studio Project File - Name="Demo_IV" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=Demo_IV - Win32 Debug
+!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
+!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
+!MESSAGE 
+!MESSAGE NMAKE /f "Demo_IV.mak".
+!MESSAGE 
+!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE 
+!MESSAGE NMAKE /f "Demo_IV.mak" CFG="Demo_IV - Win32 Debug"
+!MESSAGE 
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE 
+!MESSAGE "Demo_IV - Win32 Release" (basierend auf  "Win32 (x86) Application")
+!MESSAGE "Demo_IV - Win32 Debug" (basierend auf  "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "Demo_IV - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "..\bin\Release"
+# PROP BASE Intermediate_Dir "..\obj\Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\bin\Release"
+# PROP Intermediate_Dir "..\obj\Release"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Zi /Od /I "..\include" /I "..\..\Common\include" /I "..\..\..\OgreMain\include" /D "NDEBUG" /D "_MBCS" /D "_WINDOWS" /D "WIN32" /Fr /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib OgreMain.lib /nologo /subsystem:windows /machine:I386 /out:"../../Common/Bin/Release/Demo_IV.exe" /libpath:"..\..\..\OgreMain\lib\release"
+# SUBTRACT LINK32 /profile /debug
+
+!ELSEIF  "$(CFG)" == "Demo_IV - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "..\bin\Debug"
+# PROP BASE Intermediate_Dir "..\obj\Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\bin\Debug"
+# PROP Intermediate_Dir "..\obj\Debug"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\Common\include" /I "..\..\..\OgreMain\include" /D "_MBCS" /D "_WINDOWS" /D "_DEBUG" /D "WIN32" /FD /GZ /Zm500 /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib OgreMain_d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"LIBCMT" /out:"../../Common/Bin/Debug/Demo_IV.exe" /pdbtype:sept /libpath:"..\..\..\OgreMain\lib\debug"
+# SUBTRACT LINK32 /verbose
+
+!ENDIF 
+
+# Begin Target
+
+# Name "Demo_IV - Win32 Release"
+# Name "Demo_IV - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\src\IV.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivmanualmeshloader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivmeshdata.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivnode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivreader.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\src\ivmanualmeshloader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivmeshdata.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivnode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\ivreader.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
