Index: GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp	(revision 2756)
+++ GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp	(revision 2759)
@@ -18,7 +18,8 @@
 	mTexture = NULL;
 
-	mAmbientColor = RgbColor(0, 0, 0);
+	mAmbientColor = RgbColor(0.2, 0.2, 0.2);
 	mDiffuseColor = RgbColor(1, 1, 1);
-	mSpecularColor = RgbColor(0, 0, 0);
+	//mSpecularColor = RgbColor(0.5, 0.5, 0.5);
+	mSpecularColor = RgbColor(1, 1, 1);
 }
 
Index: GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp	(revision 2758)
+++ GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp	(revision 2759)
@@ -34,4 +34,5 @@
 float nearDist = 0.1f; 
 int winWidth, winHeight;
+float winAspectRatio = 1.0f;
 
 float visZoomFactor = 1.5f;
@@ -48,8 +49,4 @@
 Vector3 lightDir = Vector3(0.0f, 0.0f, 1.0f);  // light dir 
 
-Matrix4x4 eyeView; // eye view matrix
-Matrix4x4 eyeProjection; // eye projection matrix
-Matrix4x4 eyeProjView; //= eyeProjection*eyeView
-Matrix4x4 invEyeProjView; //= eyeProjView^(-1)
 Matrix4x4 visView; // visualisation view matrix
 
@@ -58,17 +55,4 @@
 //int renderMode = RenderTraverser::RENDER_COHERENT;
 
-// relative size of an object
-float objectSize = 3.5f;
-
-int numObjects = 2000;
-int numNextObjects = numObjects;
-float zLength = 30.0f;
-
-// this defines the volume where objects can be drawn
-Vector3 minTranslation(-2.5f, -2.5f, -3.0f);
-Vector3 maxTranslation(2.5f, 2.5f, -3.0 - zLength);
-
-const float minAngle = 0;
-const float maxAngle = 360;
 
 const int renderTimeSize = 100;
@@ -84,18 +68,18 @@
 Vector3 spec[2];
 
-void InitExtensions(void);
+void InitExtensions();
 void DisplayVisualization();
-void InitGLstate(void);
-void CleanUp(void);
-void SetupEyeView(void);
-void UpdateEyeMtx(void);
-
-
-void begin2D(void);
-void end2D(void);
+void InitGLstate();
+void CleanUp();
+void SetupEyeView();
+void UpdateEyeMtx();
+void SetupLighting();
+
+void begin2D();
+void end2D();
 void output(int x, int y, const char *string);
-void keyboard(const unsigned char c, int x, int y);
-void drawHelpMessage(void);
-void drawStatistics(void);
+void keyboard(unsigned char c, int x, int y);
+void drawHelpMessage();
+void drawStatistics();
 void display(void);
 void special(int c, int x, int y);
@@ -140,5 +124,5 @@
 
 	//const string filename("house_test.dem");
-	const string filename("city.dem");
+	const string filename("city_demo.dem");
 
 	if (loader.Load(filename, sceneEntities))
@@ -154,5 +138,6 @@
 		sceneBox.Include((*it)->GetBoundingBox());
 
-	Debug << "scene box: " << sceneBox << endl;
+	cout << "scene box: " << sceneBox << endl;
+
 
 	//SetupProjection(800, 600, 60, sceneBox);
@@ -177,5 +162,5 @@
 void InitGLstate(void) 
 {
-	glClearColor(0.0f, 1.0f, 0.0f, 0.0);
+	glClearColor(0.0f, 0.0f, 0.0f, 0.0);
 	
 	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -184,26 +169,10 @@
 	glDepthFunc(GL_LESS);
 
-	glEnable(GL_LIGHTING);
-	glEnable(GL_LIGHT0);
-	//glDisable(GL_LIGHTING);
+	SetupLighting();
 
 	glColor3f(1.0f, 0.0f, 0.0f);
 	glShadeModel(GL_SMOOTH);
 	
-	GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0};
-	GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0};
-	GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
-	GLfloat position[] = {0.0, 3.0, 3.0, 0.0};
-    
-	GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0};
-	GLfloat local_view[] = {0.0};
-
-	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
-	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
-	glLightfv(GL_LIGHT0, GL_POSITION, position);
-	
-	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
-	glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
-
+	
 	glMaterialf(GL_FRONT, GL_SHININESS, 64);
 	glEnable(GL_NORMALIZE);
@@ -216,5 +185,5 @@
 	GLfloat ambientColor[] = {0.5, 0.5, 0.5, 1.0};
 	GLfloat diffuseColor[] = {1.0, 0.0, 0.0, 1.0};
