Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp	(revision 2806)
@@ -64,5 +64,5 @@
 
 /******************************************************/
-/*           Vizualization implementation           */
+/*           Vizualization implementation             */
 /******************************************************/
 
@@ -78,5 +78,4 @@
 mFrameId(0)
 {
-	mSphere = (GLUquadric *)gluNewQuadric();
 }
 
@@ -84,5 +83,4 @@
 Visualization::~Visualization() 
 {
-	//DEL_PTR(mSphere);
 }
 
@@ -110,12 +108,4 @@
 	stack<BvhNode *> tStack;
 	tStack.push(mBvh->GetRoot());
-
-	glDisable(GL_LIGHTING);
-	
-	RenderViewPoint();
-	RenderFrustum();
-	RenderBoxForViz(mBvh->GetBox());
-
-	glEnable(GL_LIGHTING);
 
 	glEnableClientState(GL_VERTEX_ARRAY);
@@ -147,32 +137,21 @@
 				}		
 			}
-			//leaves.push_back(static_cast<BvhLeaf *>(node));
 		}
 	}
 
-	mRenderState->Reset();
-
 	glDisableClientState(GL_VERTEX_ARRAY);
 	glDisableClientState(GL_NORMAL_ARRAY);
-}
-
-
-void Visualization::RenderViewPoint()
-{
-	glPushMatrix();
-	Vector3 pos = mCamera->GetPosition();
-	pos.z += 100;
-	glTranslatef(pos.x, pos.y, pos.z);
+
+
+	mRenderState->Reset();
+
+	glPushAttrib(GL_CURRENT_BIT);
+	glDisable(GL_LIGHTING);
+	glDisable(GL_DEPTH_TEST);
+
+	RenderFrustum();
+	//RenderBoxForViz(mBvh->GetBox());
 	
-	glScalef(5.0f, 5.0f, 5.0f);
-	glPushAttrib(GL_CURRENT_BIT);
-
-	glColor3f(1.0f, 0.0f, 0.0f);
-	
-	gluSphere((::GLUquadric *)mSphere,
-		2e-3f * Magnitude(mBvh->GetBox().Size()), 6, 6);
-
 	glPopAttrib();
-	glPopMatrix();
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h	(revision 2800)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h	(revision 2806)
@@ -21,5 +21,11 @@
 	SceneQuery(const AxisAlignedBox3 &sceneBox, RenderTraverser *traverser);
 	~SceneQuery() { DEL_ARRAY_PTR(mDepth); }
+
+	/** Calculates intersection of vertical ray at position pt.x, pt.y and 
+	    stores the intersection point if valid. returns true if the intersection 
+		is valid.
+	*/
 	bool CalcIntersection(Vector3 &pt);
+
 
 protected:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h	(revision 2806)
@@ -48,15 +48,22 @@
 
 	void CalcFrustum(Frustum &frustum);
-
+	/** Computes the extremal points of this frustum.
+	*/
 	void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr,
 		               Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr);
 	
+	/** Returns the near plane.
+	*/
 	inline float GetNear() const { return mNear; }
+	/** Returns the far plane.
+	*/
+	inline float GetFar() const { return mFar; }
+	/** Sets the near plane
+	*/
 	void SetNear(float nearDist);
+	/** Sets the far plane.
+	*/
+	void SetFar(float farDist);
 	
-	inline float GetFar() const { return mFar; }
-
-	void SetFar(float farDist) { mFar = farDist; }
-
 	void SetOrtho(bool ortho);
 
@@ -64,4 +71,7 @@
 	void Pitch(float angle);
 	
+	float GetPitch() const { return mPitch; }
+	float GetYaw() const { return mYaw; }
+
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2803)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2806)
@@ -163,6 +163,7 @@
 	camera = new Camera(winWidth, winHeight, fov);
 	camera->SetNear(nearDist);
-
+	
 	visCamera = new Camera(winWidth, winHeight, fov);
+
 	visCamera->SetNear(0.0f);
 	visCamera->Yaw(.5 * M_PI);
