Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3290)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h	(revision 3295)
@@ -62,5 +62,4 @@
 #define NUM_DOF_TABS 16
 
-
 #define USE_GTX
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3230)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg	(revision 3295)
@@ -191,5 +191,6 @@
 	//-- compute color bleeding + ao
 
-	GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view), sampleIntensity);
+	GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, 
+		                    w, bl, br, tl, tr, normalize(IN.view), sampleIntensity);
 	
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp	(revision 3291)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp	(revision 3295)
@@ -294,5 +294,7 @@
 	// downscale ambient color
 	if (scaleToRange)
+	{
 		ambient *= 8e-6f;
+	}
 	else
 	{
@@ -342,7 +344,11 @@
 	// calculate final sun diffuse color.
 	if (scaleToRange)
+	{
 		diffuse = color * 3e-5f;
+	}
 	else
+	{
 		diffuse = color * 3e-1f;
+	}
 
 	// diffuse component should be more saturated (and less blueish) for high sun positions
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3294)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3295)
@@ -160,4 +160,7 @@
 int visibilitySolutionInitialState = 0;
 
+Vector3 defaultAmbient(0.2f);
+Vector3 defaultDiffuse(1.0f);
+
 
 /// the technique used for rendering
@@ -462,4 +465,6 @@
 		env.GetVectorParam(string("camDirection"), camDir);
 		env.GetVectorParam(string("lightDirection"), lightDir);
+		env.GetVectorParam(string("defaultAmbient"), defaultAmbient);
+		env.GetVectorParam(string("defaultDiffuse"), defaultDiffuse);
 
 		env.GetBoolParam(string("useFullScreen"), useFullScreen);
@@ -617,5 +622,4 @@
 	//LoadModel("toyplane2.dem", dynamicObjects);
 	//LoadModel("elephal.dem", dynamicObjects);
-	//LoadModel("sibenik.dem", dynamicObjects);
 
 	if (0) LoadPompeiiFloor();
@@ -971,5 +975,5 @@
 }
 
-/** Setup sunlight
+/** Setup lighting conditions
 */
 void SetupLighting()
@@ -1011,12 +1015,11 @@
 	else
 	{
-
-		ambient[0] = .2f;
-		ambient[1] = .2f;
-		ambient[2] = .2f;
-
-		diffuse[0] = 1.0f;
-		diffuse[1] = 1.0f;
-		diffuse[2] = 1.0f;
+		ambient[0] = defaultAmbient.x;
+		ambient[1] = defaultAmbient.y;
+		ambient[2] = defaultAmbient.z;
+
+		diffuse[0] = defaultDiffuse.x;
+		diffuse[1] = defaultDiffuse.y;
+		diffuse[2] = defaultDiffuse.z;
 	}
 
@@ -1296,5 +1299,7 @@
 
 		if (showShadowMap && !renderLightView)
+		{
 			RenderShadowMap(camera->GetFar());
+		}
 
 		//glPushAttrib(GL_VIEWPORT_BIT);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp	(revision 3280)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp	(revision 3295)
@@ -110,6 +110,4 @@
 	int bestAxis = 0;
 
-	//  cout<<"Evaluating axis..."<<endl<<flush;
-
 	const int initialPlanes = 3;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt	(revision 3280)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt	(revision 3295)
@@ -196,2 +196,9 @@
 
 find out ssao artifacts on edges (near edge no ambient occlusion)