-	GLfloat specularColor[] = {1.0, 1.0, 1.0, 1.0};
+	GLfloat specularColor[] = {0.0, 0.0, 0.0, 1.0};
 
 	glMaterialfv(GL_FRONT, GL_AMBIENT, ambientColor);
@@ -297,27 +266,70 @@
 
 
-void UpdateEyeMtx(void) 
-{
-	/*const Vector3 up(0.0, 1.0, 0.0);
-
-	look(eyeView, eyePos, viewDir, up);
-	mult(eyeProjView, eyeProjection, eyeView); //eyeProjView = eyeProjection*eyeView
-	invert(invEyeProjView, eyeProjView); //invert matrix
-	*/
-}
-
+void SetupLighting()
+{
+	glEnable(GL_LIGHTING);
+	glEnable(GL_LIGHT0);
+	glEnable(GL_LIGHT1);
+	//glDisable(GL_LIGHT1);
+	//glDisable(GL_LIGHTING);
+
+	//GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0};
+	GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
+	GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0};
+	GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
+	    
+	//GLfloat lmodel_ambient[] = {0.5f, 0.5f, 0.5f, 1.0};
+	GLfloat lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
+
+	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+	glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
+
+	GLfloat position[] = {0.0, 3.0, 3.0, 0.0};
+	glLightfv(GL_LIGHT0, GL_POSITION, position);
+
+
+	////////////
+	//-- second light
+
+	GLfloat ambient1[] = {0.2, 0.2, 0.2, 1.0};
+	GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0};
+	GLfloat specular1[] = {0.0, 0.0, 0.0, 1.0};
+
+	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);
+	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);
+	glLightfv(GL_LIGHT1, GL_SPECULAR, specular1);
+	
+	GLfloat position1[] = {0.0, 1.0, 0.0, 1.0};
+	glLightfv(GL_LIGHT1, GL_POSITION, position1);
+
+	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
+	//glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
+	//glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);
+	glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT);
+
+}
 
 void SetupEyeView(void)
 {
-	//SetupProjection(800,600,60,sceneBox);
+	
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+
+	gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(sceneBox.Diagonal()));
+
 	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();	
+
+	GLfloat position[] = {0.0f, 3.0f, 3.0f, 0.0f};
+	glLightfv(GL_LIGHT0, GL_POSITION, position);
+
+	GLfloat position1[] = {sceneBox.Center().x, sceneBox.Center().y, sceneBox.Center().z, 1.0f};
+	glLightfv(GL_LIGHT1, GL_POSITION, position1);
+
 	camera->SetupCameraView();
 
-/*	glMatrixMode(GL_PROJECTION);
-	glLoadMatrixf((float *)eyeProjection.x);
-
-	glMatrixMode(GL_MODELVIEW);
-	glLoadMatrixf((float *)eyeView.x);
-	*/
+
 }
 
@@ -336,43 +348,41 @@
 	char msg8[100];
 
-/*
-	sprintf_s(msg2, "Traversed: %4d, frustum culled: %4d, query culled: %4d (of %d nodes)",
+
+	/*sprintf_s(msg2, "Traversed: %4d, frustum culled: %4d, query culled: %4d (of %d nodes)",
 			traverser.GetNumTraversedNodes(), traverser.GetNumFrustumCulledNodes(),
 			traverser.GetNumQueryCulledNodes(), 
 			traverser.GetHierarchy()->GetNumHierarchyNodes());
-
+*/
 	char *optstr[2] = {"", ", using optimization"};
-	char *querystr[2] = {"NV", "ARB"};
-
+	
 	float fps = 1e3f;
 	long renderTime = calcRenderTime();
-	if (renderTime) fps = 1e6f / (float)calcRenderTime();
-
-	sprintf_s(msg3, "Threshold: %4d, algorithm rendering time: %ld ms (%3.3f fps), queries: %s%s", 
-		traverser.GetVisibilityThreshold(), renderTime / 1000, fps, querystr[useArbQueries], optstr[useOptimization]);
+	if (renderTime) fps = 1e3f / (float)renderTime;
+
+	//sprintf_s(msg3, "Threshold: %4d, algorithm rendering time: %ld ms (%3.3f fps), queries: %s", 
+	//	traverser.GetVisibilityThreshold(), renderTime / 1000, fps, optstr[useOptimization]);
+	sprintf_s(msg3, "render time: %ld ms (%3.3f fps), queries: %s",  renderTime, fps, optstr[useOptimization]);
 
 	string str;
 	string str2;
 
