Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2100)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2119)
@@ -73,5 +73,5 @@
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 1823)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2119)
@@ -142,9 +142,19 @@
 	void VisualizeViewCells(const bool visualize);
 
+	/** Load an iv scene.
+	*/
 	bool LoadSceneIV(const String &filename, 
 					 SceneNode *root, 
 					 const int index);
 
-	bool LoadScene(const String &filename);
+	/** Load obj scene.
+	*/
+	bool LoadSceneObj(const String &filename,
+					  const String &viewCellsFile,
+					  SceneNode *root);
+
+	/** Load a scene.
+	*/
+	bool LoadScene(const String &filename, const String &viewCellsFilename);
 
 	void loadConfig(DataStreamPtr& stream);
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2111)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2119)
@@ -89,6 +89,6 @@
 				OptimizeForProcessor="3"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\Preprocessing\src\Timer"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\Preprocessing\src\Timer;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -105,10 +105,10 @@
 				Name="VCLinkerTool"
 				IgnoreImportLibrary="TRUE"
-				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib glew32.lib glew32s.lib IVReader.lib"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib glew32.lib glew32s.lib IVReader.lib ObjReader.lib"
 				OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll"
 				Version="0.99"
 				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"
-				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Zlib\lib;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Zlib\lib;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\lib\$(ConfigurationName)&quot;"
 				ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def"
 				GenerateDebugInformation="FALSE"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2115)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2119)
@@ -23,4 +23,6 @@
 #include "IntersectableWrapper.h"
 #include "IVReader.h"
+#include "ObjReader.h"
+
 
 
@@ -154,8 +156,8 @@
 
 	// load the scene
-	LoadScene(mFilename);
-	
-	// load view cells
-	//mViewCellsLoaded = LoadViewCells(mViewCellsFilename);
+	LoadScene(mFilename, mViewCellsFilename);
+	
+	// load view cells: load later ...
+	if (0) mViewCellsLoaded = LoadViewCells(mViewCellsFilename);
 
 	if (mShowTerrain)
@@ -1592,5 +1594,6 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::LoadScene(const String &filename)
+bool OcclusionCullingSceneManager::LoadScene(const String &filename, 
+											 const String &viewCellsFilename)
 {
 	using namespace std;
@@ -1620,5 +1623,14 @@
 		const string fn = *fit;
 
-		if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl"))
+		if (strstr(fn.c_str(), ".obj"))
+		{
+			// load iv files
+			if (!LoadSceneObj(filename, viewCellsFilename, getRootSceneNode()))
+			{
+				LogManager::getSingleton().logMessage("error loading file");
+				return false;
+            }
+		}
+		else if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl"))
 		{
 			// load iv files
@@ -1682,4 +1694,30 @@
 }
 //-----------------------------------------------------------------------
+bool OcclusionCullingSceneManager::LoadSceneObj(const String &filename,
+												const String &viewCellsFile,
+												SceneNode *root)
+{
+	ObjReader objReader(this);
+
+	Timer *timer = PlatformManager::getSingleton().createTimer();
+	timer->reset();
+
+	if (!objReader.LoadFile(filename.c_str(), viewCellsFile, root))
+	{
+		PlatformManager::getSingleton().destroyTimer(timer);
+		return false;
+	}
+
+	SceneNode *node = root->createChildSceneNode("ObjSceneNode");
+
+	std::stringstream d; 
+	d << "loaded " << filename << " in " << timer->getMilliseconds() * 1e-3 << " secs";
+	LogManager::getSingleton().logMessage(d.str());
+		
+	PlatformManager::getSingleton().destroyTimer(timer);
+
+	return true;
+}
+//-----------------------------------------------------------------------
 const String OcclusionCullingSceneManagerFactory::FACTORY_TYPE_NAME = "OcclusionCullingSceneManager";
 //-----------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h	(revision 2115)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h	(revision 2119)
@@ -2,39 +2,26 @@
 #define __ObjReader_H__
 
-//#include <stdlib>
 #include <string>
 #include <vector>
 #include <Ogre.h>
 #include "Containers.h"
-/*#include "ObjNode.h"
-#include "ObjMeshData.h"
-#include "ObjManualMeshLoader.h"
-*/
 
-
-namespace GtpVisibilityPreprocessor {
-
-struct Triangle3;
-
-}
-
-//typedef std::vector<GtpVisibilityPreprocessor::Triangle3 *> TriangleContainer;
 
 class __declspec(dllexport) ObjReader
 {
 public:
-	ObjReader();
+	ObjReader(Ogre::SceneManager *sceneManager);
 	~ObjReader();
 
-	bool LoadFile(const std::string &filename,
-				  GtpVisibilityPreprocessor::ObjectContainer &objects) const;
+	bool LoadFile(const string &sceneName, 
+				  const string &visibilitySolution,
+				  Ogre::SceneNode *root);
 	
-	const std::vector<Ogre::Entity *> &GetObjects() const;
-	
-	Ogre::Entity *CreateEntity(const std::string &name);
+	Ogre::Entity *CreateEntity(const std::string &name,
+							   GtpVisibilityPreprocessor::Intersectable *object);
 
 protected:
 
-	std::vector<Ogre::Entity *> mObjects;
+	Ogre::SceneManager *mSceneManager;
 };
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2112)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2119)
@@ -73,5 +73,5 @@
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include;..\..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp	(revision 2115)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp	(revision 2119)
@@ -3,7 +3,14 @@
 #include "Triangle3.h"
 #include "IntersectableWrapper.h"
