Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1950)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1951)
@@ -25,4 +25,6 @@
 static int texWidth = 256;
 static int texHeight = 256;
+static Vector3 scaleFactor = Vector3(2000.0f, 2000.0f, 2000.0f);
+static Vector3 translFactor = Vector3(1000.0f, 1000.0f, 1000.0f);
 
 static void cgErrorCallback()
@@ -64,5 +66,5 @@
 	//gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0);
 	//gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 0.5, 10.0);
-	glOrtho(-1000, 1000, -1000, 1000, 1, 1000);
+	glOrtho(-1, 1, -1, 1, 0.5, 15);
 }
 
@@ -70,15 +72,8 @@
 void Display()
 {
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	
 	//globalLinesRenderer->DrawGeometry();
-	
 	globalLinesRenderer->CastGlobalLines(Beam(), 0);
-
 	PrintGLerror("display");
 
-	glPopMatrix();
 	glutSwapBuffers();
 }
@@ -152,13 +147,29 @@
 void GlobalLinesRenderer::DrawGeometry()
 { 
-	//mRenderer->mUseFalseColors = true;
-	ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end();
-
-	Intersectable::NewMail();
-
-	for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit)
-	{
-		RenderObject(*oit);
-	}
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+	glMatrixMode(GL_MODELVIEW);
+
+	glPushMatrix();
+	{ 
+		glLoadIdentity();
+		//translFactor = Vector3(-1, -1, -1);
+		
+		glScalef(scaleFactor.x, scaleFactor.y, scaleFactor.z);
+		glTranslatef(translFactor.x, translFactor.y, translFactor.z);
+
+		//cout << "scale: " << scaleFactor << endl;
+		//cout << "transl: " << translFactor << endl;
+
+		//mRenderer->mUseFalseColors = true;
+		ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end();
+
+		Intersectable::NewMail();
+
+		for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit)
+		{
+			RenderObject(*oit);
+		}
+	}
+	glPopMatrix();
 }
 
@@ -197,10 +208,17 @@
 
 	AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox();
-	const Vector3 midPoint = bbox.Center();
-	//const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0);
-	const Vector3 viewPoint = midPoint + Vector3(2, 0, 0);
-
-	cout << "midPoint: " << midPoint << endl;
-	cout << "viewPoint: " << viewPoint << endl;
+	
+	Vector3 center = bbox.Center();
+	translFactor = -center;
+	//translFactor.z = 0;
+	//translFactor = Vector3(-1500, -1500, -1500);
+	float diag = 2.0f / Magnitude(bbox.Diagonal());
+	scaleFactor = Vector3(diag, diag, diag);
+ 
+	Vector3 midPoint = Vector3(0, 0, 0);
+	Vector3 viewPoint = Vector3(0, 0, 500);
+
+	cout << "mid point: " << midPoint << endl;
+	cout << "view point: " << viewPoint << endl;
 	cout << "scene: " << bbox << endl;
 
@@ -246,5 +264,6 @@
 		cgCreateProgramFromFile(sCgContext, 
 								CG_SOURCE,
-								"../src/depth_peeling.cg", 
+								mNewBuffer->IsRectangleTexture() ? 
+								"../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg", 
 								GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30,
 								NULL,
@@ -269,5 +288,4 @@
 		cgGLLoadProgram(sCgPassThroughProgram);
 	}
-
 
     // setup the rendering context for the RenderTexture
@@ -289,5 +307,4 @@
 				  midPoint.x, midPoint.y, midPoint.z, 
 				  0, 1, 0);
-
 	}
 	mNewBuffer->EndCapture();
