Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling03.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling03.vcproj	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling03.vcproj	(revision 2800)
@@ -0,0 +1,357 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="FriendlyCulling"
+	ProjectGUID="{D1E30B8F-194B-4487-8303-D2CF90ED0048}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="bin/Debug"
+			IntermediateDirectory="bin/Debug"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="5"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib"
+				OutputFile="$(OutDir)/FriendlyCulling.exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/FriendlyCulling.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="bin/Release"
+			IntermediateDirectory="obj/Release"
+			ConfigurationType="1"
+			CharacterSet="2"
+			WholeProgramOptimization="TRUE">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				StringPooling="TRUE"
+				RuntimeLibrary="4"
+				EnableEnhancedInstructionSet="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib"
+				OutputFile="$(OutDir)/FriendlyCulling.exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib"
+				GenerateDebugInformation="TRUE"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="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>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="utils"
+			Filter="">
+			<Filter
+				Name="Source Files"
+				Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+				UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+				<File
+					RelativePath=".\src\AxisAlignedBox3.cpp">
+				</File>
+				<File
+					RelativePath=".\src\BvhLoader.cpp">
+				</File>
+				<File
+					RelativePath=".\src\common.cpp">
+				</File>
+				<File
+					RelativePath=".\src\gzstream.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Material.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Matrix4x4.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Plane3.cpp">
+				</File>
+				<File
+					RelativePath=".\src\SceneQuery.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Texture.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Triangle3.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Vector3.cpp">
+				</File>
+			</Filter>
+			<Filter
+				Name="Timers"
+				Filter="">
+				<File
+					RelativePath=".\src\Timer\BenchTimer.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Timer\BenchTimer.h">
+				</File>
+				<File
+					RelativePath=".\src\Timer\merror.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Timer\merror.h">
+				</File>
+				<File
+					RelativePath=".\src\Timer\mstring.h">
+				</File>
+				<File
+					RelativePath=".\src\Timer\PerfTimer.h">
+				</File>
+				<File
+					RelativePath=".\src\Timer\PerfTimerSkeleton.h">
+				</File>
+				<File
+					RelativePath=".\src\Timer\RDTSCTimer.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Timer\RDTSCTimer.h">
+				</File>
+			</Filter>
+			<Filter
+				Name="Header Files"
+				Filter="h;hpp;hxx;hm;inl;inc;xsd"
+				UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+				<File
+					RelativePath=".\src\AxisAlignedBox3.h">
+				</File>
+				<File
+					RelativePath=".\src\BvhLoader.h">
+				</File>
+				<File
+					RelativePath=".\src\common.h">
+				</File>
+				<File
+					RelativePath=".\src\glInterface.h">
+				</File>
+				<File
+					RelativePath=".\src\gzstream.h">
+				</File>
+				<File
+					RelativePath=".\src\Matrix4x4.h">
+				</File>
+				<File
+					RelativePath=".\src\Plane3.h">
+				</File>
+				<File
+					RelativePath=".\src\SceneQuery.h">
+				</File>
+				<File
+					RelativePath=".\src\Texture.h">
+				</File>
+				<File
+					RelativePath=".\src\Triangle3.h">
+				</File>
+				<File
+					RelativePath=".\src\Vector3.h">
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="scene"
+			Filter="">
+			<Filter
+				Name="Header Files"
+				Filter="">
+				<File
+					RelativePath=".\src\Bvh.h">
+				</File>
+				<File
+					RelativePath=".\src\Camera.h">
+				</File>
+				<File
+					RelativePath=".\src\Geometry.h">
+				</File>
+				<File
+					RelativePath=".\src\Material.h">
+				</File>
+				<File
+					RelativePath=".\src\OcclusionQuery.h">
+				</File>
+				<File
+					RelativePath=".\src\RenderQueue.h">
+				</File>
+				<File
+					RelativePath=".\src\RenderState.h">
+				</File>
+				<File
+					RelativePath=".\src\ResourceManager.h">
+				</File>
+				<File
+					RelativePath=".\src\SceneEntity.h">
+				</File>
+				<File
+					RelativePath=".\src\Visualization.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Visualization.h">
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				Filter="">
+				<File
+					RelativePath=".\src\Bvh.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Camera.cpp">
+				</File>
+				<File
+					RelativePath=".\src\chcdemo.cpp">
+				</File>
+				<File
+					RelativePath=".\src\Geometry.cpp">
+				</File>
+				<File
+					RelativePath=".\src\OcclusionQuery.cpp">
+				</File>
+				<File
+					RelativePath=".\src\RenderQueue.cpp">
+				</File>
+				<File
+					RelativePath=".\src\RenderState.cpp">
+				</File>
+				<File
+					RelativePath=".\src\ResourceManager.cpp">
+				</File>
+				<File
+					RelativePath=".\src\SceneEntity.cpp">
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="traversal"
+			Filter="">
+			<Filter
+				Name="Header Files"
+				Filter="">
+				<File
+					RelativePath=".\src\CHCPlusPlusTraverser.h">
+				</File>
+				<File
+					RelativePath=".\src\CHCTraverser.h">
+				</File>
+				<File
+					RelativePath=".\src\FrustumCullingTraverser.h">
+				</File>
+				<File
+					RelativePath=".\src\RenderTraverser.h">
+				</File>
+				<File
+					RelativePath=".\src\StopAndWaitTraverser.h">
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				Filter="">
+				<File
+					RelativePath=".\src\CHCPlusPlusTraverser.cpp">
+				</File>
+				<File
+					RelativePath=".\src\CHCTraverser.cpp">
+				</File>
+				<File
+					RelativePath=".\src\FrustumCullingTraverser.cpp">
+				</File>
+				<File
+					RelativePath=".\src\RenderTraverser.cpp">
+				</File>
+				<File
+					RelativePath=".\src\StopAndWaitTraverser.cpp">
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln	(revision 2800)
@@ -0,0 +1,20 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chc_revisited", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{03661866-4093-4B02-B26A-028EA91AF023}.Debug|Win32.ActiveCfg = Debug|Win32
+		{03661866-4093-4B02-B26A-028EA91AF023}.Debug|Win32.Build.0 = Debug|Win32
+		{03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.ActiveCfg = Release|Win32
+		{03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCTraverser.h	(revision 2792)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCTraverser.h	(revision 2800)
@@ -14,8 +14,10 @@
 public:
 	CHCTraverser();
-	//~CHCTraverser();
+
+	virtual int GetType() const { return CHC; }
 
 	
 protected:
+
 	/** Optimized query querying the node geometry instead
 		of the bounding box
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.h	(revision 2800)
@@ -16,5 +16,6 @@
 	StopAndWaitTraverser();
 
-	//~StopAndWaitTraverser();
+	int GetType() const { return STOP_AND_WAIT; }
+
 
 protected:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.cpp	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.cpp	(revision 2800)
@@ -2,5 +2,4 @@
 #include "glInterface.h"
 #include "common.h"
-
 
 #include <IL/il.h>
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.h	(revision 2800)
@@ -33,5 +33,6 @@
 	
 	CHCPlusPlusTraverser();
-	//~CHCPlusPlusTraverser();
+
+	virtual int GetType() const { return CHCPLUSPLUS;}
 
 
@@ -45,5 +46,5 @@
 	/** Computes the next multiquery.
 	*/
-	OcclusionQuery *GetNextMultiQuery(BvhNodeQueue &iqueue);
+	OcclusionQuery *GetNextMultiQuery(BvhNodeContainer &iqueue);
 	/** Issues batched multiqueries.
 	*/
@@ -59,6 +60,6 @@
 	QueryQueue mQueryQueue;
 
-	BvhNodeQueue mIQueue;
 	BvhNodeQueue mVQueue;
+	BvhNodeContainer mIQueue;
 
 	VisibilityPredictor mVisibilityPredictor;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2798)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2800)
@@ -27,6 +27,10 @@
 	mNumIssuedQueries = 0;
 	mNumStateChanges = 0;
+	mNumBatches = 0;
 
 	mRenderTime = 0;
+	mWaitTime = 0;
+	mQueryTime = 0;
+	mRestTime = 0;
 }
 
@@ -132,4 +136,6 @@
 	PerfTimer timer;
 	
+	glFinish();
+
 	timer.Start();
 
@@ -154,4 +160,6 @@
 	// render the contents of the render queue
 	if (mUseRenderQueue) ApplyRenderQueue();
+	
+	// reset the render state
 	mRenderState->Reset();
 
@@ -159,7 +167,16 @@
 	glDisableClientState(GL_NORMAL_ARRAY);
 
+	glFinish();
+
+
 	mStats.mRenderTime = timer.Elapsedms();
 	
+	//Debug << "type: " << GetType() << endl;
 	//if (mUseRenderQueue) Debug << "rq sort: " << 1e3f * mRenderQueue.sortTimer.TotalTime() << " ms" << endl;
+	/*
+	Debug << "wait time: " << 1e3f * waitTimer.TotalTime() << " ms" << endl;
+	Debug << "query time: " << 1e3f * queryTimer.TotalTime() << " ms" << endl;
+	Debug << "rest time: " << 1e3f * restTimer.TotalTime() << " ms" << endl;
+	*/
 }
 
@@ -219,8 +236,12 @@
 OcclusionQuery *RenderTraverser::IssueOcclusionQuery(BvhNode *node)
 {
+	queryTimer.Entry();
+
 	OcclusionQuery *query = mQueryHandler.RequestQuery();
 	query->AddNode(node);
 
 	IssueOcclusionQuery(*query);
+
+	queryTimer.Exit();
 
 	return query;
@@ -254,4 +275,7 @@
 		++ mStats.mNumStateChanges;
 		 
+	if (mRenderQueue.GetSize() > 0)
+		++ mStats.mNumBatches;
+
 	mRenderQueue.Apply();
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2800)
@@ -109,4 +109,5 @@
 	mIsFrustumCulled = false;
 	mIsNew = true;
