Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Arbol.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Arbol.cpp	(revision 834)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Arbol.cpp	(revision 895)
@@ -4,8 +4,13 @@
 #include "Arbol.h"
 
+
 //--------------------------------------------------------------------------------------------------------------------------------
 // Constructor with the name of a file cotaining the data
 //--------------------------------------------------------------------------------------------------------------------------------
-Arbol::Arbol (const char * arbol, const char* hojas, const char* simplifi, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 
+/*Arbol::Arbol (const char * arbol, const char* hojas, const char* simplifi, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 
+create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun),
+create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun),
+vertexdata(NULL), Hojas(NULL), MinDet(NULL)*/
+Arbol::Arbol (const Geometry::SubMesh *leafsSubMesh, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):
 create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun),
 create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun),
@@ -13,5 +18,22 @@
 {	
 	cx = cy= cz= 0;
-	ReadFromFile (arbol, hojas, simplifi);
+
+	//VERTICES
+/*	if ((TotVerts=LeeVertices(arbol))==0){ printf("File not found '%s'\n",arbol); exit(1); }//ThrowFileNotFoundError((const char*)arbol);
+	if ((nHojas = LeoHojas (hojas))==0) { printf("File not found '%s'\n",hojas); exit(1); }//ThrowFileNotFoundError((const char*)hojas);
+//	TotTronco = LeoTronco (tronco);
+//	CalculaNormalesVertice();	
+	if ((TotHojas = LeoHojasSimpl(simpli))==0){ printf("File not found '%s'\n",simpli); exit(1); }// ThrowFileNotFoundError((const char*)simpli);	
+	RellenoRaiz();
+
+	CalculaTexCoordsYNorms();*/
+
+
+	ReadVertices(leafsSubMesh);
+	ReadLeafs(leafsSubMesh);
+	if (!ReadSimpSeq(simpSeq)) exit(1);
+	RellenoRaiz();
+	CalculaTexCoordsYNorms();
+
 
 	// esto no sé si devería haber akí
@@ -37,5 +59,5 @@
 // leer informacion desde el fichero
 //--------------------------------------------------------------------------------------------------------------------------------
-void Arbol::ReadFromFile ( const char * arbol, const char* hojas, const char* simpli/*, char* tronco*/) // Reads a obj-model from a file
+/*void Arbol::ReadFromFile ( const char * arbol, const char* hojas, const char* simpli) // Reads a obj-model from a file
 {
 	    
@@ -49,9 +71,30 @@
 
 	CalculaTexCoordsYNorms();
-}
-
-
-#include "TMatrix.h"
-
+}*/
+
+
+//#include "TMatrix.h"
+
+
+void Arbol::ReadVertices(const Geometry::SubMesh *submesh)
+{
+	int countv=submesh->mVertexBuffer->mVertexCount;
+	vertexdata = create_vertex_data_func(2*countv);
+	Hojas = new Hoja[countv*2];
+	indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja
+	
+	vertexdata->Begin();
+	for (int i=0; i<countv; i++)
+	{
+		vertexdata->SetVertexCoord( i,	submesh->mVertexBuffer->mPosition[i].x, 
+										submesh->mVertexBuffer->mPosition[i].y, 
+										submesh->mVertexBuffer->mPosition[i].z );
+	}
+	vertexdata->End();
+
+	TotVerts = countv;
+}
+
+/*
 //--------------------------------------------------------------------------------------------------------------------------------
 // Procesar línea para extraer los VERTICES DE VERTICES.OBJ
@@ -66,7 +109,4 @@
 		bool fin_vertices = false;
 
-/*		TMatrix rot90mat;
-		rot90mat.RotateX(-90);
-*/		
 		//cuento todos los vertices, y relleno la estructura
 		if ((fp_origen = fopen (arbol, "r")) == NULL)
@@ -152,5 +192,5 @@
 
 		
-}
+}*/
 
 //--------------------------------------------------------------------------------------------------------------------------------
@@ -319,8 +359,24 @@
 }*/
 
+void Arbol::ReadLeafs(const Geometry::SubMesh *submesh)
+{
+	int numtris = submesh->mIndexCount / 3;
+	nHojas =  numtris / 2;
+	for (int h=0; h<nHojas; h++)
+	{
+		Hojas[h].Vert_Hoja[0] = submesh->mIndex[h*6+0];
+		Hojas[h].Vert_Hoja[1] = submesh->mIndex[h*6+1];
+		Hojas[h].Vert_Hoja[2] = submesh->mIndex[h*6+2];
+		Hojas[h].Vert_Hoja[3] = submesh->mIndex[h*6+5];
+		Hojas[h].visible = 0;
+
+		GetNormalH ( Hojas[h]);
+	}
+}
+
 //--------------------------------------------------------------------------------------------------------------------------------
 // Procesar línea para extraer las HOJAS DE HOJAS.OBJ
 //--------------------------------------------------------------------------------------------------------------------------------
-
+/*
   int Arbol::LeoHojas (const char* hojas)
 {
@@ -376,5 +432,5 @@
 	return (h);	
 }
-
+*/
 
 //--------------------------------------------------------------------------------------------------------------------------------
@@ -415,8 +471,70 @@
 }
 */