+
+
+///////////
+
+shadows not working proberly with chc!!! (too many triangles, slow!!)
+
+sibenik: textures dissappear!!
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env	(revision 3295)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env	(revision 3295)
@@ -0,0 +1,117 @@
+#####################################################
+#   environment file for the friendlyculling demo   #
+#####################################################
+
+
+################
+# misc stuff
+
+filename=city
+bvhname=city
+
+useLODs=1
+
+# shadow map size
+shadowSize=4096
+
+# the filenames given to recorded frames (+ number.bmp)
+recordedFramesSuffix=frames/vienna_frame
+
+# the filename for the statistics
+statsFilename=mystats
+walkThroughSuffix=walkthrough_vienna
+
+# use potentially visible sets?
+usePvs=0
+
+# if using pvs, this specifies the name of the visibility solution
+visibilitySolution=myvienna-3x1-obvh-pgv
+
+viewCellsScaleFactor=1.0f
+useSkylightForIllum=1
+
+skyDomeScaleFactor=80.0f
+
+visibilitySolutionInitialState=500000000
+# renderMode: Frustum Culling, Stop And Wait, CHC, CHC ++
+renderMode=3
+
+############
+## chc++ options
+
+assumedVisibleFrames=10
+maxBatchSize=50
+# triangles per bvh leaf (influences hierarchy depth vs. occlusion power)
+#trianglesPerVirtualLeaf=300
+trianglesPerVirtualLeaf=0
+# max depth for searching for nodes for tight bounds
+maxDepthForTestingChildren=3
+
+
+####################
+## camera / light options
+
+# move speed
+keyRotation=0.5f
+keyForwardMotion=20.0f
+keyForwardMotion=30.0f
+
+# initial camera position
+camPosition=483.398f 242.364f 186.078f
+# initial camera orientation
+camDirection=1 0 0
+
+#lightDirection=0.509293 0.784034 -0.35484
+#lightDirection=0.360937 0.0267167 -0.932207
+lightDirection=0.556361 0.559966 -0.613923
+
+#####################
+## window options
+
+#winWidth=800
+#winHeight=600
+
+winWidth=1024
+winHeight=768
+
+useFullScreen=0
+
+# the used render method (forward, forward + depth pass, deferred, deferred + depth pass
+#renderMethod=2
+renderMethod=0
+
+#modelPath=data/city/model/
+
+
+############
+## shader options for deferred rendering
+
+# tone mapping
+useHDR=0
+# use antialiasing
+useAA=0
+# show lense flare
+useLenseFlare=1
+# use ssao / color bleeding
+useAdvancedShading=1
+# skylight turbitity
+turbitity=3.0f
+#turbitity=2.0f
+#sky dome scale factor
+
+
+###############
+## ssao options
+
+# use full resolution ssao (vs. half resoltion)
+ssaoUseFullResolution=1
+# ssao kernel radius
+#ssaoKernelRadius=8e-1f
+ssaoKernelRadius=4e-1f
+# ssao sample intensity
+#ssaoSampleIntensity=0.2f
+ssaoSampleIntensity=0.8f
+# ssao temporal coherence factor
+tempCohFactor=2000.0f
+# ssao filter radius
+ssaoFilterRadius=12.0f
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/powerplant.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/powerplant.env	(revision 3295)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/powerplant.env	(revision 3295)
@@ -0,0 +1,126 @@
+#####################################################
+#   environment file for the friendlyculling demo   #
+#####################################################
+
+
+###########################
+## powerplant options
+
+# static geometry
+filename=PowerPlantM
+bvhname=PowerPlantM
+
+visibilitySolution=power-plant-2c-xx-1000b-pgv2
+#visibilitySolution=power-plant-2c-xx-1000d-pgv
+#visibilitySolution=power-plant-2c-xx-1000b-spgvu
+viewCellsScaleFactor=0.05f
+
+useSkylightForIllum=1
+skyDomeScaleFactor=1000.0f
+
+walkThroughSuffix=walkthrough_pp_1
+
+################
+# misc stuff
+
+useLODs=1
+# shadow map size
+shadowSize=4096
+# the filename for the statistics
+statsFilename=mystats
+#walkThroughSuffix=walkthrough_pp_1
+
+# use potentially visible sets?
+usePvs=0
+
+# if using pvs, this specifies the name of the visibility solution
+visibilitySolutionInitialState=500000000
+
+
+############
+## chc++ options
+
+assumedVisibleFrames=10
+maxBatchSize=50
+# triangles per bvh leaf (influences hierarchy depth vs. occlusion power)
+#trianglesPerVirtualLeaf=300
+trianglesPerVirtualLeaf=0
+# max depth for searching for nodes for tight bounds
+maxDepthForTestingChildren=3
+
+
+####################
+## camera / light options
+
+# move speed
+keyRotation=0.5f
+keyForwardMotion=500.0f
+mouseMotion=10.0f
+
+# initial camera orientation
+#camDirection=1 0 0
+
+#camPosition=-1320.57 -6306.34 3603
+#camDirection=0.292156 0.9556 0.0383878
+
+#camDirection=-0.917729 -0.397207 -0
+#camPosition=1145.31 413.602 186.678
+camPosition=763.554 -10254.5 2604
+camDirection=-0.0975121 0.994494 0.0383878
+
+lightDirection=0.360937 0.0267167 -0.932207
+#lightDirection=0.509293 0.784034 -0.35484
+
+
+#####################
+## window options
+
+#winWidth=800
+#winHeight=600
+
+winWidth=1024
+winHeight=768
+
+useFullScreen=0
+
+# the used render method (forward, forward + depth pass, deferred, deferred + depth pass
+#renderMethod=2
+renderMethod=0
+
+#modelPath=data/city/model/
+
+
+############
+## shader options for deferred rendering
+
+# tone mapping
+useHDR=0
+# use antialiasing
+useAA=0
+# show lense flare
+useLenseFlare=1
+# use ssao / color bleeding
+useAdvancedShading=1
+# skylight turbitity
+turbitity=3.0f
+#turbitity=2.0f
+#sky dome scale factor
+
+
+###############
+## ssao options
+
+# use full resolution ssao (vs. half resoltion)
+ssaoUseFullResolution=1
+# ssao kernel radius
+#ssaoKernelRadius=8e-1f
+ssaoKernelRadius=4e-1f
+# ssao sample intensity
+#ssaoSampleIntensity=0.2f
+ssaoSampleIntensity=0.8f
+# ssao temporal coherence factor
+tempCohFactor=2000.0f
+# ssao filter radius
+ssaoFilterRadius=12.0f
+
+
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp	(revision 3263)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp	(revision 3295)
@@ -403,4 +403,5 @@
 
 #if 0