+	mLastQueriedFrame = -1;
 }
 
@@ -609,5 +610,5 @@
 					GL_STATIC_DRAW_ARB);
 
-	//glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
 
 	// data handled by graphics driver from now on
@@ -904,4 +905,6 @@
 		}
 	}
+
+	ResetNodeClassifications();
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp	(revision 2786)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp	(revision 2800)
@@ -65,5 +65,5 @@
 QueryHandler::QueryHandler(): mCurrentQueryIdx(0) 
 {
-	Allocate(1000);
+	Allocate(500);
 }
 
@@ -99,4 +99,5 @@
 {
 	CLEAR_CONTAINER(mOcclusionQueries);
+	
 	mCurrentQueryIdx = 0;
 	mOcclusionQueries.clear();
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2800)
@@ -48,4 +48,5 @@
 	inline int GetCurrentVboId() { return mCurrentVboId; }
 
+
 protected:
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.h	(revision 2800)
@@ -16,4 +16,6 @@
 	FrustumCullingTraverser();
 
+	virtual int GetType() const { return CULL_FRUSTUM; }
+
 protected:
 	/** Traverses and renders the scene with the specified method
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h	(revision 2800)
@@ -4,4 +4,5 @@
 #include "common.h"
 #include "AxisAlignedBox3.h"
+
 
 namespace CHCDemoEngine
@@ -22,5 +23,4 @@
 	bool CalcIntersection(Vector3 &pt);
 
-
 protected:
 
@@ -32,5 +32,5 @@
 	AxisAlignedBox3 mSceneBox;
 
-	float *mDepth;
+	unsigned char *mDepth;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp	(revision 2800)
@@ -33,5 +33,7 @@
 				OcclusionQuery *query = IssueOcclusionQuery(node);
 
+				waitTimer.Entry();
 				bool visible = query->GetQueryResult() > mVisibilityThreshold;
+				waitTimer.Exit();
 
 				if (visible)
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/gzstream.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/gzstream.h	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/gzstream.h	(revision 2800)
@@ -0,0 +1,146 @@
+// ============================================================================
+// gzstream, C++ iostream classes wrapping the zlib compression library.
+// Copyright (C) 2001  Deepak Bandyopadhyay, Lutz Kettner
+//
+// This library 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.1 of the License, or (at your option) any later version.
+//
+// This library 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 library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// ============================================================================
+//
+// File          : gzstream.h
+// Revision      : $Revision: 1.1 $
+// Revision_date : $Date: 2004/02/16 14:46:00 $
+// Author(s)     : Deepak Bandyopadhyay, Lutz Kettner
+// 
+// Standard streambuf implementation following Nicolai Josuttis, "The 
+// Standard C++ Library".
+// ============================================================================
+
+#ifndef GZSTREAM_H
+#define GZSTREAM_H 1
+
+#include <zlib.h>
+
+// standard C++ with new header file names and std:: namespace
+#include <iostream>
+#include <fstream>
+
+#ifdef GZSTREAM_NAMESPACE
+namespace GZSTREAM_NAMESPACE {
+#endif
+
+// ----------------------------------------------------------------------------
+// Internal classes to implement gzstream. See below for user classes.
+// ----------------------------------------------------------------------------
+
+   // size of data buff
+#define gzbufferSize  303   
+
+
+
+#define STREAMBUF std::streambuf 
+#define ISTREAM std::istream
+#define OSTREAM std::ostream
+
+//#define STREAMBUF streambuf 
+//#define ISTREAM istream
+//#define OSTREAM ostream
+
+class gzstreambuf : public STREAMBUF {
+
+private:
+    // totals 512 bytes under g++ for igzstream at the end.
+
+    gzFile           file;               // file handle for compressed file
+    char             buffer[gzbufferSize]; // data buffer
+    char             opened;             // open/close state of stream
+    int              mode;               // I/O mode
+
+    int flush_buffer();
+public:
+    gzstreambuf() : opened(0) {
+        setp( buffer, buffer + (gzbufferSize-1));
+        setg( buffer + 4,     // beginning of putback area
+              buffer + 4,     // read position
+              buffer + 4);    // end position      
+        // ASSERT: both input & output capabilities will not be used together
+    }
+    int is_open() const { return opened; }
+    gzstreambuf* open( const char* name, int open_mode);
+    gzstreambuf* close();
+    ~gzstreambuf() { close(); }
+  
+    virtual int     overflow( int c = EOF);
+    virtual int     underflow();
+    virtual int     sync();
+
+};
+
+class gzstreambase : virtual public std::ios {
+
+protected:
+    gzstreambuf buf;
+public:
+  gzstreambase() { init(&buf); }
+  gzstreambase( const char* name, int open_mode);
+  ~gzstreambase();
+  void open( const char* name, int open_mode);
+  void close();
+  gzstreambuf* rdbuf() { return &buf; }
+  int is_open() const { return buf.is_open(); }
+};
+
+// ----------------------------------------------------------------------------
+// User classes. Use igzstream and ogzstream analogously to ifstream and
+// ofstream respectively. They read and write files based on the gz* 
+// function interface of the zlib. Files are compatible with gzip compression.
+// ----------------------------------------------------------------------------
+
+  
+
+  class igzstream : public gzstreambase, public ISTREAM {
+  
+  public:
+    igzstream() : gzstreambase(), ISTREAM( &buf )  {} 
+    
+    igzstream( const char* name, int open_mode = std::ios::in)
+      : gzstreambase( name, open_mode), ISTREAM( &buf) {}
+    
+    gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
+    
+    void open( const char* name, int open_mode = std::ios::in) {
+      gzstreambase::open( name, open_mode);
+    }
+  };
+  
+class ogzstream : public gzstreambase, public OSTREAM {
+  
+public:
+  ogzstream() : OSTREAM( &buf) {}
+  ogzstream( const char* name, int mode = std::ios::out)
+    : gzstreambase( name, mode), OSTREAM( &buf) {}  
+  gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
+  void open( const char* name, int open_mode = std::ios::out) {
+    gzstreambase::open( name, open_mode);
+  }
+  
+};
+
+#ifdef GZSTREAM_NAMESPACE
+} // namespace GZSTREAM_NAMESPACE
+#endif
+
+#endif // GZSTREAM_H
+// ============================================================================
+// EOF //
+
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2797)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2800)
@@ -57,5 +57,5 @@
 int maxBatchSize = 50;
 
-int trianglesPerVirtualLeaf = 1000;
+int trianglesPerVirtualLeaf = INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES;
 
 SceneQuery *sceneQuery = NULL;
@@ -83,4 +83,5 @@
 int queryCulledNodes = 0;
 int stateChanges = 0;
+int numBatches = 0;
 
 bool showHelp = false;
@@ -98,4 +99,6 @@
 bool useRenderQueue = true;
 bool useMultiQueries = true;
+
+bool flyMode = true;
 
 /// the accumulated z axis rotation
@@ -233,5 +236,6 @@
 	visualization = new Visualization(bvh, camera, NULL, &state);
 
-	//sceneQuery = new SceneQuery(bvh->GetBox(), traverser);
+	sceneQuery = new SceneQuery(bvh->GetBox(), traverser);
+
 
 	glutMainLoop();
@@ -270,5 +274,5 @@
 	glEnable(GL_CULL_FACE);
 	//glDisable(GL_CULL_FACE);
-	
+	glDisable(GL_TEXTURE_2D);
 
 	GLfloat ambientColor[] = {0.5, 0.5, 0.5, 1.0};
@@ -292,5 +296,6 @@
 		"'F3'           - shows/hides bounds (boxes or tight bounds)",
 		"'F4'           - shows/hides statistics",
-		"'F5',          - shows/hides parameters",
+		"'F5',          - toggles between fly / walkmode",
+		"'F6',          - shows/hides parameters",
 		"'SPACE'        - cycles through occlusion culling algorithms",
 		"",
@@ -390,5 +395,6 @@
 	glEnable(GL_LIGHTING);
 	glEnable(GL_LIGHT0);
-	glEnable(GL_LIGHT1);
+	//glEnable(GL_LIGHT1);
+	glDisable(GL_LIGHT1);
 
 	//GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0};
@@ -424,10 +430,10 @@
 
 	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
-	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
-	//glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
+	//glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
+	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
 	//glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);
 	glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT);
-
-}
+}
+
 
 void SetupEyeView()
@@ -476,6 +482,7 @@
 void Display() 
 {
+	Vector3 oldPos = camera->GetPosition();
+
 	PerfTimer frameTimer;
-
 	frameTimer.Start();
 
@@ -493,8 +500,18 @@
 		KeyVerticalMotion(KeyShift());
 
-	
 	Vector3 playerPos = camera->GetPosition();
-	//sceneQuery->CalcIntersection(playerPos);
+	
+	if (!flyMode)
+	{
+	Vector3 playerPos = camera->GetPosition();
+
+		bool validIntersect = sceneQuery->CalcIntersection(playerPos);
+
+		if (validIntersect &&
+			(( playerPos.z - oldPos.z) < bvh->GetBox().Size(2) * 1e-1f))
+		{
 	camera->SetPosition(playerPos);
+		}
+	}
 
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -532,5 +549,5 @@
 		break;
 	case 32: //space
-		renderMode = (renderMode + 1) % RenderTraverser::NUM_RENDERMODES;
+		renderMode = (renderMode + 1) % RenderTraverser::NUM_TRAVERSAL_TYPES;
 		ResetTraverser();
 		break;
@@ -563,15 +580,9 @@
 		break;
 	case '8':
-		{
 			eightKeyPressed = true;
-			KeyVerticalMotion(-KeyShift());
 			break;
-		}
 	case '9':
-		{
 			nineKeyPressed = true;
-			KeyVerticalMotion(+KeyShift());
 			break;
-		}	
 	case 'o':
 	case 'O':
@@ -581,29 +592,17 @@
 	case 'a':
 	case 'A':
-		{
 			leftKeyPressed = true;
-			camera->Pitch(KeyRotationAngle());
-		}
 		break;
 	case 'd':
 	case 'D':
-	{
 			rightKeyPressed = true;
-			camera->Pitch(-KeyRotationAngle());
-		}
 		break;
 	case 'w':
 	case 'W':
-		{
 			upKeyPressed = true;
-			KeyHorizontalMotion(KeyShift());
-		}
 		break;
 	case 'x':
 	case 'X':
-		{
 			downKeyPressed = true;
-			KeyHorizontalMotion(-KeyShift());
-		}
 		break;
 	case 'r':
@@ -716,4 +715,7 @@
 	case GLUT_KEY_F5:
 		showOptions = !showOptions;
+		break;
+	case GLUT_KEY_F6:
+		flyMode = !flyMode;
 		break;
 	case GLUT_KEY_LEFT:
@@ -1004,5 +1006,5 @@
 	if (numbers.size() > 0)
 	{
-		sprintf_s(hstr, "%d", numbers.back());
+		sprintf(hstr, "%d", numbers.back());
 		str.append(hstr);
 	}
@@ -1010,5 +1012,5 @@
 	for (int i = (int)numbers.size() - 2; i >= 0; i--)
 	{
-		sprintf_s(hstr, ",%03d", numbers[i]);
+		sprintf(hstr, ",%03d", numbers[i]);
 		str.append(hstr);
 	}
@@ -1050,10 +1052,11 @@
 		issuedQueries = traverser->GetStats().mNumIssuedQueries;
 		stateChanges = traverser->GetStats().mNumStateChanges;
-	}
-
-	sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d", 
+		numBatches = traverser->GetStats().mNumBatches;
+	}
+
+	sprintf(msg2, "assumed visible frames: %4d, max batch size: %4d", 
 		      assumedVisibleFrames, maxBatchSize);
 
-	sprintf_s(msg3, "render queue: %d, multiqueries: %d, tight bounds: %d", 
+	sprintf(msg3, "render queue: %d, multiqueries: %d, tight bounds: %d", 
 		      useRenderQueue, useMultiQueries, useTightBounds);
 
@@ -1064,15 +1067,15 @@
 	CalcDecimalPoint(str2, bvh->GetBvhStats().mTriangles);
 
-	sprintf_s(msg4, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)", 
+	sprintf(msg4, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)", 
 			  renderedNodes, bvh->GetNumVirtualNodes(), str.c_str(), str2.c_str()); 
 
-	sprintf_s(msg5, "traversed: %5d, frustum culled: %5d, query culled: %5d",
+	sprintf(msg5, "traversed: %5d, frustum culled: %5d, query culled: %5d",
 			  traversedNodes, frustumCulledNodes, queryCulledNodes);
 
-	sprintf_s(msg6, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges);
-
-	sprintf_s(msg8, "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf);
-
-	sprintf_s(msg7, "fps: %6.1f", fps);
+	sprintf(msg6, "issued queries: %5d, state changes: %5d, render batches: %5d", issuedQueries, stateChanges, numBatches);
+
+	sprintf(msg8, "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf);
+
+	sprintf(msg7, "fps: %6.1f", fps);
 
 
@@ -1085,5 +1088,6 @@
 	else
 	{
-		glColor3f(1.0f, 1.0f, 1.0f);
+	//	glColor3f(1.0f, 1.0f, 1.0f);
+		glColor3f(1.0f, 0.0f, 0.0f);
 		Output(850, 30, msg[renderMode]);
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp	(revision 2800)
@@ -15,7 +15,11 @@
 void CHCPlusPlusTraverser::HandleQueryResult(OcclusionQuery *query)
 {
+	waitTimer.Entry();
+
 	// wait until result available
 	const int visible = query->GetQueryResult() > mVisibilityThreshold;
 
+	waitTimer.Exit();
+
 	// multiquery
 	if (query->GetSize() > 1)
@@ -27,6 +31,11 @@
 			{
 				BvhNode *node = query->GetNodes()[i];
+#if 1
+				mIQueue.push_back(node);
+				node->SetLastQueriedFrame(mFrameId);
+#else
 				OcclusionQuery *q = IssueOcclusionQuery(node);
 				mQueryQueue.push(q);
+#endif
 			}
 		}
@@ -38,4 +47,5 @@
 				node->IncTimesTestedInvisible();
 				node->SetVisible(false);
+				node->SetLastQueriedFrame(mFrameId);
 			}
 
@@ -46,4 +56,6 @@
 	{
 		BvhNode *node = query->GetFrontNode();
+
+		node->SetLastQueriedFrame(mFrameId);
 
 		// failed query: query individual nodes
@@ -100,4 +112,5 @@
 			mQueryQueue.pop();
 
+			// waiting for query result
 			HandleQueryResult(query);
 		}	
@@ -186,4 +199,5 @@
 	if (mUseRenderQueue) ApplyRenderQueue();
 
+	restTimer.Entry();
 
 	//////////////
@@ -206,11 +220,12 @@
 		HandleQueryResult(query);
 	}
-}
-
+
+	restTimer.Exit();
+}
 
 
 void CHCPlusPlusTraverser::QueryPreviouslyInvisibleNodes(BvhNode *node)
 {
-	mIQueue.push(node);
+	mIQueue.push_back(node);
 
 	if (mIQueue.size() > mMaxBatchSize)
@@ -221,5 +236,5 @@
 
 
-OcclusionQuery * CHCPlusPlusTraverser::GetNextMultiQuery(BvhNodeQueue &iqueue)
+OcclusionQuery * CHCPlusPlusTraverser::GetNextMultiQuery(BvhNodeContainer &iqueue)
 {
 	OcclusionQuery *query = mQueryHandler.RequestQuery();
@@ -233,10 +248,15 @@
 	while (!iqueue.empty())
 	{
-		BvhNode *node = iqueue.front();
+		BvhNode *node = iqueue.back();
+
+		// node was already part of a mulitquery => avoid recursion
+		if (node->GetLastQueriedFrame() == mFrameId)
+			newPBatch = 0;
+		else
 		newPBatch *= mVisibilityPredictor.GetProbability(node);
 
 		if (query->GetNodes().empty())
 		{
-			// single node will anever cause a wasted query
+			// single node will never cause a wasted query
 			newBatchVal = 1.0f;
 		}
@@ -250,5 +270,5 @@
 			break;
 
-		iqueue.pop();
+		iqueue.pop_back();
 		query->AddNode(node);
 
@@ -263,25 +283,31 @@
 
 
+static inline bool lt(BvhNode *a, BvhNode *b)
+{
+	return a->GetTimesTestedInvisible() < b->GetTimesTestedInvisible();
+}
+
+
 void CHCPlusPlusTraverser::IssueMultiQueries()
 {
-	while (!mIQueue.empty())
-	{
-		OcclusionQuery *query;
-
-		if (mUseMultiQueries)
-		{
-			query = GetNextMultiQuery(mIQueue);
+	if (mUseMultiQueries)
+	{
+		// sort queries by #times invisible
+		sort(mIQueue.begin(), mIQueue.end(), lt);
+
+		while (!mIQueue.empty())
+			mQueryQueue.push(GetNextMultiQuery(mIQueue));
 		}
 		else
 		{
-			BvhNode *node = mIQueue.front();
-			mIQueue.pop();
-			query = IssueOcclusionQuery(node);
-		}
-
-		mQueryQueue.push(query);
-	}
-}
-
-
-}
+		BvhNodeContainer::const_iterator it, it_end = mIQueue.end();
+
+		for (it = mIQueue.begin(); it != it_end; ++ it)
+			mQueryQueue.push(IssueOcclusionQuery(*it));
+
+		mIQueue.clear();
+	}
+}
+
+
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp	(revision 2800)
@@ -103,7 +103,6 @@
 	bvh->PostProcess();
 	
-	const int trianglesPerVirtualLeaves = 1000;
 	// set virtual leaves for specified number of triangles
-	bvh->SetVirtualLeaves(trianglesPerVirtualLeaves);
+	bvh->SetVirtualLeaves(INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES);
 
 	bvh->UpdateNumLeaves(bvh->mRoot);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2800)
@@ -9,6 +9,4 @@
 
 
-/** Constructor setting render as default state.
-*/
 RenderState::RenderState():
 mAlphaTestEnabled(false), 
