Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env	(revision 2586)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env	(revision 2604)
@@ -170,5 +170,5 @@
 
 KdTree {
-	pvsArea   5e-4
+	pvsArea   8e-4
 	sahUseFaces false
 	Termination {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2598)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2604)
@@ -82,5 +82,5 @@
 struct VizBuffer
 {
-	VizBuffer(): mIndex(0), mMaxSize(10000)
+	VizBuffer(): mIndex(0), mMaxSize(1000)
 	{
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2601)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2604)
@@ -47,4 +47,6 @@
 const static int SAMPLES_INCR = 2000000;
 
+
+
 static inline bool ilt(Intersectable *obj1, Intersectable *obj2)
 {
@@ -271,15 +273,16 @@
 	GlRenderer::InitGL();
 
-	GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  };
-	/*  mat_specular and mat_shininess are NOT default values	*/
-	GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  };
-	GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  };
-	GLfloat mat_shininess[] = {  1.0  };
-
-	GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  };
-	GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  };
-	GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  };
-
-	GLfloat lmodel_ambient[] = {  0.3, 0.3, 0.3, 1.0  };
+	GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
+	
+	// mat_specular and mat_shininess are NOT default values
+	GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
+	GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f};
+	GLfloat mat_shininess[] = {1.0f};
+
+	GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
+	GLfloat light_diffuse[] = {0.4f, 0.4f, 0.4f, 1.0f};
+	GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f};
+
+	GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};
 
 
@@ -515,5 +518,5 @@
 		else 
 		{
-			if (!mRenderVisibilityEstimates)
+			if (!mRenderVisibilityEstimates && !mUseRandomColorPerPvsObject)
 			{
 				_RenderPvs();
@@ -529,8 +532,25 @@
 					Intersectable *object = it.Next(pvsData);
 
+					RgbColor color;
+
 					//float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f
 					// glColor3f(visibility, 0.0f, 0.0f);
 					//cerr << "sumpdf: " << pvsData.mSumPdf << endl;
-					RgbColor color = RainbowColorMapping(mTransferFunction*log10(pvsData.mSumPdf + 1));
+					if (mUseRandomColorPerPvsObject)
+					{
+						KdIntersectable *kdint = static_cast<KdIntersectable *>(object);
+
+						if (kdint->mGenericIdx == -1)
+						{
+							kdint->mGenericIdx = (int)mColors.size();
+							mColors.push_back(RandomColor());
+						}
+						color = mColors[kdint->mGenericIdx];
+					} 
+					else
+					{
+						color = RainbowColorMapping(mTransferFunction * log10(pvsData.mSumPdf + 1));
+					}
+
 					glColor3f(color.r, color.g, color.b);
 
@@ -562,7 +582,7 @@
 	else 
 	{
-		/*ObjectContainer::const_iterator oi = mObjects.begin();
-		for (; oi != mObjects.end(); oi++)
-		RenderIntersectable(*oi);*/
+		//ObjectContainer::const_iterator oi = mObjects.begin();
+		//for (; oi != mObjects.end(); oi++)
+		//	RenderIntersectable(*oi);
 		RenderScene();
 	}
@@ -772,5 +792,14 @@
 QtGlRendererWidget::keyPressEvent ( QKeyEvent * e )
 {
-	switch (e->key()) {
+	switch (e->key()) 
+	{
+case Qt::Key_E:
+	mRenderErrors = !mRenderErrors;
+	updateGL();
+	break;
+case Qt::Key_R:
+	mUseRandomColorPerPvsObject = !mUseRandomColorPerPvsObject;;
+	updateGL();
+	break;
 case Qt::Key_T:
 	mTopView = !mTopView;
@@ -819,4 +848,5 @@
 				}
 default:
+	cerr << "unknown key" << endl;
 	e->ignore();
 	break;
@@ -848,4 +878,6 @@
 	mRenderVisibilityEstimates = false;
 
+	mUseRandomColorPerPvsObject = false;
+
 	mHideByCost = false;
 	mUseTransparency = false;
@@ -874,5 +906,6 @@
 	mShowPiercingRays = false;
 	mShowWeightedRays = false;
-	mShowWeightedCost = false;
+	mUseStandardColors = false;
+	mShowWeightedCost = true;
 
 	mShowDistanceWeightedPvs = true;
@@ -922,4 +955,5 @@
 	connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), this, SLOT(SetUseSpatialFilter(bool)));
 	connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool)));