+#include "BvHierarchy.h"
+#include "Preprocessor.h"
+#include "OgreEntity.h"
+#include "PreprocessorFactory.h"
+#include "OgreLogManager.h"
 
 
-ObjReader::ObjReader()
+
+ObjReader::ObjReader(Ogre::SceneManager *sceneManager):
+mSceneManager(sceneManager)
 {}
 
@@ -13,67 +20,81 @@
 
 
-bool ObjReader::LoadFile(const string &filename,
-						 GtpVisibilityPreprocessor::ObjectContainer &objects) const
+bool ObjReader::LoadFile(const string &sceneName, 
+						 const string &visibilitySolution,
+						 Ogre::SceneNode *root)
 {
-	igzstream samplesIn(filename.c_str());
-	
-	if (!samplesIn.is_open())
+	GtpVisibilityPreprocessor::Debug.open("debug.log");
+	// HACK: get any preprocessor to load file
+	GtpVisibilityPreprocessor::Preprocessor *preprocessor = 
+		GtpVisibilityPreprocessor::PreprocessorFactory::CreatePreprocessor("vss");
+
+	// hack
+	preprocessor->mLoadMeshes = false;
+	GtpVisibilityPreprocessor::ObjectContainer pvsObjects;
+
+	Ogre::LogManager::getSingleton().logMessage("loading obj scene!!");
+
+	if (preprocessor->LoadScene(sceneName))
+	{
+		Ogre::LogManager::getSingleton().logMessage("scene loaded, loading objects");
+		// form objects from the scene triangles
+		if (!preprocessor->LoadObjects(visibilitySolution, pvsObjects, preprocessor->mObjects))
+		{
+			Ogre::LogManager::getSingleton().logMessage("objects cannot be loaded");
+			return false;
+		}
+	}
+	else
+	{
+		Ogre::LogManager::getSingleton().logMessage("scene cannot be loaded");
 		return false;
-	
-	// read in triangle size
-	int numTriangles;
+	}
 
-	samplesIn.read(reinterpret_cast<char *>(&numTriangles), sizeof(int));
-	objects.reserve(numTriangles);
-	
-	while (1)
-	{
-		GtpVisibilityPreprocessor::Triangle3 tri;
-		
-		samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 0), 
-					   sizeof(GtpVisibilityPreprocessor::Vector3));
-		samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 1), 
-					   sizeof(GtpVisibilityPreprocessor::Vector3));
-		samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 2), 
-					   sizeof(GtpVisibilityPreprocessor::Vector3));
+	std::stringstream d; 
+	d << "successfully loaded " << pvsObjects.size() << " objects";
 
-		// end of file reached
-		if (samplesIn.eof())
-			break;
+	Ogre::LogManager::getSingleton().logMessage(d.str());
 
