Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp	(revision 3144)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp	(revision 3146)
@@ -130,4 +130,15 @@
 
 
+	// provide the current view matrix:
+	// this is an automatic parameter that is updated each frame
+	normalMappingFragmentMrt->AddParameter("viewMatrix", 0);
+
+	// vertex program
+	normalMappingVertexMrt->AddParameter("viewMatrix", 0);
+	// needed for for ssao
+	normalMappingVertexMrt->AddParameter("modelMatrix", 1);
+	normalMappingVertexMrt->AddParameter("oldModelMatrix", 2);
+
+
 	cout << "cg initialization successful" << endl;
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg	(revision 3137)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg	(revision 3146)
@@ -49,5 +49,5 @@
 	const float ne = nd.x * nd.y *nd.z * nd.w * weights.x;
 
-#if 1
+
 	////////////
 	// depth filter => compute gradient difference
@@ -65,5 +65,5 @@
 	for (int i = 0; i < 4; ++ i)
 	{
-		dd[i] = float4(depthVals[i * 2] + depthVals[i * 2 + 1]);
+		dd[i] = depthVals[i * 2] + depthVals[i * 2 + 1];
 	}
 
@@ -89,5 +89,5 @@
 	float4 s2 = tex2Dlod(colors, float4(width + rt * w, 0, 0));
 	float4 s3 = tex2Dlod(colors, float4(width + lb * w, 0, 0));
-#endif
+
 
 	//float4 col = (s0 + s1 + s2 + s3 + centerColor) * 0.2f;
@@ -96,5 +96,6 @@
 	//float4 col = float4(de.x, de.x, de.x, 0);
 	//float4 col = float4(w, w, w, 0);
-	//float4 col = centerColor;
+	//float4 col = float4(centerNormal * 0.5f + float3(0.5f), 0);
+	//float4 col = float4(centerNormal, 0);
 	// push through the current depth
 	col.w = centerDepth.x;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg	(revision 3144)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg	(revision 3146)
@@ -86,7 +86,7 @@
 
 
-/**************************************************************/
-/* Shader computing the MRT output for normal mapped geoemtry */
-/**************************************************************/
+/******************************************************************/
+/*   Shader computing the MRT output for normal mapped geometry   */
+/******************************************************************/
 
 
@@ -126,5 +126,5 @@
 	// compute tangent space - world space transform which is the transpose,
 	// as it is the inverse of a rotation matrix 
-	float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent, IN.bitangent, IN.normal));
+	float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent.xyz, IN.bitangent.xyz, IN.normal.xyz));
 	const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz;
 	pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm);
@@ -136,13 +136,10 @@
 pixel frag(fragin IN,
 		   uniform float4x4 viewMatrix,
-		   uniform sampler2D normalMap: TEXUNIT1)
+		   uniform sampler2D normalMap: TEXUNIT0)
 {
 	pixel pix;
 	// hack: use comination of emmisive + diffuse (emmisive used as constant ambient term)
 	pix.color = glstate.material.diffuse + glstate.material.emission;
-	// save world space normal in rt => transform back into world space by
-	// multiplying with inverse view. since transforming normal with T means to 
-	// multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view)
-	pix.normal = mul(transpose(viewMatrix), IN.normal).xyz;
+	
 	// eye space depth
 	pix.color.w = length(IN.eyePos.xyz);
@@ -165,5 +162,5 @@
 	const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz;
 	pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm);
-
+	pix.normal = tangentSpaceNorm;
 	return pix;
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 3127)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 3146)
@@ -267,5 +267,5 @@
 		}
 
-		if (frag != mCurrentFragmentProgram)
+		if (1)//frag != mCurrentFragmentProgram)
 		{			
 			mCurrentFragmentProgram = frag;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3145)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3146)
@@ -114,5 +114,4 @@
 			// create shape
 			Shape *shape = new Shape(geom, mat);
-
 			mShapes.push_back(shape);
 
@@ -226,5 +225,5 @@
 }
 
-
+// mtt todo_ split that up
 void ResourceManager::LoadShapes(igzstream &str)
 {
@@ -295,5 +294,5 @@
 	if (mUseNormalMapping)
 	{
-		deferred->SetFragmentProgram(sNormalMappingVertexProgramMrt);
+		deferred->SetFragmentProgram(sNormalMappingFragmentProgramMrt);
 		deferred->SetVertexProgram(sNormalMappingVertexProgramMrt);
 	}
@@ -310,5 +309,4 @@
 	deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0);
 	
