Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp	(revision 1070)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp	(revision 2083)
@@ -4,7 +4,7 @@
 using namespace std;
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Cosntructor.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 Mesh::Mesh():
 	mVertexBuffer(0), mSubMeshCount(0), mSubMesh(0), hasSkeleton(false)
@@ -19,7 +19,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Destroyer.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 Mesh::~Mesh()
 {
@@ -28,7 +28,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Copy constructor.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 Mesh::Mesh(const Mesh &mesh)
 {
@@ -171,7 +171,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Assignment operator.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 Mesh &Mesh::operator =(const	Mesh &mesh)
 {
@@ -192,5 +192,5 @@
 
 	//	For each submesh.
-	for(size_t	i	=	0;	i < mesh.mSubMeshCount;	i++)
+	for (size_t	i	=	0;	i < mesh.mSubMeshCount;	i++)
 	{
 		mSubMesh[i].mSharedVertexBuffer					=	mesh.mSubMesh[i].mSharedVertexBuffer; //.false;
@@ -210,5 +210,7 @@
 		}
 
-		for(size_t s = 0; s < mesh.mSubMesh[i].mVertexBuffer->mVertexCount; s++)
+		for (	size_t s = 0;
+					s < mesh.mSubMesh[i].mVertexBuffer->mVertexCount;
+					s++)
 		{
 			mSubMesh[i].mVertexBuffer->mPosition[s].x = mesh.mSubMesh[i].mVertexBuffer->mPosition[s].x;
@@ -286,7 +288,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Load mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void Mesh::Load(Serializer &s)
 {
@@ -326,7 +328,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Save mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void Mesh::Save(Serializer &s)
 {
@@ -348,19 +350,37 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Export to obj mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void Mesh::exportToOBJ(char *fileName)
 {
+	size_t	vertex_count;
+
+	vertex_count	=	0;
+
 	std::ofstream obj(fileName);
-	
+
 	obj << "begin" << std::endl;
+
+	for (size_t	j	=	0;	j < mVertexBuffer->mVertexCount;	j++)
+	{	
+		obj	<<	"v "
+			<<	mVertexBuffer->mPosition[j].x
+			<<	" "
+			<<	mVertexBuffer->mPosition[j].y
+			<<	" "
+			<<	mVertexBuffer->mPosition[j].z
+			<<	" "
+			<<	std::endl;
+	}
 
 	// Vertices.
 	for (size_t	i	=	0;	i < mSubMeshCount;	i++)
 	{
-		for (size_t	j	=	0;	j < mSubMesh[i].mVertexBuffer->mVertexCount;	j++)
-		{	
-			obj	<<	"v "
+		if (!mSubMesh[i].mSharedVertexBuffer)
+		{
+			for (size_t	j	=	0;	j < mSubMesh[i].mVertexBuffer->mVertexCount;	j++)
+			{	
+				obj	<<	"v "
 					<<	mSubMesh[i].mVertexBuffer->mPosition[j].x
 					<<	" "
@@ -370,4 +390,36 @@
 					<<	" "
 					<<	std::endl;
+			}
+		}
+	}
+
+	//	Normals.
+	for (size_t	j	=	0;	j < mVertexBuffer->mVertexCount;	j++)
+	{	
+		obj	<<	"vn "
+			<<	mVertexBuffer->mNormal[j].x
+			<<	" "
+			<<	mVertexBuffer->mNormal[j].y
+			<<	" "
+			<<	mVertexBuffer->mNormal[j].z
+			<<	" "
+			<<	std::endl;
+	}
+
+	for (size_t	i	=	0;	i < mSubMeshCount;	i++)
+	{
+		if (!mSubMesh[i].mSharedVertexBuffer)
+		{
+			for (size_t	j	=	0;	j < mSubMesh[i].mVertexBuffer->mVertexCount;	j++)
+			{	
+				obj	<<	"vn "
+					<<	mSubMesh[i].mVertexBuffer->mNormal[j].x
+					<<	" "
+					<<	mSubMesh[i].mVertexBuffer->mNormal[j].y
+					<<	" "
+					<<	mSubMesh[i].mVertexBuffer->mNormal[j].z
+					<<	" "
+					<<	std::endl;
+			}
 		}
 	}
@@ -378,22 +430,24 @@
 		for (size_t	j = 0;	j < mSubMesh[i].mIndexCount;	j	=	j + 3)
 		{	
-			obj	<<	"f "
-					<<	mSubMesh[i].mIndex[j] + 1
-					<<	" "	
-					<<	mSubMesh[i].mIndex[j + 1] + 1
-					<<	" "
-					<<	mSubMesh[i].mIndex[j + 2] + 1
-					<<	std::endl;
-		}
+			int a = mSubMesh[i].mIndex[j] + 1 + vertex_count;
+			int b = mSubMesh[i].mIndex[j+1] + 1 + vertex_count;
+			int c = mSubMesh[i].mIndex[j+2] + 1 + vertex_count;
+			obj	<<	"f " <<	a	<<	"//" << a << " "	
+									 <<	b	<<	"//" << b << " "	
+									 <<	c	<<	"//" << c << " "	
+				<<	std::endl;
+
+		}
+		vertex_count	+=	mSubMesh[i].mVertexBuffer->mVertexCount;
 	}
 
 	obj	<<	"end"	<<	std::endl;
-	
+
 	obj.close();
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 // Transform to shared vertex mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 Mesh *Mesh::toSharedVertex() 
 {
@@ -536,5 +590,5 @@
 	}
 
-	/*
+
 	//	Copy mesh bones.
 	if (!mBones.empty())
@@ -545,5 +599,4 @@
 		}
 	}
-	*/
 
 	return mesh;
