Changeset 829 for GTP/trunk/Lib/Geom/shared/GeoTool
- Timestamp:
- 04/26/06 16:00:29 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h
r826 r829 14 14 #include <GeoMeshSaver.h> 15 15 #include <GeoMeshViewUI.h> 16 //#include <GeoLodStripsLibrary.h> 16 17 17 //#endif 18 namespace Geometry{ class LodTreeLibrary; } 18 19 19 20 class GeoMeshView : public fltk::GlWindow … … 33 34 bool mRotate; 34 35 bool mLodStrip; 36 bool mLodTree; 35 37 36 38 GeoMeshView(int x, … … 94 96 95 97 // Counter Clockwise mode. 96 void activeCCW(){mCCW = true;} ;97 void deactiveCCW(){mCCW = false;} ;98 void activeCCW(){mCCW = true;} 99 void deactiveCCW(){mCCW = false;} 98 100 99 101 // Pan mode. 100 void activePan(){mPan = true;} ;101 void deactivePan(){mPan = false;} ;102 void activePan(){mPan = true;} 103 void deactivePan(){mPan = false;} 102 104 103 105 // Rotate mode. 104 void activeRotate(){mRotate = true;} ;105 void deactiveRotate(){mRotate = false;} ;106 void activeRotate(){mRotate = true;} 107 void deactiveRotate(){mRotate = false;} 106 108 107 109 // LodStrip mode. 108 void activeLodStrip(){mLodStrip = true;}; 109 void deactiveLodStrip(){mLodStrip = false;}; 110 void activeLodStrip(){mLodStrip = true;} 111 void deactiveLodStrip(){mLodStrip = false;} 112 113 // LodTree mode. 114 void activeLodTree(){mLodTree = true;} 115 void deactiveLodTree(){mLodTree = false;} 116 110 117 111 118 // Ilumination modes. … … 158 165 // Sets the lodstripslibrary object. 159 166 void setLodStripsLibrary(Geometry::LodStripsLibrary *lodstrips); 167 // Sets the lodtreeslibrary object. 168 void setLodTreesLibrary(Geometry::LodTreeLibrary *lodtrees); 160 169 161 170 // Change de Level of detail of the object. … … 174 183 // LodStrips library object. 175 184 Geometry::LodStripsLibrary *lodStripsLib; 185 // LodTree library object. 186 Geometry::LodTreeLibrary *lodTreeLib; 176 187 177 188 // Flag tha activate / deactivate the color strips. … … 206 217 void drawTriangleStrip(int submesh); 207 218 void drawLodStrip(); 219 void drawLodTree(); 208 220 void enableColorStrips(); 209 221 void disableColorStrips(); -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r774 r829 42 42 #include "GeoTreeSimpSequence.h" 43 43 #include "GeoLodStripsConstructor.h" 44 #include "GeoLodTreeLibrary.h" 44 45 45 46 // About Dialog. … … 58 59 LODTREES, 59 60 SELECT_LEAVES, 60 VISUALIZE_LODSTRIPS 61 VISUALIZE_LODSTRIPS, 62 VISUALIZE_LODTREES 61 63 }; 62 64 … … 96 98 // Lod strips object. 97 99 LodStripsLibrary *lodStripsLib; 100 // Lod tree object. 101 LodTreeLibrary *lodTreeLib; 98 102 99 103 // Mesh Bounds. … … 170 174 inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); 171 175 static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); 176 inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); 177 static void cb_menuLodTreesVisualize(fltk::Item*, void*); 172 178 inline void cb_menuHelpAbout_i(fltk::Item*, void*); 173 179 static void cb_menuHelpAbout(fltk::Item*, void*); … … 206 212 207 213 // Show the LodStrips visulization panel. 208 void show VisualizeLodStrips();214 void showSlider(); 209 215 210 216 void hideStripify(); … … 218 224 219 225 // Hide the LodStrips visualization panel. 220 void hide VisualizeLodStrips();226 void hideSlider(); 221 227 222 228 // Get the number of vertices. … … 292 298 fltk::Item *menuLodStripsVisualize; 293 299 fltk::ItemGroup *menuLodTrees; 300 fltk::Item *menuLodTreesVisualize; 294 301 295 302 fltk::Item *menuSelectLeaves; … … 333 340 // Initialize the lodstripslibrary for visualization. 334 341 void setLodStripsLibrary(std::string lodfile, Mesh *geomesh); 342 // Initialize the lodtreelibrary for visualization. 343 void setLodTreesLibrary(std::string lodfile, Mesh *geomesh); 335 344 336 345 // 26-12-2005 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r826 r829 586 586 drawLodStrip(); 587 587 } 588 else if (mLodTree) 589 { 590 drawLodTree(); 591 } 588 592 else 589 593 { … … 892 896 }//End drawTriangleStrip. 893 897 898 899 //--------------------------------------------------------------------------- 900 // Paint lodtree object. 901 //--------------------------------------------------------------------------- 902 void GeoMeshView::drawLodTree() 903 { 904 SubMesh *geosubmesh; 905 Index position; 906 Vector3 vector3; 907 float x,y,z; 908 float r,g,b; 909 int color_index; 910 int current_strip; 911 912 // Initialize current strip. 913 current_strip = 0; 914 915 // For each submesh. 916 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 917 { 918 919 color_index = 0; 920 921 // Gets the actual submesh. 922 geosubmesh = &geoMesh->mSubMesh[submesh]; 923 924 // For each one of the strips. 925 for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 926 { 927 // Paint the current strip. 928 glBegin(GL_TRIANGLE_STRIP); 929 930 if (getColorStrips()) 931 { 932 // Gets the color of the strip. 933 r = mStripColors[submesh][color_index].r; 934 g = mStripColors[submesh][color_index].g; 935 b = mStripColors[submesh][color_index].b; 936 937 // Change to the next color. 938 color_index++; 939 940 // Paint a new color. 941 glColor3f(r,g,b); 942 } 943 944 // For each index of the strip. 945 for (int index = 0; index < lodTreeLib->GetStrip(current_strip).size(); index++) 946 { 947 position = lodTreeLib->GetStrip(current_strip)[index]; 948 949 // Gets the vertex normal. 950 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 951 952 x = vector3[0]; 953 y = vector3[1]; 954 z = vector3[2]; 955 956 // Sets the vertex normal. 957 glNormal3f(x,y,z); 958 959 // Gets the vertex coordinates. 960 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 961 962 x = vector3[0]; 963 y = vector3[1]; 964 z = vector3[2]; 965 966 // Sets the vertex position. 967 glVertex3f(x,y,z); 968 } 969 970 // Increments current strip. 971 current_strip++; 972 973 // A strip is generated. 974 glEnd(); 975 976 } 977 } 978 979 }//End drawTriangleStrip. 980 981 982 894 983 //--------------------------------------------------------------------------- 895 984 // Sets the lodstripslibrary object. … … 902 991 903 992 //--------------------------------------------------------------------------- 993 // Sets the lodtreeslibrary object. 994 //--------------------------------------------------------------------------- 995 void GeoMeshView::setLodTreesLibrary(LodTreeLibrary *lodtrees) 996 { 997 lodTreeLib = lodtrees; 998 activeLodTree(); 999 } 1000 1001 1002 //--------------------------------------------------------------------------- 904 1003 // Change de Level of detail of the object. 905 1004 //--------------------------------------------------------------------------- 906 1005 void GeoMeshView::GoToLod(unsigned int lod) 907 1006 { 908 lodStripsLib->GoToLod(lod); 1007 if (mLodStrip) 1008 lodStripsLib->GoToLod(lod); 1009 if (mLodTree) 1010 lodTreeLib->GoToTrunkLod(lod); 909 1011 draw(); 910 1012 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r826 r829 682 682 // Deactive Lod strip visualization. 683 683 geoMeshView->deactiveLodStrip(); 684 geoMeshView->deactiveLodTree(); 684 685 685 686 // Loads a mesh file. … … 717 718 718 719 // Show the Visulize LodStrips panel. 719 show VisualizeLodStrips();720 showSlider(); 720 721 721 722 // Repaint the window. … … 723 724 } 724 725 725 void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) 726 { 727 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 728 -> 729 cb_menuLodStripsVisualize_i(o,v); 730 } 731 732 //--------------------------------------------------------------------------- 733 // Open LodStrip trunk Callback 734 //--------------------------------------------------------------------------- 735 inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) 736 { 737 } 738 739 void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) 740 { 741 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 742 -> 743 cb_menuLodTreesOpenLodStripTrunk_i(o,v); 744 } 745 746 //--------------------------------------------------------------------------- 747 // Open leaves simplification Callback 748 //--------------------------------------------------------------------------- 749 inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) 750 { 726 727 inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) 728 { 729 fltk::FileChooser *fcho; 730 const char *lod_file; 731 732 // Sets menus application state to NONE. 733 mApplicationState = NONE; 734 735 // Deactive Lod strip visualization. 736 geoMeshView->deactiveLodTree(); 737 geoMeshView->deactiveLodStrip(); 738 739 // Loads a mesh file. 740 openMeshFile(); 741 742 // Show title. 743 mProcessTitle->label("Visualize LodTrees"); 744 745 // If an object is loaded. 746 if (mGeoMesh != NULL) 747 { 748 fcho = new fltk::FileChooser("", 749 "*.lod", 750 fltk::FileChooser::CREATE, 751 "Open Lod file"); 752 753 fcho->exec(); 754 755 // If a file was selected. 756 if (fcho->value()) 757 { 758 // Build lod strips library. 759 setLodTreesLibrary(string(fcho->value()), mGeoMesh); 760 761 // Sets the aplication mode. 762 mApplicationState = VISUALIZE_LODTREES; 763 } 764 765 // Free memory. 766 delete fcho; 767 } 768 751 769 // Hide the right panel. 752 770 hideRightPanel(); 753 771 772 // Show the Visulize LodTree panel. 773 showSlider(); 774 775 // Repaint the window. 776 mMainWindow->redraw(); 777 } 778 void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) 779 { 780 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 781 -> 782 cb_menuLodTreesVisualize_i(o,v); 783 } 784 785 void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) 786 { 787 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 788 -> 789 cb_menuLodStripsVisualize_i(o,v); 790 } 791 792 //--------------------------------------------------------------------------- 793 // Open LodStrip trunk Callback 794 //--------------------------------------------------------------------------- 795 inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) 796 { 797 } 798 799 void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) 800 { 801 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 802 -> 803 cb_menuLodTreesOpenLodStripTrunk_i(o,v); 804 } 805 806 //--------------------------------------------------------------------------- 807 // Open leaves simplification Callback 808 //--------------------------------------------------------------------------- 809 inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) 810 { 811 // Hide the right panel. 812 hideRightPanel(); 813 754 814 // Show the LodTrees panel. 755 815 showOpenLeavesSimplification(); … … 768 828 cb_menuLodTreesOpenLeavesSimplification_i(o,v); 769 829 } 830 831 770 832 771 833 //--------------------------------------------------------------------------- … … 1338 1400 // Show the LodStrips visulization panel 1339 1401 //--------------------------------------------------------------------------- 1340 void GeoMeshViewUI::show VisualizeLodStrips()1402 void GeoMeshViewUI::showSlider() 1341 1403 { 1342 1404 mLodSlider->set_visible(); … … 1347 1409 // Hide the LodStrips visualization panel 1348 1410 //--------------------------------------------------------------------------- 1349 void GeoMeshViewUI::hide VisualizeLodStrips()1411 void GeoMeshViewUI::hideSlider() 1350 1412 { 1351 1413 mLodSlider->hide(); 1352 1414 mLodSlider->deactivate(); 1353 1415 } 1416 1354 1417 1355 1418 //--------------------------------------------------------------------------- … … 1495 1558 hideOpenMeshSimplification(); 1496 1559 hideOpenLeavesSimplification(); 1497 hide VisualizeLodStrips();1560 hideSlider(); 1498 1561 hideMeshInfo(); 1499 1562 } … … 1914 1977 1915 1978 //--------------------------------------------------------------------------- 1979 // Initialize the lodTreelibrary for visualization. 1980 //--------------------------------------------------------------------------- 1981 void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) 1982 { 1983 // If there is no lod strips object. 1984 if (lodTreeLib) 1985 { 1986 delete lodTreeLib; 1987 } 1988 1989 // New lod strips object. 1990 lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh); 1991 1992 // Sets the slider range. 1993 mLodSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); 1994 1995 // Pass to geomeshview the lod strips object. 1996 geoMeshView->setLodTreesLibrary(lodTreeLib); 1997 1998 // Puts the slider in the max position. 1999 mLodSlider->value(lodTreeLib->MinTrunkLod()); 2000 } 2001 2002 //--------------------------------------------------------------------------- 1916 2003 // Open a mesh file. 1917 2004 //--------------------------------------------------------------------------- … … 2026 2113 // Initialize the lod strip object. 2027 2114 lodStripsLib = NULL; 2115 lodTreeLib = NULL; 2028 2116 2029 2117 // Identify the mesh that stores the leaves … … 2445 2533 2446 2534 // Menu LodTrees. 2447 /*2535 2448 2536 { 2449 2537 fltk::ItemGroup* o; … … 2453 2541 { 2454 2542 fltk::Item* o; 2455 o = menuLodTreesOpenLodStripTrunk = new fltk::Item("Open LodStrip trunk"); 2456 o->callback((fltk::Callback*)cb_menuLodTreesOpenLodStripTrunk); 2457 } 2458 2459 { 2460 fltk::Item* o; 2461 o = menuLodTreesOpenLeavesSimplification = new fltk::Item("Open leaves simplification"); 2462 o->callback((fltk::Callback*)cb_menuLodTreesOpenLeavesSimplification); 2463 } 2543 o = menuLodTreesVisualize = new fltk::Item("Visualize Trunk"); 2544 o->callback((fltk::Callback*)cb_menuLodTreesVisualize); 2545 } 2546 2464 2547 o->end(); 2465 2548 } 2466 */2549 2467 2550 2468 2551 {
Note: See TracChangeset
for help on using the changeset viewer.