Index: GTP/trunk/Lib/Vis/README_ONLINE.txt
===================================================================
--- GTP/trunk/Lib/Vis/README_ONLINE.txt	(revision 643)
+++ GTP/trunk/Lib/Vis/README_ONLINE.txt	(revision 657)
@@ -4,6 +4,4 @@
 1) Requirements: 
    WindowsXP
-   Ogre 1.03 for vs 7.1
-   Ogre Dependencies
    svn
 
@@ -11,36 +9,11 @@
    in the following it is assumed that your repository is located in e:\svn\gametools (not required, just replace your path)
 
-   deprecated: the current stable version is located in D:\gametools\branches\0.3
 
-2) add following environment variables:
-   OGRE_PATH: directory where ogre.sln is located
+3) add following environment variables:
+   OGRE_PATH: directory where ogre.sln is located (in directory OGRE)
 
-3) copy e:\svn\gametools\OGRE\trunk\ogre_changes into OGRE_PATH directory (only applies to version 1.03!!!!)
+4) Set preprocessor flag GTP_VISIBILITY_MODIFIED_OGRE to the example projects you want to use
 
-4) Set configuration of Ogre soluation to release. add preprocessor flag GTP_VISIBILITY_MODIFIED_OGRE to following projects:
-   Plugin_OctreeSceneManager
-   RenderSystem_GL
-   RenderSystem_Direct9
-   RenderSystem_Direct7
-   OgreMain
-   GuiRenderer
-   
-   Also add the flag to the example projects you want to use
+5) open scripts GTP\trunk\Lib\Vis\shared\GtpVisibility.sln and compile all
 
-5) Add following resources to OGRE_PATH\Samples\Common\bin\Release\resource.cfg:
-
-   FileSystem=e:\svn\gametools\OGRE\trunk\resources\materials\scripts
-   FileSystem=e:\svn\gametools\OGRE\trunk\resources\materials\textures
-   FileSystem=e:\svn\gametools\OGRE\trunk\resources\models
-   FileSystem=e:\svn\gametools\OGRE\trunk\resources\models\trees
-   FileSystem=e:\svn\gametools\OGRE\trunk\resources\overlays
-   FileSystem=e:\svn\gametools\OGRE\trunk\resources\media
-
-6) Add Plugin_VisibilitySceneManager to OGRE_PATH\Samples\Common\bin\Release\Plugins.cfg
-   and comment out OctreeSceneManager
-
-7) Copy D:\gametools\trunk\VUT\Ogre\resources\terrain.cfg into OGRE_PATH\Samples\Common\bin\Release
-
-8) open scripts\GtpVisibility.sln and compile all
-
-9) start TerrainExampleApplication for testing
+6) start TerrainExampleApplication for testing
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj	(revision 373)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj	(revision 657)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;GTP_VISIBILITY_MODIFIED_OGRE"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj	(revision 643)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj	(revision 657)
@@ -20,5 +20,5 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\GtpVisibility\include"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\GtpVisibility\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_OCCLUSIONCULLINGSCENEMANAGER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
 				MinimalRebuild="TRUE"
@@ -36,8 +36,8 @@
 				Name="VCLinkerTool"
 				IgnoreImportLibrary="TRUE"
-				AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_OctreeSceneManager.lib Plugin_DotSceneManager.lib GtpVisibility.lib"
+				AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib"
 				OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll"
 				Version="0.99"
-				LinkIncremental="2"
+				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"
 				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\bin\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp	(revision 133)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp	(revision 657)
@@ -74,8 +74,9 @@
 extern "C" void __declspec(dllexport) dllStopPlugin()
 {
-	delete heightmapTerrainPageSource;
+	//delete heightmapTerrainPageSource;
 
-	delete visibilityOctreePlugin;
-	delete visibilityTerrainPlugin;
+	// (HACK: crashes on delete!!!! FIX this 
+	//delete visibilityOctreePlugin;
+	//delete visibilityTerrainPlugin;
 	//delete occlusionDotPlugin;
 	
Index: GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 508)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 657)
@@ -61,10 +61,10 @@
 //  StdInParseHandlers: Constructors and Destructor
 // ---------------------------------------------------------------------------
-X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root) :
+X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root, const bool loadPolygonsAsMeshes):
   mElementCount(0)
   , mAttrCount(0)
   , mCharacterCount(0)
   , mSpaceCount(0)