+	connect(mControlWidget, SIGNAL(SetShowWireFrame(bool)), this, SLOT(SetShowWireFrame(bool)));
 	connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool)));
 	connect(mControlWidget, SIGNAL(SetShowWeightedCost(bool)), this, SLOT(SetShowWeightedCost(bool)));
@@ -1108,4 +1142,5 @@
 
 	QString s;
+
 	int vc = 0;
 	if (mViewCellsManager)
@@ -1116,6 +1151,7 @@
 		filter = mViewCellsManager->GetMaxFilterSize();
 
-	glColor3f(1.0f,1.0f,1.0f);
-
+	glColor3f(0.0f, 0.0f, 1.0f);
+
+#if REMOVE_TEMPORARY
 	s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)",
 		mFrame,
@@ -1128,5 +1164,5 @@
 		);
 
-	renderText(20,20,s);
+	renderText(20, 20, s);
 
 	s.sprintf("viewcells:%04d filter:%04d pvs:%04d error:%5.5f %",
@@ -1136,10 +1172,10 @@
 		mRenderError*100.0f);
 
-
-	renderText(20,40,s);
-
-
-
-
+	renderText(20, 40, s);
+#endif
+	
+	QFont font40; font40.setPointSize(30);
+	s.sprintf("pvs:%04d", mPvsSize);
+	renderText(20, 40, s, font40);
 }
 
@@ -1361,6 +1397,34 @@
 	int i;
 
+	// transparency	
+	if (!mUseTransparency)
+	{
+		glEnable(GL_DEPTH_TEST);
+		glDisable(GL_BLEND);
+	}
+	else
+	{
+		glDisable(GL_DEPTH_TEST);
+		glEnable(GL_BLEND);
+
+		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+		//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+		for (i = 0; i < viewcells.size(); ++ i) 
+		{
+			ViewCell *vc = viewcells[i];
+
+			const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center());
+			vc->SetDistance(dist);
+		}
+
+		sort(viewcells.begin(), viewcells.end(), nearerThan);
+	}
+
+	//mWireFrame = true;
+		
 	// normal rendering
-	if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison)
+	//if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison)
+	if (mUseStandardColors)
 	{
 		for (i = 0; i < viewcells.size(); ++ i) 
@@ -1369,10 +1433,7 @@
 			RgbColor c;
 
-			if (!mShowPvsSizes && !mShowPiercingRays)
-			{
-				mWireFrame = true;
-				c = vc->GetColor();
-			} 
-
+			//if (!mShowPvsSizes && !mShowPiercingRays)
+			c = vc->GetColor();
+			
 			glColor3f(c.r, c.g, c.b);
 
@@ -1385,28 +1446,5 @@
 	else // using specialised colors
 	{
-		// transparency	
-		if (!mUseTransparency)
-		{
-			glEnable(GL_DEPTH_TEST);
-			glDisable(GL_BLEND);
-		}
-		else
-		{
-			glDisable(GL_DEPTH_TEST);
-			glEnable(GL_BLEND);
-
-			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-			//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
-			for (i = 0; i < viewcells.size(); ++ i) 
-			{
-				ViewCell *vc = viewcells[i];
-
-				const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center());
-				vc->SetDistance(dist);
-			}
-
-			sort(viewcells.begin(), viewcells.end(), nearerThan);
-		}
+	
 
 		if (!mShowComparison)
@@ -1499,5 +1537,5 @@
 	if (viewcells.size() > compareInfo.size())
 	{
-		cerr << "loaded size (" << compareInfo.size() << ") does not fit to view cells size (" << viewcells.size() << ")" << endl;
+		cerr << "loaded size (" << (int)compareInfo.size() << ") does not fit to view cells size (" << (int)viewcells.size() << ")" << endl;
 		return;
 	}
@@ -1556,5 +1594,5 @@
 	QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5;
 	
-	rb1 = new QRadioButton("wireframe", parent);
+	rb1 = new QRadioButton("random colors", parent);
 	rb1->setText("wireframe");
 	connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool)));