-		GtpVisibilityPreprocessor::TriangleIntersectable *obj = 
-			new GtpVisibilityPreprocessor::TriangleIntersectable(tri);
-		objects.push_back(obj);
+	GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = pvsObjects.end();
+
+	int i = 0;
+	for (oit = pvsObjects.begin(); oit != oit_end; ++ oit, ++ i)
+	{Ogre::LogManager::getSingleton().logMessage("r");
+		const Ogre::String entname = "Object" + i;
+
+		Ogre::Entity *ent = CreateEntity(entname, *oit);
+
+		const Ogre::String nodeName = entname + "/Node";
+		root->createChildSceneNode(nodeName);
 	}
-	
-	return true;
+
+	delete preprocessor;
+
+	return false;
 }
 
 
-const std::vector<Ogre::Entity *> &ObjReader::GetObjects() const
-{
-	return mObjects;
-}
-
-
-Ogre::Entity *ObjReader::CreateEntity(const std::string &name)
-//									  ObjMeshData *mData, 
-//									  Ogre::Vector3 *translation)
+Ogre::Entity *ObjReader::CreateEntity(const std::string &name,
+									  GtpVisibilityPreprocessor::Intersectable *object)
 {
 	using namespace Ogre;
+	//using namespace GtpVisibilityPreprocessor;
+
 	Entity *entity;
 
-	
-	std::string meshName = name.substr(name.find('/',0), name.length()) + "/Mesh";
+	GtpVisibilityPreprocessor::BvhLeaf *bvhObj = 
+		static_cast<GtpVisibilityPreprocessor::BvhLeaf *>(object);
+
+	std::string meshName = name + "/Mesh";
 	std::string entityName = name + "/Entity";
 
 	MeshPtr mesh = MeshManager::getSingleton().createManual(meshName, "ObjGroup");
 	SubMesh* submesh = mesh->createSubMesh();
-int nbVertices = 99992;
+
 	// We must create the vertex data, indicating how many vertices there will be
 	submesh->useSharedVertices = false;
 	submesh->vertexData = new VertexData();
 	submesh->vertexData->vertexStart = 0;
-	submesh->vertexData->vertexCount = nbVertices;
+	submesh->vertexData->vertexCount = (int)bvhObj->mObjects.size() * 3;
 
 	static const unsigned short source = 0;
@@ -82,5 +103,5 @@
 	VertexDeclaration* declaration = HardwareBufferManager::getSingleton().createVertexDeclaration();
 
-	offset += declaration->addElement(source,offset,VET_FLOAT3,VES_POSITION).getSize();
+	offset += declaration->addElement(source, offset, VET_FLOAT3,VES_POSITION).getSize();
 	//	offset += declaration->addElement(source,offset,VET_FLOAT3,VES_NORMAL).getSize();
 	//	offset += declaration->addElement(source,offset,VET_FLOAT2,VES_TEXTURE_COORDINATES).getSize();
@@ -89,36 +110,34 @@
 	int numVertices = 0;
 
-	HardwareVertexBufferSharedPtr vbuffer = 
-		HardwareBufferManager::getSingleton().createVertexBuffer(declaration->getVertexSize(source), // size of one whole vertex
-		submesh->vertexData->vertexCount, // number of vertices
-		HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage
-		false); // no shadow buffer
+	HardwareVertexBufferSharedPtr vbuffer = HardwareBufferManager::getSingleton().
+		createVertexBuffer(declaration->getVertexSize(source),
+						   submesh->vertexData->vertexCount,
+						   HardwareBuffer::HBU_STATIC_WRITE_ONLY,
+						   false);
 
-
-	// No we get access to the buffer to fill it.  During so we record the bounding box.
+    // No we get access to the buffer to fill it.  During so we record the bounding box.
 	AxisAlignedBox aabox;
 
 	float* vdata = static_cast<float*>(vbuffer->lock(HardwareBuffer::HBL_DISCARD));
 
-	for (size_t i = 0; i < nbVertices; ++ i)
+	GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = bvhObj->mObjects.end();
+
+	for (oit = bvhObj->mObjects.begin(); oit != oit_end; ++ oit)
 	{
-		// Position
-		Vector3 position;// = 20.0f*positions[i];
-		*vdata++ = position.x;
-		*vdata++ = position.y;
-		*vdata++ = position.z;
-		aabox.merge(position);
-		// Normal
-		Vector3 normal = position.normalisedCopy();
-		*vdata++ = normal.x;
-		*vdata++ = normal.y;
-		*vdata++ = normal.z;
+		GtpVisibilityPreprocessor::TriangleIntersectable *tObj = 
+			static_cast<GtpVisibilityPreprocessor::TriangleIntersectable *>(*oit);
+		
+		GtpVisibilityPreprocessor::Triangle3 tri = tObj->GetItem();
 
-		// Texture coordinate
-		Vector2 tcoordinate;// = tcoordinates[i];
-		*vdata ++ = tcoordinate.x;
+		for (int i = 0; i < 3; ++ i)
+		{
+			Vector3 vtx(tri.mVertices[i]);
 
-		*vdata ++ = tcoordinate.y;
+			*vdata ++ = vtx.x;
+			*vdata ++ = vtx.y;
+			*vdata ++ = vtx.z;
 
+			aabox.merge(vtx);
+		}
 	}
 
@@ -126,12 +145,11 @@
 
 	// We must indicate the bounding box
-	//mesh->_setBounds(aabox); 
+	mesh->_setBounds(aabox); 
 
-	//mesh->_setBoundingSphereRadius((aabox.getMaximum()-aabox.getMinimum()).length()/2.0); 
-
+	mesh->_setBoundingSphereRadius((aabox.getMaximum()-aabox.getMinimum()).length()/2.0); 
 	mesh->load();
 	
 	// Create an entity with the mesh
-	//entity = mSceneManager->createEntity(meshName, entityName);
+	entity = mSceneManager->createEntity(meshName, entityName);
 
 	return entity;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.h	(revision 2115)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.h	(revision 2119)
@@ -15,9 +15,10 @@
 {
 public:
-  ObjectsParser(): Parser() {}
+	
+	ObjectsParser(): Parser() {}
   
-  bool ParseObjects(const string &filename, 
-					ObjectContainer &pvsObjects,
-					const ObjectContainer &preprocessorObjects);
+	bool ParseObjects(const string &filename, 
+					  ObjectContainer &pvsObjects,
+					  const ObjectContainer &preprocessorObjects);
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2117)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2119)
@@ -479,4 +479,5 @@
 	const int files = SplitFilenames(filename, filenames);
 	cout << "number of input files: " << files << endl;
