Index: GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp	(revision 1715)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp	(revision 1960)
@@ -124,5 +124,6 @@
 	{
 		const Vector3 a = (*ri)->GetOrigin();
-		const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir());
+		const Vector3 b = (*ri)->mTerminationObject ? 
+			(*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir());
 
 #if GTP_DEBUG
@@ -130,5 +131,5 @@
 		if (!a.CheckValidity())
 		{
-			cout << "error a"<<endl;
+			cout << "error a" << endl;
 			isnan = true;
 		}
@@ -136,5 +137,5 @@
 		if (!b.CheckValidity())
 		{
-			cout << "error b"<<endl;
+			cout << "error b" << endl;
 			isnan = true;
 		}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1958)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1960)
@@ -1297,5 +1297,5 @@
 Intersectable *Preprocessor::GetObjectById(const int id)
 {
-#if 0
+#if 1
 	// create a dummy mesh instance to be able to use stl
 	MeshInstance object(NULL);
@@ -1315,5 +1315,5 @@
 	}
 #else
-	return mObjects[id];
+	return mObjects[id - 1];
 #endif
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1958)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1960)
@@ -5,4 +5,6 @@
 #include "Preprocessor.h"
 #include "GlRenderer.h"
+#include "Exporter.h"
+
 // the devil library
 #include <IL/il.h>
@@ -27,7 +29,8 @@
 GlobalLinesRenderer *globalLinesRenderer = NULL;
 
-static int texWidth = 256;
-static int texHeight = 256;
-
+static int texWidth = 128;
+static int texHeight = 128;
+
+static bool isDepth = true;
 
 static void InitDevIl()
@@ -89,11 +92,12 @@
 
 
-void SetFrustum(int sizeX, int sizeY, float nearPlane, float farPlane)
+void SetFrustum(const int sizeX, const int sizeY, 
+				const float nearPlane, const float farPlane)
 {
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
 
-	glOrtho(-sizeX / 2, sizeX / 2, 
-			-sizeY / 2, sizeY / 2, 
+	glOrtho(-sizeX * 0.5, sizeX * 0.5, 
+			-sizeY * 0.5, sizeY * 0.5, 
 			nearPlane, farPlane);
 
@@ -107,5 +111,5 @@
 	//globalLinesRenderer->DrawGeometry();
 	//globalLinesRenderer->CastGlobalLines(Beam(), 0);
-	globalLinesRenderer->DisplayBuffer();
+	globalLinesRenderer->DisplayBuffer(isDepth);
 	PrintGLerror("display");
 
@@ -132,4 +136,5 @@
 
 			cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl;
+			CLEAR_CONTAINER(rays);
 			return;
 		}
@@ -142,4 +147,5 @@
 			
 			globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0);
+			CLEAR_CONTAINER(rays);
 			return;
 		}
@@ -148,11 +154,45 @@
 			//globalLinesRenderer->ApplyDepthPeeling(Beam(), 0);
 			globalLinesRenderer->ExportDepthBuffer();
+			
 			return;
 		}
 	case '4':
 		{
+			//globalLinesRenderer->ApplyDepthPeeling(Beam(), 0);
+			globalLinesRenderer->ExportItemBuffer();
+			
+			return;
+		}
+	case '8':
+		{
+			isDepth = !isDepth;
+			return;
+		}
+	case '9':
+		{
 			VssRayContainer rays;
-
 			globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0);
+			VssRayContainer outRays;
+			VssRayContainer::const_iterator vit, vit_end = rays.end();
+
+			const float p = 8.0f / (float)rays.size();
+
+			for (vit = rays.begin(); vit != vit_end; ++ vit)
+			{
+				if (Random(1.0f) < p)
+				{
+					outRays.push_back(*vit);
+				}
+			}
+
+			globalLinesRenderer->Visualize(rays);
+			CLEAR_CONTAINER(rays);
+			return;
+		}
+	case '0':
+		{
+			VssRayContainer rays;
+			globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0);
+			CLEAR_CONTAINER(rays);
 			return;
 		}