-	calcDecimalPoint(str, Geometry::CountTriangles(objectType) * traverser.GetNumRenderedGeometry());
+	/*calcDecimalPoint(str, Geometry::CountTriangles(objectType) * traverser.GetNumRenderedGeometry());
 	calcDecimalPoint(str2, Geometry::CountTriangles(objectType) * numObjects);
 
 	sprintf_s(msg4, "Rendered objects %d (of %d), rendered triangles: %s (of %s)", 
 			traverser.GetNumRenderedGeometry(), numObjects, str.c_str(), str2.c_str()); 
-
-	sprintf_s(msg5, "Next object num: %d", numNextObjects);
-	sprintf_s(msg6, "Next length in z dir: %3.3f", zLength);
-	
-	char *objectTypeStr[3] = {"teapot", "torus", "sphere"};
-
-	sprintf_s(msg7, "Next object type: %s", objectTypeStr[nextObjectType]);
-	sprintf_s(msg8, "Next object size: %3.3f", objectSize);
 */
+	
 
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
 	// bring eye modelview matrix up-to-date
-	UpdateEyeMtx(); 
 	SetupEyeView();
+
+	InitTiming();
+
+	long t1, t2;
+
+	t1 = GetTime();
 
 	glEnableClientState(GL_VERTEX_ARRAY);
@@ -408,4 +418,9 @@
 	glDisable(GL_TEXTURE_2D);
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+	
+
+	t2 = GetTime();
+	long loop_time = TimeDiff(t1, t2);
+	//cout<<"t: " << loop_time<<endl;
 
 	/*
@@ -413,6 +428,8 @@
 	traverser.SetProjViewMatrix(eyeProjView);
 	traverser.Render(renderMode);
+	*/
+
 	// cycle through rendertime array
-	renderTimes[renderTimesIdx] = traverser.GetRenderTime();
+	renderTimes[renderTimesIdx] = loop_time;// traverser.GetRenderTime();
 	renderTimesIdx = (renderTimesIdx + 1) % renderTimeSize;
 
@@ -420,7 +437,6 @@
 		renderTimesValid = renderTimesIdx;
 
-	if(visMode)
-		displayVisualization();
-	*/
+	//if(visMode) displayVisualization();
+	
 
 	
@@ -445,7 +461,8 @@
 				output(10, winHeight-90,  msg5);
 			}
+
 			output(10, winHeight-70, msg3);
-			output(10, winHeight-50, msg4);
-			output(10, winHeight-30, msg2);
+			//output(10, winHeight-50, msg4);
+			//output(10, winHeight-30, msg2);
 		}
 	}
@@ -469,7 +486,5 @@
 		break;
 	case 32: //space
-	
-		//	renderMode = (renderMode + 1) % RenderTraverser::NUM_RENDERMODES;
-		
+		// renderMode = (renderMode + 1) % RenderTraverser::NUM_RENDERMODES;
 		resetTimer();
 		//traverser.Render(renderMode);		// render once so stats are updated
@@ -568,16 +583,16 @@
 		break;
 	case GLUT_KEY_F4:
-		zLength -= 1;
-		if(zLength < 0) zLength = 0;
+		//zLength -= 1;
+		//if(zLength < 0) zLength = 0;
 		break;
 	case GLUT_KEY_F5:
-		zLength += 1;
+		//zLength += 1;
 		break;		
 	case GLUT_KEY_F6:
-		objectSize -= 0.1;
-		if(objectSize < 0.1) objectSize = 0.1;
+		//objectSize -= 0.1;
+		//if(objectSize < 0.1) objectSize = 0.1;
 		break;
 	case GLUT_KEY_F7:
-		objectSize += 0.1;
+		//objectSize += 0.1;
 		break;
 	case GLUT_KEY_F8:
@@ -608,5 +623,5 @@
 void reshape(const int w, const int h) 
 {
-	double winAspectRatio = 1.0;
+	winAspectRatio = 1.0f;
 
 	glViewport(0, 0, w, h);
@@ -615,13 +630,11 @@
 	winHeight = h;
 
-	if (w) winAspectRatio = (double) h / (double) w;
+	if (w) winAspectRatio = (float) h / (float) w;
 
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
 
-	gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0 * Magnitude(sceneBox.Diagonal()));
+	gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(sceneBox.Diagonal()));
 	glMatrixMode(GL_MODELVIEW);
-
-	//perspectiveDeg(eyeProjection, 60.0, 1.0f/winAspectRatio, nearDist, 150.0);
 
 	glutPostRedisplay();
@@ -790,5 +803,5 @@
 		for (i = 0; i < len; i++) 
 		{
-			glutBitmapCharacter(GLUT_BITMAP_8_BY_13,string[i]);
+			glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string[i]);
 		}
 	}