@@ -22,9 +20,10 @@
 bool RenderState::SetState(Mode mode)
 {
+	///////////
 	//-- just change the modewhen necessary
+
 	if (mode == mMode) return false;
 
 	mMode = mode;
-	//++ state_changes;
 
 	if (mode == QUERY)
@@ -62,6 +61,6 @@
 	{
 		mTexturesEnabled = true;
-		glEnable(GL_TEXTURE_2D);
-		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+		//glEnable(GL_TEXTURE_2D);
+		//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 	}
 
@@ -74,6 +73,6 @@
 	{
 		mAlphaTestEnabled = true;
-		glEnable(GL_ALPHA_TEST);
-		glAlphaFunc(GL_GEQUAL, 0.5f);
+		//glEnable(GL_ALPHA_TEST);
+		//glAlphaFunc(GL_GEQUAL, 0.5f);
 	}
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 2800)
@@ -81,5 +81,5 @@
 	}
 
-	cout << "loaded " << mTextureTable.size() << " textures" << endl;
+	cout << "loaded " << (int)mTextureTable.size() << " textures" << endl;
 }
 
@@ -102,5 +102,5 @@
 	}
 
-	cout << "loaded " << mGeometryTable.size() << " shapes" << endl;
+	cout << "loaded " << (int)mGeometryTable.size() << " shapes" << endl;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2800)
@@ -7,4 +7,5 @@
 #include "Camera.h"
 #include "RenderQueue.h"