- // , mCurrentObjectId(0)
+  , mLoadPolygonsAsMeshes(loadPolygonsAsMeshes)
 {
   mCurrentNode = root;
@@ -124,6 +124,20 @@
 	if (ptr == endptr || index == -1) {
 	  if (vertices.size() > 2) {
-	    Face *face = new Face(vertices);
-	    mCurrentMesh->mFaces.push_back(face);
+		  Face *face = new Face(vertices);
+
+		   mCurrentMesh->mFaces.push_back(face);
+
+		   // every polygon is a mesh => store in mesh instance and create new mesh
+		  if (mLoadPolygonsAsMeshes)
+		  {
+			  mCurrentMesh->Preprocess();
+
+			  // make an instance of this mesh
+			  MeshInstance *mi = new MeshInstance(mCurrentMesh);
+			  mCurrentNode->mGeometry.push_back(mi);
+
+			  mCurrentMesh = new Mesh();
+		  }
+
 	  }
 	  vertices.clear();
@@ -163,34 +177,53 @@
 				  AttributeList&  attributes)
 {
-  int len = attributes.getLength();
-  int i;
-  VertexContainer vertices;
-  for (i=0; i < len; i++) {
-    string attrName(StrX(attributes.getName(i)).LocalForm());
-    if (attrName == "point") {
-      StrX attrValue(attributes.getValue(i));
-      const char *ptr = attrValue.LocalForm();
-      char *endptr;
-      while(1) {
-	float x = (float)strtod(ptr, &endptr);
-	if (ptr == endptr)
-	  break;
-	ptr = endptr;
-	float y = (float)strtod(ptr, &endptr);
-	if (ptr == endptr)
-	  break;
-	ptr = endptr;
-	float z = (float)strtod(ptr, &endptr);
-	if (ptr == endptr)
-	  break;
-	ptr = endptr;
-	if (*ptr == ',')
-	  ptr++;
-	Vector3 v(x, y, z);
-	vertices.push_back(v);
-      }
-      mCurrentMesh->mVertices = vertices;
-    }
-  }
+	int len = attributes.getLength();
+	
+	int i;
+	VertexContainer vertices;
+	
+	for (i=0; i < len; i++) 
+	{
+		string attrName(StrX(attributes.getName(i)).LocalForm());
+	  
+		if (attrName == "point") 
+		{
+			StrX attrValue(attributes.getValue(i));
+		  
+
+			const char *ptr = attrValue.LocalForm();
+			char *endptr;
+
+
+			while(1) 
+			{
+				float x = (float)strtod(ptr, &endptr);
+                
+				if (ptr == endptr)
+				  break;
+			  
+				ptr = endptr;
+				
+				float y = (float)strtod(ptr, &endptr);
+			  
+				if (ptr == endptr)
+					break;
+
+				ptr = endptr;
+			  
+				float z = (float)strtod(ptr, &endptr);
+				if (ptr == endptr)
+					break;
+			  
+				ptr = endptr;
+			  
+				if (*ptr == ',')
+					ptr ++;
+
+				Vector3 v(x, y, z);
+				vertices.push_back(v);
+			}
+			mCurrentMesh->mVertices = vertices;
+		}
+	}
 }
 
@@ -284,5 +317,6 @@
 bool
 X3dParser::ParseFile(const string filename,
-		     SceneGraphNode **root)
+					 SceneGraphNode **root,
+					 const bool loadPolygonsAsMeshes)
 {
   // Initialize the XML4C system
@@ -317,5 +351,5 @@
   //
   *root = new SceneGraphNode;
-  X3dParseHandlers handler(*root);
+  X3dParseHandlers handler(*root, loadPolygonsAsMeshes);
   parser->setDocumentHandler(&handler);
   parser->setErrorHandler(&handler);
@@ -389,5 +423,5 @@
 // ---------------------------------------------------------------------------
 X3dViewCellsParseHandlers::X3dViewCellsParseHandlers(ViewCellsManager *viewCellsManager, 
-													 float viewCellHeight):
+													 const float viewCellHeight):
 mElementCount(0), 
 mAttrCount(0), 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h	(revision 490)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h	(revision 657)
@@ -12,5 +12,5 @@
   X3dParser():Parser(), mViewCellHeight(5.0f) {}
   
-  bool ParseFile(const string filename, SceneGraphNode **root);
+  bool ParseFile(const string filename, SceneGraphNode **root, const bool loadPolygonsAsMeshes = false);
   bool ParseFile(const string filename, ViewCellsManager &viewCells);
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h	(revision 490)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h	(revision 657)
@@ -24,5 +24,5 @@
   //  Constructors and Destructor
   // -----------------------------------------------------------------------
