Changeset 1078 for GTP/trunk/Lib/Geom/shared/GeoTool/src
- Timestamp:
- 07/05/06 17:15:14 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
r1071 r1078 642 642 // Read a mesh file. 643 643 //--------------------------------------------------------------------------- 644 645 #include "GeoLodStripsLibrary.h" 646 #include "GeoLodStripsConstructor.h" 647 644 648 void GeoMeshLoader::readMesh(FILE *f, Mesh *geoMesh, int option) 645 649 { … … 670 674 chunkID == M_MESH_BOUNDS || 671 675 chunkID == M_SUBMESH_NAME_TABLE || 672 chunkID == M_EDGE_LISTS)) 676 chunkID == M_EDGE_LISTS || 677 chunkID == 0xabcd || 678 chunkID == 0xdcba)) 673 679 { 674 680 switch(chunkID) 675 681 { 682 case 0xabcd: 683 cout << "LODSTRIPS_Chunk" << endl; 684 int aux,v,c; 685 LODRegisterType lod_register; 686 LODData dataaux; 687 int tam; 688 689 fread(&tam, sizeof(int), 1, f); 690 lodstripsdata.mFileVertices.clear(); 691 for (v=0; v<tam; v++) 692 { 693 fread(&aux, sizeof(int), 1, f); 694 lodstripsdata.mFileVertices.push_back(aux); 695 } 696 697 lodstripsdata.mFileChangesLOD.clear(); 698 fread(&tam, sizeof(int), 1, f); 699 for (c=0; c<tam; c++) 700 { 701 fread(&dataaux, sizeof(LODData), 1, f); 702 lod_register.strip= dataaux.strip; 703 lod_register.position= dataaux.nP; 704 lod_register.vertexRepetition= dataaux.nL1; 705 lod_register.edgeRepetition= dataaux.nL2; 706 //lod_register.obligatory=false; 707 //lod_register.obligatory= dataaux.obligatory; 708 709 lodstripsdata.mFileChangesLOD.push_back(lod_register); 710 } 711 712 lodstripsdata.mData.clear(); 713 fread(&tam, sizeof(int), 1, f); 714 for (int b=0; b<tam; b++) 715 { 716 fread(&aux, sizeof(int), 1, f); 717 lodstripsdata.mData.push_back(aux); 718 } 719 720 lodstripsdata.p_changes.clear(); 721 fread(&tam, sizeof(int), 1, f); 722 for (int p=0; p<tam; p++) 723 { 724 fread(&aux, sizeof(int), 1, f); 725 lodstripsdata.p_changes.push_back(aux); 726 } 727 728 break; 729 730 case 0xdcba: 731 cout << "LODTREES_Chunk" << endl; 732 int size; 733 fread(&size, sizeof(int), 1, f); 734 treesimpseq.mSteps.clear(); 735 for (int i=0; i<size; i++) 736 { 737 Geometry::TreeSimplificationSequence::Step auxstep; 738 fread(&auxstep.mV0,sizeof(int),1,f); 739 fread(&auxstep.mV1,sizeof(int),1,f); 740 fread(&auxstep.mT0,sizeof(int),1,f); 741 fread(&auxstep.mT1,sizeof(int),1,f); 742 fread(auxstep.mNewQuad,sizeof(int),4,f); 743 treesimpseq.mSteps.push_back(auxstep); 744 } 745 746 break; 747 748 676 749 case M_GEOMETRY: 677 750 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r1070 r1078 892 892 current_strip = 0; 893 893 894 int begin_index = 0; 895 894 896 // For each submesh. 895 897 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) … … 966 968 }*/ 967 969 970 int indices_to_render = lodStripsLib->indices_x_submesh[submesh]; 971 972 968 973 glBegin(GL_TRIANGLE_STRIP); 969 for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 974 //for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 975 for (int index = begin_index; index < indices_to_render+begin_index; index ++) 970 976 { 971 977 position = lodStripsLib->dataRetrievalInterface->GetIndex(index); … … 1001 1007 } 1002 1008 glEnd(); 1009 begin_index += indices_to_render; 1003 1010 1004 1011 } … … 1026 1033 // DRAW THE TRUNK AS A LODSTRIP OBJECT 1027 1034 1035 int begin_index = 0; 1036 1028 1037 // For each submesh. 1029 1038 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) … … 1102 1111 1103 1112 }*/ 1113 1114 int indices_to_render = lodTreeLib->trunk->indices_x_submesh[submesh]; 1115 1104 1116 glBegin(GL_TRIANGLE_STRIP); 1105 for (int index = 0; index < lodTreeLib->CurrentLOD_Trunk_Indices()->GetNumValidIndices(); index ++)1117 for (int index = begin_index; index < lodTreeLib->trunk->indices_x_submesh[submesh]; index ++) 1106 1118 { 1107 1119 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); … … 1137 1149 } 1138 1150 glEnd(); 1151 begin_index += indices_to_render; 1139 1152 1140 1153 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r1070 r1078 811 811 if (mGeoMesh != NULL) 812 812 { 813 fcho = new fltk::FileChooser("",813 /* fcho = new fltk::FileChooser("", 814 814 "*.lod", 815 815 fltk::FileChooser::CREATE, … … 820 820 // If a file was selected. 821 821 if (fcho->value()) 822 { 822 {*/ 823 823 // Build lod strips library. 824 setLodStripsLibrary( string(fcho->value()), mGeoMesh);824 setLodStripsLibrary(geoMeshLoader->lodstripsdata, mGeoMesh); 825 825 826 826 // Sets the aplication mode. 827 827 mApplicationState = VISUALIZE_LODSTRIPS; 828 }828 /* } 829 829 830 830 // Free memory. 831 delete fcho; 831 delete fcho;*/ 832 832 833 833 // Hide the right panel. … … 883 883 884 884 // If an object is loaded. 885 if (mGeoMesh != NULL)885 /* if (mGeoMesh != NULL) 886 886 { 887 887 fcho = new fltk::FileChooser("", 888 "*. lod",888 "*.mesh", 889 889 fltk::FileChooser::CREATE, 890 890 "Open Lod file"); … … 908 908 if (fcho->value()) 909 909 { 910 std::string leafseqFile(fcho->value()); 911 912 setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 910 std::string leafseqFile(fcho->value());*/ 911 912 //setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 913 setLodTreesLibrary(geoMeshLoader->lodstripsdata, geoMeshLoader->treesimpseq, mGeoMesh, leafsSubMeshID); 913 914 914 915 // Sets the aplication mode. 915 916 mApplicationState = VISUALIZE_LODTREES; 916 }917 /* } 917 918 } 918 919 919 920 // Free memory. 920 921 delete fcho; 921 922 */ 922 923 // Hide the right panel. 923 924 hideRightPanel(); … … 932 933 // Repaint the window. 933 934 mMainWindow->redraw(); 934 } 935 /* }*/ 935 936 } 936 937 } … … 1243 1244 { 1244 1245 // Choose between aplication state. 1245 switch(mApplicationState)1246 if (mApplicationState==LODSTRIPS_AUTO || mApplicationState==LODTREES_AUTO) 1246 1247 { 1247 // Build the LOD file. 1248 case LODTREES_AUTO: 1249 1250 // Open file chooser dialog. 1251 file_name = fltk::file_chooser("Build LOD","*",""); 1252 1253 if (!file_name) 1254 { 1255 break; 1256 } 1257 1258 std::cout << "Creando secuencia de simplificacion de hojas..."; 1259 1260 createLeavesSequence(file_name+std::string(".leafseq")); 1261 1262 std::cout << "OK!" << std::endl; 1263 1264 /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); 1265 auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); 1266 1267 if (auxTreeSimpSequence && mGeoMesh) 1268 { 1269 LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); 1270 delete auxLodTreeConstructor; 1271 } 1272 else 1273 { 1274 fltk::alert("There is no leaf simplification sequence."); 1275 break; 1276 } 1277 1278 1279 delete auxTreeSimpSequence;*/ 1280 1281 case LODSTRIPS_AUTO: 1282 1283 // Builder 1284 if (!file_name) 1285 { 1286 file_name = fltk::file_chooser("Build LOD","*",""); 1287 } 1288 1289 // If a file was selected. 1290 if (file_name) 1291 { 1292 // Undo the simplification changes. 1293 undo(); 1294 1295 // Stripify the mesh object. 1296 stripify(); 1297 1298 // Reset the build bar. 1299 mBuildBar->position(0); 1300 1301 // Simplification sequence. 1302 oMeshSimpSequence = new MeshSimplificationSequence(); 1303 1304 // Loads a simplification sequence file. 1305 oMeshSimpSequence->Load(Serializer( "SimplifSequence.txt", 1306 Serializer::READ)); 1307 1308 // If the simplification sequence and the mesh exist. 1309 if (oMeshSimpSequence && mGeoMesh) 1248 file_name = fltk::file_chooser("Build LOD","*.mesh",""); 1249 1250 // If a file was selected. 1251 if (file_name) 1252 { 1253 // Undo the simplification changes. 1254 undo(); 1255 1256 // Stripify the mesh object. 1257 stripify(); 1258 1259 // Reset the build bar. 1260 mBuildBar->position(0); 1261 1262 // Simplification sequence. 1263 oMeshSimpSequence = new MeshSimplificationSequence(); 1264 1265 // Loads a simplification sequence file. 1266 oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ)); 1267 1268 // If the simplification sequence and the mesh exist. 1269 if (oMeshSimpSequence && mGeoMesh) 1270 { 1271 oLodStrip = new LodStripsConstructor( mGeoMesh, 1272 oMeshSimpSequence, 1273 idMeshLeaves, 1274 progress_function); 1275 1276 // oSerializer = new Serializer(file_name,Serializer::Mode::WRITE); 1277 1278 oLodStrip->UpdateMesh(); 1279 1280 // Deletes the previous mesh. 1281 delete mUndoMesh; 1282 1283 mUndoMesh = new Mesh(); 1284 1285 // Sets the undo mesh. 1286 *mUndoMesh = *mGeoMesh; 1287 1288 delete mGeoMesh; 1289 1290 mGeoMesh = oLodStrip->GetMesh(); 1291 1292 geoMeshView->setMesh(mGeoMesh); 1293 1294 mesh_saver = new GeoMeshSaver(); 1295 // file_name[strlen(file_name) - 4] = '\0'; 1296 1297 mesh_saver->leavesSubMesh=idMeshLeaves; 1298 mesh_saver->leavesVB=origSubMeshVB; 1299 mesh_saver->numindices=orig_numindices; 1300 mesh_saver->indices=orig_indices; 1301 mesh_saver->save(mGeoMesh,file_name); 1302 delete mesh_saver; 1303 oLodStrip->Save(file_name); 1304 // Close file. 1305 // delete oSerializer; 1306 } 1307 else 1308 { 1309 // Error message. 1310 fltk::alert("There is no simplification sequence."); 1311 } 1312 1313 // Deletes the siplification sequence object. 1314 delete oMeshSimpSequence; 1315 1316 if (mApplicationState==LODTREES_AUTO) 1317 { 1318 // Open file chooser dialog. 1319 /* file_name = fltk::file_chooser("Build LOD","*",""); 1320 1321 if (!file_name) 1310 1322 { 1311 oLodStrip = new LodStripsConstructor( mGeoMesh, 1312 oMeshSimpSequence, 1313 idMeshLeaves, 1314 progress_function); 1315 1316 oSerializer = new Serializer( strcat(file_name,".lod"), 1317 Serializer::Mode::WRITE); 1318 1319 oLodStrip->Save(*oSerializer); 1320 1321 // Close file. 1322 delete oSerializer; 1323 1324 // Deletes the previous mesh. 1325 delete mUndoMesh; 1326 1327 mUndoMesh = new Mesh(); 1328 1329 // Sets the undo mesh. 1330 *mUndoMesh = *mGeoMesh; 1331 1332 delete mGeoMesh; 1333 1334 mGeoMesh = oLodStrip->GetMesh(); 1335 1336 geoMeshView->setMesh(mGeoMesh); 1337 1338 mesh_saver = new GeoMeshSaver(); 1339 file_name[strlen(file_name) - 4] = '\0'; 1340 1341 mesh_saver->leavesSubMesh=idMeshLeaves; 1342 mesh_saver->leavesVB=origSubMeshVB; 1343 mesh_saver->numindices=orig_numindices; 1344 mesh_saver->indices=orig_indices; 1345 mesh_saver->save(mGeoMesh,strcat(file_name,".mesh")); 1346 1347 delete mesh_saver; 1348 } 1349 else 1350 { 1351 // Error message. 1352 fltk::alert("There is no simplification sequence."); 1353 } 1354 1355 // Deletes the siplification sequence object. 1356 delete oMeshSimpSequence; 1357 } 1358 break; 1323 break; 1324 }*/ 1325 1326 std::cout << "Creando secuencia de simplificacion de hojas..."; 1327 1328 createLeavesSequence(file_name); 1329 1330 std::cout << "OK!" << std::endl; 1331 } 1332 } 1359 1333 } 1334 1360 1335 // Refresh data aplication. 1361 1336 refreshApplicationBar(); … … 2236 2211 tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); 2237 2212 2238 tree_sequencer->putMeshName(nombremesh); 2239 tree_sequencer->Save(Serializer(filename,Serializer:: WRITE));2213 tree_sequencer->putMeshName(nombremesh); 2214 tree_sequencer->Save(Serializer(filename,Serializer::APPEND)); 2240 2215 2241 2216 delete tree_sequencer; … … 2392 2367 // Initialize the lodstripslibrary for visualization. 2393 2368 //--------------------------------------------------------------------------- 2394 void GeoMeshViewUI::setLodStripsLibrary( std::string lodfile, Mesh *geomesh)2369 void GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData &loddata, Mesh *geomesh) 2395 2370 { 2396 2371 // If there is no lod strips object. … … 2401 2376 2402 2377 // New lod strips object. 2403 lodStripsLib = new LodStripsLibrary(lod file, geomesh);2378 lodStripsLib = new LodStripsLibrary(loddata, geomesh); 2404 2379 2405 2380 // Sets the slider range. … … 2417 2392 // Initialize the lodTreelibrary for visualization. 2418 2393 //--------------------------------------------------------------------------- 2419 //void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) 2420 void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) 2421 2394 void GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData &lodstripsdata, const TreeSimplificationSequence &treesimpseq, Mesh *geomesh, uint32 ileafSubMesh) 2422 2395 { 2423 2396 // If there is no lod strips object. … … 2428 2401 2429 2402 // New lod strips object. 2430 /* lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj", 2431 "\\\\quake\\home\\\Modelos\\betula_populifolia\\hojas.obj", 2432 "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj");*/ 2433 2434 lodTreeLib = new Geometry::LodTreeLibrary(lodfile,leafseqfile,geomesh,ileafSubMesh); 2403 2404 lodTreeLib = new Geometry::LodTreeLibrary(lodstripsdata,treesimpseq,geomesh,ileafSubMesh); 2435 2405 2436 2406 // Sets the slider range. 2437 // mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod());2438 // mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod());2439 2407 mLodStripSlider->range(0.0f,1.0f); 2440 2408 mLodTreeSlider->range(0.0f,1.0f);
Note: See TracChangeset
for help on using the changeset viewer.