-
 	deferred->GetVertexProgramParameters()->SetModelMatrixParam(1);
 	deferred->GetVertexProgramParameters()->SetOldModelMatrixParam(2);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3144)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3146)
@@ -471,9 +471,13 @@
 	//-- load some dynamic stuff
 
-	resourceManager->mUseNormalMapping = true;
+	//resourceManager->mUseNormalMapping = true;
 	//resourceManager->mUseNormalMapping = false;
 
-	LoadModel("fisch.dem", dynamicObjects);
+	//LoadModel("fisch.dem", dynamicObjects);
 	//LoadModel("hbuddha.dem", dynamicObjects);
+	//LoadModel("venusm.dem", dynamicObjects);
+	//LoadModel("objects.dem", dynamicObjects);
+	//LoadModel("toyplane2.dem", dynamicObjects);
+	LoadModel("elephal.dem", dynamicObjects);
 
 	resourceManager->mUseNormalMapping = false;
@@ -481,4 +485,6 @@
 	buddha = dynamicObjects.back();
 	
+	cout << "here3 " << buddha->GetWorldCenter() << " " << buddha->GetBoundingBox().Center() << endl;
+
 	const Vector3 sceneCenter(470.398f, 240.364f, 182.5f);
 	
@@ -804,11 +810,4 @@
 	ambient[2] = sunAmbient.z;
 
-	// no tone mapping => scale
-	if (0)//!useToneMapping)
-	{
-		float maxComponent = sunDiffuse.MaxComponent();
-		sunDiffuse /= maxComponent;
-	}
-
 	diffuse[0] = sunDiffuse.x;
 	diffuse[1] = sunDiffuse.y;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.cpp	(revision 3128)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.cpp	(revision 3146)
@@ -147,6 +147,6 @@
 
 	bool alphaTestEnabled = false;
-	bool cullFaceEnabled = false;
-	//bool cullFaceEnabled = true;
+	//bool cullFaceEnabled = false;
+	bool cullFaceEnabled = true;
 
 	str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool));
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp	(revision 3128)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp	(revision 3146)
@@ -7,4 +7,6 @@
 
 using namespace std;