+
 	bool result = false;
 	bool isObj = false;
@@ -533,22 +534,21 @@
 		
 				result = parser->ParseFile(filename, 
-								   mSceneGraph->GetRoot(),
-								   mLoadMeshes,
-								   fi);
-						
+										   mSceneGraph->GetRoot(),
+										   mLoadMeshes,
+										   fi);
+
 				cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl;
+
 				// only works for triangles
 				if (result && !mLoadMeshes)
 				{
 					cout << "exporting binary obj to " << bnFile << "... " << endl;
+
 					ExportBinaryObj(bnFile, mSceneGraph->GetRoot());
+				
 					cout << "finished" << endl;
 				}
 
 				delete parser;
-			}
-			else if (0)
-			{
-				ExportBinaryObj("../data/test.bn", mSceneGraph->GetRoot());
 			}
 		}
@@ -741,11 +741,9 @@
 
         Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf);
-		
 		cout << "loading objects from " << buf << endl;
 
 		// load objects which will be used as pvs entries
 		ObjectContainer pvsObjects;
-
-		LoadObjects(buf, pvsObjects, mObjects);
+		if (0) LoadObjects(buf, pvsObjects, mObjects);
 
 		cout << "loading view cells from " << buf << endl;
@@ -1649,5 +1647,5 @@
 {
 	ObjectsParser parser;
-
+Debug << "here322 " << filename << endl;
 	const bool success = parser.ParseObjects(filename, 
 											 pvsObjects, 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorFactory.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorFactory.cpp	(revision 1942)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorFactory.cpp	(revision 2119)
@@ -14,6 +14,7 @@
 Preprocessor *PreprocessorFactory::CreatePreprocessor(const string &preprocessorType)
 {
+	Debug << "here9191" << endl;
 	if (preprocessorType == "vss")
-	{
+	{Debug << "here21112" << endl;
 		return new VssPreprocessor();
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2117)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2119)
@@ -2609,5 +2609,4 @@
 	}
 #else
-	cout<<"b";
 	pvs.AddSample(obj, pdf);
 #endif
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 2115)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 2119)
@@ -365,4 +365,5 @@
 {
 	friend class ViewCellsParseHandlers;
+	friend class ObjectsParseHandlers;
 	friend class HierarchyManager;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp	(revision 2105)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp	(revision 2119)
@@ -2264,6 +2264,5 @@
   
   int startIndex = (int)rays.size();
-  //  Debug<<"B"<<flush;
-  
+    
   AxisAlignedBox3 box = GetBBox(leaf);
   AxisAlignedBox3 dirBox = GetDirBBox(leaf);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h	(revision 2115)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h	(revision 2119)
@@ -25,4 +25,6 @@
 {
 public:
+
+	friend class BvHierarchy;
 
 	// -----------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp	(revision 2042)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp	(revision 2119)
@@ -236,18 +236,20 @@
 
 	while (fgets(str, 1000, file) != NULL)
-	{++ line;
+	{
+		++ line;
 	  switch (str[0]) 
 		{
 		case 'v': // vertex  or normal
 		  {
-			switch (str[1]) {
+			switch (str[1]) 
+			{
 			case 'n' :
-			  // normal do nothing
-			  break;
+				// normal do nothing
+				break;
 			default:
-			  float x, y, z; //cout << "v";	
-			  sscanf(str + 1, "%f %f %f", &x, &y, &z);
-			  vertices.push_back(Vector3(x,y,z));
-			  //cout << "vertex: " << vertices.back() << endl;
+				float x, y, z; //cout << "v";	
+				sscanf(str + 1, "%f %f %f", &x, &y, &z);
+				vertices.push_back(Vector3(x,y,z));
+			 
 			}
 			break;
@@ -258,4 +260,5 @@
 				{
 					Face *face = LoadFace(str, vertices, hashTable);
+
 					if (!face) break;
 	
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.cpp	(revision 2115)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.cpp	(revision 2119)
@@ -88,5 +88,5 @@
 	//if (!is_sorted(mPvsObjects.begin(), mPvsObjects.end(), ilt))
 		sort(mPvsObjects.begin(), mPvsObjects.end(), ilt);
-
+Debug << "here333";
 	//if (!is_sorted(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt))
 		//sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt);
@@ -133,5 +133,4 @@
 	if (element == "Leaf") 
 	{
-		//cout << "l";
 		StartBvhLeaf(attributes);
 	}
@@ -196,4 +195,5 @@
 }
 
+
 void ObjectsParseHandlers::StartBvhLeaf(AttributeList& attributes)
 {
@@ -217,8 +217,8 @@
 			sscanf(ptr, "%f %f %f", &maxBox.x, &maxBox.y, &maxBox.z);
 		}
-		/*if (attrName == "objects")
+		if (attrName == "objects")
 		{
 			StartBvhLeafObjects(objects, ptr);
-		}*/
+		}
 	}
 
@@ -227,6 +227,6 @@
 	BvhLeaf *leaf = new BvhLeaf(box, NULL, (int)objects.size());
 
-	//leaf->mObjects = objects;
-	//BvHierarchy::AssociateObjectsWithLeaf(leaf);
+	leaf->mObjects = objects;
+	BvHierarchy::AssociateObjectsWithLeaf(leaf);
 
 	// new pvs object
@@ -370,4 +370,5 @@
 
 			GzFileInputSource isource(myFilePath);
+			Debug<<"here93" << endl;
 			parser->parse(isource);
 #else
@@ -375,5 +376,5 @@
 
 #endif
-
+Debug<<"here932" << endl;
 			const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
 			duration = endMillis - startMillis;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 2115)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp	(revision 2119)
@@ -464,5 +464,4 @@
 	if (element == "BoundingBox")
 	{
-		// cout << "b";
 		StartBoundingBox(attributes);
 	}