@@ -185,8 +225,10 @@
 
 
-void GlobalLinesRenderer::DisplayBuffer()
-{
-	//mNewTexture->Bind();
-	mNewTexture->BindDepth();
+void GlobalLinesRenderer::DisplayBuffer(const bool isDepth)
+{
+	if (!isDepth)
+		mNewTexture->Bind();
+	else
+		mNewTexture->BindDepth();
 	mNewTexture->EnableTextureTarget();
 	
@@ -262,4 +304,5 @@
 		for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit)
 		{
+			cout << (*oit)->GetId() << " ";
 			RenderObject(*oit);
 		}
@@ -297,5 +340,5 @@
 	InitDevIl();
 
-	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
+    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
 	glutInitWindowPosition(50, 50);
 	glutInitWindowSize(512, 512);
@@ -321,36 +364,44 @@
 	// initialise the receiving buffers
 	mNewDepthBuffer = new float[texWidth * texHeight];
+	mNewItemBuffer = new unsigned char[texWidth * texHeight * 4];
+
 	mOldDepthBuffer = new float[texWidth * texHeight];
-	
+    mOldItemBuffer = new unsigned char[texWidth * texHeight * 4];
+
 	for (int i = 0; i < texWidth * texHeight; ++ i)
 	{
 		mNewDepthBuffer[i] = 1;
 		mOldDepthBuffer[i] = 1;
-	}
-
-	mNewItemBuffer = new int[texWidth * texHeight *4];
-	mOldItemBuffer = new int[texWidth * texHeight *4];
-	
-	for (int i = 0; i < texWidth * texHeight * 4; ++ i)
-	{
-		mNewItemBuffer[i] = 0;
-		mOldItemBuffer[i] = 0;
+
+		mNewItemBuffer[i * 4]     = 255;
+		mNewItemBuffer[i * 4 + 1] = 255;
+		mNewItemBuffer[i * 4 + 2] = 255;
+		mNewItemBuffer[i * 4 + 3] = 255;
+
+		mOldItemBuffer[i * 4]     = 255;
+		mOldItemBuffer[i * 4 + 1] = 255;
+		mOldItemBuffer[i * 4 + 2] = 255;
+		mOldItemBuffer[i * 4 + 3] = 255;
 	}
 
 	AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox();
 	
-	mViewPoint = bbox.Center();
+	Vector3 midPoint = bbox.Center();
 	
 	const float sceneSize = Magnitude(bbox.Diagonal());
-	Vector3 viewPoint = mViewPoint + Vector3(0.5 * sceneSize, 0, 0);
-	
-	cout << "mid point: " << mViewPoint << endl;
-	cout << "view point: " << viewPoint << endl;
+	mViewPoint = midPoint + Vector3(0.5 * sceneSize, 0, 0);
+	
+	cout << "mid point: " << midPoint << endl;
+	cout << "view point: " << mViewPoint << endl;
 	cout << "scene: " << bbox << endl;
 
-	mEyeVec = Normalize(viewPoint - mViewPoint);
+	mNear = 1;
+	mFar = sceneSize;
+	mWidth = sceneSize;
+
+	mEyeVec = Normalize(midPoint - mViewPoint);
 	mEyeVec.RightHandedBase(mUpVec, mLeftVec);
 
-	/*gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z, 
+	/*gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 
 			  midPoint.x, midPoint.y, midPoint.z, 
 			  0, 1, 0);
@@ -422,5 +473,5 @@
 		//Reshape(texWidth, texHeight);
 		glViewport(0, 0, texWidth, texHeight);
-		SetFrustum(sceneSize, sceneSize, 1, sceneSize);
+		SetFrustum(mWidth, mWidth, mNear, mFar);
 
 		// for item buffer: white means no color
@@ -430,5 +481,8 @@
 		glFrontFace(GL_CCW);
 		glCullFace(GL_BACK);
-		glEnable(GL_CULL_FACE);
+
+		glDisable(GL_CULL_FACE);
+		//glEnable(GL_CULL_FACE);
+
 		glShadeModel(GL_FLAT);
 		glEnable(GL_DEPTH_TEST);
@@ -436,9 +490,8 @@
 		glMatrixMode(GL_MODELVIEW);
 		glLoadIdentity();
-		gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z, 
-				  mViewPoint.x, mViewPoint.y, mViewPoint.z, 
+		gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 
+				  midPoint.x, midPoint.y, midPoint.z, 
 				  0, 1, 0);
 
-		//SetFrustum(sceneSize, sceneSize, 1, sceneSize);
 	}
 	mNewTexture->EndCapture();
@@ -452,5 +505,5 @@
 		//Reshape(texWidth, texHeight);
 		glViewport(0, 0, texWidth, texHeight);
-		SetFrustum(sceneSize, sceneSize, 1, sceneSize);
+		SetFrustum(mWidth, mWidth, mNear, mFar);
 
 		glMatrixMode(GL_MODELVIEW);
@@ -459,10 +512,13 @@
 		glFrontFace(GL_CCW);
 		glCullFace(GL_BACK);
-		glEnable(GL_CULL_FACE);
+		
+		glDisable(GL_CULL_FACE);
+		//glEnable(GL_CULL_FACE);
+		
 		glShadeModel(GL_FLAT);
 		glEnable(GL_DEPTH_TEST);
 		
-		gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z, 
-				  mViewPoint.x, mViewPoint.y, mViewPoint.z, 
+		gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 
+				  midPoint.x, midPoint.y, midPoint.z, 
 				  0, 1, 0);
 
@@ -475,17 +531,72 @@
 
 
-Intersectable *GetObject(const int index)
-{
-	return NULL;
-}
-
-
-void GlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays)
+Intersectable *GlobalLinesRenderer::ExtractSamplePoint(float *depthBuffer,
+													   unsigned char *itemBuffer,
+													   const int x, 
+													   const int y,
+													   Vector3 &hitPoint,
+													   const bool isFrontBuffer) const
+{
+	const int depthIndex = x + texWidth * y;
+	const int itemIndex = 4 * depthIndex;
+
+	const float depth = depthBuffer[depthIndex];
+	const float eyeDist = mNear + (mFar - mNear) * depth;
+	
+	const float leftDist = 0.5f * mWidth - mWidth * ((float)x + 0.5f) / texWidth;
+	//const float upDist = 0.5f * mWidth - (float)mWidth * ((float)y + 0.5f) / texHeight;
+	const float upDist = -0.5f * mWidth + mWidth * ((float)y + 0.5f) / texHeight;
+	
+	hitPoint = mViewPoint + 
+		       eyeDist * mEyeVec + 
+			   leftDist * mUpVec + 
+			   upDist * mLeftVec;
+				
+	unsigned char r = itemBuffer[itemIndex];
+	unsigned char g = itemBuffer[itemIndex + 1];
+	unsigned char b = itemBuffer[itemIndex + 2];
+			
+	// 3 times 255 means no valid object
+	if ((r == 255) && (g == 255) && (b == 255))
+		return NULL;
+
+	const int id = mRenderer->GetId(r, g, b);
+	//cout << "r: " << (int)r << "g: " << (int)g << " b: " << (int)b << " id: " << id << "|";
+	Intersectable *intersect = mPreprocessor->GetObjectById(id);
+
+	const Vector3 dir = isFrontBuffer ? mEyeVec : -mEyeVec;
+	// HACK: assume triangle intersectable
+	const Vector3 norm = intersect->GetNormal(0); 
+
+	//if (DotProd(dir, norm) >= -Limits::Small) 
+		return intersect;
+}
+
+
+void GlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays, 
+											 const bool oldBufferInitialised)
 {
 	GrabDepthBuffer(mNewDepthBuffer, mNewTexture);
-	GrabDepthBuffer(mOldDepthBuffer, mOldTexture);
-
 	GrabItemBuffer(mNewItemBuffer, mNewTexture);
-	GrabItemBuffer(mOldItemBuffer, mOldTexture);
+
+	if (oldBufferInitialised)
+	{
+		GrabDepthBuffer(mOldDepthBuffer, mOldTexture);
+		GrabItemBuffer(mOldItemBuffer, mOldTexture);
+	}
+	else
+	{
+		for (int i = 0; i < texWidth * texHeight; ++ i)
+		{
+			mOldDepthBuffer[i] = 0;
+
+			mOldItemBuffer[i * 4]     = 255;
+			mOldItemBuffer[i * 4 + 1] = 255;
+			mOldItemBuffer[i * 4 + 2] = 255;
+			mOldItemBuffer[i * 4 + 3] = 255;
+		}
+	}
+
+	cout << "vp: " << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl;
 
 	for (int y = 0; y < texHeight; ++ y)
@@ -493,47 +604,32 @@
 		for (int x = 0; x < texWidth; ++ x)
 		{
-			const int index = x + texWidth * y;
-			const float newDepth = mNewDepthBuffer[index];
-			const float oldDepth = mOldDepthBuffer[index];
-
-			float newDummy1 = mNear + (mFar - mNear) * newDepth;
-			float oldDummy1 = mNear + (mFar - mNear) * oldDepth;
-
-			float newDummy2 = x - texWidth / 2;
-			float newDummy3 = y - texHeight / 2;
-
-			float oldDummy2 = newDummy2;
-			float oldDummy3 = newDummy3;
-
-			const Vector3 newPt = mViewPoint + newDepth * mEyeVec + newDummy1 * mLeftVec + newDummy2 * mUpVec;
-			const Vector3 oldPt = mViewPoint + oldDepth * mEyeVec + oldDummy1 * mLeftVec + oldDummy2 * mUpVec;
-
-			//cout << "viewpoint: " << mViewPoint << " new: " << newPt << " old: " << newPt << endl;
-			
-			int r = mNewItemBuffer[index];
-			int g = mNewItemBuffer[index + 1];
-			int b = mNewItemBuffer[index + 2];
-			
-			Intersectable *termObj1 = NULL;
-			Intersectable *termObj2 = NULL;
-
-			// 3 times 255 means no valid object
-			if (!((r == 255) && (g == 255) && (b == 255)))
+			Vector3 newPt, oldPt;
+
+			Intersectable *termObj1 = ExtractSamplePoint(mNewDepthBuffer, 
+														 mNewItemBuffer, 
+														 x, 
+														 y, 
+														 newPt, 
+														 true);
+
+			Intersectable *termObj2 = ExtractSamplePoint(mOldDepthBuffer, 
+														 mOldItemBuffer, 
+														 x, 
+														 y, 
+														 oldPt, 
+														 false);
+
+			// create rays in both directions
+			if (termObj1)
 			{
-				const int id = mRenderer->GetId(r, g, b);
-				cout << id << " ";
-				//termObj1 = mPreprocessor->GetObjectById(id);
+				vssRays.push_back(new VssRay(oldPt, newPt, NULL, termObj1));
+				//cout << "new pt: " << newPt << endl;
 			}
 
-			/*r = mOldItemBuffer[index];
-			g = mOldItemBuffer[index + 1];
-			b = mOldItemBuffer[index + 2];
-
-			if (!((r == 255) && (g == 255) && (b == 255)))
-				Intersectable *termObj2 = mPreprocessor->GetObjectById(mRenderer->GetId(r, g, b));
-*/
-			// create rays in both directions
-			//vssRays.push_back(new VssRay(oldPt, newPt, NULL, termObj1));
-			//vssRays.push_back(new VssRay(newPt, oldPt, NULL, termObj2));
+			//if (termObj2)
+			//{
+			//	vssRays.push_back(new VssRay(oldPt, newPt, NULL, termObj2));
+			//	cout << "old pt: " << oldPt << endl;
+			//}
 		}
 	}
