Changeset 895 for GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves
- Timestamp:
- 05/04/06 13:18:08 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Arbol.cpp
r834 r895 4 4 #include "Arbol.h" 5 5 6 6 7 //-------------------------------------------------------------------------------------------------------------------------------- 7 8 // Constructor with the name of a file cotaining the data 8 9 //-------------------------------------------------------------------------------------------------------------------------------- 9 Arbol::Arbol (const char * arbol, const char* hojas, const char* simplifi, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 10 /*Arbol::Arbol (const char * arbol, const char* hojas, const char* simplifi, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 11 create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 12 create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun), 13 vertexdata(NULL), Hojas(NULL), MinDet(NULL)*/ 14 Arbol::Arbol (const Geometry::SubMesh *leafsSubMesh, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 10 15 create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 11 16 create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun), … … 13 18 { 14 19 cx = cy= cz= 0; 15 ReadFromFile (arbol, hojas, simplifi); 20 21 //VERTICES 22 /* if ((TotVerts=LeeVertices(arbol))==0){ printf("File not found '%s'\n",arbol); exit(1); }//ThrowFileNotFoundError((const char*)arbol); 23 if ((nHojas = LeoHojas (hojas))==0) { printf("File not found '%s'\n",hojas); exit(1); }//ThrowFileNotFoundError((const char*)hojas); 24 // TotTronco = LeoTronco (tronco); 25 // CalculaNormalesVertice(); 26 if ((TotHojas = LeoHojasSimpl(simpli))==0){ printf("File not found '%s'\n",simpli); exit(1); }// ThrowFileNotFoundError((const char*)simpli); 27 RellenoRaiz(); 28 29 CalculaTexCoordsYNorms();*/ 30 31 32 ReadVertices(leafsSubMesh); 33 ReadLeafs(leafsSubMesh); 34 if (!ReadSimpSeq(simpSeq)) exit(1); 35 RellenoRaiz(); 36 CalculaTexCoordsYNorms(); 37 16 38 17 39 // esto no sé si devería haber akí … … 37 59 // leer informacion desde el fichero 38 60 //-------------------------------------------------------------------------------------------------------------------------------- 39 void Arbol::ReadFromFile ( const char * arbol, const char* hojas, const char* simpli/*, char* tronco*/) // Reads a obj-model from a file61 /*void Arbol::ReadFromFile ( const char * arbol, const char* hojas, const char* simpli) // Reads a obj-model from a file 40 62 { 41 63 … … 49 71 50 72 CalculaTexCoordsYNorms(); 51 } 52 53 54 #include "TMatrix.h" 55 73 }*/ 74 75 76 //#include "TMatrix.h" 77 78 79 void Arbol::ReadVertices(const Geometry::SubMesh *submesh) 80 { 81 int countv=submesh->mVertexBuffer->mVertexCount; 82 vertexdata = create_vertex_data_func(2*countv); 83 Hojas = new Hoja[countv*2]; 84 indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja 85 86 vertexdata->Begin(); 87 for (int i=0; i<countv; i++) 88 { 89 vertexdata->SetVertexCoord( i, submesh->mVertexBuffer->mPosition[i].x, 90 submesh->mVertexBuffer->mPosition[i].y, 91 submesh->mVertexBuffer->mPosition[i].z ); 92 } 93 vertexdata->End(); 94 95 TotVerts = countv; 96 } 97 98 /* 56 99 //-------------------------------------------------------------------------------------------------------------------------------- 57 100 // Procesar línea para extraer los VERTICES DE VERTICES.OBJ … … 66 109 bool fin_vertices = false; 67 110 68 /* TMatrix rot90mat;69 rot90mat.RotateX(-90);70 */71 111 //cuento todos los vertices, y relleno la estructura 72 112 if ((fp_origen = fopen (arbol, "r")) == NULL) … … 152 192 153 193 154 } 194 }*/ 155 195 156 196 //-------------------------------------------------------------------------------------------------------------------------------- … … 319 359 }*/ 320 360 361 void Arbol::ReadLeafs(const Geometry::SubMesh *submesh) 362 { 363 int numtris = submesh->mIndexCount / 3; 364 nHojas = numtris / 2; 365 for (int h=0; h<nHojas; h++) 366 { 367 Hojas[h].Vert_Hoja[0] = submesh->mIndex[h*6+0]; 368 Hojas[h].Vert_Hoja[1] = submesh->mIndex[h*6+1]; 369 Hojas[h].Vert_Hoja[2] = submesh->mIndex[h*6+2]; 370 Hojas[h].Vert_Hoja[3] = submesh->mIndex[h*6+5]; 371 Hojas[h].visible = 0; 372 373 GetNormalH ( Hojas[h]); 374 } 375 } 376 321 377 //-------------------------------------------------------------------------------------------------------------------------------- 322 378 // Procesar línea para extraer las HOJAS DE HOJAS.OBJ 323 379 //-------------------------------------------------------------------------------------------------------------------------------- 324 380 /* 325 381 int Arbol::LeoHojas (const char* hojas) 326 382 { … … 376 432 return (h); 377 433 } 378 434 */ 379 435 380 436 //-------------------------------------------------------------------------------------------------------------------------------- … … 415 471 } 416 472 */ 473 474 475 /// returns the number of total leafs 476 bool Arbol::ReadSimpSeq(const char *simpSeqFile) 477 { 478 FILE* fp_simpli; 479 char linea[256], str[10]; 480 int v0, v1, v2, v3, tn, tv1,tv2, e=0; 481 482 if ((fp_simpli = fopen (simpSeqFile, "r")) == NULL) 483 { 484 printf ("No he podido abrir el fichero %s\n", simpSeqFile); 485 return false; 486 } 487 else 488 { 489 tn = nHojas; 490 while (fgets (linea, 255, fp_simpli) != NULL) 491 { 492 if (linea[0]<'0' || linea[0]>'9') 493 continue; 494 495 //N 446 Ver 10176 10178 10169 10171 Tv 156 154 E 2 496 497 // sscanf(linea, "%s %lu %s %lu %lu %lu %lu %s %lu %lu %s %i", 498 // &str, &tn, &str, &v0, &v1, &v2, &v3, &str, &tv1, &tv2, &str, &e ); 499 long int triviej00=-1, triviej01=-1; 500 long int triviej10=-1, triviej11=-1; 501 sscanf(linea, "%lu %lu %lu %lu & %lu %lu %lu %lu", &triviej00,&triviej01,&triviej10,&triviej11, &v0,&v1,&v2,&v3); 502 503 Hojas[tn].Vert_Hoja[0] = v0; 504 Hojas[tn].Vert_Hoja[1] = v1; 505 Hojas[tn].Vert_Hoja[2] = v2; 506 Hojas[tn].Vert_Hoja[3] = v3; 507 508 Hojas[tn].visible = 0; 509 510 GetNormalH (Hojas[tn]); 511 512 tv1 = triviej00/2; 513 tv2 = triviej10/2; 514 515 Hojas[tn].hijoi= tv1; 516 Hojas[tn].hijod= tv2; 517 518 Hojas[tv1].padre = tn; 519 Hojas[tv2].padre = tn; 520 521 tn++; 522 } 523 524 } 525 526 fclose(fp_simpli); 527 528 TotHojas=tn; 529 530 return true; 531 } 532 533 534 417 535 //--------------------------------------------------------------------------------------------------------------------- 418 536 // Procesar línea para extraer las HOJAS DE SIMPLIFICA.OBJ 419 537 //--------------------------------------------------------------------------------------------------------------------- 420 538 /* 421 539 int Arbol::LeoHojasSimpl (const char* simplifica) 422 540 { … … 501 619 return (tn); 502 620 } 503 621 */ 504 622 505 623 //-------------------------------------------------------------------------------------------------------------------------------- -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp
r834 r895 14 14 Cuantas_hojas = 1; 15 15 dist = coplanar = criterio = hoja_cop = hoja_crit =-1; 16 existe = true;16 existe = false; 17 17 padre=-1; 18 18 hijoi = hijod = -1; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/arbol.h
r830 r895 7 7 #include "Point3D.h" 8 8 #include "Activas.h" 9 10 9 #include "GeoSubMesh.h" 11 10 12 11 class Arbol … … 37 36 38 37 public : 39 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 38 // 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 39 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 40 40 Arbol (Arbol *a); 41 41 virtual ~Arbol (void); // Destructor 42 42 43 43 // Montan la estructura 44 void ReadFromFile (const char *, const char*, const char*/*, char**/); // Reads a obj-model from a file45 int LeeVertices ( const char * );44 // void ReadFromFile (const char *, const char*, const char*/*, char**/); // Reads a obj-model from a file 45 /* int LeeVertices ( const char * ); 46 46 int LeoHojas( const char *); 47 47 // int LeoTronco( char *); 48 int LeoHojasSimpl( const char*); 48 int LeoHojasSimpl( const char*);*/ 49 void ReadLeafs(const Geometry::SubMesh *); 50 void ReadVertices(const Geometry::SubMesh *); 51 bool ReadSimpSeq(const char*); /// returns true when successful 49 52 void RellenoRaiz (void); 50 53 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp
r830 r895 992 992 993 993 } 994 995 /****************************************** IMPOSTORES **************************************************/996 997 //--------------------------------------------------------------------------------------------------------------------------------998 // Dibuja la caja envolvente. DibujaCaja la dibuja realmente, y la999 //--------------------------------------------------------------------------------------------------------------------------------1000 /*1001 void Foliage::DibujaCaja (float alfa, float d)1002 {1003 1004 glPushMatrix();1005 1006 glColor3f(1.0, 0.0, 0.0);1007 1008 // glLineWidth(2.0);1009 // glTranslated (0.0,cy, 0.0);1010 // glScalef (width,heigth,depth);1011 // glutWireCube ( 1.0);1012 glRotatef(-alfa,0,1,0);1013 1014 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);1015 glBegin (GL_POLYGON);1016 1017 glVertex3f (MiArbol->cx + MiArbol->rad, MiArbol->cy - MiArbol->rad, d);1018 glVertex3f (MiArbol->cx - MiArbol->rad, MiArbol->cy - MiArbol->rad, d);1019 glVertex3f (MiArbol->cx - MiArbol->rad, MiArbol->cy + MiArbol->rad, d);1020 glVertex3f (MiArbol->cx + MiArbol->rad, MiArbol->cy + MiArbol->rad, d);1021 1022 1023 glEnd();1024 1025 1026 glColor3f(1.0, 1.0, 1.0);1027 1028 glPopMatrix();1029 1030 1031 }1032 1033 */
Note: See TracChangeset
for help on using the changeset viewer.