-  X3dParseHandlers(SceneGraphNode *root);
+  X3dParseHandlers(SceneGraphNode *root, const bool loadPolygonsAsMeshes = false);
   ~X3dParseHandlers();
   
@@ -64,5 +64,5 @@
   Mesh *mCurrentMesh;
   Material *mCurrentMaterial;
-  //int mCurrentObjectId;
+  bool mLoadPolygonsAsMeshes;
 
   // Handlers for X3D
@@ -117,5 +117,5 @@
   // -----------------------------------------------------------------------
   X3dViewCellsParseHandlers(ViewCellsManager *viewCellsManager, 
-							float viewCellHeight);
+							const float viewCellHeight);
   ~X3dViewCellsParseHandlers();
   
@@ -156,4 +156,5 @@
   ViewCellsManager *mViewCellsManager;
   float mViewCellHeight;
+ 
 
   VertexIndexContainer mCurrentVertexIndices;
Index: GTP/trunk/Lib/Vis/shared/EvalStats/stdafx.h
===================================================================
--- GTP/trunk/Lib/Vis/shared/EvalStats/stdafx.h	(revision 656)
+++ GTP/trunk/Lib/Vis/shared/EvalStats/stdafx.h	(revision 656)
@@ -0,0 +1,12 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#include <iostream>
+#include <tchar.h>
+
+// TODO: reference additional headers your program requires here
Index: GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp
===================================================================
--- GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp	(revision 656)
+++ GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp	(revision 656)
@@ -0,0 +1,82 @@
+// EvalStats.cpp : Defines the entry point for the console application.
+//
+#include "stdafx.h"
+
+#include <string>
+#include <vector>
+#include <istream>
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+
+bool extractRenderCost(ifstream &file, vector<float> &renderCosts)
+{
+	if (!file.is_open())
+		return false;
+		
+	string buf;
+	bool isRenderCost = false;
+
+	while (!(getline(file, buf)).eof())
+	{
+		if (buf[0] == '#')
+		{
+			char entry[50];	
+
+			sscanf(buf.c_str(), "#%s", entry);
+			
+			if (strcmp(entry, "TotalRenderCost") == 0)
+				isRenderCost = true;
+		}
+		else if (isRenderCost)
+		{
+			float rc;
+			sscanf(buf.c_str(), "%f", &rc);
+			
+			renderCosts.push_back(rc);
+			isRenderCost = false;
+		}
+	}
+
+	return true;
+}
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+	vector<float> renderCosts1;
+	vector<float> renderCosts2;
+	
+	ifstream file1(argv[1]);
+	ifstream file2(argv[2]);
+
+	ofstream statsOut(argv[3]);
+
+	extractRenderCost(file1, renderCosts1);
+	extractRenderCost(file2, renderCosts2);
+
+	//statsOut << "rc1 size: " << (int)renderCosts1.size() << " " << (int)renderCosts2.size() << endl << endl;
+	int n = min((int)renderCosts1.size(), (int)renderCosts2.size());
+	
+	if (argc > 4)
+	{
+		char *endptr = NULL;
+			
+		int limit = strtol(argv[4], &endptr, 10);
+		
+		n = min(n, limit);
+	}
+
+	for (int i = 0; i < n; ++ i)
+	{
+		float costRatio = renderCosts2[i] != 0 ? 
+			renderCosts1[i] / renderCosts2[i] : renderCosts1[i] / 0.0000001f;
+
+		statsOut << "#ViewCells\n" << i + 1 << endl
+				 << "#RenderCostRatio\n" << costRatio * 100.0f << endl;
+	}
+
+	return 0;
+}
+
Index: GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.vcproj	(revision 656)
+++ GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.vcproj	(revision 656)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="EvalStats"
+	ProjectGUID="{935D1BDD-41B0-49F1-A86C-EB49B94DDB20}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="5"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/EvalStats.exe"
+				LinkIncremental="2"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/EvalStats.pdb"
+				SubSystem="1"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="4"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/EvalStats.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<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;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath=".\EvalStats.cpp">
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath=".\stdafx.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: GTP/trunk/Lib/Vis/shared/EvalStats/stdafx.cpp
===================================================================
--- GTP/trunk/Lib/Vis/shared/EvalStats/stdafx.cpp	(revision 656)
+++ GTP/trunk/Lib/Vis/shared/EvalStats/stdafx.cpp	(revision 656)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// EvalStats.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
