Changeset 895 for GTP/trunk/Lib/Geom/shared/GeoTool/src
- Timestamp:
- 05/04/06 13:18:08 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.