+
+
+ /// returns the number of total leafs
+bool Arbol::ReadSimpSeq(const char *simpSeqFile)
+{
+	FILE* fp_simpli;
+	char linea[256], str[10];
+	int v0, v1, v2, v3, tn, tv1,tv2, e=0;
+
+	if ((fp_simpli = fopen (simpSeqFile, "r")) == NULL)
+	{
+		printf ("No he podido abrir el fichero %s\n", simpSeqFile);
+		return false;
+	}
+	else
+	{
+		tn = nHojas;
+		while (fgets (linea, 255, fp_simpli) != NULL)
+		{
+			if (linea[0]<'0' || linea[0]>'9')
+				continue;
+		
+			//N 446 Ver 10176 10178 10169 10171  Tv 156 154 E 2
+
+//			sscanf(linea, "%s %lu %s %lu %lu  %lu %lu %s %lu %lu %s %i", 
+//				&str, &tn, &str, &v0, &v1, &v2, &v3, &str, &tv1, &tv2, &str, &e );
+			long int triviej00=-1, triviej01=-1;
+			long int triviej10=-1, triviej11=-1;
+			sscanf(linea, "%lu %lu %lu %lu & %lu %lu %lu %lu", &triviej00,&triviej01,&triviej10,&triviej11, &v0,&v1,&v2,&v3);
+
+			Hojas[tn].Vert_Hoja[0] = v0;
+			Hojas[tn].Vert_Hoja[1] = v1;
+			Hojas[tn].Vert_Hoja[2] = v2;
+			Hojas[tn].Vert_Hoja[3] = v3;
+
+			Hojas[tn].visible = 0;
+
+			GetNormalH  (Hojas[tn]);
+
+			tv1 = triviej00/2;
+			tv2 = triviej10/2;
+
+			Hojas[tn].hijoi= tv1;
+			Hojas[tn].hijod= tv2;
+
+			Hojas[tv1].padre = tn;
+			Hojas[tv2].padre = tn;		
+
+			tn++;
+		}
+
+	}
+
+	fclose(fp_simpli);
+
+	TotHojas=tn;
+		
+	return true;
+}
+
+
+
 //---------------------------------------------------------------------------------------------------------------------
 // Procesar línea para extraer las HOJAS DE SIMPLIFICA.OBJ
 //---------------------------------------------------------------------------------------------------------------------
-
+/*
   int Arbol::LeoHojasSimpl (const char* simplifica)
 {
@@ -501,5 +619,5 @@
 	return (tn);
 }
-
+*/
  
 //--------------------------------------------------------------------------------------------------------------------------------
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp	(revision 834)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp	(revision 895)
@@ -14,5 +14,5 @@
 	Cuantas_hojas = 1;
 	dist = coplanar = criterio = hoja_cop = hoja_crit =-1;
-	existe = true;
+	existe = false;
 	padre=-1;
 	hijoi = hijod = -1;
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/arbol.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/arbol.h	(revision 830)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/arbol.h	(revision 895)
@@ -7,6 +7,5 @@
 #include "Point3D.h"
 #include "Activas.h"
-
-
+#include "GeoSubMesh.h"
 
 class Arbol
@@ -37,14 +36,18 @@
 
 	public :
-		Arbol (const char *, const char *, const char*, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); // Constructor with the name of a file cotaining the data
+//		Arbol (const char *, const char *, const char*, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); // Constructor with the name of a file cotaining the data
+		Arbol (const Geometry::SubMesh *, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); // Constructor with the name of a file cotaining the data
 		Arbol (Arbol *a);
 		virtual ~Arbol (void); // Destructor
 		
 		// Montan la estructura
-		void ReadFromFile (const char *, const char*, const char*/*, char**/); // Reads a obj-model from a file
-		int LeeVertices ( const char * );
+//		void ReadFromFile (const char *, const char*, const char*/*, char**/); // Reads a obj-model from a file
+/*		int LeeVertices ( const char * );
 		int LeoHojas( const char *);
 //		int LeoTronco( char *);
-		int LeoHojasSimpl( const char*);
+		int LeoHojasSimpl( const char*);*/
+		void ReadLeafs(const Geometry::SubMesh *);
+		void ReadVertices(const Geometry::SubMesh *);
+		bool ReadSimpSeq(const char*); /// returns true when successful
 		void RellenoRaiz (void);
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp	(revision 830)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp	(revision 895)
@@ -992,42 +992,2 @@
 
  }
-
-/******************************************   IMPOSTORES **************************************************/
-	
-//--------------------------------------------------------------------------------------------------------------------------------
-// Dibuja la caja envolvente. DibujaCaja la dibuja realmente, y la 
-//--------------------------------------------------------------------------------------------------------------------------------
-			/*	
-void Foliage::DibujaCaja (float alfa, float d)
-{
-
-	glPushMatrix();
-
-	glColor3f(1.0, 0.0, 0.0);
-
-//	glLineWidth(2.0);
-//	glTranslated (0.0,cy, 0.0);
-//	glScalef (width,heigth,depth);
-//	glutWireCube ( 1.0);
-	glRotatef(-alfa,0,1,0);
-
-	glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
-	glBegin (GL_POLYGON); 
-
-		glVertex3f (MiArbol->cx + MiArbol->rad, MiArbol->cy - MiArbol->rad, d); 
-		glVertex3f (MiArbol->cx - MiArbol->rad, MiArbol->cy - MiArbol->rad, d);
-		glVertex3f (MiArbol->cx - MiArbol->rad, MiArbol->cy + MiArbol->rad, d);
-		glVertex3f (MiArbol->cx + MiArbol->rad, MiArbol->cy + MiArbol->rad, d);
-
-
-	glEnd();
-
-
-	glColor3f(1.0, 1.0, 1.0);
-
-	glPopMatrix();
-	
-
-}
-
-*/
