Changeset 895 for GTP/trunk/Lib/Geom
- Timestamp:
- 05/04/06 13:18:08 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h
r831 r895 16 16 { 17 17 class IndexData; 18 class VertexData; 18 19 class LodTreeLibrary 19 20 { … … 22 23 LodTreeLibrary(LodTreeLibrary*);*/ 23 24 LodTreeLibrary( std::string trunkSimpSeqFile, 25 std::string leafSimpSeqFile, 24 26 Geometry::Mesh *treeGeoMesh, 25 std::string foliage_verts, 27 uint32 leafSubMeshID 28 /*std::string foliage_verts, 26 29 std::string foliage_leafs, 27 30 std::string foliage_simpl/*, … … 54 57 uint32 CurrentLOD_Foliage_IndexCount(void) const; 55 58 const IndexData* CurrentLOD_Foliage_Indices(void) const; 56 /*const VertexData* Get_Foliage_VertexData(void) const;57 */ 59 const VertexData* Get_Foliage_VertexData(void) const; 60 58 61 // Geometry::IndexData *trunk_all_indices; 59 62 // unsigned int *indices_offsets; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp
r831 r895 10 10 11 11 Geometry::LodTreeLibrary::LodTreeLibrary(std::string trunkSimpSeqFile, 12 Geometry::Mesh *treeGeoMesh, 13 std::string foliage_verts, 14 std::string foliage_leafs, 15 std::string foliage_simpl/*, 12 std::string leafSimpSeqFile, 13 Geometry::Mesh *treeGeoMesh, 14 uint32 leafSubMeshID/* 15 std::string foliage_verts, 16 std::string foliage_leafs, 17 std::string foliage_simpl, 16 18 uint32 leafSubMeshID, 17 19 CREATEVERTEXDATAFUNC vdfun, … … 25 27 26 28 // Cargar la copa del árbol 27 arbol = new Arbol(foliage_verts.c_str(),foliage_leafs.c_str(),foliage_simpl.c_str(),NULL/*vdfun*/,NULL/*idfun*/); 29 // arbol = new Arbol(foliage_verts.c_str(),foliage_leafs.c_str(),foliage_simpl.c_str(),NULL/*vdfun*/,NULL/*idfun*/); 30 Geometry::SubMesh * leafsSubMesh = &(treeGeoMesh->mSubMesh[leafSubMeshID]); 31 arbol = new Arbol(leafsSubMesh,leafSimpSeqFile.c_str()); 28 32 foliage = new Foliage(arbol); 29 33 } … … 151 155 uint32 LodTreeLibrary::MinFoliageLod(void) const 152 156 { 153 return arbol->minHojas; // una hoja: preguntar a francisco 157 // return arbol->minHojas; 158 return arbol->nHojas; 154 159 } 155 160 uint32 LodTreeLibrary::MaxFoliageLod(void) const 156 161 { 157 // return arbol->TotHojas; 158 return arbol->nHojas; 162 // return arbol->TotHojas; 163 //return arbol->nHojas; 164 return arbol->minHojas; 159 165 } 160 166 … … 170 176 }*/ 171 177 172 /* 178 173 179 const VertexData* LodTreeLibrary::Get_Foliage_VertexData(void) const 174 180 { 175 181 return arbol->vertexdata; 176 182 } 177 */ 183 178 184 const IndexData* LodTreeLibrary::CurrentLOD_Foliage_Indices(void) const 179 185 { -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimplifier.cpp
r834 r895 179 179 Hojasa[pos].Vert_Hoja[1]=v2; 180 180 Hojasa[pos].Vert_Hoja[2]=v3; 181 Hojasa[pos].id_triangulo[0]=num_triangulo; 182 Hojasa[pos].existe=true; 181 183 num_triangulo++; 182 Hojasa[pos].id_triangulo[0]=num_triangulo;183 184 184 185 // Segundo triángulo 185 186 v3=mesh->mSubMesh[meshLeaves].mIndex[j+5]; 186 187 Hojasa[pos].Vert_Hoja[3]=v3; 188 Hojasa[pos].id_triangulo[1]=num_triangulo; 187 189 num_triangulo++; 188 Hojasa[pos].id_triangulo[1]=num_triangulo;189 190 190 191 Centroh(Hojasa[pos]); … … 1025 1026 Hojasa[counth].existe = true; 1026 1027 Hojasa[counth].criterio = 1000; 1028 Hojasa[counth].id_triangulo[0] = counth*2; 1029 Hojasa[counth].id_triangulo[1] = counth*2+1; 1027 1030 1028 1031 //coplanaridad -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/SimplificationMethod.cpp
r891 r895 663 663 //Unify the model to work with it 664 664 //The vertices that have the same space coordinates are stored as an unique vertex 665 //in order to not produceholes in the simplification665 //in order to avoid holes in the simplification 666 666 //The necessary information to store correctly the decimation data is stored 667 667 void SimplificationMethod::geomesh2simplifModel(void) … … 679 679 { 680 680 //If the model has texture information 681 if (objmesh->mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_TEXCOORDS)681 /* if (objmesh->mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_TEXCOORDS) 682 682 { 683 683 //For all the vertices of each submesh … … 727 727 } 728 728 else //the model has not texture information 729 { 729 { */ 730 730 //For all the vertices of each submesh 731 731 for (size_t j=0; j<objmesh->mSubMesh[i].mVertexBuffer->mVertexCount; j++) … … 764 764 } 765 765 } 766 }767 }768 if (objmesh->mSubMesh[i].mSharedVertexBuffer)769 {770 printf("Shared break\n");771 break;766 /* }*/ 767 if (objmesh->mSubMesh[i].mSharedVertexBuffer) 768 { 769 printf("Shared break"); 770 break; 771 } 772 772 } 773 773 } -
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 */ -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h
r829 r895 169 169 170 170 // Change de Level of detail of the object. 171 void GoToLod(unsigned int lod); 171 void GoToLod_LodStrip(unsigned int lod); 172 void GoToLod_LodTree(unsigned int lod); 172 173 173 174 private: -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r841 r895 42 42 #include "GeoTreeSimpSequence.h" 43 43 #include "GeoLodStripsConstructor.h" 44 #include "GeoLodTreeConstructor.h" 44 45 #include "GeoLodTreeLibrary.h" 45 46 … … 58 59 LODSTRIPS_AUTO, 59 60 LODTREES, 61 LODTREES_AUTO, 60 62 SELECT_LEAVES, 61 63 VISUALIZE_LODSTRIPS, … … 174 176 inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); 175 177 static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); 178 inline void cb_menuLodTreesGenerate_i(fltk::Item*, void*); 179 static void cb_menuLodTreesGenerate(fltk::Item*, void*); 176 180 inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); 177 181 static void cb_menuLodTreesVisualize(fltk::Item*, void*); … … 187 191 inline void cb_mMeshInfo_i(fltk::Browser*, void*); 188 192 static void cb_mMeshInfo(fltk::Browser*, void*); 189 inline void cb_mLodSlider_i(fltk::Slider*, void*); 190 static void cb_mLodSlider(fltk::Slider*, void*); 193 inline void cb_mLodStripSlider_i(fltk::Slider*, void*); 194 static void cb_mLodStripSlider(fltk::Slider*, void*); 195 inline void cb_mLodTreeSlider_i(fltk::Slider*, void*); 196 static void cb_mLodTreeSlider(fltk::Slider*, void*); 191 197 192 198 // Logo's callback. … … 204 210 void showOpenMeshSimplification(); 205 211 void showAutoGenerateLodStrips(); 212 void showAutoGenerateLodTrees(); 206 213 207 214 // Shows the LodTrees panel. … … 212 219 213 220 // Show the LodStrips visulization panel. 214 void showSlider(); 221 void showLodStripSlider(); 222 void showLodTreeSlider(); 215 223 216 224 void hideStripify(); … … 224 232 225 233 // Hide the LodStrips visualization panel. 226 void hideSlider(); 234 void hideLodStripSlider(); 235 void hideLodTreeSlider(); 227 236 228 237 // Get the number of vertices. … … 247 256 248 257 // Create a siplification sequence of the leaves. 249 void createLeavesSequence( );258 void createLeavesSequence(const std::string &); 250 259 251 260 // Stripify the mesh object. … … 301 310 fltk::Item *menuLodStripsVisualize; 302 311 fltk::ItemGroup *menuLodTrees; 312 fltk::Item *menuLodTreesGenerate; 303 313 fltk::Item *menuLodTreesVisualize; 304 314 … … 321 331 fltk::Button *mButtonBuild; 322 332 fltk::ProgressBar *mBuildBar; 323 fltk::Slider *mLodSlider; 333 fltk::Slider *mLodStripSlider; 334 fltk::Slider *mLodTreeSlider; 324 335 fltk::CheckButton *mGeometryBased; 325 336 fltk::CheckButton *mImageBased; … … 344 355 void setLodStripsLibrary(std::string lodfile, Mesh *geomesh); 345 356 // Initialize the lodtreelibrary for visualization. 346 void setLodTreesLibrary(std::string lodfile, Mesh *geomesh);357 void setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh); 347 358 348 359 // 26-12-2005 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r842 r895 1 1 #include "GeoMeshView.h" 2 #include <VertexData.h> 2 3 3 4 using namespace Geometry; … … 413 414 mPan = false; 414 415 mLodStrip = false; 416 mLodTree = false; 415 417 mIdVisualList = 0; 416 418 mSubMeshCount = 0; … … 913 915 current_strip = 0; 914 916 917 918 // DRAW THE TRUNK AS A LODSTRIP OBJECT 919 915 920 // For each submesh. 916 921 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) … … 976 981 } 977 982 } 983 984 // DRAW THE LEAVES AS A TRIANGLE SOUP 985 glColor3f(0,1,1); 986 glDisable(GL_LIGHTING); 987 glBegin(GL_TRIANGLES); 988 const Geometry::VertexData *foliage_verts = lodTreeLib->Get_Foliage_VertexData(); 989 const Geometry::IndexData *foliage_inds = lodTreeLib->CurrentLOD_Foliage_Indices(); 990 for (int j=0; j<lodTreeLib->CurrentLOD_Foliage_IndexCount(); j++) 991 { 992 float vx,vy,vz; 993 foliage_verts->GetVertexCoord(foliage_inds->GetIndex(j),vx,vy,vz); 994 glVertex3f(vx,vy,vz); 995 } 996 glEnd(); 997 998 glEnable(GL_LIGHTING); 999 glColor3f(1,1,1); 978 1000 979 1001 }//End drawTriangleStrip. … … 1002 1024 // Change de Level of detail of the object. 1003 1025 //--------------------------------------------------------------------------- 1004 void GeoMeshView::GoToLod (unsigned int lod)1026 void GeoMeshView::GoToLod_LodStrip(unsigned int lod) 1005 1027 { 1006 1028 if (mLodStrip) … … 1010 1032 draw(); 1011 1033 } 1034 1035 //--------------------------------------------------------------------------- 1036 // Change de Level of detail of the object. 1037 //--------------------------------------------------------------------------- 1038 void GeoMeshView::GoToLod_LodTree(unsigned int lod) 1039 { 1040 if (mLodTree) 1041 lodTreeLib->GoToFoliageLod(lod); 1042 draw(); 1043 } 1044 1012 1045 1013 1046 //--------------------------------------------------------------------------- -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r891 r895 3 3 #include "GeoMeshViewUI.h" 4 4 #include "resource.h" 5 #include "GeoLodTreeConstructor.h" 5 6 6 7 using namespace Geometry; … … 65 66 66 67 // Save the file mesh. 67 mesh_saver->save( mGeoMesh, 68 mFileName); 68 mesh_saver->save(mGeoMesh, mFileName); 69 69 70 70 // Free memory. … … 100 100 { 101 101 mesh_saver = new GeoMeshSaver(mMeshBounds); 102 103 mesh_saver->save( mGeoMesh, 104 filename_name(fcho->value())); 105 102 mesh_saver->save(mGeoMesh,filename_name(fcho->value())); 106 103 delete mesh_saver; 107 104 } … … 151 148 152 149 // Open file chooser dialog. 153 p = fltk::file_chooser( "Export to OBJ", 154 "*.obj", 155 ""); 150 p = fltk::file_chooser("Export to OBJ","*.obj",""); 156 151 if (p && mGeoMesh) 157 152 { … … 667 662 668 663 //--------------------------------------------------------------------------- 664 // Auto Generate LodStrips Callback 665 //--------------------------------------------------------------------------- 666 inline void GeoMeshViewUI::cb_menuLodTreesGenerate_i(fltk::Item*, void*) 667 { 668 // Show title. 669 mProcessTitle->label("Generate LodTree"); 670 mProcessBar->position(0); 671 mBuildBar->position(0); 672 673 // Hide the right panel. 674 hideRightPanel(); 675 676 // Show the LodStrips panel. 677 showAutoGenerateLodTrees(); 678 679 // Sets menus application state to LODSTRIPS_AUTO. 680 mApplicationState = LODTREES_AUTO; 681 682 // Repaint the window. 683 mMainWindow->redraw(); 684 } 685 686 void GeoMeshViewUI::cb_menuLodTreesGenerate(fltk::Item* o, void* v) 687 { 688 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 689 -> 690 cb_menuLodTreesGenerate_i(o,v); 691 } 692 693 694 //--------------------------------------------------------------------------- 669 695 // Visualize LodStrips Callback 670 696 //--------------------------------------------------------------------------- … … 715 741 716 742 // Show the Visulize LodStrips panel. 717 show Slider();743 showLodStripSlider(); 718 744 719 745 // Repaint the window. … … 739 765 // Show title. 740 766 mProcessTitle->label("Visualize LodTrees"); 767 768 /*if (geoMeshView->getLeavesSubmesh()==-1) 769 { 770 fltk::alert("No se ha seleccionado el submesh de hojas!"); 771 return; 772 }*/ 773 774 // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS 775 int leafsSubMeshID = -1; 776 for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 777 if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 778 { 779 leafsSubMeshID=i; 780 break; 781 } 782 783 741 784 742 785 // If an object is loaded. … … 754 797 { 755 798 // Build lod strips library. 756 setLodTreesLibrary(string(fcho->value()), mGeoMesh); 757 758 // Sets the aplication mode. 759 mApplicationState = VISUALIZE_LODTREES; 799 800 std::string lodstripFile(fcho->value()); 801 delete fcho; 802 fcho = new fltk::FileChooser("", 803 "*.leafseq", 804 fltk::FileChooser::CREATE, 805 "Open LeafSeq file"); 806 807 fcho->exec(); 808 809 if (fcho->value()) 810 { 811 std::string leafseqFile(fcho->value()); 812 813 setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 814 815 // Sets the aplication mode. 816 mApplicationState = VISUALIZE_LODTREES; 817 } 760 818 } 761 819 … … 768 826 769 827 // Show the Visulize LodTree panel. 770 showSlider(); 828 showLodStripSlider(); 829 showLodTreeSlider(); 771 830 772 831 // Repaint the window. … … 904 963 905 964 // Create the leaves simplification sequence. 906 createLeavesSequence( );965 createLeavesSequence("leavesSimplification.txt"); 907 966 908 967 break; 909 968 910 969 // Simplify and generate simplification sequence. 970 case LODTREES_AUTO: 971 if (idMeshLeaves==(unsigned short)-1) 972 { 973 fltk::alert("Leaves submesh not selected!"); 974 } 975 else 976 { 977 std::cout << "Simplificando hojas..."; 978 simplifyLeavesCollapse(); 979 std::cout << "OK!" << std::endl; 980 981 // std::cout << "Creando secuencia de simplificacion de hojas..."; 982 // createLeavesSequence("leavesSimplification.txt"); 983 // std::cout << "OK!" << std::endl; 984 985 undo(); 986 987 988 std::cout << "Simplificando tronco..."; 989 std::cout << "OK!" << std::endl; 990 991 // Transform NoSV Mesh to a SV Mesh. 992 mesh_aux = mGeoMesh->toSharedVertex(); 993 994 // Deletes the mesh No Shared Vertex. 995 delete mGeoMesh; 996 997 // Gets the mesh Shared Vertex. 998 mGeoMesh = mesh_aux; 999 1000 geoMeshView->setMesh(mGeoMesh); 1001 1002 // Simplify the mesh object. 1003 simplifyEdgeCollapse(); 1004 1005 // Create the qslim simplification sequence. 1006 createQslimSequence(); 1007 1008 } 1009 1010 break; 1011 911 1012 case LODSTRIPS_AUTO: 912 1013 … … 994 1095 inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) 995 1096 { 996 char *file_name;1097 char *file_name=NULL; 997 1098 GeoMeshSaver *mesh_saver; 998 1099 Serializer *oSerializer; … … 1011 1112 { 1012 1113 // Build the LOD file. 1114 case LODTREES_AUTO: 1115 1116 // Open file chooser dialog. 1117 file_name = fltk::file_chooser("Build LOD","*",""); 1118 if (!file_name) 1119 break; 1120 1121 std::cout << "Creando secuencia de simplificacion de hojas..."; 1122 createLeavesSequence(file_name+std::string(".leafseq")); 1123 std::cout << "OK!" << std::endl; 1124 1125 /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); 1126 auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); 1127 1128 if (auxTreeSimpSequence && mGeoMesh) 1129 { 1130 LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); 1131 delete auxLodTreeConstructor; 1132 } 1133 else 1134 { 1135 fltk::alert("There is no leaf simplification sequence."); 1136 break; 1137 } 1138 1139 1140 delete auxTreeSimpSequence;*/ 1141 1142 1013 1143 case LODSTRIPS_AUTO: 1014 1144 1015 // Builder 1016 // Open file chooser dialog. 1017 file_name = fltk::file_chooser( "Build LOD", 1018 "*", 1019 ""); 1020 1145 // Builder 1146 if (!file_name) 1147 file_name = fltk::file_chooser("Build LOD","*",""); 1021 1148 // If a file was selected. 1022 1149 if (file_name) … … 1035 1162 1036 1163 // Loads a simplification sequence file. 1037 oMeshSimpSequence->Load(Serializer( "mqslimSequence.txt", 1038 Serializer::READ)); 1164 oMeshSimpSequence->Load(Serializer("mqslimSequence.txt",Serializer::READ)); 1039 1165 1040 1166 // If the simplification sequence and the mesh exist. … … 1046 1172 progress_function); 1047 1173 1048 oSerializer = new Serializer( strcat(file_name,".lod"), 1049 Serializer::Mode::WRITE); 1174 oSerializer = new Serializer(strcat(file_name,".lod"),Serializer::Mode::WRITE); 1050 1175 1051 1176 oLodStrip->Save(*oSerializer); … … 1070 1195 mesh_saver = new GeoMeshSaver(mMeshBounds); 1071 1196 file_name[strlen(file_name) - 4] = '\0'; 1072 mesh_saver->save( mGeoMesh, 1073 strcat(file_name,".mesh")); 1197 mesh_saver->save(mGeoMesh, strcat(file_name,".mesh")); 1074 1198 delete mesh_saver; 1075 1199 … … 1101 1225 // Lod Slider Callback 1102 1226 //--------------------------------------------------------------------------- 1103 inline void GeoMeshViewUI::cb_mLodS lider_i(fltk::Slider *o, void *)1227 inline void GeoMeshViewUI::cb_mLodStripSlider_i(fltk::Slider *o, void *) 1104 1228 { 1105 1229 // Change the lod. 1106 geoMeshView->GoToLod ((unsigned int)o->value());1230 geoMeshView->GoToLod_LodStrip((unsigned int)o->value()); 1107 1231 1108 1232 // Refresh data aplication. … … 1112 1236 } 1113 1237 1114 void GeoMeshViewUI::cb_mLodSlider(fltk::Slider *o, void *v) 1115 { 1116 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 1117 -> 1118 cb_mLodSlider_i(o,v); 1119 } 1238 void GeoMeshViewUI::cb_mLodStripSlider(fltk::Slider *o, void *v) 1239 { 1240 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 1241 -> 1242 cb_mLodStripSlider_i(o,v); 1243 } 1244 1245 1246 //--------------------------------------------------------------------------- 1247 // Lod Slider Callback for the foliage 1248 //--------------------------------------------------------------------------- 1249 inline void GeoMeshViewUI::cb_mLodTreeSlider_i(fltk::Slider *o, void *) 1250 { 1251 // Change the lod. 1252 geoMeshView->GoToLod_LodTree((unsigned int)o->value()); 1253 1254 // Refresh data aplication. 1255 refreshApplicationBar(); 1256 1257 mMainWindow->flush(); 1258 } 1259 1260 void GeoMeshViewUI::cb_mLodTreeSlider(fltk::Slider *o, void *v) 1261 { 1262 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 1263 -> 1264 cb_mLodTreeSlider_i(o,v); 1265 } 1266 1267 1120 1268 1121 1269 //--------------------------------------------------------------------------- … … 1418 1566 mBuildBar->activate(); 1419 1567 } 1568 //--------------------------------------------------------------------------- 1569 // Shows the auto generate LodStrips panel 1570 //--------------------------------------------------------------------------- 1571 void GeoMeshViewUI::showAutoGenerateLodTrees() 1572 { 1573 // Shows the simplify panel. 1574 showEdgeCollapse(); 1575 1576 mButtonBuild->set_visible(); 1577 mButtonBuild->activate(); 1578 1579 mBuildBar->set_visible(); 1580 mBuildBar->activate(); 1581 } 1420 1582 1421 1583 //--------------------------------------------------------------------------- 1422 1584 // Show the LodStrips visulization panel 1423 1585 //--------------------------------------------------------------------------- 1424 void GeoMeshViewUI::show Slider()1425 { 1426 mLodS lider->set_visible();1427 mLodS lider->activate();1586 void GeoMeshViewUI::showLodStripSlider() 1587 { 1588 mLodStripSlider->set_visible(); 1589 mLodStripSlider->activate(); 1428 1590 } 1429 1591 … … 1431 1593 // Hide the LodStrips visualization panel 1432 1594 //--------------------------------------------------------------------------- 1433 void GeoMeshViewUI::hideSlider() 1434 { 1435 mLodSlider->hide(); 1436 mLodSlider->deactivate(); 1595 void GeoMeshViewUI::hideLodStripSlider() 1596 { 1597 mLodStripSlider->hide(); 1598 mLodStripSlider->deactivate(); 1599 } 1600 1601 //--------------------------------------------------------------------------- 1602 // Show the LodTree visulization panel 1603 //--------------------------------------------------------------------------- 1604 void GeoMeshViewUI::showLodTreeSlider() 1605 { 1606 mLodTreeSlider->set_visible(); 1607 mLodTreeSlider->activate(); 1608 } 1609 1610 //--------------------------------------------------------------------------- 1611 // Hide the LodTree visualization panel 1612 //--------------------------------------------------------------------------- 1613 void GeoMeshViewUI::hideLodTreeSlider() 1614 { 1615 mLodTreeSlider->hide(); 1616 mLodTreeSlider->deactivate(); 1437 1617 } 1438 1618 … … 1580 1760 hideOpenMeshSimplification(); 1581 1761 hideOpenLeavesSimplification(); 1582 hideSlider(); 1762 hideLodStripSlider(); 1763 hideLodTreeSlider(); 1583 1764 hideMeshInfo(); 1584 1765 } … … 1858 2039 // Create a simplification sequence of the leaves. 1859 2040 //--------------------------------------------------------------------------- 1860 void GeoMeshViewUI::createLeavesSequence( )2041 void GeoMeshViewUI::createLeavesSequence(const std::string &filename) 1861 2042 { 1862 2043 TreeSimplificationSequence *tree_sequencer; … … 1865 2046 1866 2047 tree_sequencer->putMeshName(nombremesh); 1867 tree_sequencer->Save(Serializer( "leavesSequence.txt",Serializer::WRITE));2048 tree_sequencer->Save(Serializer(filename,Serializer::WRITE)); 1868 2049 1869 2050 delete tree_sequencer; … … 2032 2213 2033 2214 // Sets the slider range. 2034 mLodS lider->range(lodStripsLib->MaxLod(),2215 mLodStripSlider->range(lodStripsLib->MaxLod(), 2035 2216 lodStripsLib->MinLod()); 2036 2217 … … 2039 2220 2040 2221 // Puts the slider in the max position. 2041 mLodS lider->value(lodStripsLib->MinLod());2222 mLodStripSlider->value(lodStripsLib->MinLod()); 2042 2223 } 2043 2224 … … 2045 2226 // Initialize the lodTreelibrary for visualization. 2046 2227 //--------------------------------------------------------------------------- 2047 void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) 2228 //void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) 2229 void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) 2230 2048 2231 { 2049 2232 // If there is no lod strips object. … … 2054 2237 2055 2238 // New lod strips object. 2056 lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj",2239 /* lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj", 2057 2240 "\\\\quake\\home\\\Modelos\\betula_populifolia\\hojas.obj", 2058 "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj"); 2241 "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj");*/ 2242 2243 lodTreeLib = new Geometry::LodTreeLibrary(lodfile,leafseqfile,geomesh,ileafSubMesh); 2059 2244 2060 2245 // Sets the slider range. 2061 mLodSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); 2246 mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); 2247 mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod()); 2062 2248 2063 2249 // Pass to geomeshview the lod strips object. … … 2065 2251 2066 2252 // Puts the slider in the max position. 2067 mLodSlider->value(lodTreeLib->MinTrunkLod()); 2253 mLodStripSlider->value(lodTreeLib->MinTrunkLod()); 2254 mLodTreeSlider->value(lodTreeLib->MinFoliageLod()); 2068 2255 } 2069 2256 … … 2289 2476 { 2290 2477 fltk::Slider* o; 2291 o = mLodS lider = new fltk::Slider(16, 50, 30, 450);2478 o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); 2292 2479 o->type(fltk::Slider::TICK_BELOW); 2293 2480 o->set_vertical(); 2294 o->callback((fltk::Callback*)cb_mLodSlider); 2481 o->callback((fltk::Callback*)cb_mLodStripSlider); 2482 o->hide(); 2483 o->deactivate(); 2484 } 2485 { 2486 fltk::Slider* o; 2487 o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); 2488 o->type(fltk::Slider::TICK_BELOW); 2489 o->set_vertical(); 2490 o->callback((fltk::Callback*)cb_mLodTreeSlider); 2295 2491 o->hide(); 2296 2492 o->deactivate(); … … 2609 2805 { 2610 2806 fltk::Item* o; 2611 o = menuLodTreesVisualize = new fltk::Item("Visualize Trunk"); 2807 o = menuLodTreesGenerate = new fltk::Item("Generate"); 2808 o->callback((fltk::Callback*)cb_menuLodTreesGenerate); 2809 } 2810 { 2811 fltk::Item* o; 2812 o = menuLodTreesVisualize = new fltk::Item("Visualize"); 2612 2813 o->callback((fltk::Callback*)cb_menuLodTreesVisualize); 2613 2814 }
Note: See TracChangeset
for help on using the changeset viewer.