@@ -544,4 +640,51 @@
 {
 	glutMainLoop();
+}
+
+
+void SetupFalseColor(const unsigned int id, 
+					 unsigned char &r,
+					 unsigned char &g,
+					 unsigned char &b
+					 )
+{
+	// swap bits of the color
+	r = id & 255;
+	g = (id >> 8) & 255;
+	b = (id >> 16) & 255;
+}
+
+
+void GlobalLinesRenderer::Visualize(const VssRayContainer &vssRays)
+{
+	Exporter *exporter = Exporter::GetExporter("globalLines.wrl");
+	
+	if (!exporter)
+		return;
+
+	exporter->SetWireframe();
+	//exporter->ExportGeometry(preprocessor->mObjects);
+	exporter->SetFilled();
+
+	VssRayContainer::const_iterator vit, vit_end = vssRays.end();
+
+	for (vit = vssRays.begin(); vit != vit_end; ++ vit)
+	{
+		VssRay *ray = *vit;
+		Intersectable *obj = (*vit)->mTerminationObject;	
+		exporter->ExportIntersectable(obj);
+		
+		unsigned char r, g, b;
+		SetupFalseColor(obj->GetId(), r, g, b);
+		int id = mRenderer->GetId(r, g, b);
+
+		if (id != obj->GetId())
+			cout << "error!" << endl;
+		else cout <<"x";
+	}	
+
+	exporter->ExportRays(vssRays);
+
+	delete exporter;
 }
 
