Index: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h	(revision 1007)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h	(revision 1024)
@@ -22,5 +22,4 @@
 	-# The simplified mesh, contained in a Geometry::Mesh object.
 	-# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object.
-	
 	*/
 
@@ -67,4 +66,7 @@
 			//	Progress bar function.
 			Geometry::TIPOFUNC	mUPB;
+
+			//	Sort mesh bones.
+			void	sortBones();
 	};
 
@@ -113,8 +115,5 @@
 		// Returns the simplified mesh.
 		//Mesh *GetMesh();
-
-
 	};
-
 
 	/// Implementation of a simplification algorithm based on geometry information.
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h	(revision 1009)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h	(revision 1024)
@@ -4,7 +4,10 @@
 #include	"mesh.h"
 #include	<vector>
+#include	<map>
 
 namespace	VMI
 {
+	typedef std::vector<int> INTVECTOR;
+
 	typedef struct change
 	{
@@ -63,4 +66,6 @@
 	//	Save simplification sequence in Geometry Game Tools format.
 	extern void	saveSimplificationSequence(Change	*c);
+
+	extern std::map<int, INTVECTOR> inversemap;
 }
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp	(revision 1009)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp	(revision 1024)
@@ -332,40 +332,52 @@
 }
 
+namespace VMI{
+std::map<int, INTVECTOR> inversemap;
+}
+
 //	Save simplification sequence in Geometry Game Tools format.
 extern void	VMI::saveSimplificationSequence(Change	*c)
 {
-	vmiStep	step;
-	step.mV0	=	c->u;
-	step.mV1	=	c->v;
-
-	//	If only one triangle has been deleted.
-	if (c->numDel == 1)
-	{
-		step.mT0	=	c->deleted[0].id;
-		step.mT1	=	c->deleted[0].id;
-	}
-	//	If two triangles have been deleted.
-	else
-	{
-		step.mT0	=	c->deleted[0].id;
-		step.mT1	=	c->deleted[1].id;
-	}
-
-	step.x	=	0.0;
-	step.y	=	0.0;
-	step.z	=	0.0;
-
-	//	Write obligatory field.
-	step.obligatory	=	0;
-
-	//	List of new triangles.
-	//	For each modified triangle.
-	for (int	i = 0;	i < c->numMod;	i++)
-	{
-		step.mModfaces.push_back(c->modified[i].id);
-	}
-
-	//	Add step to list of changes.
-	mVMISteps.push_back(step);
-}
-
+
+	int stepnum= 1;
+	for(INTVECTOR::iterator it= inversemap[c->u].begin(); it!=inversemap[c->u].end(); it++)
+	{
+		vmiStep	step;
+		step.mV0	=	*it;
+		step.mV1	=	c->v;
+
+		//	If only one triangle has been deleted.
+		if (c->numDel == 1)
+		{
+			step.mT0	=	c->deleted[0].id;
+			step.mT1	=	c->deleted[0].id;
+		}
+		//	If two triangles have been deleted.
+		else
+		{
+			step.mT0	=	c->deleted[0].id;
+			step.mT1	=	c->deleted[1].id;
+		}
+
+		step.x	=	0.0;
+		step.y	=	0.0;
+		step.z	=	0.0;
+
+		//	Write obligatory field.
+		if (stepnum==inversemap[c->u].size())
+			step.obligatory	=	0;
+		else
+			step.obligatory	=	1;
+		stepnum++;
+
+		//	List of new triangles.
+		//	For each modified triangle.
+		for (int	i = 0;	i < c->numMod;	i++)
+		{
+			step.mModfaces.push_back(c->modified[i].id);
+		}
+
+		//	Add step to list of changes.
+		mVMISteps.push_back(step);
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp	(revision 1014)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp	(revision 1024)
@@ -59,4 +59,84 @@
 {
 	return msimpsequence;
+}
+
+//---------------------------------------------------------------------------
+//	Sort mesh bones.
+//---------------------------------------------------------------------------
+void	MeshSimplifier::sortBones()
+{
+	Mesh									*mesh_copy;
+	int										n;
+	int 									o;
+	int										p;
+	VertexBoneAssignment	assign;
+	VertexBuffer					*mesh_vb;
+	VertexBuffer					*undo_vb;
+	SubMesh								*geosubmesh;
+	SubMesh								*undosubmesh;
+	
+	//	Gets a copy of the mesh.
+	mesh_copy		=	new Mesh();
+	*mesh_copy	=	*mGeoMesh;
+	
+	//	For each submesh.
+	for (size_t	i	=	0; i < mGeoMesh->mSubMeshCount; i++)
+	{
+		geosubmesh	=	&mGeoMesh->mSubMesh[i];
+		undosubmesh	=	&mesh_copy->mSubMesh[i];
+		
+		//	If there is submesh bones.
+		if (!geosubmesh->mBones.empty())
+		{
+			assign.boneIndex	=	0;
+			assign.weight			=	1;
+
+			geosubmesh->mBones.clear();
+
+			for (int	m	=	0;	m < geosubmesh->mVertexBuffer->mVertexCount;	m++)
+			{
+				assign.vertexIndex	=	m;
+				
+				geosubmesh->mBones.push_back(assign);
+			}
+
+			//	Change bones.
+			for (int	m = 0;	m < geosubmesh->mBones.size();	m++)
+			{
+				n	=	geosubmesh->mBones[m].vertexIndex;
+
+				//	Initialize o.
+				o	=	0;
+
+				mesh_vb	=	geosubmesh->mVertexBuffer;
+				undo_vb	=	undosubmesh->mVertexBuffer;
+
+				while (!(
+							(mesh_vb->mPosition[n].x == undo_vb->mPosition[o].x)
+							&&
+							(mesh_vb->mPosition[n].y == undo_vb->mPosition[o].y)
+							&&
+							(mesh_vb->mPosition[n].z == undo_vb->mPosition[o].z)
+							))
+				{
+					o++;
+				}
+
+				//	Initialize p.
+				p	=	0;
+
+				while (undosubmesh->mBones[p].vertexIndex != o)
+				{
+					p++;
+				}
+
+				//	Same bone for 'm' and 'p'.
+				geosubmesh->mBones[m].boneIndex	=	undosubmesh->mBones[p].boneIndex;
+			}
+		}
+	}
+
+	//	Delete copy of the mesh.
+	delete	mesh_copy;
 }
 
@@ -306,5 +386,46 @@
 
 //---------------------------------------------------------------------------
-//	Init vmi mesh structure for a geometry mesh given.
+//	Class for join triangle holes.
+//---------------------------------------------------------------------------
+class _coord_
+{
+	public:
+		float x,y,z;
+		inline _coord_(	float x	=	0.0f,
+										float y	=	0.0f,
+										float z	=	0.0f)
+		{ this->x = x; this->y = y; this->z = z; }
+		
+		inline _coord_(const _coord_ &f)
+		{
+			x	=	f.x;
+			y=f.y;
+			z=f.z;
+		}
+		
+		inline _coord_ & operator=(const _coord_ &f)
+		{
+			x	=	f.x;
+			y	=	f.y;
+			z	=	f.z;
+			
+			return *this;
+		}
+		
+		inline bool operator<(const _coord_ &f) const
+		{
+			if (x<f.x-0.0001) return true;
+			if (x>f.x+0.0001) return false;
+			if (y<f.y-0.0001) return true;
+			if (y>f.y+0.0001) return false;
+			if (z<f.z-0.0001) return true;
+			if (z>f.z+0.0001) return false;
+			
+			return	false;
+		}
+};
+
+//---------------------------------------------------------------------------
+//	Initialize the mesh of VMI module.
 //---------------------------------------------------------------------------
 VMI::Mesh *	ViewPointDrivenSimplifier::initMeshStructure(Mesh	*geoMesh)
@@ -360,8 +481,31 @@
 
 	printf("Adding vertices...");
-	
 	//	Fill up vertices.
+	std::map<_coord_, int> uniquevertices;
+	std::map<int, int> newindices;
 	for (i = 0; i < vertex_buffer->mVertexCount; i++)
 	{
+ 		_coord_ vertex_aux;
+		vertex_aux.x= vertex_buffer->mPosition[i].x;
+		vertex_aux.y= vertex_buffer->mPosition[i].y;
+		vertex_aux.z= vertex_buffer->mPosition[i].z;
+		//New index
+		if (uniquevertices.find(vertex_aux)==uniquevertices.end())
+		{
+			uniquevertices[vertex_aux]= i;
+			newindices[i]= i;
+
+			VMI::INTVECTOR intvectoraux;
+			intvectoraux.push_back(i);
+			VMI::inversemap[i]= intvectoraux;
+
+		}else//The map of unique vertices already contains this vertex
+		{
+			int newindex= uniquevertices[vertex_aux];
+			newindices[i]= newindex;
+
+			VMI::inversemap[newindex].push_back(i);;
+		}
+
 		// Vertices start at 0.
 		vmi_mesh->vertices[i].x = vertex_buffer->mPosition[i].x;
@@ -394,7 +538,7 @@
 			vmi_mesh->triangles[index].id 				= index;
 			vmi_mesh->triangles[index].submesh		= submesh;
-			vmi_mesh->triangles[index].indices[0] = geosubmesh->mIndex[(3 * i)];
-			vmi_mesh->triangles[index].indices[1] = geosubmesh->mIndex[(3 * i) + 1];
-			vmi_mesh->triangles[index].indices[2] = geosubmesh->mIndex[(3 * i) + 2];
+			vmi_mesh->triangles[index].indices[0] = newindices[geosubmesh->mIndex[(3 * i)]];
+			vmi_mesh->triangles[index].indices[1] = newindices[geosubmesh->mIndex[(3 * i) + 1]];
+			vmi_mesh->triangles[index].indices[2] = newindices[geosubmesh->mIndex[(3 * i) + 2]];
 
 			vmi_mesh->triangles[index].area = computeTriangleArea(vmi_mesh->vertices, 
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/OffsetMapping.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/OffsetMapping.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/OffsetMapping.material	(revision 1024)
@@ -0,0 +1,127 @@
+// Bump map with Parallax offset vertex program, support for this is required 
+vertex_program Examples/OffsetMappingVP cg 
+{ 
+   source OffsetMapping.cg 
+   entry_point main_vp 
+   profiles vs_1_1 arbvp1 
+} 
+
+// Bump map with parallax fragment program 
+fragment_program Examples/OffsetMappingFP cg
+{ 
+   source OffsetMapping.cg
+   entry_point main_fp
+   profiles ps_2_0 arbfp1
+} 
+
+// Bump map with parallax fragment program 
+fragment_program Examples/OffsetMappingPS asm 
+{ 
+   source OffsetMapping_specular.asm 
+   // sorry, only for ps_1_4 and above:) 
+   syntax ps_1_4 
+} 
+
+
+material Examples/OffsetMapping/Specular 
+{ 
+
+  // This is the preferred technique which uses both vertex and 
+   // fragment programs, supports coloured lights 
+   technique 
+   { 
+      // do the lighting  and bump mapping with parallax pass 
+      // NB we don't do decal texture here because this is repeated per light 
+      pass 
+      { 
+       
+         // Vertex program reference 
+         vertex_program_ref Examples/OffsetMappingVP 
+         { 
+            param_named_auto lightPosition light_position_object_space 0 
+            param_named_auto eyePosition camera_position_object_space 
+            param_named_auto worldViewProj worldviewproj_matrix 
+         } 
+
+         // Fragment program 
+         fragment_program_ref Examples/OffsetMappingFP
+         { 
+            param_named_auto lightDiffuse light_diffuse_colour 0 
+            param_named_auto lightSpecular light_specular_colour 0 
+            // Parallax Height scale and bias 
+            param_named scaleBias float4 0.04 -0.02 1 0 
+         } 
+          
+         // Normal + height(alpha) map 
+         texture_unit 
+         { 
+            texture rockwall_NH.tga
+            tex_coord_set 0 
+         } 
+
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+            tex_coord_set 1 
+         } 
+      } 
+   } 
+
+
+   // This is the preferred technique which uses both vertex and 
+   // fragment programs, supports coloured lights 
+   technique 
+   { 
+      // do the lighting  and bump mapping with parallax pass 
+      // NB we don't do decal texture here because this is repeated per light 
+      pass 
+      { 
+       
+         // Vertex program reference 
+         vertex_program_ref Examples/OffsetMappingVP 
+         { 
+            param_named_auto lightPosition light_position_object_space 0 
+            param_named_auto eyePosition camera_position_object_space 
+            param_named_auto worldViewProj worldviewproj_matrix 
+         } 
+
+         // Fragment program 
+         fragment_program_ref Examples/OffsetMappingPS 
+         { 
+            param_indexed_auto 0 light_diffuse_colour 0 
+            param_indexed_auto 1 light_specular_colour 0 
+            // Parallax Height scale and bias 
+            param_indexed 2 float4 0.04 -0.02 1 0 
+         } 
+          
+         // Normal + height(alpha) map 
+         texture_unit 
+         { 
+            texture rockwall_NH.tga
+            tex_coord_set 0 
+         } 
+
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+            tex_coord_set 1 
+         } 
+      } 
+   } 
+   
+   // Simple no-shader fallback
+   technique 
+   { 
+      pass 
+      { 
+         // Base diffuse texture map 
+         texture_unit 
+         { 
+            texture rockwall.tga
+         } 
+	  }
+   }
+
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example-DynTex.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example-DynTex.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example-DynTex.material	(revision 1024)
@@ -0,0 +1,86 @@
+
+material Examples/DynaTest
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			depth_write off
+			scene_blend alpha_blend
+			lighting off
+		}
+	}
+}
+
+
+material Examples/DynaTest2
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			diffuse 0.8 0.8 0.8
+			specular 0.7 0.7 0.7 40.0
+			ambient 0.5 0.5 0.5
+		}
+	}
+}
+
+material Examples/DynaTest3
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			diffuse 0.2 0.8 0.8
+			specular 0.4 0.7 0.7 30.0
+			ambient 0.2 0.5 1.0
+			depth_write off
+			scene_blend alpha_blend
+		}
+	}
+}
+
+material Examples/DynaTest4
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture DynaTex 2d
+			}
+			diffuse 0.8 0.8 0.8
+			specular 0.7 0.7 0.4 20.0
+			ambient 1.0 0.5 0.2
+		}
+	}
+}
+
+material Examples/VTDarkStuff
+{
+	technique
+	{
+		pass
+		{
+			diffuse 0.0 0.0 0.0
+			ambient 0.1 0.1 0.15
+			cull_hardware none
+			lighting on
+		}
+		
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example-Water.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example-Water.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example-Water.material	(revision 1024)
@@ -0,0 +1,178 @@
+
+material Examples/Water0
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+
+			texture_unit
+			{
+				texture Water01.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water1
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+				scale 0.25 0.25
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water2
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+
+			texture_unit
+			{
+				texture Water01.jpg
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water3
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+
+			texture_unit
+			{
+				texture Water02.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+				rotate_anim 0.03
+			}
+		}
+	}
+}
+material Examples/Water4
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture Water02.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water5
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+				scale 0.25 0.25
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				env_map spherical
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/Water6
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+material Examples/Water7
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+				scale 0.25 0.25
+			}
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+material Examples/Water8
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Example.material	(revision 1024)
@@ -0,0 +1,714 @@
+
+material Examples/EnvMappedRustySteel
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+
+			texture_unit
+			{
+				texture spheremap.png
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+				env_map spherical
+			}
+		}
+	}
+}
+material Examples/OgreLogo
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.8 0.8 0.8
+
+			texture_unit
+			{
+				texture ogrelogo.png
+			}
+		}
+	}
+}
+material Examples/DarkMaterial
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.1 0.1 0.1
+
+			texture_unit
+			{
+				texture BeachStones.jpg
+			}
+		}
+	}
+}
+material Examples/SpaceSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture stevecube.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Examples/SceneSkyBox1
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture cubemap_fr.jpg cubemap_bk.jpg cubemap_lf.jpg cubemap_rt.jpg cubemap_up.jpg cubemap_dn.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Examples/SceneCubeMap1
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture cubemap.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+material Examples/SceneSkyBox2
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture cubescene_fr.jpg cubescene_bk.jpg cubescene_lf.jpg cubescene_rt.jpg cubescene_up.jpg cubescene_dn.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Examples/SceneCubeMap2
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+
+			texture_unit
+			{
+				cubic_texture cubescene.jpg combinedUVW
+				tex_address_mode clamp
+				env_map cubic_reflection
+			}
+		}
+	}
+}
+
+material Examples/CloudyNoonSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture cloudy_noon.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material Examples/StormySkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture stormy.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material Examples/MorningSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture morning.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material Examples/EveningSkyBox
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				cubic_texture evening.jpg separateUV
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+
+material Examples/CloudySky
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+
+			texture_unit
+			{
+				texture clouds.jpg
+				scroll_anim 0.15 0
+			}
+		}
+	}
+}
+material Examples/RustySteel
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+		}
+	}
+}
+material Examples/Chrome
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture Chrome.jpg
+				env_map spherical
+			}
+		}
+	}
+}
+material Examples/SpaceSkyPlane
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			depth_write off
+			fog_override true none
+
+			texture_unit
+			{
+				texture spacesky.jpg
+			}
+		}
+	}
+}
+material Examples/TextureEffect1
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.75 0.75 0.75
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BumpyMetal.jpg
+				rotate_anim 0.2
+				wave_xform scale_x sine 1 0.1 0 5
+				wave_xform scale_y sine 0.5 0.2 0.5 3
+			}
+		}
+	}
+}
+material Examples/TextureEffect2
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture Water02.jpg
+				scroll_anim 0.5 0
+			}
+		}
+	}
+}
+material Examples/TextureEffect3
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.7 0.7 0.7
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture Water01.jpg
+				scroll_anim -0.25 0.1
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+				scroll_anim -0.1 0.25
+			}
+		}
+	}
+}
+material Examples/TextureEffect4
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.3 0.3 0.3
+			scene_blend colour_blend
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture Water02.jpg
+				scroll_anim 0.01 0.01
+			}
+		}
+	}
+}
+material Examples/BumpyMetal
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.75 0.75 0.75
+			cull_hardware none
+			cull_software none
+
+			texture_unit
+			{
+				texture BumpyMetal.jpg
+			}
+		}
+	}
+}
+material Examples/TransparentTest
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture Water01.jpg
+				scroll_anim 0.25 0
+			}
+
+			texture_unit
+			{
+				texture Water01.jpg
+				wave_xform scroll_y sine 0 0.1 0 0.5
+			}
+		}
+	}
+}
+material Examples/Flare
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture flare.png
+			}
+		}
+	}
+}
+material Examples/Flare2
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend add
+			depth_write off
+
+			texture_unit
+			{
+				texture flaretrail.png
+			}
+		}
+	}
+}
+
+material Examples/Droplet
+{
+	technique
+	{
+		pass
+		{
+			scene_blend colour_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture basic_droplet.png
+			}
+		}
+	}
+}
+material Examples/Hilite/Yellow
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture dkyellow.png
+			}
+		}
+	}
+}
+material Examples/Rocky
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2
+
+			texture_unit
+			{
+				texture egyptrockyfull.jpg
+			}
+		}
+	}
+}
+material Examples/10PointBlock
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture 10points.png
+			}
+		}
+	}
+}
+material Material__25
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture texmap2.jpg
+			}
+		}
+	}
+}
+material 2 - Default
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture MtlPlat2.jpg
+			}
+		}
+	}
+}
+material Material #8
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture BODY.jpg
+			}
+		}
+	}
+}
+material Material #3
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture HEAD4.jpg
+			}
+		}
+	}
+}
+material Material #9
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture LEGS.jpg
+			}
+		}
+	}
+}
+
+material Examples/Fish
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture steelhead.png
+			}
+		}
+	}
+}
+material Examples/Ninja
+{
+	technique
+	{
+		pass
+		{
+		
+			texture_unit
+			{
+				texture nskingr.jpg
+			}
+		}
+	}
+}
+
+material Examples/Robot
+{
+	// Hardware skinning technique
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Ogre/HardwareSkinningOneWeight
+			{
+				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
+				param_named_auto viewProjectionMatrix viewproj_matrix
+				param_named_auto lightPos[0] light_position 0
+				param_named_auto lightPos[1] light_position 1
+				param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
+				param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
+				param_named_auto ambient ambient_light_colour
+			
+			}
+			// alternate shadow caster program
+			shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster
+			{
+				param_named_auto worldMatrix3x4Array[0] world_matrix_array_3x4
+				param_named_auto viewProjectionMatrix viewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			
+			}
+
+			texture_unit
+			{
+				texture r2skin.jpg
+			}
+		}
+	}
+
+	// Software blending technique
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture r2skin.jpg
+			}
+		}
+	}
+}
+
+material Examples/GrassFloor
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture grass_1024.jpg
+			}
+		}
+	}
+}
+
+vertex_program Examples/GrassWaverVp cg
+{
+	source Grass.cg
+	entry_point grass_vp
+	profiles vs_1_1 arbvp1
+}
+
+material Examples/GrassBlades
+{
+	// Vertex program waving grass
+    technique
+    {
+        pass
+        {
+			vertex_program_ref Examples/GrassWaverVp
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+				param_named_auto objSpaceLight light_position_object_space 0
+				param_named_auto lightColour light_diffuse_colour 0
+				param_named_auto offset custom 999
+			}
+			alpha_rejection greater 150 
+			scene_blend alpha_blend
+		    cull_hardware none
+            cull_software none
+            texture_unit
+            {
+                texture gras_02.png 
+            }
+        }
+    }
+
+	// Non-vertex program technique (no waving)
+	technique
+    {
+        pass
+        {
+			alpha_rejection greater 150 
+			scene_blend alpha_blend
+		    cull_hardware none
+            cull_software none
+            texture_unit
+            {
+                texture gras_02.png 
+            }
+        }
+    }
+}
+
+material Examples/Rockwall
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture rockwall.tga
+			}
+		}
+	}
+}
+
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Ogre.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Ogre.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Ogre.material	(revision 1024)
@@ -0,0 +1,119 @@
+
+material Ogre/Earring
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.5 0.5 0
+			diffuse 1 1 0
+
+			texture_unit
+			{
+				texture spheremap.png
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+				env_map spherical
+			}
+		}
+	}
+}
+material Ogre/Skin
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.7 0.7 0.7
+			cull_hardware none
+
+			texture_unit
+			{
+				texture GreenSkin.jpg
+				tex_address_mode mirror
+			}
+		}
+	}
+}
+material Ogre/Tusks
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.5 0.5 0.4
+			diffuse 1 1 0.8
+
+			texture_unit
+			{
+				texture dirt01.jpg
+				colour_op_ex add src_texture src_current
+				colour_op_multipass_fallback one one
+			}
+		}
+	}
+}
+material Ogre/Eyes
+{
+	technique
+	{
+		pass
+		{
+
+			texture_unit
+			{
+				texture WeirdEye.png
+			}
+		}
+	}
+}
+material Cursor/default
+{
+	technique
+	{
+		pass
+		{
+			scene_blend alpha_blend
+
+			texture_unit
+			{
+				texture cursor.png
+				tex_address_mode clamp
+			}
+		}
+	}
+}
+material Core/StatsBlockBorder/Down
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_check off
+
+			texture_unit
+			{
+				texture ogreborder.png
+			}
+		}
+	}
+}
+material Core/StatsBlockBorder/Up
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_check off
+
+			texture_unit
+			{
+				texture ogreborderUp.png
+			}
+		}
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/RZR-002.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/RZR-002.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/RZR-002.material	(revision 1024)
@@ -0,0 +1,14 @@
+
+material RZR-002
+{
+	technique
+	{
+		pass
+		{
+			texture_unit
+			{
+				texture RZR-002.png
+			}
+		}
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/smoke.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/smoke.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/smoke.material	(revision 1024)
@@ -0,0 +1,19 @@
+
+material Examples/Smoke
+{
+	technique
+	{
+		pass
+		{
+			lighting off
+			scene_blend alpha_blend
+			depth_write off
+
+			texture_unit
+			{
+				texture smoke.png
+				tex_address_mode clamp
+			}
+		}
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/toonturtle.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/toonturtle.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/toonturtle.material	(revision 1024)
@@ -0,0 +1,18 @@
+
+material Material0
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2 1
+			diffuse 0.8 0.8 0.8 1
+
+			texture_unit
+			{
+				texture toonturtle.jpg
+			}
+		}
+	}
+}
+
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/enano.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/enano.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/enano.material	(revision 1024)
@@ -0,0 +1,49 @@
+
+material Material0
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2 1
+			diffuse 0.8 0.8 0.8 1
+
+			texture_unit
+			{
+				texture axe.jpg
+			}
+		}
+	}
+}
+material Material1
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2 1
+			diffuse 0.8 0.8 0.8 1
+
+			texture_unit
+			{
+				texture dwarf.jpg
+			}
+		}
+	}
+}
+material Material2
+{
+	technique
+	{
+		pass
+		{
+			ambient 0.2 0.2 0.2 1
+			diffuse 0.8 0.8 0.8 1
+
+			texture_unit
+			{
+				texture dwarf2.jpg
+			}
+		}
+	}
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Examples-Advanced.material
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Examples-Advanced.material	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/media/materials/Examples-Advanced.material	(revision 1024)
@@ -0,0 +1,1131 @@
+// -------------------------------
+// Cel Shading Section
+// -------------------------------
+vertex_program Ogre/CelShadingVP cg
+{
+	source Example_CelShading.cg
+	entry_point main_vp
+	profiles vs_1_1 arbvp1
+
+	default_params
+	{
+		param_named_auto lightPosition light_position_object_space 0
+		param_named_auto eyePosition camera_position_object_space
+		param_named_auto worldViewProj worldviewproj_matrix
+		param_named shininess float 10 
+	}
+}
+
+fragment_program Ogre/CelShadingFP cg
+{
+	source Example_CelShading.cg
+	entry_point main_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+
+material Examples/CelShading
+{
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Ogre/CelShadingVP
+			{
+				// map shininess from custom renderable param 1
+				param_named_auto shininess custom 1
+			}
+			fragment_program_ref Ogre/CelShadingFP
+			{
+				// map diffuse from custom renderable param 2
+				param_named_auto diffuse custom 2
+				// map specular from custom renderable param 2
+				param_named_auto specular custom 3
+			}
+			texture_unit
+			{
+				texture cel_shading_diffuse.png 1d
+				tex_address_mode clamp
+				filtering none
+			}
+			texture_unit
+			{
+				texture cel_shading_specular.png 1d
+				tex_address_mode clamp
+				filtering none
+				tex_coord_set 1
+			}
+			texture_unit
+			{
+				texture cel_shading_edge.png 1d
+				tex_address_mode clamp
+				filtering none
+				tex_coord_set 2
+			}
+		}
+	}
+	
+}
+
+
+
+//------------------------
+// Bump mapping section
+//------------------------
+
+// Bump map vertex program, support for this is required
+vertex_program Examples/BumpMapVP cg
+{
+	source Example_BumpMapping.cg
+	entry_point main_vp
+	profiles vs_1_1 arbvp1
+}
+
+// Bump map fragment program, support for this is optional
+fragment_program Examples/BumpMapFP cg
+{
+	source Example_BumpMapping.cg
+	entry_point main_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+// Bump map with specular vertex program, support for this is required
+vertex_program Examples/BumpMapVPSpecular cg
+{
+	source Example_BumpMapping.cg
+	entry_point specular_vp
+	profiles vs_1_1 arbvp1
+}
+
+// Bump map fragment program, support for this is optional
+fragment_program Examples/BumpMapFPSpecular cg
+{
+	source Example_BumpMapping.cg
+	entry_point specular_fp
+	profiles ps_1_1 arbfp1 fp20
+}
+
+// Single light material, less passes (one pass on a 4-unit card)
+material Examples/BumpMapping/SingleLight
+{
+	// Preferred technique, uses vertex and fragment programs
+	// to support a single coloured light
+	technique
+	{
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFP
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+			// Decal
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+		}
+	}
+	// Fallback technique, uses vertex program but only fixed-function
+	// fragment shading, which does not support coloured light
+	technique
+	{
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+			// Decal
+			texture_unit
+			{
+				texture RustySteel.jpg
+			}
+		}
+	}
+}
+
+// Any number of lights, diffuse
+material Examples/BumpMapping/MultiLight
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0 
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFP
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+
+	}
+}
+
+// Any number of lights, diffuse and specular
+material Examples/BumpMapping/MultiLightSpecular
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVPSpecular
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto eyePosition camera_position_object_space
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFPSpecular
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+				param_named_auto lightSpecular light_specular_colour 0
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+			// Normalisation cube map #2
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 2
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use, NB does not support specular colour
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture NMBumpsOut.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture RustedMetal.jpg 
+			}
+			
+		}
+
+	}
+}
+
+//---------------------------
+// Projective texture section
+//---------------------------
+
+
+vertex_program Examples/TexProjectionVP cg
+{
+	source Example_Projection.cg
+	entry_point generalPurposeProjection_vp
+	profiles vs_1_1 arbvp1
+}
+
+fragment_program Examples/TexProjectionFP cg
+{
+	source Example_Projection.cg
+	entry_point generalPurposeProjection_fp
+	// sorry, ps_1_1 can't do this, fp20 can though
+	profiles ps_2_0 arbfp1 fp20
+}
+
+material Examples/GeneralTexProjection
+{
+	technique
+	{
+		pass 
+		{
+			
+			vertex_program_ref Examples/TexProjectionVP
+			{
+				param_named_auto worldViewProjMatrix worldviewproj_matrix
+				param_named_auto worldMatrix world_matrix
+				// You'll need to update the tex projection, I suggest using
+				// the Frustum class
+				//param_named_auto texWorldViewProj worldviewproj_matrix
+			}
+			fragment_program_ref Examples/TexProjectionFP
+			{
+				// no params
+			}
+			texture_unit
+			{
+				// Project the OGRE logo
+				texture ogrelogo.png
+				tex_address_mode clamp
+			}
+		}
+		
+			
+	}
+    
+}
+
+//----------------------------
+// Distortion effects
+//----------------------------
+
+vertex_program Examples/FresnelRefractReflectVP cg
+{
+	source Example_Fresnel.cg
+	entry_point main_vp
+	profiles vs_1_1 arbvp1
+}
+
+fragment_program Examples/FresnelRefractReflectFP cg
+{
+	source Example_Fresnel.cg
+	entry_point main_fp
+	// sorry, ps_1_1 and fp20 can't do this
+	profiles ps_2_0 arbfp1
+}
+
+fragment_program Examples/FresnelRefractReflectPS asm
+{
+	source Example_FresnelPS.asm
+	// sorry, only for ps_1_4 :)
+	syntax ps_1_4
+
+}
+
+material Examples/FresnelReflectionRefraction
+{
+	// ps_2_0 / arbfp1
+	technique
+	{
+		pass 
+		{
+			
+			vertex_program_ref Examples/FresnelRefractReflectVP
+			{
+				param_named_auto worldViewProjMatrix worldviewproj_matrix
+				param_named_auto eyePosition camera_position_object_space
+				param_named fresnelBias float -0.3 
+				param_named fresnelScale float 1.4 
+				param_named fresnelPower float 8  
+				param_named_auto timeVal time 0.05
+				param_named scroll float 1  
+				param_named scale float 4 
+				param_named noise float 1 
+				// scroll and noisePos will need updating per frame
+			}
+			fragment_program_ref Examples/FresnelRefractReflectFP
+			{
+				param_named distortionRange float 0.025 
+				param_named tintColour float4 0 0 0 1
+			}
+			// Noise
+			texture_unit
+			{
+				// Perlin noise volume
+				texture perlinvolume.dds 3d
+				// min / mag filtering, no mip
+				filtering linear linear none
+			}
+			// Reflection
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Reflection
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 1
+			}
+			// Refraction
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Refraction
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 2
+			}
+		}
+		
+			
+	}
+
+	// ATI 8500 +
+	technique
+	{
+		pass
+		{
+			vertex_program_ref Examples/FresnelRefractReflectVP
+			{
+				param_named_auto worldViewProjMatrix worldviewproj_matrix
+				param_named_auto eyePosition camera_position_object_space
+				param_named fresnelBias float -0.3
+				param_named fresnelScale float 1.4
+				param_named fresnelPower float 8
+				param_named_auto timeVal time 0.05
+				param_named scroll float 1 
+				param_named scale float 4 
+				param_named noise float 1
+				// scroll and noisePos will need updating per frame
+			}
+
+			// for ATI RADEON 8500 - 9200
+			fragment_program_ref Examples/FresnelRefractReflectPS
+			{
+				// distortionRange
+				param_indexed 0  float 0.025  
+				// tintColour
+				param_indexed 1  float4 0.05 0.12 0.15 1
+			}
+
+			// Noise
+			texture_unit
+			{
+				// Perlin noise volume
+				texture perlinvolume.dds 3d
+				// min / mag filtering, no mip
+				filtering linear linear none
+			}
+			// Reflection
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Reflection
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 1
+			}
+			// Refraction
+			texture_unit
+			{
+				// Will be filled in at runtime
+				texture Refraction
+				tex_address_mode clamp
+				// needed by ps.1.4
+				tex_coord_set 2
+			}
+		}
+	}    
+}
+
+// Normal-mapped Athene statue
+material Examples/Athene/NormalMapped
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0 
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFP
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg
+			}
+			
+		}
+
+	}
+}
+
+// Basic Athene statue
+material Examples/Athene/Basic
+{
+
+	technique
+	{
+		pass
+		{
+			ambient 0.3 0.3 0.3
+			diffuse 1.0 1.0 0.9
+
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+}
+
+
+// Any number of lights, diffuse and specular
+material Examples/Athene/NormalMappedSpecular
+{
+
+	// This is the preferred technique which uses both vertex and
+	// fragment programs, supports coloured lights
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVPSpecular
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto eyePosition camera_position_object_space
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+
+			// Fragment program
+			fragment_program_ref Examples/BumpMapFPSpecular
+			{
+				param_named_auto lightDiffuse light_diffuse_colour 0 
+				param_named_auto lightSpecular light_specular_colour 0
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+			}
+			// Normalisation cube map #2
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 2
+				tex_address_mode clamp
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+	}
+
+	// This is the fallback which cards which don't have fragment program 
+	// support will use, NB does not support specular colour
+	// Note that it still requires vertex program support
+	technique
+	{
+		// Base ambient pass
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 1 1 1
+			diffuse 0 0 0 
+			specular 0 0 0 0
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named_auto ambient ambient_light_colour
+			}
+			
+		}
+		// Now do the lighting pass
+		// NB we don't do decal texture here because this is repeated per light
+		pass
+		{
+			// base colours, not needed for rendering, but as information
+			// to lighting pass categorisation routine
+			ambient 0 0 0 
+			// do this for each light
+			iteration once_per_light
+
+		
+			scene_blend add
+
+			// Vertex program reference
+			vertex_program_ref Examples/BumpMapVP
+			{
+				param_named_auto lightPosition light_position_object_space 0
+				param_named_auto worldViewProj worldviewproj_matrix
+			}
+			
+			// Base bump map
+			texture_unit
+			{
+				texture atheneNormalMap.png
+				colour_op replace
+			}
+			// Normalisation cube map, with dot product on bump map
+			texture_unit
+			{
+				cubic_texture nm.png combinedUVW
+				tex_coord_set 1
+				tex_address_mode clamp
+				colour_op_ex dotproduct src_texture src_current
+				colour_op_multipass_fallback dest_colour zero
+			}
+		}
+		
+		// Decal pass
+		pass
+		{
+			lighting off
+			// Really basic vertex program
+			// NB we don't use fixed function here because GL does not like
+			// mixing fixed function and vertex programs, depth fighting can
+			// be an issue
+			vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
+			{
+				param_named_auto worldViewProj worldviewproj_matrix
+				param_named ambient float4 1 1 1 1
+			}
+			scene_blend dest_colour zero
+			texture_unit
+			{
+				texture egyptrockyfull.jpg 
+			}
+			
+		}
+
+	}
+}
+
Index: GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMaterialLoader.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMaterialLoader.h	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMaterialLoader.h	(revision 1024)
@@ -0,0 +1,43 @@
+#include	<string>
+#include	<vector>
+#include	<map>
+#include	<fltk/dirent.h>
+#include	<iostream>
+#include	<fstream>
+
+using	namespace	std;
+
+class	GeoMaterialLoader
+{
+	private:
+
+		//	Directory path.
+		string	mMatPath;
+		string	mTexPath;
+		
+		//	List of files.
+		vector<string>	mFiles;
+		
+		//	Mat of materials and textures.
+		map<string,string>	mMatMap;
+		
+		//	Load material.
+		void	load();
+		
+		//	Search material files.
+		void	search(string	path);
+		
+	public:
+
+		///	Constructor.
+		GeoMaterialLoader();
+
+		///	Destroyer.
+		~GeoMaterialLoader();
+		
+		//	Check if material name exists.
+		bool	existsMaterial(string	matName);
+
+		//	Gets texture filename of the material.
+		string	getTextureFileName(string	matName);
+};
Index: GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h	(revision 994)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h	(revision 1024)
@@ -52,4 +52,6 @@
 #include	"../resource.h"
 