+
 bool ObjConverter::WriteFile(const string &filename)
 {
@@ -480,5 +481,7 @@
 	return true;
 }
+
 #else
+
 bool ObjConverter::WriteFile(const string &filename)
 {
@@ -562,27 +565,30 @@
 
 
-	int entityCount = 1;
+	//int entityCount = 1;
+	int entityCount = mNumShapes;
 	ofile.write(reinterpret_cast<char *>(&entityCount), sizeof(int));
 
 
 	//////////
-	//-- write single scene entity
-
-	// no transformation
-	bool hasTrafo = false;
-	ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool));
-
-	// a dummy lod
-	int numLODs = 1;
-	ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int));
-
-	float dist = 0;
-	ofile.write(reinterpret_cast<char *>(&dist), sizeof(float));
-
-	ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int));
+	//-- q: write single scene entity with all shapes or many entities with one shape
 
 	// all shapes belong to this scene entity
 	for (int i = 0; i < mNumShapes; ++ i)
 	{
+		// no transformation
+		bool hasTrafo = false;
+		ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool));
+
+		// a dummy lod
+		int numLODs = 1;
+		ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int));
+
+		float dist = 0;
+		ofile.write(reinterpret_cast<char *>(&dist), sizeof(float));
+
+		//ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int));
+		int one = 1;
+		ofile.write(reinterpret_cast<char *>(&one), sizeof(int));
+
 		int shapeId = i;
 		ofile.write(reinterpret_cast<char *>(&shapeId), sizeof(int));
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp	(revision 3275)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp	(revision 3295)
@@ -1,3 +1,3 @@
-#include "ObjConverter2.h"
+#include "ObjConverter.h"
 #include <iostream>
 #include <time.h>
@@ -10,8 +10,9 @@
 	int returnCode = 0;
 
-	ObjConverter2 converter;
+	//ObjConverter2 converter;
+	ObjConverter converter;
 
 	cout << "converting obj to dem format" << endl;
-#if 0	
+#if 1
 	if (!converter.LoadMaterials(model_path + argv[3]))
 	{
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env	(revision 3295)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env	(revision 3295)
@@ -0,0 +1,116 @@
+#####################################################
+#   environment file for the friendlyculling demo   #
+#####################################################
+
+
+################
+# misc stuff
+
+filename=sibenik
+
+useLODs=1
+
+# shadow map size
+shadowSize=1024
+
+# the filenames given to recorded frames (+ number.bmp)
+recordedFramesSuffix=frames/vienna_frame
+
+# the filename for the statistics
+statsFilename=mystats
+walkThroughSuffix=walkthrough_vienna
+
+# use potentially visible sets?
+usePvs=0
+
+viewCellsScaleFactor=1.0f
+useSkylightForIllum=0
+
+
+visibilitySolutionInitialState=500000000
+# renderMode: Frustum Culling, Stop And Wait, CHC, CHC ++
+renderMode=3
+
+############
+## chc++ options
+
+assumedVisibleFrames=10
+maxBatchSize=50
+# triangles per bvh leaf (influences hierarchy depth vs. occlusion power)
+#trianglesPerVirtualLeaf=300
+trianglesPerVirtualLeaf=0
+# max depth for searching for nodes for tight bounds
+maxDepthForTestingChildren=3
+
+
+####################
+## camera / light options
+
+# move speed
+keyRotation=0.5f
+keyForwardMotion=20.0f
+keyForwardMotion=30.0f
+
+camPosition=53.7718 -2.29418 8.67807
+camDirection=-0.994522 0.104525 -0
+
+#lightDirection=0.509293 0.784034 -0.35484
+#lightDirection=0.360937 0.0267167 -0.932207
+lightDirection=0.556361 0.559966 -0.613923
+
+#####################
+## window options
+
+winWidth=800
+winHeight=600
+
+#winWidth=1024
+#winHeight=768
+
+useFullScreen=0
+
+# the used render method (forward, forward + depth pass, deferred, deferred + depth pass
+#renderMethod=2
+renderMethod=0
+
+#modelPath=data/city/model/
+
+
+############
+## shader options for deferred rendering
+
+# tone mapping
+useHDR=0
+# use antialiasing
+useAA=0
+# show lense flare
+useLenseFlare=0
+# use ssao / color bleeding
+useAdvancedShading=1
+# skylight turbitity
+turbitity=3.0f
+#turbitity=2.0f
+#sky dome scale factor
+skyDomeScaleFactor=15.0f
+
+
+###############
+## ssao options
+
+# use full resolution ssao (vs. half resoltion)
+ssaoUseFullResolution=1
+# ssao kernel radius
+ssaoKernelRadius=2.5f
+# ssao sample intensity
+#ssaoSampleIntensity=0.2f
+ssaoSampleIntensity=0.8f
+# ssao temporal coherence factor
+tempCohFactor=2000.0f
+# ssao filter radius
+ssaoFilterRadius=12.0f
+
+
+defaultAmbient=0.4 0.4 0.4
+defaultDiffuse=1.4 1.4 1.4
+
+fix normals: read bavoil!!
