Changeset 1560


Ignore:
Timestamp:
10/03/06 14:11:36 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h

    r1552 r1560  
    3535        { 
    3636                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; 
    4141        }       LODRegisterType; 
    4242 
     
    7373        class LodStripsLibraryData 
    7474        { 
    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; 
    8081        }; 
     82 
    8183        class LodStripsLibrary : public Geometry::LodObject 
    8284        { 
     
    8890                        //      Structures with the data read from the file 
    8991                        //      We won't work with these structures 
    90                         SmallIntVector                                  mFileVertices; 
     92                        SmallIntVector                                                          mFileVertices; 
    9193                        std::vector     <LODRegisterType>       mFileChangesLOD; 
    9294                        std::vector     <SmallIntVector>        mFileStrips; 
    93                         LongVector                                              mData; 
     95                        LongVector                                                                              mData; 
    9496 
    9597                        //      Structures with the data to work with 
     
    113115 
    114116                        //      For the efficient version. 
    115                         SmallInt        mTotalFaces; 
    116                         SmallInt        *mCurrentData; 
    117                         SmallInt        *mStripsChanges; 
     117                        SmallInt                                mTotalFaces; 
     118                        SmallInt                                *mCurrentData; 
     119                        SmallInt                                *mStripsChanges; 
    118120                        LODRegisterType *mCurrentRegLOD; 
    119                         SmallInt        *mVertex; 
     121                        SmallInt                                *mVertex; 
    120122 
    121123                        SmallInt        minFaces, maxFaces; 
     
    140142                        //      Strips vector. 
    141143                        SmallIntVector  *mStrips; 
    142                         int *indices_x_submesh; 
     144 
     145                        int     *indices_x_submesh; 
    143146                        int *offsets_x_submesh; 
    144147 
    145                         void UpdateDataRetrievalInterface(void);                         
     148                        void UpdateDataRetrievalInterface(void); 
    146149 
    147150                        //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; 
    154158 
    155159                public: 
    156160 
    157                         IndexData *GetIndexDataInterface(void){ return dataRetrievalInterface; } 
     161                        IndexData *GetIndexDataInterface(void) 
     162                        { 
     163                                return dataRetrievalInterface; 
     164                        } 
    158165                         
    159166                        /**     Constructor, receives as a parameter the name of the file 
    160167                         *      including the multiresolution object. 
    161168                        */ 
    162                         LodStripsLibrary(const LodStripsLibraryData *, Mesh *geomesh, IndexData * userindexdata = NULL); 
     169                        LodStripsLibrary(       const   LodStripsLibraryData *, 
     170                                                                                                Mesh    *geomesh, 
     171                                                                                                IndexData       *userindexdata = NULL); 
    163172 
    164173                        /// Destructor. 
     
    184193                        uint32  MinVertices(); 
    185194 
    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                        } 
    193219        }; 
    194220} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r1552 r1560  
    1818//      Constructor. 
    1919//----------------------------------------------------------------------------- 
    20 LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh, IndexData *userindexdata) 
    21 //:dataRetrievalInterface(idfun?idfun:DefaultIndexDataCreator) 
    22 { 
    23 //      const   char    *name_of_file; 
    24  
     20LodStripsLibrary::LodStripsLibrary(     const LodStripsLibraryData      *lodstripsdata, 
     21                                                                                                                                                Mesh                                                                                            *geomesh, 
     22                                                                                                                                                IndexData                                                                               *userindexdata) 
     23{ 
    2524        //      Sets the current lod. 
    2625        mCurrentLod     =       0; 
    2726 
    28         //      Converts a String to const char *. 
    29 //      name_of_file    =       name.data(); 
    30  
    3127        //      Sets the global mesh. 
    3228        mGeoMesh = geomesh; 
    3329 
    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; 
    4338         
    4439        //      Loads the Level Of Detail file. 
    4540        LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh); 
    4641 
    47         GoToLod(0.0f);   
    48         minFaces = 0; 
     42        GoToLod(0.0f); 
     43 
     44        minFaces        =       0; 
     45 
    4946        for (unsigned int strip = 0; strip < mTotalStrips; strip++) 
    50                 minFaces += int(mStrips[strip].size() - 2); 
     47        { 
     48                minFaces        +=      int(mStrips[strip].size() - 2); 
     49        } 
    5150 
    5251        GoToLod(1.0f); 
    53         maxFaces = 0; 
     52 
     53        maxFaces        =       0; 
     54 
    5455        for (unsigned int strip = 0; strip < mTotalStrips; strip++) 
    55                 maxFaces += int(mStrips[strip].size() - 2); 
     56        { 
     57                maxFaces        +=      int(mStrips[strip].size() - 2); 
     58        } 
    5659} 
    5760 
     
    668671void LodStripsLibrary::UpdateDataRetrievalInterface(void) 
    669672{ 
    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 
    673677        current_triangle_count = 0; 
    674678 
    675679        // indices_x_submesh is calculated without degenerates,  
    676680        // 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. 
    682689        for (unsigned int i = 0; i < mTotalStrips; i++, strip_count++) 
    683690        { 
    684691                if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
    685692                { 
    686                         if (target_submesh==0) 
     693                        if (target_submesh == 0) 
     694                        { 
    687695                                offsets_x_submesh[target_submesh] = 0; 
     696                        } 
    688697                        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                        } 
    690703 
    691704                        mStripsSubmesh[target_submesh]  =       (int)strip_count; 
     
    695708                        ii_submesh = 0; 
    696709                        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); 
    697715                         
    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 
    703719                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++) 
    705724                { 
    706725                        // repeat the first index of the strip: degenerate (DEG!) 
    707726                        // 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 
    711731                                dataRetrievalInterface->SetIndex(ii_submesh,*it);                                
    712732                                ii_submesh++; 
    713733                        } 
    714                         lastindex=*it; 
     734 
     735                        lastindex       =       *it; 
    715736                        dataRetrievalInterface->SetIndex(ii_submesh,*it); 
    716737                } 
     
    718739                // repeat last vertex of the strip: degenerate (DEG!) 
    719740                // 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) 
    721742                { 
    722743                        dataRetrievalInterface->SetIndex(ii_submesh,lastindex); 
     
    727748        if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
    728749        { 
    729                 if (target_submesh==0) 
     750                if (target_submesh == 0) 
     751                { 
    730752                        offsets_x_submesh[target_submesh] = 0; 
     753                } 
    731754                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 
    736764                target_submesh++; 
    737765        } 
     
    739767        dataRetrievalInterface->End(); 
    740768} 
     769 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp

    r1526 r1560  
    769769 
    770770        //      Reserve memory for vert_info array. 
    771         vinfo.init(m.vertCount()*10); 
     771        vinfo.init(m.vertCount()*2); 
    772772 
    773773        if (simplif::will_use_vertex_constraint) 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r1549 r1560  
    10341034                                else 
    10351035                                { 
     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 
    10361048                                        //      Simplify the mesh object. 
    10371049                                        if(simplifyEdgeCollapse()) 
    10381050                                        { 
    1039                                                 delete  mMeshSimplifier; 
    10401051                                                geoMeshView->restoreContext(); 
    10411052                                        } 
     
    10561067                                //      Simplify and generate simplification sequence. 
    10571068                        case    LODTREES_AUTO: 
    1058                                 if (idMeshLeaves==(unsigned short)-1) 
     1069 
     1070                                if (idMeshLeaves == (unsigned short)-1) 
    10591071                                { 
    10601072                                        fltk::alert("Leaves submesh not selected!"); 
     
    11411153                                        if (simplifyEdgeCollapse()) 
    11421154                                        { 
    1143                                                 //      Create the simplification sequence. 
    1144                                                 //createSimplificationSequence(); 
    1145                                                  
    11461155                                                //delete        mMeshSimplifier; 
    11471156                                                geoMeshView->restoreContext(); 
     
    26002609                                        o->box(fltk::FLAT_BOX); 
    26012610                                        o->color((fltk::Color)0xffffff00); 
    2602                                         //fltk::Group::current()->resizable(o); 
    26032611                                } 
    26042612 
     
    26212629                                { 
    26222630                                        fltk::Button* o; 
    2623                                         //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process"); 
    26242631                                        o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); 
    26252632                                        o->callback((fltk::Callback*)cb_mButtonProcess); 
     
    26302637                                { 
    26312638                                        fltk::ProgressBar* o; 
    2632                                         //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18); 
    26332639                                        o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); 
    26342640                                        o->hide(); 
     
    26692675                                        fltk::Slider* o; 
    26702676                                        o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); 
     2677                                        o->linesize(0.01f); 
    26712678                                        o->type(fltk::Slider::TICK_BELOW); 
    26722679                                        o->set_vertical(); 
     
    26782685                                        fltk::Slider* o; 
    26792686                                        o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); 
     2687                                        o->linesize(0.01f); 
    26802688                                        o->type(fltk::Slider::TICK_BELOW); 
    26812689                                        o->set_vertical(); 
     
    27062714                                } 
    27072715 
    2708                                 //mChangeVertices = new fltk::CheckButton(30, 104, 25, 25, "Change vertices"); 
    2709  
    27102716                                { 
    27112717                                        mProcessTitle           = new fltk::Widget(0, 0, 230, 25, ""); 
     
    27192725                                } 
    27202726 
    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  
    27332727                                { 
    27342728                                        mMeshReductionLabel     = new fltk::Output(26, 124, 0, 25, "Mesh Reduction"); 
     
    27412735                                } 
    27422736 
    2743                                 //mChangeTexture = new fltk::CheckButton(30, 104, 25, 25, "Change texture"); 
    2744  
    27452737                                { 
    27462738                                        fltk::Group* o; 
     
    28152807                                } 
    28162808 
    2817                                 //{ 
    2818                                 //      fltk::Item* o = menuFileTransformSharedVertex = new fltk::Item("Transform to Shared Vertex"); 
    2819                                 //      o->callback((fltk::Callback*)cb_menuFileTransformSharedVertex); 
    2820                                 //} 
    2821  
    28222809                                { 
    28232810                                        menuLoadTextures = new fltk::ItemGroup("Load Textures"); 
     
    28622849                                } 
    28632850 
    2864                                 //{ 
    2865                                 //      fltk::Item* o = menuEditZoom = new fltk::Item("Zoom"); 
    2866                                 //      o->callback((fltk::Callback*)cb_menuEditZoom); 
    2867                                 //} 
    2868  
    28692851                                new fltk::Divider(); 
    28702852 
     
    28792861                                        o->callback((fltk::Callback*)cb_menuSelectLeaves); 
    28802862                                } 
    2881  
    28822863                                o->end(); 
    28832864                        } 
     
    29002881                                } 
    29012882 
    2902                                 //new fltk::Divider(); 
    2903  
    29042883                                { 
    29052884                                        fltk::Item* o = menuRenderCW = new fltk::Item("CW"); 
    29062885                                        o->type(fltk::Item::RADIO); 
    29072886                                        o->callback((fltk::Callback*)cb_menuRenderCW); 
    2908  
    2909                                         //o->hide(); 
    29102887                                } 
    29112888 
     
    29152892                                        o->set_value(); 
    29162893                                        o->callback((fltk::Callback*)cb_menuRenderCCW); 
    2917  
    2918                                         //o->hide(); 
    29192894                                } 
    29202895 
     
    29962971 
    29972972                        //      Menu LodTrees. 
    2998                          
    29992973                        { 
    30002974                                fltk::ItemGroup* o; 
     
    30293003                        } 
    30303004 
    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  
    30403005                        o->end(); 
    30413006                } 
     
    30463011                        o->box(fltk::BORDER_BOX); 
    30473012                        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                         */ 
    30583013 
    30593014                        { 
     
    30713026                                o->labelfont(fltk::HELVETICA_BOLD); 
    30723027                                o->color((fltk::Color)0xe0dfe300); 
    3073  
    3074                                 //      Hide triangle count. 
    3075                                 //o->hide(); 
    30763028                        } 
    30773029 
     
    30833035                                o->color((fltk::Color)0xe0dfe300); 
    30843036                        } 
    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                         //} 
    30933037 
    30943038                        { 
     
    31013045                        o->end(); 
    31023046                } 
    3103  
    3104  
    31053047                o->end(); 
    31063048        } 
     
    31083050        fltk::focus(geoMeshView); 
    31093051         
    3110  
    31113052        /*Hide Right Panel*/ 
    31123053        hideRightPanel(); 
Note: See TracChangeset for help on using the changeset viewer.