+#include	<GeoMaterialLoader.h>
+
 //	State of the button process.
 enum	ProcessState
@@ -282,4 +284,7 @@
 	bool	fileExists(const char	*fileNameMesh);
 
+	//	Set textures to mesh model.
+	void setTextures();
+
 	public:
 
@@ -296,6 +301,6 @@
 	fltk::Item					*menuMeshExportOBJ;
 	fltk::Item					*menuFileTransformSharedVertex;
-	fltk::ItemGroup				*menuLoadTextures;
-	fltk::Item						*menuFileLoadTexture;
+	fltk::ItemGroup			*menuLoadTextures;
+	fltk::Item					*menuFileLoadTexture;
 
 	fltk::Item					*menuFileQuit;
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp	(revision 989)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp	(revision 1024)
@@ -427,4 +427,5 @@
 	//	Gets material name.
 	fgets(materialName,255,f);
+	materialName[strlen(materialName) - 1]	=	'\0';
 
 	fread(&useSharedVertices,sizeof(bool),1,f);
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMaterialLoader.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMaterialLoader.cpp	(revision 1024)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMaterialLoader.cpp	(revision 1024)
@@ -0,0 +1,150 @@
+#include	<GeoMaterialLoader.h>
+
+using	namespace	std;
+
+//---------------------------------------------------------------------------
+//	Private:
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//	Search material files.
+//---------------------------------------------------------------------------
+void	GeoMaterialLoader::search(string path)
+{
+	dirent	**files;
+	int			num_files;
+	
+	num_files	=	filename_list(path.c_str(),	&files);
+
+	//	For each file.
+	for (int	i	=	0;	i < num_files;	i++)
+	{
+		//	If is ".material" file.
+		if (filename_match(files[i]->d_name,	"*.material"))
+		{
+			//	Add filename to list.
+			mFiles.push_back(string(files[i]->d_name));
+		}
+		
+		//	Free filename.
+		free(files[i]);
+	}
+	
+	//	Free memory of filenames.
+	free(files);
+}
+
+//---------------------------------------------------------------------------
+//	Load materials.
+//---------------------------------------------------------------------------
+void	GeoMaterialLoader::load()
+{
+	ifstream	*in_file;
+	string		filename;
+	char			line[256];
+	char			delim[4]	=	" \n\t";
+	char			*elem;
+	string 		mat_name;
+
+	//	For each file in list.
+	for (int i = 0;	i < mFiles.size();	i++)
+	{
+		//	File name.
+		filename	=mMatPath + mFiles[i];
+			
+		//	Open file.
+		in_file	=	new ifstream(filename.c_str());
+		
+		//	While no EOF reached.
+		while (in_file->good())
+		{
+			//	Read line.
+			in_file->getline(line,	256);
+
+			//	Gets first token.
+			elem	=	strtok(line,	delim);
+
+			
+			if (elem != NULL)
+			{
+				if (strcmp(elem,	"material") == 0)
+				{
+					//	Gets material name.
+					elem	=	strtok(NULL, delim);
+
+					//	Save material name.
+					mat_name	=	string(elem);
+
+					mMatMap[mat_name] = string("");
+				}
+				else
+				{
+					if (strcmp(elem,	"texture") == 0)
+					{
+						//	Gets texture filename.
+						elem	=	strtok(NULL, delim);
+
+						mMatMap[mat_name] =	string(elem);
+
+						//	Debug.
+						cout	<<	mat_name
+									<<	": "
+									<<	string(elem)
+									<<	endl;
+					}
+				}
+			}
+		}
+
+		//	Close file.
+		in_file->close();
+	}
+}
+
+//---------------------------------------------------------------------------
+//	Public:
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//	Constructor.
+//---------------------------------------------------------------------------
+GeoMaterialLoader::GeoMaterialLoader()
+{
+	mMatPath	=	string("./media/materials/");
+	mTexPath	=	string("./media/textures/");
+
+	search(mMatPath);
+	
+	load();
+}
+
+//---------------------------------------------------------------------------
+//	Destroyer.
+//---------------------------------------------------------------------------
+GeoMaterialLoader::~GeoMaterialLoader()
+{
+}
+
+//---------------------------------------------------------------------------
+//	Check for a material name.
+//---------------------------------------------------------------------------
+bool	GeoMaterialLoader::existsMaterial(string	matName)
+{
+	//	If material not found.
+	if (mMatMap.find(matName) == mMatMap.end())
+	{
+		return	false;
+	}
+	else
+	{
+		return	true;
+	}
+}
+
+//---------------------------------------------------------------------------
+//	Gets texture file name.
+//---------------------------------------------------------------------------
+string	GeoMaterialLoader::getTextureFileName(string	matName)
+{
+	return	mTexPath + mMatMap[matName];
+}
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 1017)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 1024)
@@ -25,5 +25,4 @@
 	geoMeshView->deactiveLodTree();
 