@@ -233,9 +234,10 @@
 	}
 
+	camera->SetFar(0.7f * Magnitude(bvh->GetBox().Diagonal()));
+
 	bvh->SetCamera(camera);
 
 	ResetTraverser();
 
-	//camera->SetDirection(Vector3(0.961829f, 0.273652f, 0.0f));
 	camera->Pitch(-M_PI * 0.5);
 	camera->SetPosition(Vector3(483.398f, 242.364f, 186.078f));
@@ -992,5 +994,5 @@
 	glColor4f(0.0,0.0,0.0,0.5); 
 
-	glRecti(winWidth, 0, winWidth - winWidth / 4, winHeight / 3);
+	glRecti(winWidth, 0, winWidth - winWidth / 3, winHeight / 3);
 	glDisable(GL_BLEND);
 	End2D();
@@ -1002,18 +1004,27 @@
 	const float yoffs = box.Size().y * 0.5f;
 
-	Vector3 vizpos = Vector3(box.Center().x, box.Center().y, box.Max().z);
+	Vector3 pos = camera->GetPosition();
+
+	Vector3 vizpos = Vector3(box.Min().x, box.Min().y + 700, box.Min().z + box.Size().z * 50);
+	
 	visCamera->SetPosition(vizpos);
 	
-	glViewport(winWidth - winWidth / 4, winHeight - winHeight / 3, winWidth / 4, winHeight / 3);
+	glViewport(winWidth - winWidth / 3, winHeight - winHeight / 3, winWidth / 3, winHeight / 3);
 
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
 	
-	glOrtho(-xoffs, xoffs, -yoffs, yoffs, 0.0f, box.Size().z); 
+	glOrtho(-xoffs, xoffs, -xoffs, xoffs, 0.0f, box.Size().z * 100.0f); 
 
 	glMatrixMode(GL_MODELVIEW);
 
 	visCamera->SetupCameraView();
-	
+
+	Matrix4x4 rotZ = RotationZMatrix(-camera->GetPitch());
+	glMultMatrixf((float *)rotZ.x);
+
+	glTranslatef(-pos.x, -pos.y, -pos.z);
+
+
 	GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f};
 	glLightfv(GL_LIGHT0, GL_POSITION, position);
@@ -1024,4 +1035,5 @@
 	glClear(GL_DEPTH_BUFFER_BIT);
 
+
 	////////////
 	//-- visualization of the occlusion culling
@@ -1029,4 +1041,5 @@
 	visualization->Render();
 	
+	// reset vp
 	glViewport(0, 0, winWidth, winHeight);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h	(revision 2806)
@@ -20,5 +20,7 @@
 {
 public:
-	
+	/** Main constructor taking a bvh, a camera, a visualization camera and the current render state
+	    as parameters
+	*/
 	Visualization(Bvh *bvh, Camera *camera, Camera *vizCamera, RenderState *renderState);
 
@@ -49,7 +51,4 @@
 	*/
 	void RenderFrustum();
-	/** Renders the current view point.
-	*/
-	void RenderViewPoint();
 
 
@@ -67,6 +66,4 @@
 	/// the current frame id
 	int mFrameId;
-
-	GLUquadric *mSphere;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2796)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2806)
@@ -66,4 +66,10 @@
 {
 	mNear = nearDist;
+}
+
+
+void Camera::SetFar(float farDist) 
+{ 
+	mFar = farDist; 
 }
 