@@ -1588,5 +1626,5 @@
 	vbox2->addWidget(rb5);
 	
-	rb1->setChecked(true);
+	rb5->setChecked(true);
 
 	vbox2->addStretch(1);
@@ -1710,8 +1748,14 @@
 	vbox->setLayout(vl);
 
-	QLabel *label = new QLabel("Granularity");
+	QLabel *label;
+	QSlider *slider;
+	QPushButton *button;
+
+#if REMOVE_TEMPORARY
+
+	label = new QLabel("Granularity");
 	vbox->layout()->addWidget(label);
 
-	QSlider *slider = new QSlider(Qt::Horizontal, vbox);
+	slider = new QSlider(Qt::Horizontal, vbox);
 	vl->addWidget(slider);
 	slider->show();
@@ -1739,9 +1783,7 @@
 	////////////////////////////////////////7
 
-
-	QPushButton *button = new QPushButton("Update all PVSs", vbox);
+	button = new QPushButton("Update all PVSs", vbox);
 	vbox->layout()->addWidget(button);
 	connect(button, SIGNAL(clicked()), SLOT(UpdateAllPvs()));
-
 
 	////////////////////////////////////////77777
@@ -1758,4 +1800,6 @@
 
 	connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetVisibilityFilterSize(int)));
+
+#endif
 
 
@@ -1923,10 +1967,10 @@
 	//////////////////////////////
 
-
+#if REMOVE_TEMPORARY
 	cb = new QCheckBox("Cut scene", vbox);
 	vbox->layout()->addWidget(cb);
 	cb->setChecked(false);
 	connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetCutScene(bool)));
-
+#endif
 	cb = new QCheckBox("Render boxes", vbox);
 	vbox->layout()->addWidget(cb);
@@ -1945,6 +1989,6 @@
 	connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool)));
 
-
 	bool tmp;
+#if REMOVE_TEMPORARY
 
 	cb = new QCheckBox("Use filter", vbox);
@@ -1953,5 +1997,5 @@
 	cb->setChecked(tmp);
 	connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseFilter(bool)));
-
+#endif
 
 	cb = new QCheckBox("Use spatial filter", vbox);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2591)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2604)
@@ -14,4 +14,6 @@
 #include "QtPreprocessorThread.h"
 #include "LogReader.h"
+#include "Material.h"
+
 
 
@@ -127,7 +129,8 @@
   void SetShowRenderCost(bool);
   void SetShowPvsSizes(bool);
+  void SetShowWireFrame(bool);
   void SetShowPiercingRays(bool);
   void SetShowWeightedRays(bool);
-   void SetShowComparison(bool);
+  void SetShowComparison(bool);
   void SetShowWeightedCost(bool);
  
@@ -176,4 +179,5 @@
 	bool mShowPiercingRays;
 	bool mShowWeightedRays;
+	bool mUseStandardColors;
 	bool mShowRays;
 
@@ -215,4 +219,8 @@
 
 	ViewCellInfoContainer mCompareInfo;
+
+	vector<RgbColor> mColors;
+
+	bool mUseRandomColorPerPvsObject;
 
 	QtGlRendererWidget(SceneGraph *sceneGraph,
@@ -392,4 +400,10 @@
 		updateGL();
 	}
+
+	void SetShowWireFrame(bool b) {
+		mUseStandardColors = b;
+		updateGL();
+	}
+	
 
 	void SetShowWeightedRays(bool b) {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 2593)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 2604)
@@ -52,17 +52,25 @@
 void QtGlViewer::RenderScene()
 {
-	GLfloat mat_ambient[] = {0.1, 0.1, 0.1, 1.0};
-
+	GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  };
+	
 	// mat_specular and mat_shininess are NOT default values