@@ -560,5 +703,5 @@
 
 
-void GlobalLinesRenderer::GrabItemBuffer(int *data, RenderTexture *rt)
+void GlobalLinesRenderer::GrabItemBuffer(unsigned char *data, RenderTexture *rt)
 {
 	rt->Bind();
@@ -567,5 +710,5 @@
 
 	const int texFormat = GL_RGBA;
-	glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_FLOAT, data);
+	glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_UNSIGNED_BYTE, data);
 
 	mNewTexture->DisableTextureTarget();
@@ -579,5 +722,5 @@
 	cout << "depth: " << mNewTexture->GetDepthBits() << endl;
 
-	const bool components = 1;//mNewTexture->GetDepthBits() / 8;
+	const int components = 1;//mNewTexture->GetDepthBits() / 8;
 
 	float *data = new float[texWidth * texHeight * components];
@@ -609,21 +752,18 @@
 }
 
-
 /*
 void GlobalLinesRenderer::ExportItemBuffer()
 {
-	mNewTexture->BindDepth();
+	mNewTexture->Bind();
 	mNewTexture->EnableTextureTarget();
 	cout << "depth: " << mNewTexture->GetDepthBits() << endl;
 
-	const bool components = 1;//mNewTexture->GetDepthBits() / 8;
-
-	float *data = new float[texWidth * texHeight * components];
-	//const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV;
-	const int texFormat = GL_DEPTH_COMPONENT;
-	//const int texFormat = GL_RGBA;
+	const int components = 4;//mNewTexture->GetDepthBits() / 8;
+
+	float *data = new float[texWidth * texHeight * components*8];
+	const int texFormat = GL_RGBA;
 	glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_FLOAT, data);
 
-	string filename("depth.tga");
+	string filename("items.tga");
 	ilRegisterType(IL_FLOAT);
 
@@ -631,5 +771,7 @@
 	const int bpp = components;
 
-	ilTexImage(texWidth, texHeight, depth, bpp, IL_LUMINANCE, IL_FLOAT, data);
+	cout << "saving items to file " << endl;
+
+	ilTexImage(16, 16, depth, bpp, IL_RGBA, IL_FLOAT, data);
 	ilSaveImage((char *const)filename.c_str());
 
@@ -641,4 +783,32 @@
 }
 */
