Changeset 1560 for GTP/trunk/Lib/Geom
- Timestamp:
- 10/03/06 14:11:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h
r1552 r1560 35 35 { 36 36 unsigned long strip; // change this to uint32 37 char position;38 char vertexRepetition;39 char edgeRepetition;40 char obligatory;37 char position; 38 char vertexRepetition; 39 char edgeRepetition; 40 char obligatory; 41 41 } LODRegisterType; 42 42 … … 73 73 class LodStripsLibraryData 74 74 { 75 public: 76 SmallIntVector mFileVertices; 77 std::vector <LODRegisterType> mFileChangesLOD; 78 LongVector mData; 79 std::vector<unsigned int> p_changes; 75 public: 76 77 SmallIntVector mFileVertices; 78 std::vector <LODRegisterType> mFileChangesLOD; 79 LongVector mData; 80 std::vector<unsigned int> p_changes; 80 81 }; 82 81 83 class LodStripsLibrary : public Geometry::LodObject 82 84 { … … 88 90 // Structures with the data read from the file 89 91 // We won't work with these structures 90 SmallIntVector mFileVertices;92 SmallIntVector mFileVertices; 91 93 std::vector <LODRegisterType> mFileChangesLOD; 92 94 std::vector <SmallIntVector> mFileStrips; 93 LongVector mData;95 LongVector mData; 94 96 95 97 // Structures with the data to work with … … 113 115 114 116 // For the efficient version. 115 SmallInt mTotalFaces;116 SmallInt *mCurrentData;117 SmallInt *mStripsChanges;117 SmallInt mTotalFaces; 118 SmallInt *mCurrentData; 119 SmallInt *mStripsChanges; 118 120 LODRegisterType *mCurrentRegLOD; 119 SmallInt *mVertex;121 SmallInt *mVertex; 120 122 121 123 SmallInt minFaces, maxFaces; … … 140 142 // Strips vector. 141 143 SmallIntVector *mStrips; 142 int *indices_x_submesh; 144 145 int *indices_x_submesh; 143 146 int *offsets_x_submesh; 144 147 145 void UpdateDataRetrievalInterface(void); 148 void UpdateDataRetrievalInterface(void); 146 149 147 150 //Number of strips in each submesh 148 int* mStripsSubmesh; 149 bool delete_indexdata; 150 int *submesh_x_strip; 151 Real lodFactor; 152 IndexData *dataRetrievalInterface; 153 uint32 current_triangle_count; 151 int *mStripsSubmesh; 152 bool delete_indexdata; 153 int *submesh_x_strip; 154 Real lodFactor; 155 156 IndexData *dataRetrievalInterface; 157 uint32 current_triangle_count; 154 158 155 159 public: 156 160 157 IndexData *GetIndexDataInterface(void){ return dataRetrievalInterface; } 161 IndexData *GetIndexDataInterface(void) 162 { 163 return dataRetrievalInterface; 164 } 158 165 159 166 /** Constructor, receives as a parameter the name of the file 160 167 * including the multiresolution object. 161 168 */ 162 LodStripsLibrary(const LodStripsLibraryData *, Mesh *geomesh, IndexData * userindexdata = NULL); 169 LodStripsLibrary( const LodStripsLibraryData *, 170 Mesh *geomesh, 171 IndexData *userindexdata = NULL); 163 172 164 173 /// Destructor. … … 184 193 uint32 MinVertices(); 185 194 186 uint32 GetValidIndexCount(int submeshid) const { return indices_x_submesh[submeshid]; } 187 // uint32 GetValidOffset(int submeshid) const { return offsets_x_submesh[submeshid]; } 188 uint32 GetTotalStripCount(void) const { return mTotalStrips; } 189 uint32 GetSubMeshtripCount(int submeshid) const { return mStripsSubmesh[submeshid]; } 190 uint32 GetCurrentTriangleCount(void) const { return current_triangle_count; } 191 192 virtual Real GetCurrentLodFactor(void) const { return lodFactor; } 195 uint32 GetValidIndexCount(int submeshid) const 196 { 197 return indices_x_submesh[submeshid]; 198 } 199 200 uint32 GetTotalStripCount(void) const 201 { 202 return mTotalStrips; 203 } 204 205 uint32 GetSubMeshtripCount(int submeshid) const 206 { 207 return mStripsSubmesh[submeshid]; 208 } 209 210 uint32 GetCurrentTriangleCount(void) const 211 { 212 return current_triangle_count; 213 } 214 215 virtual Real GetCurrentLodFactor(void) const 216 { 217 return lodFactor; 218 } 193 219 }; 194 220 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp
r1552 r1560 18 18 // Constructor. 19 19 //----------------------------------------------------------------------------- 20 LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh, IndexData *userindexdata) 21 //:dataRetrievalInterface(idfun?idfun:DefaultIndexDataCreator) 22 { 23 // const char *name_of_file; 24 20 LodStripsLibrary::LodStripsLibrary( const LodStripsLibraryData *lodstripsdata, 21 Mesh *geomesh, 22 IndexData *userindexdata) 23 { 25 24 // Sets the current lod. 26 25 mCurrentLod = 0; 27 26 28 // Converts a String to const char *.29 // name_of_file = name.data();30 31 27 // Sets the global mesh. 32 28 mGeoMesh = geomesh; 33 29 34 delete_indexdata=false; 35 dataRetrievalInterface=userindexdata; 36 37 indices_x_submesh = NULL; 38 offsets_x_submesh = NULL; 39 mStripsSubmesh = NULL; 40 submesh_x_strip = NULL; 41 lodFactor=1.0f; 42 current_triangle_count=0; 30 delete_indexdata = false; 31 dataRetrievalInterface = userindexdata; 32 indices_x_submesh = NULL; 33 offsets_x_submesh = NULL; 34 mStripsSubmesh = NULL; 35 submesh_x_strip = NULL; 36 lodFactor = 1.0f; 37 current_triangle_count = 0; 43 38 44 39 // Loads the Level Of Detail file. 45 40 LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh); 46 41 47 GoToLod(0.0f); 48 minFaces = 0; 42 GoToLod(0.0f); 43 44 minFaces = 0; 45 49 46 for (unsigned int strip = 0; strip < mTotalStrips; strip++) 50 minFaces += int(mStrips[strip].size() - 2); 47 { 48 minFaces += int(mStrips[strip].size() - 2); 49 } 51 50 52 51 GoToLod(1.0f); 53 maxFaces = 0; 52 53 maxFaces = 0; 54 54 55 for (unsigned int strip = 0; strip < mTotalStrips; strip++) 55 maxFaces += int(mStrips[strip].size() - 2); 56 { 57 maxFaces += int(mStrips[strip].size() - 2); 58 } 56 59 } 57 60 … … 668 671 void LodStripsLibrary::UpdateDataRetrievalInterface(void) 669 672 { 670 int target_submesh = 0; 671 size_t strip_count = 0; 672 unsigned int ii_submesh = 0; 673 int target_submesh = 0; 674 size_t strip_count = 0; 675 unsigned int ii_submesh = 0; 676 673 677 current_triangle_count = 0; 674 678 675 679 // indices_x_submesh is calculated without degenerates, 676 680 // we must add the degenerate indices added here 677 uint32 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 678 679 dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh] + numdeg); 680 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 681 681 uint32 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount * 2 - 2; 682 683 dataRetrievalInterface->Begin(target_submesh, 684 indices_x_submesh[target_submesh] + numdeg); 685 686 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 687 688 // For each strip. 682 689 for (unsigned int i = 0; i < mTotalStrips; i++, strip_count++) 683 690 { 684 691 if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 685 692 { 686 if (target_submesh==0) 693 if (target_submesh == 0) 694 { 687 695 offsets_x_submesh[target_submesh] = 0; 696 } 688 697 else 689 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 698 { 699 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] 700 + 701 offsets_x_submesh[target_submesh-1]; 702 } 690 703 691 704 mStripsSubmesh[target_submesh] = (int)strip_count; … … 695 708 ii_submesh = 0; 696 709 dataRetrievalInterface->End(); 710 711 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 712 713 dataRetrievalInterface->Begin(target_submesh, 714 indices_x_submesh[target_submesh] + numdeg); 697 715 698 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 699 dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh] + numdeg); 700 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 701 } 702 716 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 717 } 718 703 719 int lastindex = -1; 704 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii_submesh++) 720 721 for ( SmallIntVector::iterator it = mStrips[i].begin(); 722 it != mStrips[i].end(); 723 it++, ii_submesh++) 705 724 { 706 725 // repeat the first index of the strip: degenerate (DEG!) 707 726 // except for the first strip in a mesh 708 if (lastindex==-1 && strip_count>0) 709 { 710 lastindex=*it; 727 if ((lastindex == -1) && (strip_count > 0)) 728 { 729 lastindex = *it; 730 711 731 dataRetrievalInterface->SetIndex(ii_submesh,*it); 712 732 ii_submesh++; 713 733 } 714 lastindex=*it; 734 735 lastindex = *it; 715 736 dataRetrievalInterface->SetIndex(ii_submesh,*it); 716 737 } … … 718 739 // repeat last vertex of the strip: degenerate (DEG!) 719 740 // except for the last strip in a mesh 720 if (strip_count <mGeoMesh->mSubMesh[target_submesh].mStripCount-1)741 if (strip_count < mGeoMesh->mSubMesh[target_submesh].mStripCount-1) 721 742 { 722 743 dataRetrievalInterface->SetIndex(ii_submesh,lastindex); … … 727 748 if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 728 749 { 729 if (target_submesh==0) 750 if (target_submesh == 0) 751 { 730 752 offsets_x_submesh[target_submesh] = 0; 753 } 731 754 else 732 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 733 734 mStripsSubmesh[target_submesh] = (int)strip_count; 735 strip_count = 0; 755 { 756 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] 757 + 758 offsets_x_submesh[target_submesh-1]; 759 } 760 761 mStripsSubmesh[target_submesh] = (int)strip_count; 762 strip_count = 0; 763 736 764 target_submesh++; 737 765 } … … 739 767 dataRetrievalInterface->End(); 740 768 } 769 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp
r1526 r1560 769 769 770 770 // Reserve memory for vert_info array. 771 vinfo.init(m.vertCount()* 10);771 vinfo.init(m.vertCount()*2); 772 772 773 773 if (simplif::will_use_vertex_constraint) -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r1549 r1560 1034 1034 else 1035 1035 { 1036 // Transform NoSV Mesh to a SV Mesh. 1037 mesh_aux = mGeoMesh->toSharedVertex(); 1038 1039 // Deletes the mesh No Shared Vertex. 1040 delete mGeoMesh; 1041 1042 // Gets the mesh Shared Vertex. 1043 mGeoMesh = mesh_aux; 1044 1045 // Visualize mesh. 1046 geoMeshView->setMesh(mGeoMesh); 1047 1036 1048 // Simplify the mesh object. 1037 1049 if(simplifyEdgeCollapse()) 1038 1050 { 1039 delete mMeshSimplifier;1040 1051 geoMeshView->restoreContext(); 1041 1052 } … … 1056 1067 // Simplify and generate simplification sequence. 1057 1068 case LODTREES_AUTO: 1058 if (idMeshLeaves==(unsigned short)-1) 1069 1070 if (idMeshLeaves == (unsigned short)-1) 1059 1071 { 1060 1072 fltk::alert("Leaves submesh not selected!"); … … 1141 1153 if (simplifyEdgeCollapse()) 1142 1154 { 1143 // Create the simplification sequence.1144 //createSimplificationSequence();1145 1146 1155 //delete mMeshSimplifier; 1147 1156 geoMeshView->restoreContext(); … … 2600 2609 o->box(fltk::FLAT_BOX); 2601 2610 o->color((fltk::Color)0xffffff00); 2602 //fltk::Group::current()->resizable(o);2603 2611 } 2604 2612 … … 2621 2629 { 2622 2630 fltk::Button* o; 2623 //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process");2624 2631 o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); 2625 2632 o->callback((fltk::Callback*)cb_mButtonProcess); … … 2630 2637 { 2631 2638 fltk::ProgressBar* o; 2632 //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18);2633 2639 o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); 2634 2640 o->hide(); … … 2669 2675 fltk::Slider* o; 2670 2676 o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); 2677 o->linesize(0.01f); 2671 2678 o->type(fltk::Slider::TICK_BELOW); 2672 2679 o->set_vertical(); … … 2678 2685 fltk::Slider* o; 2679 2686 o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); 2687 o->linesize(0.01f); 2680 2688 o->type(fltk::Slider::TICK_BELOW); 2681 2689 o->set_vertical(); … … 2706 2714 } 2707 2715 2708 //mChangeVertices = new fltk::CheckButton(30, 104, 25, 25, "Change vertices");2709 2710 2716 { 2711 2717 mProcessTitle = new fltk::Widget(0, 0, 230, 25, ""); … … 2719 2725 } 2720 2726 2721 /*2722 {2723 mTypeLabel = new fltk::Output(26, 82, 5, 25, "Type");2724 fltk::Output* o = mTypeLabel;2725 o->set_vertical();2726 o->box(fltk::NO_BOX);2727 o->labelfont(fltk::HELVETICA_BOLD);2728 o->color((fltk::Color)0xe0dfe300);2729 o->align(fltk::ALIGN_RIGHT);2730 }2731 */2732 2733 2727 { 2734 2728 mMeshReductionLabel = new fltk::Output(26, 124, 0, 25, "Mesh Reduction"); … … 2741 2735 } 2742 2736 2743 //mChangeTexture = new fltk::CheckButton(30, 104, 25, 25, "Change texture");2744 2745 2737 { 2746 2738 fltk::Group* o; … … 2815 2807 } 2816 2808 2817 //{2818 // fltk::Item* o = menuFileTransformSharedVertex = new fltk::Item("Transform to Shared Vertex");2819 // o->callback((fltk::Callback*)cb_menuFileTransformSharedVertex);2820 //}2821 2822 2809 { 2823 2810 menuLoadTextures = new fltk::ItemGroup("Load Textures"); … … 2862 2849 } 2863 2850 2864 //{2865 // fltk::Item* o = menuEditZoom = new fltk::Item("Zoom");2866 // o->callback((fltk::Callback*)cb_menuEditZoom);2867 //}2868 2869 2851 new fltk::Divider(); 2870 2852 … … 2879 2861 o->callback((fltk::Callback*)cb_menuSelectLeaves); 2880 2862 } 2881 2882 2863 o->end(); 2883 2864 } … … 2900 2881 } 2901 2882 2902 //new fltk::Divider();2903 2904 2883 { 2905 2884 fltk::Item* o = menuRenderCW = new fltk::Item("CW"); 2906 2885 o->type(fltk::Item::RADIO); 2907 2886 o->callback((fltk::Callback*)cb_menuRenderCW); 2908 2909 //o->hide();2910 2887 } 2911 2888 … … 2915 2892 o->set_value(); 2916 2893 o->callback((fltk::Callback*)cb_menuRenderCCW); 2917 2918 //o->hide();2919 2894 } 2920 2895 … … 2996 2971 2997 2972 // Menu LodTrees. 2998 2999 2973 { 3000 2974 fltk::ItemGroup* o; … … 3029 3003 } 3030 3004 3031 /* {3032 fltk::SharedImage *gifLogo = logo->get("media\\logos\\logo.gif");3033 3034 //o->callback((fltk::Callback*)cb_mLogo);3035 3036 mLogo = new fltk::InvisibleBox(406, 1, 43, 13);3037 mLogo->image(gifLogo);3038 }*/3039 3040 3005 o->end(); 3041 3006 } … … 3046 3011 o->box(fltk::BORDER_BOX); 3047 3012 o->begin(); 3048 3049 /*3050 {3051 fltk::Widget* o;3052 o = mFPS = new fltk::Widget(10, 4, 30, 15, "FPS ");3053 o->box(fltk::NO_BOX);3054 o->labelfont(fltk::HELVETICA_BOLD);3055 o->color((fltk::Color)0xe0dfe300);3056 }3057 */3058 3013 3059 3014 { … … 3071 3026 o->labelfont(fltk::HELVETICA_BOLD); 3072 3027 o->color((fltk::Color)0xe0dfe300); 3073 3074 // Hide triangle count.3075 //o->hide();3076 3028 } 3077 3029 … … 3083 3035 o->color((fltk::Color)0xe0dfe300); 3084 3036 } 3085 3086 //{3087 // fltk::Widget* o;3088 // o = mQuads = new fltk::Widget(454, 4, 40, 15, "Quads");3089 // o->box(fltk::NO_BOX);3090 // o->labelfont(fltk::HELVETICA_BOLD);3091 // o->color((fltk::Color)0xe0dfe300);3092 //}3093 3037 3094 3038 { … … 3101 3045 o->end(); 3102 3046 } 3103 3104 3105 3047 o->end(); 3106 3048 } … … 3108 3050 fltk::focus(geoMeshView); 3109 3051 3110 3111 3052 /*Hide Right Panel*/ 3112 3053 hideRightPanel();
Note: See TracChangeset
for help on using the changeset viewer.