-	GLfloat mat_diffuse[] = {0.5, 1.0, 0.5, 1.0};
-	GLfloat mat_specular[] = {0.3, 0.3, 0.3, 1.0};
-	GLfloat mat_shininess[] = {1.0};
-
-	GLfloat light_ambient[] = {0.1, 0.1, 0.1, 1.0};
-	GLfloat light_diffuse[] = {0.5, 0.5, 0.5, 1.0};
-	GLfloat light_specular[] = {0.0, 0.0, 0.0, 1.0};
-
-	GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0};
-
+	GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  };
+	GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  };
+	GLfloat mat_shininess[] = {  1.0  };
+
+	GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  };
+	GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  };
+	GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  };
+
+	GLfloat lmodel_ambient[] = {0.3, 0.3, 0.3, 1.0};
+
+
+	// set position of the light
+	GLfloat infinite_light[] = {1.0, 0.8, 1.0, 0.0};
+	glLightfv (GL_LIGHT0, GL_POSITION, infinite_light);
+
+	// set position of the light2
+	GLfloat infinite_light2[] = {-0.3, 1.5, 1.0, 0.0};
+	glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2);
 
 	// default material
@@ -76,14 +84,18 @@
 	glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
 	glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
+	
+	glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
+	glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
+	glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
+	
 	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
 
-	
 	//GLfloat infinite_light2[] = {-0.3, 1.5f, 1.0f, 0.0f};
 	//glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2);
+	//glColor3f(1.0f, 1.0f, 1.0f);
 	glColor3f(0.8f, 0.8f, 0.8f);
 	
 	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-	glDisable(GL_COLOR_MATERIAL);
-	//glEnable(GL_COLOR_MATERIAL);
+	glEnable(GL_COLOR_MATERIAL);
 
 	++ mRenderer->mFrame;
@@ -99,6 +111,8 @@
 	mRenderer->mDummyViewPoint = mDummyViewPoint;
 	
-	glDisable(GL_LIGHTING);
-	//glEnable(GL_LIGHTING);
+	glEnable(GL_NORMALIZE);
+	glEnable(GL_LIGHTING);
+	glEnable(GL_LIGHT0);
+	glEnable(GL_LIGHT1);
 
 	mRenderer->RenderPvs();
@@ -163,7 +177,7 @@
 
 	glLoadIdentity();
-	gluLookAt(0.0, 0.0, 1.0,  /* eye is at (0,0,30) */
-		      0.0, 0.0, 0.0,  /* center is at (0,0,0) */
-		      0.0, 1.0, 0.);  /* up is in positive Y direction */
+	gluLookAt(0.0f, 10.0f, 0.0f,  // eye is at (0,0,30) 
+		      0.0f, 0.0f, 0.0f,  // center is at (0,0,0) 
+		      0.0f, 0.0f, 1.0f); // up is in positive Y direction 
 
 	build_rotmatrix(m.x, manipulatorLastQuat);
@@ -212,15 +226,16 @@
 
 void
-QtGlViewer::keyPressEvent ( QKeyEvent * e )
+QtGlViewer::keyPressEvent(QKeyEvent * e)
 {
   switch (e->key()) {
   case Qt::Key_W:
-		mWireframe  = !mWireframe;
+		mWireframe = !mWireframe;
 		updateGL();
   default:
 		e->ignore();
+		cerr << "unknown key" << endl;
 		break;
   }
-  updateGL();
+  //updateGL();
 }
 
@@ -228,6 +243,6 @@
 QtGlViewer::mouseMoveEvent(QMouseEvent *event)
 {
-  int dx = event->x() - lastPos.x();
-  int dy = event->y() - lastPos.y();  
+  int dx = event->x() + lastPos.x();
+  int dy = event->y() + lastPos.y();  
   
   if (event->modifiers() & Qt::CTRL)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2601)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2604)
@@ -396,5 +396,5 @@
 	glEnable(GL_NORMALIZE);
 
-	glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
+	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
 
 	OcclusionQuery::GenQueries(mOcclusionQueries, 10);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp	(revision 2575)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp	(revision 2604)
@@ -170,5 +170,5 @@
 
 KdIntersectable::KdIntersectable(KdNode *item, const AxisAlignedBox3 &box) :
-  IntersectableWrapper<KdNode *>(item), mNumTriangles(-1), mBox(box)
+  IntersectableWrapper<KdNode *>(item), mNumTriangles(-1), mBox(box), mGenericIdx(-1)
 {
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h	(revision 2599)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h	(revision 2604)
@@ -182,4 +182,6 @@
 	AxisAlignedBox3 mBox;
 
+	int mGenericIdx;
+
 protected:
 