+void GlobalLinesRenderer::ExportItemBuffer()
+{
+	mNewTexture->Bind();
+	mNewTexture->EnableTextureTarget();
+	cout << "depth: " << mNewTexture->GetDepthBits() << endl;
+
+	const int components = 4;//mNewTexture->GetDepthBits() / 8;
+
+	unsigned char *data = new unsigned char [texWidth * texHeight * components];
+	//const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV;
+	const int texFormat = GL_RGBA;
+	glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_UNSIGNED_BYTE, data);
+
+	string filename("items.jpg");
+	ilRegisterType(IL_UNSIGNED_BYTE);
+
+	const int depth = 1;
+	const int bpp = components;
+
+	ilTexImage(texWidth, texHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data);
+	ilSaveImage((char *const)filename.c_str());
+
+	cout << "finished" << endl;
+	delete data;
+	cout << "data deleted" << endl;
+	mNewTexture->DisableTextureTarget();
+	PrintGLerror("grab texture");
+}
 
 
@@ -659,5 +829,5 @@
 
 	// process the buffers for the first layer
-	ProcessDepthBuffer(rays);
+	ProcessDepthBuffer(rays, false);
 
 	for(int i = 0; i < mMaxDepth; ++ i) 
@@ -685,10 +855,9 @@
 			cgGLDisableTextureParameter(sTextureParam);
 			cgGLDisableProfile(sCgFragmentProfile);
