Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp	(revision 3250)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp	(revision 3268)
@@ -109,6 +109,6 @@
 
 	// scale the sky dome so no intersection with the scene is visible
-	//const float scaleFactor = 80.0f;
-	const float scaleFactor = 500.0f;
+	const float scaleFactor = 80.0f;
+	//const float scaleFactor = 500.0f;
 
 	position.z -= 3.0f * scaleFactor;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp	(revision 3262)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp	(revision 3268)
@@ -187,5 +187,5 @@
 	AxisAlignedBox3 box;
 	
-	if (!numEntities)
+	if (numEntities <= 0)
 	{	// no box => just initialize
 		box.Initialize();
@@ -209,5 +209,5 @@
 	AxisAlignedBox3 box;
 	
-	if (!entities.empty())
+	if (entities.empty())
 	{	// no box => just initialize
 		box.Initialize();
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3267)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3268)
@@ -587,6 +587,6 @@
 	//LoadModel("sibenik.dem", dynamicObjects);
 
-	LoadModel("procedural_pompeii_area6_hires/pompeii.dem", dynamicObjects);
-
+	//LoadModel("procedural_pompeii_area6_hires/pompeii.dem", dynamicObjects);
+/*
 	AxisAlignedBox3 box;
 	box.Initialize();
@@ -603,5 +603,5 @@
 
 	cout << "pompeii bb:\n" << box << endl;
-
+*/
 #if 0
 	const Vector3 sceneCenter(470.398f, 240.364f, 181.7f);
@@ -645,6 +645,9 @@
 
 	BvhFactory bvhFactory;
-	//bvh = bvhFactory.Create(bvh_filename, staticObjects, dynamicObjects, maxDepthForTestingChildren);
+#if 1
 	bvh = bvhFactory.Create(staticObjects, dynamicObjects, maxDepthForTestingChildren);
+#else
+	bvh = bvhFactory.Create(bvh_filename, staticObjects, dynamicObjects, maxDepthForTestingChildren);
+#endif
 
 	if (!bvh)
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp	(revision 3267)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp	(revision 3268)
@@ -130,5 +130,5 @@
 		// no split could be achieved => just halve number of objects
 		split = (leaf->mLast + leaf->mFirst) / 2;
-		cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << endl;
+		//cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << endl;
 	}
 
@@ -185,12 +185,12 @@
 	BvhLeaf *l = new BvhLeaf(NULL);
 	
-	l->mBox = SceneEntity::ComputeBoundingBox(mEntities + mFirst, mFirst - mLast + 1);
-
 	l->mFirst = mFirst;
 	l->mLast = mLast;
+
+	cout << "constructing bvh from "  << l->mFirst << " to " << l->mLast << endl;
+
+	l->mBox = SceneEntity::ComputeBoundingBox(mEntities + mFirst, mLast - mFirst + 1);
 	l->mArea = l->mBox.SurfaceArea();
 	
-	cout << "constructing bvh from "  << l->mFirst << " to " << l->mLast << endl;
-
 	root = SubdivideLeaf(l, 0);
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj	(revision 3266)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj	(revision 3268)
@@ -155,5 +155,5 @@
 				IgnoreAllDefaultLibraries="false"
 				IgnoreDefaultLibraryNames="LIBCMT"
-				GenerateDebugInformation="true"
+				GenerateDebugInformation="false"
 				SubSystem="1"
 				LargeAddressAware="2"
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter2.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter2.cpp	(revision 3265)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter2.cpp	(revision 3268)
@@ -128,6 +128,6 @@
 				for (int j = 0; j < 3; ++ j)
 				{
-					if (tIndices[idx[j]] >= (int)texcoords.size())
-						cerr << "error: texcoord indices exceed array size " << texcoords.size() << " " << tIndices[idx[j]] << endl;
+					//if (tIndices[idx[j]] >= (int)texcoords.size())
+						//cerr << "error: texcoord indices exceed array size " << texcoords.size() << " " << tIndices[idx[j]] << endl;
 					const int tidx = min((int)texcoords.size() - 1, tIndices[idx[j]]);
 
@@ -240,4 +240,6 @@
 	vector<string>::const_iterator it, it_end = filenames.end();
 
+	ofstream outstr("mydebug.log");
+
 	for (it = filenames.begin(); it != it_end; ++ it)
 	{
@@ -245,4 +247,7 @@
 
 		cout << "\n==================\n loading file " << filename << endl;
+
+		outstr << "loading file: " << filename << endl;
+		outstr << flush;
 
 		if (!ReadFile(filename))
@@ -253,5 +258,5 @@
 	}
 
-	cout << "\n*******************\n writing file " << outputFilename << endl;
+	cout << "\n*******************\nwriting file " << outputFilename << endl;
 
 	if (!WriteFile(outputFilename))
@@ -385,5 +390,5 @@
 				{
 					cerr << "loading material library failed" << endl;
-					exit(0);
+					return false;
 				}
 			}
@@ -538,4 +543,6 @@
 	}
 
+	ofile.close();
+
 	return true;
 }
@@ -545,5 +552,4 @@
 {
 	FILE *file;
-
 	if ((file = fopen(matFileName.c_str(), "r")) == NULL) return false;
 	
@@ -610,4 +616,6 @@
 	}
 
+	fclose(file);
+
 	return true;
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp	(revision 3265)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp	(revision 3268)
@@ -31,16 +31,19 @@
 #else
 	
-	//const int numFiles = 879;
-	const int numFiles = 10;
+	const int numFiles = 879;
+	//const int numFiles = 300;
 
 	vector<string> filenames;
 	const string base(model_path + argv[1]);
 
+	char filename[100];
+
 	for (int i = 0; i < numFiles; ++ i)
 	{
-		char filename[100];
 		sprintf(filename, "%s%s%d%s", base.c_str(), ".b", i, ".obj");
 		filenames.push_back(filename);
 	}
+
+	//cout << "press any key" << std::cin.get();
 
 	if (!converter.Convert2(filenames, model_path + argv[2]))
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3262)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3268)
@@ -8,4 +8,5 @@
 
 filename=vienna_full_hp
+filename=procedural_pompeii_area6_hires/pompeii
 #filename=city
 useLODs=1
@@ -47,5 +48,7 @@
 
 # initial camera position
-camPosition=483.398f 242.364f 186.078f
+#camPosition=483.398f 242.364f 186.078f
+camPosition=1300.0f -2500.0f 10.0f
+
 # initial camera orientation
 camDirection=1 0 0