+#include "Timer/PerfTimer.h"
 
 
@@ -37,8 +38,12 @@
 	int mNumIssuedQueries;
 	int mNumStateChanges;
+	int mNumBatches;
 	
 	double mRenderTime;
+
+	double mWaitTime;
+	double mQueryTime;
+	double mRestTime;
 };
-
 
 
@@ -49,5 +54,5 @@
 public:
 	
-	enum {CULL_FRUSTUM, STOP_AND_WAIT, CHC, CHCPLUSPLUS, NUM_RENDERMODES};
+	enum {CULL_FRUSTUM, STOP_AND_WAIT, CHC, CHCPLUSPLUS, NUM_TRAVERSAL_TYPES};
 
 	RenderTraverser();
@@ -118,4 +123,5 @@
 	void SetShowBounds(bool showBounds);
 
+	virtual int GetType() const = 0;
 	
 protected:
@@ -187,4 +193,9 @@
 
 	bool mShowBounds;
+
+	// timers
+	PerfTimer restTimer;
+	PerfTimer waitTimer;
+	PerfTimer queryTimer;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp	(revision 2797)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp	(revision 2800)
@@ -5,8 +5,20 @@
 #include "SceneQuery.h"
 #include "RenderTraverser.h"
+#include <IL/il.h>
+#include <assert.h>
 
 
-void startil();
-void stopil();
+void startil()
+{
+	ilInit();
+	assert(ilGetError() == IL_NO_ERROR);
+}
+
+
+void stopil()
+{
+	ilShutDown();
+	assert(ilGetError() == IL_NO_ERROR);
+}
 
 
@@ -17,6 +29,7 @@
 
 
-const static int viewport[4] = {0, 0, 512, 512};
-//const static int viewport[4] = {0, 0, 1024, 768};
+//const static int viewport[4] = {0, 0, 512, 512};
+const static int viewport[4] = {0, 0, 1024, 768};
+//const static int viewport[4] = {0, 0, 2048, 2048};
 
 
@@ -34,13 +47,20 @@
 	int py = (pt.y - mSceneBox.Min(1)) * (viewport[3] - 1) / mSceneBox.Size(1);
 
-	const float d = mDepth[px + py * viewport[1]];
+	unsigned char d = mDepth[px + py * viewport[2]];
 
-	if (d > 0.0f)
+	const float offs = mSceneBox.Size(2) * 1e-1f;
+
+	static float depth = (float)d;
+
+	if (d > 0)
 	{
-		pt.z =  mSceneBox.Max().z - mSceneBox.Size().z * d;
-		cout << "new depth " << pt.z << " (" << d << ")" << endl;
+		const float x = 0.1f;
+		depth = depth * x + d * (1.0f - x);
+		pt.z =  mSceneBox.Max().z - mSceneBox.Size().z * depth / 255.0f + offs;
+		//cout << "new depth " << pt.z << " (" << d << ")" << endl;
 
 		return true;
 	}
+	//cout << "invalid depth: " << d << endl;
 
 	return false;
@@ -65,4 +85,6 @@
 
 	//glPixelStorei(GL_PACK_ROW_LENGTH, viewport[2]);
+	glPixelStorei(GL_PACK_ALIGNMENT, 1);
+	glReadBuffer(GL_BACK);
 
 	// hack: should create offscreen buffer for this
@@ -80,5 +102,6 @@
 	glClear(GL_DEPTH_BUFFER_BIT);
 
-	mDepth = new float[viewport[2] * viewport[3]];
+	mDepth = new unsigned char[viewport[2] * viewport[3]];
+	//mDepth = new float[viewport[2] * viewport[3]];
 
 	//renderer->SetCamera(orthoCam);
@@ -86,6 +109,26 @@
 	renderer->RenderScene();
 
-	glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_FLOAT, mDepth);
+	glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, mDepth);
+	//glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_FLOAT, mDepth);
+/*
+	startil();
 
+	if (!ilTexImage(viewport[2], viewport[3], 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, mDepth))
+	{
+		cerr << "IL error " << ilGetError() << endl;
+		stopil();
+		return;
+	}
+
+	ILstring writename = ILstring("out.tga");
+
+	ilSetInteger(IL_TGA_RLE, 1);
+	if (!ilSaveImage(writename))
+	{
+		cerr << "TGA write error " << ilGetError() << endl;
+	}
+
+	stopil();
+*/
 	DEL_PTR(orthoCam);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 2800)
@@ -21,5 +21,5 @@
 	int tsize2 = t2 ? t2->GetByteSize() : 0;
 
-	return tsize1 < tsize2;
+	return tsize1 > tsize2;
 }
 
@@ -88,4 +88,5 @@
 	Debug << "\nrq size: " << GetSize() << endl;
 	Debug << "texture size: " << endl;
+
 	// show ordering by texture size
 	for (sit = mEntities.begin(); sit != sit_end; ++ sit)
@@ -93,4 +94,5 @@
 		SceneEntity *ent = *sit;
 		Texture *t = ent->GetMaterial()->GetTexture();
+	
 		int tsize = t ? t->GetByteSize() : 0;
 		Debug << tsize << " ";
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2792)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2800)
@@ -52,4 +52,6 @@
 		/// if the node is newly processed with no prior history available
 		bool mIsNew;
+		/// the frame this node was last queried
+		int mLastQueriedFrame;
 	};
 
@@ -113,6 +115,6 @@
 	inline void SetTurnedVisibleFrame(int turnedVisibleFrame);
 
-	inline int GetLastTestedFrame();
-	inline void SetLastTestedFrame(int lastTested);
+	inline int GetLastQueriedFrame() const;
+	inline void SetLastQueriedFrame(int lastTested);
 	
 	inline bool IsViewFrustumCulled() const;
@@ -155,6 +157,4 @@
 	/////////////
 	
-	/// some flags
-	//int mFlags;
 	/// the depth of this node
 	unsigned char mDepth;
@@ -217,7 +217,9 @@
 
 
+
 /////////////////
 //-- public inline functions
 