+
+//#define USE_TEXTURE
 
 
@@ -18,5 +20,5 @@
 						)
 {
-	vector<char *> substrings;
+	vector<string> triples;
 
 	char *next_token;
@@ -25,7 +27,10 @@
 	char *pch = strtok_s(str + 1, " ", &next_token);
 
-	while (pch != NULL)
-	{
-		substrings.push_back(pch);
+	while (pch)
+	{
+		string s(pch);
+		//s += "\n",
+		triples.push_back(s);
+		
 		pch = strtok_s(NULL, " ", &next_token);	  
 	}
@@ -35,26 +40,38 @@
 	vector<int> tIndices;
 
-	for (size_t i = 0; i < substrings.size(); ++ i)
-	{
+	char seps[] = " /\t\n";
+
+	for (size_t i = 0; i < triples.size(); ++ i)
+	{
+		static int dummy = 0;
+
+		size_t found;
+		found = triples[i].find_first_of(seps);
+		size_t prevfound = 0;
 		// vertex, normal, texture indices
-		char *str = strtok_s(substrings[i], "/", &next_token);	  
-		int index = (int)strtol(str, NULL, 10) - 1;
+		string str = triples[i].substr(prevfound, found);
+
+		int index = (int)strtol(str.c_str(), NULL, 10) - 1;
 
 		int tIndex = index;
-		int nIndex = index;
-
-		str = strtok_s(substrings[i], "/", &next_token);	  
-
-		if (str != NULL)
-		{
-			int idx = (int)strtol(str, NULL, 10) - 1;
-			if (idx) tIndex = idx;
-		}
-		str = strtok_s(substrings[i], "/", &next_token);	  
-
-		if (str != NULL)
-		{
-			int idx = (int)strtol(str, NULL, 10) - 1;
-			if (idx) nIndex = idx;
+		int nIndex = index;	
+		
+		prevfound = found;
+		found = triples[i].find_first_of(seps, found + 1);  
+
+		if (found != string::npos)
+		{
+			str = triples[i].substr(prevfound, found);
+
+			int idx = (int)strtol(str.c_str(), NULL, 10) - 1;
+			if (idx > 0) tIndex = idx;
+		}
+
+		if ((found + 1) < triples[i].size())
+		{
+			str = triples[i].substr(found + 1);
+
+			int idx = (int)strtol(str.c_str(), NULL, 10) - 1;
+			if (idx > 0) nIndex = idx;
 		}
 
@@ -84,6 +101,8 @@
 			faceVertices.push_back(vertices[indices[idx3]]);
 
+
 			if (!normals.empty())
 			{
+				//if (dummy < 3) cout << nIndices[idx1] << " " << nIndices[idx2] << " " << nIndices[idx3] << endl;
 				faceNormals.push_back(normals[nIndices[idx1]]);
 				faceNormals.push_back(normals[nIndices[idx2]]);
@@ -92,6 +111,8 @@
 			else
 			{
-				// no face normals?
-				const SimpleTri tri(vertices[indices[idx1]], vertices[indices[idx2]], vertices[indices[idx3]]);
+				// no face normals? => create normals
+				const SimpleTri tri(vertices[indices[idx1]],
+					                vertices[indices[idx2]], 
+									vertices[indices[idx3]]);
 				const SimpleVec n = tri.GetNormal();
 
@@ -101,4 +122,5 @@
 			}
 
+			++ dummy;
 			if (!texcoords.empty())
 			{
@@ -150,5 +172,5 @@
 	for (int i = 0; i < numElements; ++ i)
 	{
-#if 0
+#if 1
 		// convert to our camera system: change y and z
 		geom->mVertices[i].x = faceVertices[i].x;
@@ -159,4 +181,5 @@
 		geom->mNormals[i].y = -faceNormals[i].z;
 		geom->mNormals[i].z = faceNormals[i].y;
+
 #else
 		geom->mVertices[i].x = faceVertices[i].x;
@@ -169,7 +192,4 @@
 
 #endif
-		geom->mVertices[i].x += 470.398f;
-		geom->mVertices[i].y += 240.364f;
-		geom->mVertices[i].z += 182.5f;
 
 		if (i < geom->mTexcoordCount)
@@ -236,5 +256,4 @@
 
 	int line = 0;
-
 	const int len = 10000;
 	char str[len];
@@ -242,7 +261,5 @@
 	while (fgets(str, len, file) != NULL)
 	{
-//		if (1)//(line % 100) == 0)
-//			cout << "read line " << line << " " << str;
-		switch (str[0]) 
+		switch (str[0])
 		{
 		case 'v': // vertex or normal
@@ -262,5 +279,6 @@
 				default:
 					sscanf(str + 1, "%f %f %f", &x, &y, &z);
-					vertices.push_back(SimpleVec(x, y, z));
+					const float scale = 5e-3f;
+					vertices.push_back(SimpleVec(x * scale, y * scale, z* scale));
 					//cout <<"v " << x << " " << y << " "<< z << " ";
 				}
@@ -305,4 +323,5 @@
 			break;
 		default:
+			// throw away line
 			break;
 		}
@@ -346,11 +365,15 @@
 	//-- texture
 
-	//int texId = -1;
+#ifdef USE_TEXTURE
 	int texId = 0;
+#else
+	int texId = -1;
+#endif
+
 	str.write(reinterpret_cast<char *>(&texId), sizeof(int));
 
 	bool alphaTestEnabled = false;
-	bool cullFaceEnabled = false;
-	//bool cullFaceEnabled = true;
+	//bool cullFaceEnabled = false;
+	bool cullFaceEnabled = true;
 
 	str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool));
@@ -368,5 +391,5 @@
 		ambient.x = ambient.y = ambient.z = 0.2f;
 		diffuse.x = diffuse.y = diffuse.z = 1.0f;
-		spec.x   = spec.y   = spec.z   =  .0f;
+		spec.x    = spec.y    = spec.z    =  .0f;
 		emm = spec;
 
@@ -391,7 +414,9 @@
 	//-- write textures
 
+#ifdef USE_TEXTURE
 	int textureCount = 1;
-	//int textureCount = 0;
-
+#else
+	int textureCount = 0;
+#endif
 	ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int));
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp	(revision 3076)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp	(revision 3146)
@@ -22,5 +22,5 @@
 		exit(0);
 	}
-
+	//std::cin.get();
 	cout << "conversion successful" << endl;
 
