Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.h	(revision 3261)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.h	(revision 3274)
@@ -21,5 +21,5 @@
 public:
 
-	int WriteGeometry(Geometry *geom, std::ofstream &ostream);
+	int WriteGeometry(Geometry *geom, std::ofstream &ostream, Transform3 *trafo);
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 3259)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 3274)
@@ -40,5 +40,5 @@
 	if (delData)
 	{
-		DEL_ARRAY_PTR(mVertices);
+		//DEL_ARRAY_PTR(mVertices);
 		DEL_ARRAY_PTR(mNormals);
 		DEL_ARRAY_PTR(mTexCoords);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.cpp	(revision 3273)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.cpp	(revision 3274)
@@ -3,4 +3,5 @@
 #include "Shape.h"
 #include "Geometry.h"
+#include "Transform3.h"
 
 
@@ -20,5 +21,5 @@
 
 
-int ObjExporter::WriteGeometry(Geometry *geom, ofstream &ostream)
+int ObjExporter::WriteGeometry(Geometry *geom, ofstream &ostream, Transform3 *trafo)
 {
 	int numVertices;
@@ -30,5 +31,6 @@
 	for (int i = 0; i < numVertices; ++ i)
 	{
-		Vector3 v = vertices[i];
+		Vector3 v = trafo->GetMatrix() * vertices[i];
+
 		sprintf(str, "v %f %f %f\n", v.x, v.z, -v.y);
 		ostream << str;
@@ -75,4 +77,6 @@
 		 for (int i = 0; i < geometrySize; ++ i)
 		 {
+			 Transform3 *trafo = entities[i]->GetTransform();
+
 			 ShapeContainer::iterator sit, send;
 			 entities[i]->GetLODLevel(0, sit, send);
@@ -89,5 +93,5 @@
 				 }
 
-				 numVertices += WriteGeometry(geom, ostream);
+				 numVertices += WriteGeometry(geom, ostream, trafo);
 			 }
 		 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3272)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3274)
@@ -382,6 +382,6 @@
 	}
 
-	//const bool delGeometry = true;
-	const bool delGeometry = false;
+	const bool delGeometry = true;
+	//const bool delGeometry = false;
 	return new Geometry(vertices, normals, texcoords, vertexCount, delGeometry, NULL);//tangents);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 3267)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 3274)
@@ -359,7 +359,11 @@
 	*/
 	inline int GetNumNodes() const;
-	/** Counts the number of bvh nodes under this node
+	/** Counts the number of nodes in this subtree
 	*/
 	int CountNumNodes(BvhNode *node) const;
+	/** Counts the number of virtual nodes in this subtree
+	*/
+	int CountNumVirtualNodes(BvhNode *node) const;
+
 	/** Returns number of bvh leaves.
 	*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 3271)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 3274)
@@ -355,4 +355,32 @@
 
 
+int Bvh::CountNumVirtualNodes(BvhNode *node) const
+{
+	int numNodes = 0;
+
+	stack<BvhNode *> tStack;
+
+	tStack.push(node);
+
+	while (!tStack.empty())
+	{
+		BvhNode *node = tStack.top();
+		tStack.pop();
+
+		++ numNodes;
+
+		if (!node->IsVirtualLeaf())
+		{
+			BvhInterior *interior = static_cast<BvhInterior *>(node);
+
+			tStack.push(interior->mFront);
+			tStack.push(interior->mBack);
+		}
+	}
+
+	return numNodes;
+}
+
+
 void Bvh::CollectNodes(BvhNode *node, BvhNodeContainer &nodes)
 {
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3273)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3274)
@@ -600,7 +600,5 @@
 	AxisAlignedBox3 pompeiiBox = SceneEntity::ComputeBoundingBox(staticObjects);
 
-	cout << "here34 " << pompeiiBox << endl;
-	
-#if 0
+#if 1
 	// todo: dispose texture
 	Texture *floorTex = new Texture(model_path + "stairs.c.01.tif");
@@ -726,6 +724,6 @@
 
 
-	ObjExporter().Export(model_path + "myvienna.obj", bvh);
-	BvhExporter().Export(model_path + "myvienna.bv", bvh);
+	ObjExporter().Export(model_path + "mypompeii.obj", bvh);
+	BvhExporter().Export(model_path + "mypompeii.bv", bvh);
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhExporter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhExporter.cpp	(revision 3273)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhExporter.cpp	(revision 3274)
@@ -22,5 +22,5 @@
 	int buffer[4];
 
-	if (node->IsLeaf()) 
+	if (node->IsVirtualLeaf()) 
 	{
 		BvhLeaf *leaf = (BvhLeaf*)node;
@@ -55,5 +55,5 @@
 											int &last)
 {
-	if (!node->IsLeaf())
+	if (!node->IsVirtualLeaf())
 	{
 		int m;
@@ -94,5 +94,5 @@
 	 buffer[3] = 0; // construction method
 	 buffer[4] = 1; // termination leaves
-	 buffer[5] = bvh->CountNumNodes(bvh->GetStaticRoot());
+	 buffer[5] = bvh->CountNumVirtualNodes(bvh->GetStaticRoot());
 
 	 int first = 0, last;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj	(revision 3272)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj	(revision 3274)
@@ -155,5 +155,5 @@
 				IgnoreAllDefaultLibraries="false"
 				IgnoreDefaultLibraryNames="LIBCMT"
-				GenerateDebugInformation="true"
+				GenerateDebugInformation="false"
 				SubSystem="1"
 				LargeAddressAware="2"
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3273)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3274)
@@ -7,11 +7,12 @@
 # misc stuff
 
-filename=vienna_full_hp
-bvhname=vienna_full_hp
+#filename=vienna_full_hp
+#bvhname=vienna_full_hp
 #filename=newvienna
 #bvhname=newvienna
-#filename=procedural_pompeii_area6_hires/pompeii_full
+filename=procedural_pompeii_area6_hires/pompeii_full
 #filename=procedural_pompeii_area6_hires/pompeii_part
 #filename=city
+#bvhname=city
 useLODs=1
 # shadow map size
@@ -38,5 +39,6 @@
 maxBatchSize=50
 # triangles per bvh leaf (influences hierarchy depth vs. occlusion power)
-trianglesPerVirtualLeaf=300
+#trianglesPerVirtualLeaf=300
+trianglesPerVirtualLeaf=0
 # max depth for searching for nodes for tight bounds
 maxDepthForTestingChildren=3
@@ -53,7 +55,7 @@
 
 # initial camera position
-camPosition=483.398f 242.364f 186.078f
+#camPosition=483.398f 242.364f 186.078f
 # pompeii view point
-#camPosition=1300.0f -2500.0f 10.0f
+camPosition=1300.0f -2500.0f 10.0f
 
 # initial camera orientation
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp	(revision 3273)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp	(revision 3274)
@@ -538,5 +538,5 @@
 			const int idx = 3 * mGlobalTriangleIds[j];
 
-			//cout << "idx: " << mGlobalTriangleIds[j] << " j " << j << " " << vertices.size() / 3 << endl;
+			//cout << "idx: " << 3 * mGlobalTriangleIds[j] << " j " << j << " " << vertices.size()<< endl;
 			for (int k = 0; k < 3; ++ k)
 			{
