Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2861)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2933)
@@ -89,5 +89,5 @@
 	{
 		mCullFaceEnabled = true;
-		glEnable(GL_CULL_FACE);
+		//glEnable(GL_CULL_FACE);
 	}
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp	(revision 2932)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp	(revision 2933)
@@ -223,5 +223,5 @@
 	//-- first find the free parameter values n, and P (the projection center), and the projection depth
 
-	const float n = 1e2f;
+	const float n = 1e3f;
 	//const float n = 1e6f;
 	//const float n = ComputeN(bounds_ls) * 100;
@@ -230,5 +230,5 @@
 
 	const Vector3 nearPt = GetNearCameraPointE(body);
-	const float dummy = 0;
+	
 	//get the coordinates of the near camera point in light space
 	const Vector3 lsNear = lightSpace * nearPt;
@@ -249,5 +249,5 @@
 
 	// light space y size
-	const float d = fabs(bounds_ls.Max()[2] - bounds_ls.Min()[2])+dummy;
+	const float d = fabs(bounds_ls.Max()[2] - bounds_ls.Min()[2]);
 
 	const float dy = fabs(bounds_ls.Max()[1] - bounds_ls.Min()[1]);
@@ -263,5 +263,5 @@
 	Matrix4x4 matLispSM;
 	
-	matLispSM = GetFrustum(-1.0, 1.0, -1.0, 1.0, n+dummy, n + d);
+	matLispSM = GetFrustum(-1.0, 1.0, -1.0, 1.0, n, n + d);
 
 	//cout << "lispsm\n" << matLispSM << endl;
@@ -310,5 +310,5 @@
 	}
 
-	//	Invert(eyeView); return eyeView * nearest;
+	//	return Invert(eyeView) * nearest;
 	return nearest;
 }
@@ -346,5 +346,6 @@
 #endif
 
-Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, const VertexArray &pts) const 
+Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, 
+								  const VertexArray &pts) const 
 {
 	//get the point in the LVS volume that is nearest to the camera
@@ -359,5 +360,5 @@
 	Vector3 projDir(b_lp - e_lp);
 
-	Matrix4x4 dummy = lightSpace;
+	Matrix4x4 dummy = Invert(lightSpace);
 	Invert(dummy);
 	Vector3 dummyVec = dummy * e_lp;
@@ -412,5 +413,5 @@
 
 	//switch to the lightspace used in the article
-	//lightProj = lightProj * transform2LispSM;
+	lightProj = lightProj * transform2LispSM;
 
 	const Vector3 projViewDir = GetProjViewDir(lightView * lightProj, frustumPoints);
@@ -418,5 +419,5 @@
 
 	cout << "projViewDir: " << projViewDir << " orig " << mCamera->GetDirection() << endl;
-
+								
 	//do Light Space Perspective shadow mapping
 	//rotate the lightspace so that the projected light view always points upwards
@@ -424,7 +425,8 @@
 	//look(from position, into the direction of the projected direction, with unchanged up-vector)
 	const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y());
+	//const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Z());
 
 	cout << "frame\n " << frame << endl;
-	//lightProj = lightProj * frame;
+	lightProj = lightProj * frame;
 
 	cout << "here9\n" << lightProj << endl;
@@ -443,5 +445,5 @@
 	transformToGL.x[3][3] =  1.0f;
 
-	//lightProj = lightProj * transformToGL;
+	lightProj = lightProj * transformToGL;
 	//cout << "here4 \n" << lightProj << endl;
 
@@ -562,6 +564,6 @@
 
 	Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir);
-	Matrix4x4 lightView = 
-		MyLookAt(mShadowCam->GetPosition(), dir, upVec);
+	Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, -upVec);
+	//Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, mCamera->GetDirection());
 
 	mShadowCam->mViewOrientation = lightView;
@@ -601,5 +603,5 @@
 
 	mLightProjView = lightView * lightProj;
-
+glEnable(GL_CULL_FACE);
 	cout << "here3" << endl;
 	DEL_PTR(lightPoly);
@@ -674,5 +676,7 @@
 
 	Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir);
-	Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, upVec);
+	Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, -upVec);
+	//Matrix4x4 lightView = Invert(_lightView);
+	//Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, mCamera->GetDirection());
 
 	mShadowCam->mViewOrientation = lightView;
@@ -706,4 +710,6 @@
 	glPushMatrix();
 	glLoadIdentity();
+
+	glDisable(GL_CULL_FACE);
 
 	mShadowCam->SetupCameraView();
@@ -722,5 +728,4 @@
 	glDisable(GL_DEPTH_TEST);
 	glDepthMask(GL_FALSE);
-	glDisable(GL_CULL_FACE);
 
 	Polyhedron *hpoly = CreatePolyhedron(projView, mSceneBox);
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp	(revision 2932)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp	(revision 2933)
@@ -748,5 +748,5 @@
 	Vector3 position = m * -pos;
 	
-	// note: left handet system => we go into positive z
+	// note: left handed system => we go into positive z
 	m.x[3][0] = position.x;
 	m.x[3][1] = position.y;