+
 int BvhNode::GetLastVisitedFrame() const 
 { 
@@ -268,5 +270,5 @@
 
 
-void BvhNode::SetViewFrustumCulled(const bool frustumCulled) 
+void BvhNode::SetViewFrustumCulled(bool frustumCulled) 
 { 
 	mVisibility.mIsFrustumCulled = frustumCulled; 
@@ -280,5 +282,5 @@
 
 
-void BvhNode::SetIsNew(const bool isNew) 
+void BvhNode::SetIsNew(bool isNew) 
 { 
 	mVisibility.mIsNew = isNew; 
@@ -320,4 +322,17 @@
 	return mVisibility.mAssumedVisibleFrameId;
 }
+
+
+int BvhNode::GetLastQueriedFrame() const
+{
+	return mVisibility.mLastQueriedFrame;
+}
+
+
+void BvhNode::SetLastQueriedFrame(int lastTested)
+{
+	mVisibility.mLastQueriedFrame = lastTested;
+}
+
 
 
@@ -429,4 +444,11 @@
 	*/
 	inline int GetNumLeaves() const { return mNumNodes / 2 + 1;}
+	/** Returns number of 'virtual' nodes in the hierarchy, i.e.
+		the number of nodes actually used for traversal.
+	*/
+	int GetNumVirtualNodes() const  { return mNumVirtualNodes; }
+	/** Returns number of bvh leaves.
+	*/
+	inline int GetNumVirtualLeaves() const { return mNumVirtualNodes / 2 + 1;}
 	/** Returns root node of the bvh.
 	*/
@@ -512,5 +534,5 @@
 	*/
 	void SetVirtualLeaves(int numTriangles);
-
+	
 
 	////////
@@ -526,11 +548,10 @@
 	void SetAreaRatioThresholdForTestingChildren(float ratio);
 
+
+	////////////////////////////
+
 	/** Returns stats.
 	*/
 	const BvhStats &GetBvhStats() const { return mBvhStats; }
-	/** Returns number of 'virtual' nodes in the hierarchy, i.e.
-		the number of nodes actually used for traversal.
-	*/
-	int GetNumVirtualNodes() const  { return mNumVirtualNodes; }
 	/** Render wireframe bvh for visualization purpose.
 	*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/gzstream.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/gzstream.cpp	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/gzstream.cpp	(revision 2800)
@@ -0,0 +1,175 @@
+// ============================================================================
+// gzstream, C++ iostream classes wrapping the zlib compression library.
+// Copyright (C) 2001  Deepak Bandyopadhyay, Lutz Kettner
+//
+// This library 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.1 of the License, or (at your option) any later version.
+//
+// This library 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 library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// ============================================================================
+//
+// File          : gzstream.C
+// Revision      : $Revision: 1.1 $
+// Revision_date : $Date: 2004/02/16 14:46:00 $
+// Author(s)     : Deepak Bandyopadhyay, Lutz Kettner
+// 
+// Standard streambuf implementation following Nicolai Josuttis, "The 
+// Standard C++ Library".
+// ============================================================================
+
+#include "gzstream.h"
+#include <string.h>  // for memcpy
+
+#ifdef GZSTREAM_NAMESPACE
+namespace GZSTREAM_NAMESPACE {
+#endif
+
+// ----------------------------------------------------------------------------
+// Internal classes to implement gzstream. See header file for user classes.
+// ----------------------------------------------------------------------------
+
+// --------------------------------------
+// class gzstreambuf:
+// --------------------------------------
+
+gzstreambuf*
+gzstreambuf::open( const char* name, int open_mode) {
+  if ( is_open() )
+    return (gzstreambuf*)0;
+  mode = open_mode;
+  // no append nor read/write mode
+  if ((mode & std::ios::ate) || (mode & std::ios::app)
+      || ((mode & std::ios::in) && (mode & std::ios::out)))
+    return (gzstreambuf*)0;
+  char fmode[10];
+  char* fmodeptr = fmode;
+  if ( mode & std::ios::in)
+    *fmodeptr++ = 'r';
+  else
+    if ( mode & std::ios::out)
+      *fmodeptr++ = 'w';
+  *fmodeptr++ = 'b';
+  *fmodeptr = '\0';
+  file = gzopen( name, fmode);
+  if (file == 0)
+    return (gzstreambuf*)0;
+  opened = 1;
+  return this;
+}
+  
+gzstreambuf *
+gzstreambuf::close() {
+  if ( is_open()) {
+    sync();
+    opened = 0;
+    if ( gzclose( file) == Z_OK)
+      return this;
+  }
+  return (gzstreambuf*)0;
+}
+  
+int
+gzstreambuf::underflow() { // used for input buffer only
+  if ( gptr() && ( gptr() < egptr()))
+    return * reinterpret_cast<unsigned char *>( gptr());
+  
+  if ( ! (mode & std::ios::in) || ! opened)
+    return EOF;
+  // Josuttis' implementation of inbuf
+  int n_putback = gptr() - eback();
+  if ( n_putback > 4)
+    n_putback = 4;
+  memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback);
+  
+  int num = gzread( file, buffer+4, gzbufferSize-4);
+  if (num <= 0) // ERROR or EOF
+    return EOF;
+  
+  // reset buffer pointers
+  setg( buffer + (4 - n_putback),   // beginning of putback area
+	buffer + 4,                 // read position
+	buffer + 4 + num);          // end of buffer
+  
+  // return next character
+  return * reinterpret_cast<unsigned char *>( gptr());    
+}
+  
+int
+gzstreambuf::flush_buffer() {
+  // Separate the writing of the buffer from overflow() and
+  // sync() operation.
+  int w = pptr() - pbase();
+  if ( gzwrite( file, pbase(), w) != w)
+    return EOF;
+  pbump( -w);
+  return w;
+}
+  
+int
+gzstreambuf::overflow( int c) { // used for output buffer only
+  if ( ! ( mode & std::ios::out) || ! opened)
+    return EOF;
+  if (c != EOF) {
+    *pptr() = c;
+    pbump(1);
+  }
+  if ( flush_buffer() == EOF)
+    return EOF;
+  return c;
+}
+  
+int
+gzstreambuf::sync() {
+  // Changed to use flush_buffer() instead of overflow( EOF)
+  // which caused improper behavior with std::endl and flush(),
+  // bug reported by Vincent Ricard.
+  if ( pptr() && pptr() > pbase()) {
+    if ( flush_buffer() == EOF)
+      return -1;
+  }
+  return 0;
+}
+  
+  
+  // --------------------------------------
+  // class gzstreambase:
+// --------------------------------------
+
+gzstreambase::gzstreambase( const char* name, int mode)
+{
+  init( &buf);
+  open( name, mode);
+}
+  
+  gzstreambase::~gzstreambase()
+  {
+    buf.close();
+  }
+  
+  void
+  gzstreambase::open( const char* name, int open_mode) {
+    if ( ! buf.open( name, open_mode))
+      clear( rdstate() | std::ios::badbit);
+}
+
+void gzstreambase::close() {
+    if ( buf.is_open())
+        if ( ! buf.close())
+            clear( rdstate() | std::ios::badbit);
+}
+
+#ifdef GZSTREAM_NAMESPACE
+} // namespace GZSTREAM_NAMESPACE
+#endif
+
+// ============================================================================
+// EOF //
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h	(revision 2795)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h	(revision 2800)
@@ -476,4 +476,5 @@
 static std::string model_path("data/city/model/");
 
+
 ///////////
 //-- typedefs
@@ -490,13 +491,16 @@
 static std::ofstream Debug("debug.log");
 
-}
-
-#endif
-
-
-
-
-
-
-
-
+
+#define INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES 1000
+
+}
+
+#endif
+
+
+
+
+
+
+
+
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Timers.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Timers.cpp	(revision 2782)
+++ 	(revision )
@@ -1,143 +1,0 @@
-#include <time.h>
-
-
-#ifdef HRTIME
-#include <hrtime.h>
-#endif
-
-#ifdef _WIN32
-
-#include <windows.h>
-#include <sys/types.h>
-#include <sys/timeb.h>
-#include <time.h>
-//#include <resource.h>
-
-#else
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/times.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#endif
-
-
-#include "Timers.h"
-
-/*real time or user time*/
-
-#define REAL_TIME 
-
-
-// global file streams
-/*ofstream debugs("debug.log");*/
-
-static int hasHRTimer = 0;
-
-#ifdef  _MSC_VER
-static LARGE_INTEGER hrFreq;
-#endif
-
-
-#ifdef HRTIME
-struct hrtime_struct *hrTimer = NULL;
-#endif
-
-void initTiming()
-{
-#ifdef  _MSC_VER
-     hasHRTimer = QueryPerformanceFrequency(&hrFreq);
-#else
-#ifdef HRTIME
-     if (hrtime_is_present()) 
-     {
-	  hrtime_init();
-	  hasHRTimer = (0 == get_hrtime_struct(0, &hrTimer));
-	  debugs<<"Using UNIX hires timer"<<endl;
-     } else 
-     {
-	  debugs<<"No UNIX hires timer"<<endl;
-     }
-#endif
-#endif
-}
-
-void finishTiming()
-{
-#ifdef HRTIME
-     if (hasHRTimer == 1)
-	  free_hrtime_struct(hrTimer);
-#endif
-  
-}
-
-
-long
-getTime()
-{
-#ifndef  _MSC_VER
-
-#ifdef REAL_TIME
-
-  static struct timeval _tstart;
-  static struct timezone tz;
-
-  gettimeofday(&_tstart,&tz);
-  return (long)(1000000*_tstart.tv_sec + _tstart.tv_usec);
-
-#else
-  
-  if (hasHRTimer == 0) {
-
-    static struct rusage r;
-    getrusage(RUSAGE_SELF,&r);
-    return r.ru_utime.tv_usec+1000000*r.ru_utime.tv_sec;
-  } else {
-#ifdef HRTIME
-    hrtime_t dest;
-    get_hrutime(hrTimer, &dest);
-    return (long) (dest/500.0);
-#else
-    return 0;
-#endif
-  }
-#endif
-  
-#else
-
-	if (hasHRTimer == 1) 
-	{
-		LARGE_INTEGER counter;
-		QueryPerformanceCounter(&counter);
-		// return in usec
-		return (long) (1000000*counter.QuadPart/(hrFreq.QuadPart));
-	} else {
-		static struct _timeb mtime;
-		_ftime(&mtime);
-
-		return 1000 * (1000 * mtime.time + mtime.millitm);
-	}
-#endif
-}
-
-
-// return time diff. in ms
-double
-timeDiff(long time1,long time2) // in ms
-{
-  const double clk=1.0E-3; // ticks per second
-  long t=time2-time1;
-  
-  return ((t<0)?-t:t)*clk;
-}
-
-char
-*timeString()
-{
-  time_t t;
-  time(&t);
-
-  return ctime(&t);
-}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/HierarchyNode.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/HierarchyNode.h	(revision 2782)
+++ 	(revision )
@@ -1,167 +1,0 @@
-#ifndef NO_PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifndef HIERARCHYNODE_H
-#define HIERARCHYNODE_H
-
-#include "Geometry.h"
-/*extern "C"
-{
-	#include "DataTypes.h"
-}*/
-
-#include <vector>
-#include <stack>
-
-using namespace std;
-
-class HierarchyNode;
-
-/**
-	This class implements the compare operator for the priority queue.
-	a lower distance has a higher value in the queue
-*/
-template <typename T> class myless
-{
-public:
-	
-	//bool operator() (HierarchyNode *v1, HierarchyNode *v2) const
-	bool operator() (T v1, T v2) const
-    {
-		return (v1->mDistance > v2->mDistance);
-    }
-};
-
-/** This class represents a node in a k-d tree hierarchy. A
-	node has two children. The node can be either an interior node (i.e., left and right child
-	NULL) or a leaf node, which holds the actual geometry.
-*/
-
-class HierarchyNode
-{
-public:
-	typedef stack<HierarchyNode *> TraversalStack;
-    typedef vector<Geometry *> GeometryList;
-
-	HierarchyNode();
-	HierarchyNode(const Vector3 boundLower, const Vector3 boundUpper, 
-				 HierarchyNode *parent, int depth);
-	~HierarchyNode();
-	//! was this node visible the last time it was visited?
-	bool Visible();
-	//! last time this node was visited (in framenumber)
-	unsigned int LastVisited();
-	//! sets visible flag
-	void SetVisible(bool visible);
-	//! sets timestamp (current framenumber)
-	void SetLastVisited(unsigned int lastVisited);
-	//! is this node a leaf node (i.e., geometry)
-	bool IsLeaf();
-	//! renders the geometry in this node. returns number of rendered geometry
-	int Render();
-	//! returns occlusion query id
-	int GetOcclusionQuery();
-	//! sets occlusion query id
-	void SetOcclusionQuery(int occlusionQuery);
-	//! renders the bounding volume  (i.e., a axis aligned bounding box) of the node
-	void RenderBoundingVolume();
-	//! adds geometry to this node (rendered if this node is a leaf)
-	void AddGeometry(Geometry *geometry);
-
-	void SetLeftChild(HierarchyNode *child);
-	void SetRightChild(HierarchyNode *child);
-
-	HierarchyNode *GetParent();
-    HierarchyNode *GetLeftChild();
-	HierarchyNode *GetRightChild();
-
-	//! compute bounding volume (i.e., a axis aligned bounding box) for this geometry.
-	//void CalcBoundingVolume();
-	const AABox& GetBoundingVolume();
-	
-	//! generates the kd-tree from this root-node, returns number of nodes in hierarchy.
-	int	GenerateKdTree();
-
-	//! returns number of nodes in hierarchy with this node.
-	int GetNumHierarchyNodes();
-
-	//! add children of this node ordered to a traversal stack with respect to the view point
-	void PushChildrenOrdered(const Vector3 viewpoint, TraversalStack &traversalStack);
-
-	//! if this node was culled, set the type of culling (frustum, query)
-	void SetCulledType(int culledtype);
-	//! returns type of culling
-	int GetCulledType();
-	//! set gl state to visible render bounding volume
-	void RenderBoundingVolumeForVisualization();
-	//! returns geometry list
-	GeometryList &GetGeometry();
-
-	//! visibly renders also bounding volume of this node
-	static void SetRenderBoundingVolume(bool renderBoundingVolume);
-	
-	/**
-		initialises the static termination criteria.
-		shall be called after all geometry has been added to the root node.
-	*/
-	static void InitKdTree(HierarchyNode *root);
-
-	float GetSquaredDistance();
-	void SetDistance(float distance);
-
-	float mDistance;
-
-protected:
-	
-	enum {X_AXIS, Y_AXIS, Z_AXIS};
-
-	//! criteria to stop the splitting of this kd-tree node
-	bool SimpleEnough();
-	//! split plane of the kd-tree (according to mSplitAxis, it is the x, y, or z axis)
-	float ComputeSplitPlane();
-
-	/** calculates a value that expresses if it's reasonable to split the 
-	   node at the specified position (the smaller the value the better the split)
-	   */
-	float ComputeHeuristics(float pos);
-
-	GeometryList mGeometry;
-	//! id of this occlusion query of this node
-	int mOcclusionQuery;
-
-	HierarchyNode *mLeftChild;	
-	HierarchyNode *mRightChild;
-	HierarchyNode *mParent;
-	
-	bool  mVisible;
-	int mLastVisited;
-	bool mAABValid;
-	bool mEnclosedSpaceValid;
-	int mNumHierarchyNodes;
-	
-	AABox mBoundingBox;
-	// the enclosed space of the pure kd-treenode (without considering the geometry)
-	AABox mEnclosedSpace;
-	
-	int mSplitAxis;
-	int mLastRendered;
-	float mSplitValue;
-	int mDepth;
-
-	static bool sRenderBoundingVolume;
-	static float sSplitBandwith;
-
-	// --termination criteria
-
-	static int sGeometryThreshold;
-	// the maximum bounding box surface
-	static float HierarchyNode::sSurfaceThreshold;
-	// the maximum tree depth
-	static int HierarchyNode::sMaxDepth;
-	// the default bounding box drawing color
-	float mBoxColor[3];
-	// distance to the view point
-};
-
-#endif // HIERARCHYNODE_H
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/HierarchyNode.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/HierarchyNode.cpp	(revision 2782)
+++ 	(revision )
@@ -1,491 +1,0 @@
-#if TOIMPLEMENT
-
-#include "HierarchyNode.h"
-#include "glInterface.h"
-#include <math.h>
-#include <limits.h>
-#include <float.h>
-
-typedef vector<Geometry *> GeometryList;
-
-// criteria and values partly taken from Piringer's thesis
-
-// values used as termination criteria for the tree generation
-// the overall surface
-float HierarchyNode::sSurfaceThreshold;
-// the maximum tree depth
-int HierarchyNode::sMaxDepth;
-// maximum number of objects in a node
-int HierarchyNode::sGeometryThreshold;
-
-// percentage of allowed deviation from the center split plane
-float HierarchyNode::sSplitBandwith;
-
-// also render bounding volume
-bool HierarchyNode::sRenderBoundingVolume = false;
-
-HierarchyNode::HierarchyNode(): 
-mVisible(false), 
-mLastVisited(0), 
-mParent(NULL), 
-mOcclusionQuery(0), 
-mAABValid(false), 
-mLeftChild(NULL), 
-mRightChild(NULL),
-mNumHierarchyNodes(1), 
-mSplitAxis(X_AXIS), 
-mLastRendered(-1), 
-mSplitValue(0),
-mDepth(0), 
-mEnclosedSpaceValid(false), 
-mDistance(0)
-{
-	copyVector3Values(mBoundingBox.min, 0, 0, 0);
-	copyVector3Values(mBoundingBox.max, 0, 0, 0);
-
-	copyVector3Values(mEnclosedSpace.min, 0, 0, 0);
-	copyVector3Values(mEnclosedSpace.max, 0, 0, 0);
-
-	// bounding box color
-	mBoxColor[0] = mBoxColor[2] = 0; mBoxColor[1] = 1.0;
-}
-
-
-HierarchyNode::HierarchyNode(const Vector3 boundLower, 
-							 const Vector3 boundUpper, 
-							 HierarchyNode *parent, 
-							 int depth)
-:mNumHierarchyNodes(1), 
-mOcclusionQuery(0), 
-mLeftChild(NULL), 
-mRightChild(NULL), 
-mSplitAxis(X_AXIS), 
-mVisible(false), 
-mLastVisited(0), 
-mParent(parent), 
-mAABValid(false), 
-mLastRendered(-1), 
-mSplitValue(0), 
-mDepth(depth), 
-mEnclosedSpaceValid(true), 
-mDistance(0)
-{
-	copyVector3Values(mBoundingBox.min, 0, 0, 0);
-	copyVector3Values(mBoundingBox.max, 0, 0, 0);
-
-	copyVector3(mEnclosedSpace.min, boundLower);
-	copyVector3(mEnclosedSpace.max, boundUpper);
-
-	float vol = calcAABoxSurface(mEnclosedSpace);
-
-	mBoxColor[0] = mBoxColor[2] = 0; mBoxColor[1] = 1.0;
-}
-
-
-void HierarchyNode::InitKdTree(HierarchyNode *root)
-{
-	sMaxDepth = (int)((log((float) root->GetGeometry().size())/log(2.0f)) * 20.0f);
-
-	sSurfaceThreshold = FLT_MAX;
-
-	// factor times mininal surface as determination criterium
-	const float factor = 2.5;
-
-	for (GeometryList::const_iterator it = root->GetGeometry().begin(); it != root->GetGeometry().end(); it++)
-	{
-		// same geometry can possible be in to or more nodes => also test for them
-		float surface = calcAABoxSurface((*it)->GetBoundingVolume()) * factor;
-
-		if(surface < sSurfaceThreshold) sSurfaceThreshold = surface;
-	}
-
-	// number of objects in a leaf
-	sGeometryThreshold = 1;
-
-	// percentage of allowed deviation from the center split plane
-	sSplitBandwith = 0.15;
-}
-
-
-HierarchyNode::~HierarchyNode()
-{
-	if(mLeftChild)
-		delete mLeftChild;
-
-	if(mRightChild)
-		delete mRightChild;
-}
-
-int HierarchyNode::Render()
-{
-	int renderedGeometry = 0;
-
-	if(sRenderBoundingVolume)
-	{
-		glColor3fv(mBoxColor);
-        RenderBoundingVolumeForVisualization();
-	}
-
-	// prevent the geometry to be rendered several times in the same frame
-	if(mLastRendered != mLastVisited)
-	{
-		for (GeometryList::const_iterator it = mGeometry.begin(); it != mGeometry.end(); it++)
-		{
-			// same geometry can possible be in to or more nodes => also test for them
-			if((*it)->GetLastVisited() != mLastVisited)
-			{
-				(*it)->SetLastVisited(mLastVisited);
-				(*it)->Render();
-				renderedGeometry ++;
-			}
-		}
-		mLastRendered = mLastVisited;
-	}
-
-	return renderedGeometry;
-}
-
-bool HierarchyNode::Visible()
-{
-	return mVisible;
-}
-
-void HierarchyNode::SetVisible(bool visible)
-{
-	mVisible = visible;
-}
-
-void HierarchyNode::SetLeftChild(HierarchyNode *child)
-{
-	mLeftChild = child;
-}
-
-void HierarchyNode::SetRightChild(HierarchyNode *child)
-{
-	mRightChild = child;
-}
-
-HierarchyNode *HierarchyNode::GetLeftChild()
-{
-	return mLeftChild;
-}
-
-HierarchyNode *HierarchyNode::GetRightChild()
-{
-	return mRightChild;
-}
-
-unsigned int HierarchyNode::LastVisited()
-{
-	return mLastVisited;
-}
-
-void HierarchyNode::SetLastVisited(unsigned int lastVisited)
-{
-	mLastVisited = lastVisited;
-}
-
-bool HierarchyNode::IsLeaf()
-{
-	return (!mLeftChild && !mRightChild);
-}
-
-void HierarchyNode::AddGeometry(Geometry *geometry)
-{
-	mGeometry.push_back(geometry);
-		
-	if(!mAABValid)
-	{
-		copyVector3(mBoundingBox.min, geometry->GetBoundingVolume().min);
-		copyVector3(mBoundingBox.max, geometry->GetBoundingVolume().max);
-
-		mAABValid = true;
-	}
-	else
-		combineAABoxes(&mBoundingBox, geometry->GetBoundingVolume());
-
-	// root node
-	if(mDepth == 0)
-	{
-		if(!mEnclosedSpaceValid)
-		{
-			copyVector3(mEnclosedSpace.min, geometry->GetBoundingVolume().min);
-			copyVector3(mEnclosedSpace.max, geometry->GetBoundingVolume().max);
-
-			mEnclosedSpaceValid = true;
-		}
-		else 
-			combineAABoxes(&mEnclosedSpace, geometry->GetBoundingVolume());	
-	}
-	else
-	{
-		// cut boxes so they fit into the enclosed space
-		clipAABoxByAABox(&mBoundingBox, mEnclosedSpace);
-	}
-}
-
-HierarchyNode *HierarchyNode::GetParent()
-{
-	return mParent;
-}
-
-int HierarchyNode::GetOcclusionQuery()
-{
-	return mOcclusionQuery;
-}
-
-void HierarchyNode::SetOcclusionQuery(int occlusionQuery)
-{
-	mOcclusionQuery = occlusionQuery;
-}
-
-void HierarchyNode::RenderBoundingVolume()
-{
-	Vector3x8 vertices;
-
-	calcAABoxPoints(vertices, mBoundingBox);
-
-	//glPolygonMode(GL_FRONT, GL_LINE);
-	//     7+------+6
-	//     /|     /|
-	//    / |    / |
-	//   / 4+---/--+5
-	// 3+------+2 /    y   z
-	//  | /    | /     |  /
-	//  |/     |/      |/
-	// 0+------+1      *---x
-
-	//---- render AABB
-	glBegin(GL_TRIANGLE_FAN);
-		glVertex3dv(vertices[6]);
-		glVertex3dv(vertices[5]);
-		glVertex3dv(vertices[4]);
-		glVertex3dv(vertices[7]);
-		glVertex3dv(vertices[3]);
-		glVertex3dv(vertices[2]);
-		glVertex3dv(vertices[1]);
-		glVertex3dv(vertices[5]);
-	glEnd();
-
-	//---- render second half of AABB
-	glBegin(GL_TRIANGLE_FAN);
-		glVertex3dv(vertices[0]);
-		glVertex3dv(vertices[1]);
-		glVertex3dv(vertices[2]);
-		glVertex3dv(vertices[3]);
-		glVertex3dv(vertices[7]);
-		glVertex3dv(vertices[4]);
-		glVertex3dv(vertices[5]);
-		glVertex3dv(vertices[1]);
-	glEnd();
-}
-
-
-void HierarchyNode::RenderBoundingVolumeForVisualization()
-{
-	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-	glDisable(GL_LIGHTING);
-	glDisable(GL_CULL_FACE);
-		
-	RenderBoundingVolume();
-
-	glEnable(GL_CULL_FACE);
-	glEnable(GL_LIGHTING);
-	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-}
-
-
-
-const AABox &HierarchyNode::GetBoundingVolume()
-{
-	return mBoundingBox;
-}
-
-int	HierarchyNode::GenerateKdTree()
-{
-	// check the termination criterium (a heuristic)
-	if (SimpleEnough()) 
-	{
-		return 1;
-	}
-
-	// largest dimension will be split
-	Vector3 size;
-	diffVector3(size, mBoundingBox.max, mBoundingBox.min);
-    
-	if (size[X_AXIS] > size[Y_AXIS])	
-		mSplitAxis	= (size[X_AXIS] > size[Z_AXIS]) ? X_AXIS : Z_AXIS;
-	else					
-		mSplitAxis	= (size[Y_AXIS] > size[Z_AXIS]) ? Y_AXIS : Z_AXIS;
-
-	// select the value of the split plane
-	mSplitValue = ComputeSplitPlane();
-	
-	// generate the children
-	Vector3 changedLower;
-	Vector3 changedUpper;
-
-	copyVector3(changedLower, mEnclosedSpace.min);
-	copyVector3(changedUpper, mEnclosedSpace.max);
-	   	
-	changedLower[mSplitAxis] = mSplitValue;
-	changedUpper[mSplitAxis] = mSplitValue;
-
-	mLeftChild	= new HierarchyNode(mEnclosedSpace.min, changedUpper, this, mDepth + 1);
-	mRightChild	= new HierarchyNode(changedLower, mEnclosedSpace.max, this, mDepth + 1);
-
-	// add the geometry to the according children
-	for (GeometryList::iterator it = mGeometry.begin(); it != mGeometry.end(); it++)
-	{
-		if ((*it)->GetBoundingVolume().min[mSplitAxis] >= mSplitValue)
-		{
-			// box lies completely within right part
-			mRightChild->AddGeometry(*it);
-		}
-		else if ((*it)->GetBoundingVolume().max[mSplitAxis] <= mSplitValue)
-		{
-			// box lies completely within left part
-			mLeftChild->AddGeometry((*it));
-		}
-		else
-		{
-			//---- box intersects both parts
-			mLeftChild->AddGeometry((*it));
-			mRightChild->AddGeometry((*it));
-		}
-	}
-
-	//---- we continue with the children
-	int leftSize  = mLeftChild->GenerateKdTree();
-	int rightSize = mRightChild->GenerateKdTree();
-
-	// since the geometry is now referenced by the children
-	mGeometry.clear();
-	
-	mNumHierarchyNodes = leftSize + rightSize + 1;
-
-	return mNumHierarchyNodes;
-}
-
-bool HierarchyNode::SimpleEnough()
-{
-	return ((mGeometry.size() <= (unsigned int)sGeometryThreshold) ||
-		    (calcAABoxSurface(mBoundingBox) <= sSurfaceThreshold) ||
-			(sMaxDepth <= mDepth));
-}
-
-float HierarchyNode::ComputeSplitPlane()
-{
-	float left	= mBoundingBox.min[mSplitAxis];
-	float right	= mBoundingBox.max[mSplitAxis];
-
-	// the smaller the value returned from the heuristic, the better => big starting value
-	float bestValue	= FLT_MAX; 
-	float result = 0.0f;
-
-	bool found	= false;
-
-	// calculate the borders of the band
-	float currLeft, currRight;
-	currLeft = currRight = (left + right) / 2.0f;
-	
-	currLeft  -= (right - left) * sSplitBandwith;
-	currRight += (right - left) * sSplitBandwith;
-
-	// check all geometry within that node
-	for (GeometryList::const_iterator it = mGeometry.begin(); it != mGeometry.end(); it++)
-	{
-		// one border of the geometry's AABB
-		float leftPlane	 = (*it)->GetBoundingVolume().min[mSplitAxis];
-		// the other border of the geometry's AABB
-		float rightPlane = (*it)->GetBoundingVolume().max[mSplitAxis];
-		
-		// only consider planes that lie within the band
-		if ((leftPlane > currLeft) && (leftPlane < currRight))
-		{
-			// compute the heuristic for the left plane and note the value if it was good
-			float currValue	= ComputeHeuristics(leftPlane);
-
-			if (currValue < bestValue)
-			{
-				bestValue = currValue;
-				result	  = leftPlane;
-				found	  = true;
-			}
-		}
-
-		if ((rightPlane > currLeft) && (rightPlane < currRight))
-		{
-			// compute the heuristic for the right plane and note the value if it was good
-			float currValue = ComputeHeuristics(rightPlane);
-
-			if (currValue < bestValue)
-			{
-				bestValue	= currValue;
-				result		= rightPlane;
-				found		= true;
-			}
-		}
-	}
-
-	// in case we haven't found any proper plane, we simply take the center
-	if (!found)	
-		result = (left + right) / 2.0f;
-			
-	return result;
-}
-
-float HierarchyNode::ComputeHeuristics(float pos)
-{
-	// this implements a very simple heuristic: it simply counts the nodes being intersected by the splitplane
-	float result = 0.0f;
-
-	for (GeometryList::const_iterator it = mGeometry.begin(); it != mGeometry.end(); it++)
-	{
-		if (((*it)->GetBoundingVolume().min[mSplitAxis] < pos) &&
-			((*it)->GetBoundingVolume().max[mSplitAxis] > pos))
-		{
-			result += 1.0f;
-		}
-	}
-
-	return result;
-}
-
-int HierarchyNode::GetNumHierarchyNodes()
-{
-	return mNumHierarchyNodes;
-}
-
-void HierarchyNode::PushChildrenOrdered(const Vector3 viewpoint, TraversalStack &traversalStack)
-{
-	if(viewpoint[mSplitAxis] > mSplitValue)
-	{
-		traversalStack.push(mLeftChild);
-		traversalStack.push(mRightChild);
-	}
-	else
-	{
-		traversalStack.push(mRightChild);
-		traversalStack.push(mLeftChild);
-	}
-}
-
-
-void HierarchyNode::SetRenderBoundingVolume(bool renderBoundingVolume)
-{
-	sRenderBoundingVolume = renderBoundingVolume;
-}
-
-
-GeometryList &HierarchyNode::GetGeometry()
-{
-	return mGeometry;
-}
-
-void HierarchyNode::SetDistance(float distance)
-{
-	mDistance = distance;
-}
-
-#endif
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling03.sln
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling03.sln	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling03.sln	(revision 2800)
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FriendlyCulling", "FriendlyCulling03.vcproj", "{D1E30B8F-194B-4487-8303-D2CF90ED0048}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfiguration) = preSolution
+		Debug = Debug
+		Release = Release
+	EndGlobalSection
+	GlobalSection(ProjectConfiguration) = postSolution
+		{D1E30B8F-194B-4487-8303-D2CF90ED0048}.Debug.ActiveCfg = Debug|Win32
+		{D1E30B8F-194B-4487-8303-D2CF90ED0048}.Debug.Build.0 = Debug|Win32
+		{D1E30B8F-194B-4487-8303-D2CF90ED0048}.Release.ActiveCfg = Release|Win32
+		{D1E30B8F-194B-4487-8303-D2CF90ED0048}.Release.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+	EndGlobalSection
+	GlobalSection(ExtensibilityAddIns) = postSolution
+	EndGlobalSection
+EndGlobal
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2800)
@@ -0,0 +1,686 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8,00"
+	Name="chc_revisited"
+	ProjectGUID="{03661866-4093-4B02-B26A-028EA91AF023}"
+	RootNamespace="chc_revisited"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)"
+			IntermediateDirectory="obj/$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				RuntimeTypeInfo="false"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)"
+			IntermediateDirectory="obj/$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				EnableFiberSafeOptimizations="true"
+				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE; _CRT_SECURE_NO_WARNINGS"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				EnableEnhancedInstructionSet="2"
+				RuntimeTypeInfo="false"
+				UsePrecompiledHeader="0"
+				BrowseInformation="1"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib"
+				GenerateDebugInformation="false"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="util"
+			>
+			<File
+				RelativePath=".\src\AxisAlignedBox3.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\BvhLoader.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\BvhLoader.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\common.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\common.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\glInterface.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\gzstream.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\gzstream.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Matrix4x4.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Matrix4x4.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Plane3.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Plane3.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\ResourceManager.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\ResourceManager.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\SceneQuery.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\SceneQuery.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Triangle3.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Triangle3.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Vector3.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Vector3.h"
+				>
+			</File>
+			<Filter
+				Name="timer"
+				>
+				<File
+					RelativePath=".\src\Timer\BenchTimer.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\BenchTimer.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\merror.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\merror.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\mstring.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\PerfTimer.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\PerfTimerSkeleton.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\RDTSCTimer.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Timer\RDTSCTimer.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="traversal"
+			>
+			<Filter
+				Name="Header Files"
+				>
+				<File
+					RelativePath=".\src\CHCPlusPlusTraverser.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\CHCTraverser.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\CHCTraverser.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\FrustumCullingTraverser.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\RenderTraverser.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\StopAndWaitTraverser.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				>
+				<File
+					RelativePath=".\src\CHCPlusPlusTraverser.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\FrustumCullingTraverser.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\RenderTraverser.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\StopAndWaitTraverser.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="render"
+			>
+			<Filter
+				Name="Header Files"
+				Filter="h;hpp;hxx;hm;inl;inc;xsd"
+				UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+				>
+				<File
+					RelativePath=".\src\Bvh.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Camera.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Geometry.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\OcclusionQuery.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\RenderQueue.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\RenderState.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\SceneEntity.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Texture.h"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Visualization.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+				UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+				>
+				<File
+					RelativePath=".\src\Bvh.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\Camera.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\chcdemo.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Geometry.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Material.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\OcclusionQuery.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\RenderQueue.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\RenderState.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\SceneEntity.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\Texture.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\Visualization.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							ObjectFile="$(IntDir)\$(InputName)1.obj"
+							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/chc_revisited.sln
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/chc_revisited.sln	(revision 2785)
+++ 	(revision )
@@ -1,20 +1,0 @@
-﻿
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chc_revisited", "chc_revisited.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{03661866-4093-4B02-B26A-028EA91AF023}.Debug|Win32.ActiveCfg = Debug|Win32
-		{03661866-4093-4B02-B26A-028EA91AF023}.Debug|Win32.Build.0 = Debug|Win32
-		{03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.ActiveCfg = Release|Win32
-		{03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/chc_revisited.vcproj.UNKNOWN.matt.user
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/chc_revisited.vcproj.UNKNOWN.matt.user	(revision 2785)
+++ 	(revision )
@@ -1,65 +1,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioUserFile
-	ProjectType="Visual C++"
-	Version="8,00"
-	ShowAllFiles="false"
-	>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			>
-			<DebugSettings
-				Command="$(TargetPath)"
-				WorkingDirectory=""
-				CommandArguments=""
-				Attach="false"
-				DebuggerType="3"
-				Remote="1"
-				RemoteMachine="UNKNOWN"
-				RemoteCommand=""
-				HttpUrl=""
-				PDBPath=""
-				SQLDebugging=""
-				Environment=""
-				EnvironmentMerge="true"
-				DebuggerFlavor=""
-				MPIRunCommand=""
-				MPIRunArguments=""
-				MPIRunWorkingDirectory=""
-				ApplicationCommand=""
-				ApplicationArguments=""
-				ShimCommand=""
-				MPIAcceptMode=""
-				MPIAcceptFilter=""
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			>
-			<DebugSettings
-				Command="$(TargetPath)"
-				WorkingDirectory=""
-				CommandArguments=""
-				Attach="false"
-				DebuggerType="3"
-				Remote="1"
-				RemoteMachine="UNKNOWN"
-				RemoteCommand=""
-				HttpUrl=""
-				PDBPath=""
-				SQLDebugging=""
-				Environment=""
-				EnvironmentMerge="true"
-				DebuggerFlavor=""
-				MPIRunCommand=""
-				MPIRunArguments=""
-				MPIRunWorkingDirectory=""
-				ApplicationCommand=""
-				ApplicationArguments=""
-				ShimCommand=""
-				MPIAcceptMode=""
-				MPIAcceptFilter=""
-			/>
-		</Configuration>
-	</Configurations>
-</VisualStudioUserFile>
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/chc_revisited.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/chc_revisited.vcproj	(revision 2795)
+++ 	(revision )
@@ -1,686 +1,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="chc_revisited"
-	ProjectGUID="{03661866-4093-4B02-B26A-028EA91AF023}"
-	RootNamespace="chc_revisited"
-	Keyword="Win32Proj"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)"
-			IntermediateDirectory="obj/$(ConfigurationName)"
-			ConfigurationType="1"
-			CharacterSet="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				RuntimeTypeInfo="false"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)"
-			IntermediateDirectory="obj/$(ConfigurationName)"
-			ConfigurationType="1"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				InlineFunctionExpansion="2"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				EnableFiberSafeOptimizations="true"
-				AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE; _CRT_SECURE_NO_WARNINGS"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				BufferSecurityCheck="false"
-				EnableEnhancedInstructionSet="2"
-				RuntimeTypeInfo="false"
-				UsePrecompiledHeader="0"
-				BrowseInformation="1"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib"
-				GenerateDebugInformation="false"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				OptimizeForWindows98="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="util"
-			>
-			<File
-				RelativePath=".\src\AxisAlignedBox3.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\BvhLoader.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\BvhLoader.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\common.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\common.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\glInterface.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\gzstream.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\gzstream.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Matrix4x4.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Matrix4x4.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Plane3.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Plane3.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\ResourceManager.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\ResourceManager.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\SceneQuery.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\SceneQuery.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Triangle3.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Triangle3.h"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Vector3.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\Vector3.h"
-				>
-			</File>
-			<Filter
-				Name="timer"
-				>
-				<File
-					RelativePath=".\src\Timer\BenchTimer.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\BenchTimer.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\merror.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\merror.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\mstring.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\PerfTimer.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\PerfTimerSkeleton.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\RDTSCTimer.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Timer\RDTSCTimer.h"
-					>
-				</File>
-			</Filter>
-		</Filter>
-		<Filter
-			Name="traversal"
-			>
-			<Filter
-				Name="Header Files"
-				>
-				<File
-					RelativePath=".\src\CHCPlusPlusTraverser.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\CHCTraverser.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\CHCTraverser.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\FrustumCullingTraverser.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\RenderTraverser.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\StopAndWaitTraverser.h"
-					>
-				</File>
-			</Filter>
-			<Filter
-				Name="Source Files"
-				>
-				<File
-					RelativePath=".\src\CHCPlusPlusTraverser.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\FrustumCullingTraverser.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\RenderTraverser.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\StopAndWaitTraverser.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-			</Filter>
-		</Filter>
-		<Filter
-			Name="render"
-			>
-			<Filter
-				Name="Header Files"
-				Filter="h;hpp;hxx;hm;inl;inc;xsd"
-				UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-				>
-				<File
-					RelativePath=".\src\Bvh.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Camera.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Geometry.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\OcclusionQuery.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\RenderQueue.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\RenderState.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\SceneEntity.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Texture.h"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Visualization.h"
-					>
-				</File>
-			</Filter>
-			<Filter
-				Name="Source Files"
-				Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-				UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-				>
-				<File
-					RelativePath=".\src\Bvh.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\Camera.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\chcdemo.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Geometry.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Material.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\OcclusionQuery.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\RenderQueue.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\RenderState.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\SceneEntity.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\Texture.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\Visualization.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-			</Filter>
-		</Filter>
-		<File
-			RelativePath=".\ReadMe.txt"
-			>
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