-
-			// process the buffers for following layer
-			ProcessDepthBuffer(rays);
-
 		}
 		mNewTexture->EndCapture();
+
+		// process the buffers for following layer
+		ProcessDepthBuffer(rays, true);
 	}
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1944)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1960)
@@ -251,5 +251,5 @@
 
 void
-GlRenderer::SetupFalseColor(const int id)
+GlRenderer::SetupFalseColor(const unsigned int id)
 {
 	// swap bits of the color
@@ -258,8 +258,11 @@
 
 
-int GlRenderer::GetId(int r, int g, int b) const
+unsigned int GlRenderer::GetId(const unsigned char r, 
+							   const unsigned char g, 
+							   const unsigned char b) const
 {
 	return r + (g << 8) + (b << 16);
 }
+
 
 void
@@ -269,4 +272,5 @@
 	glColor3fv(&(m->mDiffuseColor.r));
 }
+
 
 void
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h	(revision 1958)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h	(revision 1960)
@@ -48,11 +48,21 @@
 	*/
 	void DrawGeometry();
-void Run();
-void GrabDepthBuffer(float *data, RenderTexture *rt);
-void GrabItemBuffer(int *data, RenderTexture *rt);
-void ApplyDepthPeeling(VssRayContainer &rays, Beam &beam, const int samples);
-void ExportDepthBuffer();
-void ProcessDepthBuffer(VssRayContainer &vssRays);
-void DisplayBuffer();
+	void Run();
+	void GrabDepthBuffer(float *data, RenderTexture *rt);
+	void GrabItemBuffer(unsigned char *data, RenderTexture *rt);
+	void ApplyDepthPeeling(VssRayContainer &rays, Beam &beam, const int samples);
+	void ExportDepthBuffer();
+	void ExportItemBuffer();
+	void ProcessDepthBuffer(VssRayContainer &vssRays, const bool oldBufferInitialised);
+	void DisplayBuffer(const bool isDepth);
+	
+	Intersectable *ExtractSamplePoint(float *depthBuffer,
+									  unsigned char *itemBuffer,
+									  const int x, 
+									  const int y,
+									  Vector3 &hitPoint,
+									  const bool isFrontBuffer) const;
+
+	void Visualize(const VssRayContainer &vssRays);
 
 	int mMaxDepth;
@@ -62,4 +72,5 @@
 	float mFar;
 	float mNear;
+	float mWidth;
 
 	Vector3 mViewPoint;
@@ -67,7 +78,8 @@
 	float *mNewDepthBuffer;
 	float *mOldDepthBuffer;
-	int *mNewItemBuffer;
-	int *mOldItemBuffer;
-RenderTexture *mNewTexture;
+	unsigned char *mNewItemBuffer;
+	unsigned char *mOldItemBuffer;
+	
+	RenderTexture *mNewTexture;
 	RenderTexture *mOldTexture;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 1952)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 1960)
@@ -13,5 +13,6 @@
 
 
-IntelRayCaster::IntelRayCaster(const Preprocessor &preprocessor, const string externKdTree):
+IntelRayCaster::IntelRayCaster(const Preprocessor &preprocessor, 
+							   const string externKdTree):
 RayCaster(preprocessor)
 {
@@ -74,8 +75,8 @@
 		Vector3 dir = -simpleRay.mDirection;
 		hittriangle = mlrtaIntersectAS(
-			&simpleRay.mOrigin.x,
-			&dir.x,
-			normal,
-			dist);
+										&simpleRay.mOrigin.x,
+										&dir.x,
+										normal,
+										dist);
 
 		Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1949)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1960)
@@ -106,5 +106,5 @@
   virtual void RandomViewPoint();
 
-  void SetupFalseColor(const int id);
+  void SetupFalseColor(const unsigned int id);
   void RenderIntersectable(Intersectable *);
   void RenderViewCell(ViewCell *vc);
@@ -152,5 +152,7 @@
   virtual int GetHeight() const { return 0; }
 
-  int GetId(int r, int g, int b) const;
+  unsigned int GetId(const unsigned char r, 
+					 const unsigned char g, 
+					 const unsigned char b) const;
 
   inline const bool GetSnapErrorFrames() { return mSnapErrorFrames; }