@@ -165,6 +171,6 @@
 						   Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr)
 {
-	float z_near = 0.1f;
-	float z_far = 300;
+	float z_near = mNear;
+	float z_far = mFar;
 
 	const float h_near = 2.0f * tan(mFovy / 2) * z_near;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Readme.txt
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Readme.txt	(revision 2789)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Readme.txt	(revision 2806)
@@ -1,3 +1,3 @@
-HARDWARE OCCLUSION QUERIES MADE USEFUL
+GAME ENGINE FRIENDLY OCCLUSION CULLING
 ======================================
 
@@ -37,6 +37,6 @@
 SPACE key (view-frustum culling, hierarchical stop and wait, coherent hierarchical culling, chc++).
 
-A bird eye view visualization of the culling algorithm from can be shown by pressing '1' on the keyboard.
-
+A bird eye view visualization of the culling algorithm from can be shown by pressing 'F2' on the keyboard.
+Pressing 'F8' switches between using / not using the glFinish command, which causes slightly slower frame rates but brings more reliable fps measurements.
 
 ----------
@@ -59,5 +59,5 @@
 -------------
 
-We use a simple OpenGL based engine which was designed to be as simple as possible while providing the necessary feature list to simulate the behaviour of full-fledged game engines like Ogre3D. The engine supports simple material sorting mainly based on the texture size, avoiding the mix of differently sized textures, which according to various sources induces one of the costliest state change. We demonstrate the integration of the culling algorithm into the engine, and show how occlusion cullig and state sorting are possible within one framework, two paradigms that were previously considered to be cancelling out each other ("either you do front-back-sorting or material sorting").
+We use a simple OpenGL based engine which was designed to be as simple as possible while providing the necessary feature list to simulate the behaviour of full-fledged game engines like Ogre3D. The engine supports simple material sorting mainly based on the texture format, avoiding the mix of different texture formats, which according to various sources induces one of the costliest state change. We demonstrate the integration of the culling algorithm into the engine, and show how occlusion cullig and state sorting are possible within one framework, two paradigms that were previously considered to be cancelling out each other ("either you do front-back-sorting or material sorting").
 
 
@@ -66,5 +66,5 @@
 ----------
 
-A binary for Win32 and a solution for visual studio 2005 included. The program should work under XP and Windows Vista.
+A binary for Win32 and a solution for visual studio 2005 and 2003 included. The program should work under XP and Windows Vista.
 
 
@@ -77,7 +77,7 @@
 The rendering core of the engine is provided by the class RenderTraverser, which provides front to back scene traversal based on a priority queue. It's subclasses implement the various culling algorithms. The new algorithm is represented by the class CHCPlusPlusTraverser.
 
-The main routine is implemented in chcdemo.cpp. Also it contains the OpenGl setup code, glut stuff, and sets up of the scene hierarchy.
+The main routine is implemented in chcdemo.cpp. Also it contains the OpenGl setup code, glut stuff, and setups of the scene hierarchy.
 
-The project is separated into one section containing supportive code (utils), the traversal algorithms (traversal), and the basic engine classes like Camera, Geometry, Material, or RenderState (scene). 
+The project is separated into one section containing supportive code (utils), the traversal algorithms (traversal), and the basic engine classes like Camera, Geometry, Material, or RenderState (rendering). 
 
 If you find any problem with the code or have any comments, please feel free to ask us at any time.
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2801)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2806)
@@ -3,5 +3,5 @@
 	ProjectType="Visual C++"
 	Version="8,00"
-	Name="chc_revisited"
+	Name="friendlyculling"
 	ProjectGUID="{03661866-4093-4B02-B26A-028EA91AF023}"
 	RootNamespace="chc_revisited"
@@ -243,12 +243,4 @@
 			</File>
 			<File
-				RelativePath=".\src\ResourceManager.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\ResourceManager.h"
-				>
-			</File>
-			<File
 				RelativePath=".\src\SceneQuery.cpp"
 				>
@@ -458,5 +450,5 @@
 		</Filter>
 		<Filter
-			Name="render"
+			Name="rendering"
 			>
 			<Filter
@@ -494,4 +486,8 @@
 				</File>
 				<File
+					RelativePath=".\src\ResourceManager.h"
+					>
+				</File>
+				<File
 					RelativePath=".\src\SceneEntity.h"
 					>
@@ -632,4 +628,8 @@
 						/>
 					</FileConfiguration>
+				</File>
+				<File
+					RelativePath=".\src\ResourceManager.cpp"
+					>
 				</File>
 				<File