@@ -331,24 +348,14 @@
 void GlobalLinesRenderer::ApplyDepthPeeling(Beam &beam, const int samples)
 {
-	//if (mNewBuffer->IsDoubleBuffered()) 
-	//	glDrawBuffer(GL_BACK);
-
 	mNewBuffer->BeginCapture();
 	{
 		//cgGLBindProgram(sCgPassThroughProgram);
 		//cgGLEnableProfile(sCgFragmentProfile);
-		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		{ 
-			//glutSolidTorus(0.25, 1, 32, 64);
-			DrawGeometry();
-		}
-		glPopMatrix();
+		DrawGeometry();
 	}
 	mNewBuffer->EndCapture();
 	
 	//mNewBuffer->BindDepth();
-	float *data = new float[texWidth * texHeight];
+	/*float *data = new float[texWidth * texHeight];
 	//const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV;
 	const int texFormat = GL_LUMINANCE;
@@ -356,9 +363,8 @@
 	
 	delete [] data;
-
-	PrintGLerror("get data");
+*/
+	PrintGLerror("firstpass");
 
 	if (mNewBuffer->IsRectangleTexture()) cout << "rect" << endl;
-//else cout << "haga"<<endl;
 
 	for(int i = 0; i < mMaxDepth; ++ i) 
@@ -380,11 +386,7 @@
 			cgGLEnableTextureParameter(sTextureParam);
 
-			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-			glMatrixMode(GL_MODELVIEW);
-			glPushMatrix();
-			{ 
-				//glutSolidTorus(0.25, 1, 32, 64);
-				DrawGeometry();
-			}
+			//glutSolidTorus(0.25, 1, 32, 64);
+			DrawGeometry();
+			
 			glPopMatrix();
 
@@ -395,31 +397,35 @@
 	}
 
-	PrintGLerror("display 1");
+	PrintGLerror("endpeeling");
 
 	//mNewBuffer->Bind();
 	mNewBuffer->BindDepth();
 	mNewBuffer->EnableTextureTarget();
-
-
-	PrintGLerror("display 2");
-	glColor3f(1,1,1);
-	glBegin(GL_QUADS);
-    glTexCoord2f(0, 0); glVertex3f(-1000, -1000, -0.5f);
-    glTexCoord2f(1, 0); glVertex3f( 1000, -1000, -0.5f);
-    glTexCoord2f(1, 1); glVertex3f( 1000,  1000, -0.5f);
-    glTexCoord2f(0, 1); glVertex3f(-1000,  1000, -0.5f);
-    glEnd();
-
-    if (mNewBuffer->IsFloatTexture())
-	{
-		// cgGLDisableTextureParameter(textureParam);
-		// cgGLDisableProfile(theProfile);
-	}
-	else 
-	{
-		mNewBuffer->DisableTextureTarget();
-	}
-}
-
-
-}
+	
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+	
+	if (mNewBuffer->IsRectangleTexture())
+	{
+		glBegin(GL_QUADS);
+		glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f);
+		glTexCoord2f(mNewBuffer->GetWidth(), 0); glVertex3f( 1, -1, -0.5f);
+		glTexCoord2f(mNewBuffer->GetWidth(), mNewBuffer->GetHeight()); glVertex3f( 1,  1, -0.5f);
+		glTexCoord2f(0, mNewBuffer->GetHeight()); glVertex3f(-1, 1, -0.5f);
+		glEnd();
+	}
+	else
+	{
+		glBegin(GL_QUADS);
+		glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f);
+		glTexCoord2f(1, 0); glVertex3f( 1, -1, -0.5f);
+		glTexCoord2f(1, 1); glVertex3f( 1,  1, -0.5f);
+		glTexCoord2f(0, 1); glVertex3f(-1,  1, -0.5f);
+		glEnd();
+	}  
+
+	mNewBuffer->DisableTextureTarget();
+	PrintGLerror("displaytexture");
+}
+
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp	(revision 1867)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp	(revision 1951)
@@ -2183,5 +2183,5 @@
 Vector3 AxisAlignedBox3::Diagonal() const 
 { 
-	return (mMax -mMin); 
+	return (mMax - mMin); 
 }
 
