Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h	(revision 3272)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h	(revision 3277)
@@ -15,5 +15,4 @@
 
 class ogzstream;
-
 struct BvhInterior;
 
@@ -140,4 +139,11 @@
 
 
+	bool ReadObjSimple(const std::string &filename,
+		std::vector<CHCDemoEngine::Triangle3 *> &triangles);
+
+	void ConstructBvhObjects2(const std::vector<CHCDemoEngine::Triangle3 *> &triangles);
+
+
+
 	//////////////////////////////////
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp	(revision 3274)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp	(revision 3277)
@@ -231,5 +231,5 @@
 
 	//if (!LoadSolution(bvhInputFilename))
-	if (!LoadSolutionTest(bvhInputFilename))
+	if (!LoadSolution(bvhInputFilename))
 	{
 		cerr << "could not read solution file" << endl;
@@ -270,4 +270,5 @@
 bool VisibilitySolutionConverter::ReadScene(const string &filename)
 {
+	/*
 	VertexArray vertices;
 	VertexArray normals;
@@ -278,5 +279,17 @@
 		ConstructBvhObjects(vertices, normals, texCoords);
 		return true;
-	}
+	}*/
+
+	vector<CHCDemoEngine::Triangle3 *> triangles;
+
+	if (ReadObjSimple(filename, triangles)) 
+	{
+		ConstructBvhObjects2(triangles);
+		return true;
+	}
+
+	/*for (size_t i = 0; i < triangles.size(); ++ i)
+	delete triangles[i];
+	*/
 
 	return false;
@@ -417,6 +430,6 @@
 
 	bool alphaTestEnabled = false;
-	//bool cullFaceEnabled = true;
-	bool cullFaceEnabled = false;
+	bool cullFaceEnabled = true;
+	//bool cullFaceEnabled = false;
 
 	str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool));
@@ -929,2 +942,129 @@
 	return true;
 }
+
+
+bool VisibilitySolutionConverter::ReadObjSimple(const string &filename,
+												vector<CHCDemoEngine::Triangle3 *> &triangles
+												) 
+{
+	FILE *file;
+
+	if ((file = fopen(filename.c_str(), "r")) == NULL) return false;
+	
+	VertexArray vertices;
+
+	int line = 0;
+	const int len = 10000;
+	char str[len];
+
+	const string binFilename = ReplaceSuffix(filename, ".obj", ".bn");
+
+	cout << "binary dump " << binFilename << " not available, loading ascii obj" << endl;
+
+	while (fgets(str, len, file) != NULL)
+	{
+		if (line % 500000 == 0)
+			cout << line << " " << str;
+
+		++ line;
+
+		switch (str[0])
+		{
+		case 'v': // vertex or normal
+			{
+				float x, y, z;
+
+				sscanf(str + 1, "%f %f %f", &x, &y, &z);
+				CHCDemoEngine::Vector3 v = CHCDemoEngine::Vector3(x, -z, y) * sScale;
+				vertices.push_back(v);
+
+				if (vertices.size() == 3)
+				{
+					CHCDemoEngine::Triangle3 *tri = 
+						new CHCDemoEngine::Triangle3(vertices[0], vertices[1], vertices[2]);
+
+					triangles.push_back(tri);
+					vertices.clear();
+				}
+				break;
+			}
+		default:
+			// throw away line
+			break;
+		}
+	}
+
+	fclose(file);
+
+	return !triangles.empty();
+}
+
+
+void VisibilitySolutionConverter::ConstructBvhObjects2(const vector<CHCDemoEngine::Triangle3 *> &triangles)
+{
+	CHCDemoEngine::AxisAlignedBox3 testBox;
+	testBox.Initialize();
+
+	for (size_t i = 0; i < triangles.size(); ++ i)
+	{
+		testBox.Include(triangles[i]->mVertices[0]);
+		testBox.Include(triangles[i]->mVertices[1]);
+		testBox.Include(triangles[i]->mVertices[2]);
+	}
+
+	cout << "geometry bounds: " << testBox << endl;
+
+	mGeometry.reserve(mBvhLeaves.size());
+	mNumShapes = (int)mBvhLeaves.size();
+
+	VertexArray _vertices;	
+	VertexArray _normals;
+	vector<TexCoord> _texCoords;
+
+	int total = 0;
+	for (size_t i = 0; i < mBvhLeaves.size(); ++ i)
+	{
+		BvhLeaf *node = mBvhLeaves[i];
+		const int size = node->last - node->first + 1;
+
+		total += size;
+
+		if (i % 1000 == 0)
+			cout << "o " << i << " " << size << " " << total << endl;
+
+		_vertices.clear();
+		_normals.clear();
+		_texCoords.clear();
+
+		//cout << "vtx: " << size << endl;
+		for (int j = node->first; j <= node->last; ++ j)
+		{
+			const int idx = mGlobalTriangleIds[j];
+
+			//cout << "idx: " << 3 * mGlobalTriangleIds[j] << " j " << j << " " << vertices.size()<< endl;
+			for (int k = 0; k < 3; ++ k)
+			{
+				_vertices.push_back(triangles[idx]->mVertices[k]);
+			}
+
+			const CHCDemoEngine::Vector3 n = triangles[idx]->GetNormal();
+
+			_normals.push_back(n);
+			_normals.push_back(n);
+			_normals.push_back(n);
+
+			delete triangles[idx];
+		}
+
+		LoadShape(_vertices, _normals, _texCoords);
+		
+		// we store geometry in our bvh => change first and last pointer
+		// from triangles to geometry
+		node->first = (int)mGeometry.size() - 1;
+		node->last = (int)mGeometry.size() - 1;
+
+		//_vertices.clear();
+		//_normals.clear();
+		//_texCoords.clear();
+	}
+}