-	geoMeshView->resetTextures();
 	BuildLoadTextureSubMeshMenu();
 
@@ -1003,8 +1002,4 @@
 }
 
-VertexBuffer *origSubMeshVB=NULL;
-int orig_numindices=0;
-Index *orig_indices=NULL;
-
 //---------------------------------------------------------------------------
 //	Button Process Callback
@@ -1018,6 +1013,4 @@
 	progressBarType	=	PROCESS;
 	mProcessBar->position(0);
-
-	origSubMeshVB=NULL;
 
 	//	Initialize error flag.
@@ -1086,10 +1079,4 @@
 				else
 				{
-					origSubMeshVB=mGeoMesh->mSubMesh[idMeshLeaves].mVertexBuffer->Clone();
-					orig_numindices=mGeoMesh->mSubMesh[idMeshLeaves].mIndexCount;
-					orig_indices=new Index[orig_numindices];
-					for (int i=0; i<orig_numindices; i++)
-						orig_indices[i]=mGeoMesh->mSubMesh[idMeshLeaves].mIndex[i];
-
 					std::cout << "Simplificando hojas...";
 					simplifyLeavesCollapse();
@@ -1336,8 +1323,4 @@
 						file_name[strlen(file_name) - 4]	=	'\0';
 						
-						mesh_saver->leavesSubMesh=idMeshLeaves;
-						mesh_saver->leavesVB=origSubMeshVB;
-						mesh_saver->numindices=orig_numindices;
-						mesh_saver->indices=orig_indices;
 						mesh_saver->save(	mGeoMesh,
 															strcat(file_name,".mesh"));
@@ -2502,4 +2485,8 @@
 			//	Visualize mesh.
 			geoMeshView->setMesh(mGeoMesh);
+			
+			//	Set textures.
+			geoMeshView->resetTextures();
+			setTextures();
 
 			//	Hide right panel.
@@ -2544,4 +2531,38 @@
 	//	Free memory.
 	delete	fcho;
+}
+
+//	Set textures to mesh model.
+void GeoMeshViewUI::setTextures()
+{
+	GeoMaterialLoader	*loader;
+	string						filename;
+	string						material;
+	
+	loader	= new	GeoMaterialLoader();
+
+	//	For each submesh.
+	for (int submesh = 0; submesh < mGeoMesh->mSubMeshCount; submesh++)
+	{
+		material	= string(mGeoMesh->mSubMesh[submesh].mMaterialName);
+				
+		if (loader->existsMaterial(material))
+		{
+			//	Debug.
+			cout	<<	"Material "
+						<<	material
+						<<	" found."
+						<<	endl;
+			
+			filename	=	loader->getTextureFileName(material);
+
+			//	Debug.
+			cout	<<	"File: "
+						<<	filename.c_str()
+						<<	endl;
+			
+			geoMeshView->LoadTextureSubMesh(submesh,	filename.c_str());
+		}
+	}
 }
 
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp	(revision 1017)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp	(revision 1024)
@@ -215,4 +215,5 @@
 
 	// Material Name.
+	strcat(geoSubMesh->mMaterialName,"\n");
 	mSerializer->WriteData(geoSubMesh->mMaterialName);
 
Index: GTP/trunk/Lib/Geom/shared/GeoTool/GeoTool.vcproj
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/GeoTool.vcproj	(revision 1014)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/GeoTool.vcproj	(revision 1024)
@@ -138,4 +138,7 @@
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
 			<File
+				RelativePath=".\src\GeoMaterialLoader.cpp">
+			</File>
+			<File
 				RelativePath=".\src\GeoMeshLoader.cpp">
 			</File>
@@ -161,4 +164,7 @@
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
 			<File
+				RelativePath=".\include\GeoMaterialLoader.h">
+			</File>
+			<File
 				RelativePath=".\include\GeoMeshLoader.h">
 			</File>
