Changeset 891


Ignore:
Timestamp:
05/04/06 12:56:05 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
13 edited

Legend:

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

    r774 r891  
    4646                SubMesh *mSubMesh;        ///< Array of subMesehs 
    4747                size_t   mSubMeshCount;   ///< Total count of subMeshes 
    48                 MeshType mType;           ///< Type of mesh 
    4948 
    5049                //OSCAR 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h

    r774 r891  
    6565        }; 
    6666 
    67         /// Implementation of a simplification algorithm based on images. 
    68         /** This class implements a simplification algorithm based on an image evaluation technique. */ 
    69         class ImageBasedSimplifier : public MeshSimplifier 
     67        /// Implementation of a simplification algorithm based on viewpoint. 
     68        /** This class implements a simplification algorithm based on a viewpoint evaluation technique. */ 
     69        class ViewPointDrivenSimplifier : public MeshSimplifier 
    7070        { 
     71        private: 
     72 
    7173        public: 
    7274                /// Class constructor. Will call Simplifier class constructor. 
    73                 ImageBasedSimplifier (const Geometry::Mesh      *, 
     75                ViewPointDrivenSimplifier (const Geometry::Mesh         *, 
    7476                                                                                                        Geometry::TIPOFUNC              upb=0); 
    7577 
    7678                /// Class destructor. 
    77                 virtual ~ImageBasedSimplifier (void); 
     79                virtual ~ViewPointDrivenSimplifier (void); 
    7880 
    7981                /// Copy constructor 
    80                 //ImageBasedSimplifier(const ImageBasedSimplifier&); 
     82                //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&); 
    8183 
    8284                /// Assignment operator 
    83                 //ImageBasedSimplifier& operator =(const ImageBasedSimplifier&); 
     85                //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&); 
    8486 
    8587                /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification. 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoSubMesh.h

    r826 r891  
    99#include "GeoSerializable.h" 
    1010 
    11 namespace Geometry { 
     11namespace Geometry 
     12{ 
    1213 
    1314        /// SubMesh interface 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp

    r841 r891  
    10651065                                        Index   *aux    =       this->geoMesh->mSubMesh[i].mStrip[j]; 
    10661066 
     1067                                        /* 
    10671068                                        if (j != 0) 
    10681069                                        { 
     
    10721073                                                indice_acum++; 
    10731074                                        } 
     1075                                        */ 
    10741076 
    10751077                                        if (j+1 < this->geoMesh->mSubMesh[i].mStripCount) 
     
    10871089                                                } 
    10881090 
    1089                                                 tira.pop_back(); 
     1091                                                //tira.pop_back(); 
     1092 
    10901093                                                this->cStrips.push_back(tira); 
    10911094                                        } 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r829 r891  
    540540 
    541541                        //      If the strips is not the first. 
     542                        /* 
    542543                        if (strip != 0) 
    543544                        { 
    544545                                indexBegin++; 
    545546                        } 
     547                        */ 
    546548 
    547549                        //      If is the final strip 
     
    557559 
    558560                                //      Remove degenerated 
    559                                 indexEnd--; 
     561                                //indexEnd--; 
    560562                        } 
    561563                         
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp

    r826 r891  
    66//---------------------------------------------------------------------------- 
    77Mesh::Mesh(): 
    8         mVertexBuffer(0), mSubMeshCount(0), mSubMesh(0), mType(GEO_TRIANGLE_LIST) 
     8        mVertexBuffer(0), mSubMeshCount(0), mSubMesh(0) 
    99{ 
    1010} 
     
    2121        // constructor copia 
    2222        mVertexBuffer=new VertexBuffer(); 
    23         mType=objmesh.mType; 
    2423        mSubMeshCount=objmesh.mSubMeshCount; 
    2524        mSubMesh = new Geometry::SubMesh[objmesh.mSubMeshCount]; 
     
    121120        bool copiados   =       false; // indica si los vértices compartidos han sido copiados 
    122121        mVertexBuffer   =       new VertexBuffer(); 
    123         mType                                   =       objmesh.mType; 
    124122        mSubMeshCount   =       objmesh.mSubMeshCount; 
    125123        mSubMesh                        =       new Geometry::SubMesh[objmesh.mSubMeshCount]; 
     
    321319         
    322320        mesh->mVertexBuffer=new VertexBuffer(); 
    323         mesh->mType=this->mType; 
    324321        mesh->mSubMeshCount = this->mSubMeshCount; 
    325322        // Reserva memoria para los submeshes 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp

    r774 r891  
    4242} 
    4343 
    44 ImageBasedSimplifier::ImageBasedSimplifier (const Geometry::Mesh        *m, 
     44GeometryBasedSimplifier::GeometryBasedSimplifier (const Geometry::Mesh  *m, 
    4545                                                                                                                                                                                Geometry::TIPOFUNC              upb) 
    4646                                                                                                                                                                                :MeshSimplifier(m,upb) 
     
    4848} 
    4949 
    50 ImageBasedSimplifier::~ImageBasedSimplifier() 
     50GeometryBasedSimplifier::~GeometryBasedSimplifier() 
    5151{ 
    5252} 
    5353 
    5454// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification. 
    55 void ImageBasedSimplifier::Simplify (Geometry::Real paramlod) 
     55void GeometryBasedSimplifier::Simplify (Geometry::Real paramlod) 
    5656{ 
    5757        SimplificationMethod *m_qslim   =       new SimplificationMethod(objmesh); 
     
    6565 
    6666// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification. 
    67 void ImageBasedSimplifier::Simplify (Geometry::uint32 numvertices) 
     67void GeometryBasedSimplifier::Simplify (Geometry::uint32 numvertices) 
    6868{ 
    6969        SimplificationMethod *m_qslim   =       new SimplificationMethod(objmesh); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshStripifier.cpp

    r826 r891  
    7373        size_t                                          index_count; 
    7474        size_t                                          strip_count; 
     75        size_t                                          strip_index_count; 
    7576        SubMesh                                         *geosubmesh; 
    7677        primitive_vector        PrimitivesVector; 
     
    8283        for (int        submesh =       0;      submesh < mGeoMesh->mSubMeshCount;      submesh++) 
    8384        { 
    84                 //      If is not the Leaveas submesh. 
    85                 if (submesh != mSubMeshLeaves) 
     85                //      Gets the submesh. 
     86                geosubmesh      =       &mGeoMesh->mSubMesh[submesh]; 
     87 
     88                //      Free index vector. 
     89                Indices.clear(); 
     90 
     91                //      Progress bar increment. 
     92                increment       =       20      /       mGeoMesh->mSubMeshCount; 
     93                increment       =       increment       /       geosubmesh->mIndexCount; 
     94                update          =       0.0; 
     95 
     96                //      For each index. 
     97                for (int        index   =       0;      index   <       geosubmesh->mIndexCount;        index++) 
    8698                { 
    87  
    88                         //      Gets the submesh. 
    89                         geosubmesh      =       &mGeoMesh->mSubMesh[submesh]; 
    90  
    91                         //      Free index vector. 
    92                         Indices.clear(); 
    93  
    94                         //      Progress bar increment. 
    95                         increment       =       20      /       mGeoMesh->mSubMeshCount; 
    96                         increment       =       increment       /       geosubmesh->mIndexCount; 
    97                         update          =       0.0; 
    98  
    99                         //      For each index. 
    100                         for (int        index   =       0;      index   <       geosubmesh->mIndexCount;        index++) 
    101                         { 
    102                                 //      Update progress bar. 
    103                                 if (mUPB) 
     99                        //      Update progress bar. 
     100                        if (mUPB) 
     101                        { 
     102                                update  =       update + increment; 
     103 
     104                                if (update > 0.9) 
    104105                                { 
    105                                         update  =       update + increment; 
    106  
    107                                         if (update > 0.9) 
    108                                         { 
    109                                                 mUPB(1.0); 
    110  
    111                                                 update  =       0; 
    112                                         } 
     106                                        mUPB(1.0); 
     107 
     108                                        update  =       0; 
    113109                                } 
    114  
    115                                 //      Add an index. 
    116                                 Indices.push_back(geosubmesh->mIndex[index]); 
    117                         } 
    118  
    119                         // we want to time the tri_stripper object destruction as well. 
    120                         tri_stripper TriStripper(Indices); 
    121  
    122                         //      Sets the progress bar function for stripper algorithm. 
    123                         TriStripper.SetProgressFunc(mUPB,60/mGeoMesh->mSubMeshCount); 
    124  
    125                         TriStripper.SetMinStripSize(2); 
    126                         TriStripper.SetCacheSize(32); 
    127                         //TriStripper.SetBackwardSearch(false); 
    128  
    129                         TriStripper.Strip(&PrimitivesVector); 
    130  
    131                         //      Free submesh indices. 
    132                         delete  []      geosubmesh->mIndex; 
    133  
    134                         //      Initialize index count. 
    135                         geosubmesh->mIndexCount =       0; 
    136  
    137                         //      Initialize strip count. 
    138                         strip_count     =       0; 
    139  
    140                         //      For each strip or triangle list. 
    141                         for (size_t i = 0; i < PrimitivesVector.size(); ++i) 
    142                         { 
    143                                 if (PrimitivesVector[i].Type == TRIANGLE_STRIP) 
     110                        } 
     111 
     112                        //      Add an index. 
     113                        Indices.push_back(geosubmesh->mIndex[index]); 
     114                } 
     115 
     116                // we want to time the tri_stripper object destruction as well. 
     117                tri_stripper TriStripper(Indices); 
     118 
     119                //      Sets the progress bar function for stripper algorithm. 
     120                TriStripper.SetProgressFunc(mUPB,60/mGeoMesh->mSubMeshCount); 
     121 
     122                TriStripper.SetMinStripSize(2); 
     123                TriStripper.SetCacheSize(32); 
     124                //TriStripper.SetBackwardSearch(false); 
     125 
     126                TriStripper.Strip(&PrimitivesVector); 
     127 
     128                //      Free submesh indices. 
     129                delete  []      geosubmesh->mIndex; 
     130 
     131                //      Initialize index count. 
     132                geosubmesh->mIndexCount =       0; 
     133 
     134                //      Initialize strip count. 
     135                strip_count     =       0; 
     136 
     137                //      For each strip or triangle list. 
     138                for (size_t strip = 0; strip < PrimitivesVector.size(); ++strip) 
     139                { 
     140                        if (PrimitivesVector[strip].Type == TRIANGLE_STRIP) 
     141                        { 
     142                                strip_count++; 
     143 
     144                                //      Gets the index count. 
     145                                strip_index_count       =       PrimitivesVector[strip].Indices.size(); 
     146 
     147                                //      Adds indices of the current strip to total index count. 
     148                                geosubmesh->mIndexCount +=      strip_index_count; 
     149                        } 
     150                        else 
     151                        { 
     152                                strip_count += PrimitivesVector[strip].Indices.size() / 3; 
     153 
     154                                geosubmesh->mIndexCount +=      PrimitivesVector[strip].Indices.size(); 
     155                        } 
     156 
     157                } 
     158 
     159                //      Reserve memory for strips list. 
     160                geosubmesh->mStrip                      =       new     Index*[strip_count]; 
     161                geosubmesh->mStripCount =       strip_count; 
     162 
     163                //      Reserve memory for indices. 
     164                geosubmesh->mIndex      =       new     Index[geosubmesh->mIndexCount]; 
     165 
     166                //      Initialize index count. 
     167                index_count     =       0; 
     168 
     169                //      For each strip. 
     170                for (size_t     strip   =       0; strip < PrimitivesVector.size();     strip++) 
     171                { 
     172                        if (PrimitivesVector[strip].Type == TRIANGLE_STRIP) 
     173                        { 
     174                                //      Asigns the beginning of the strip. 
     175                                geosubmesh->mStrip[strip]       =       &geosubmesh->mIndex[index_count]; 
     176 
     177                                //      Gets the index count of the current strip. 
     178                                strip_index_count       =       PrimitivesVector[strip].Indices.size(); 
     179 
     180         
     181                                //      Fill up the index array. 
     182                                for (   size_t  index   =       0; 
     183                                                index < PrimitivesVector[strip].Indices.size(); 
     184                                                index++) 
    144185                                { 
    145                                         strip_count++; 
    146                                         geosubmesh->mIndexCount +=      PrimitivesVector[i].Indices.size(); 
    147  
    148                                         //      Degenerate triangles. 
    149                                         geosubmesh->mIndexCount +=      2; 
     186                                        geosubmesh->mIndex[index + index_count] =       PrimitivesVector[strip].Indices[index]; 
    150187                                } 
    151                                 else 
    152                                 { 
    153                                         strip_count += PrimitivesVector[i].Indices.size()/3; 
    154  
    155                                         geosubmesh->mIndexCount +=      PrimitivesVector[i].Indices.size(); 
    156  
    157                                         //      Degenerate triangles. 
    158                                         geosubmesh->mIndexCount +=      2*(PrimitivesVector[i].Indices.size()/3); 
    159                                 } 
    160  
    161                         } 
    162  
    163                         //      Reserve memory for strips list. 
    164                         geosubmesh->mStrip                      =       new     Index*[strip_count]; 
    165                         geosubmesh->mStripCount =       strip_count; 
    166  
    167                         //      Adjust the index count. 
    168                         geosubmesh->mIndexCount -=      2; 
    169  
    170                         //      Reserve memory for indices. 
    171                         geosubmesh->mIndex      =       new     Index[geosubmesh->mIndexCount]; 
    172  
    173                         //      Initialize index count. 
    174                         index_count     =       0; 
    175  
    176                         //      For each strip. 
    177                         for (size_t     strip   =       0; strip < PrimitivesVector.size();     strip++) 
    178                         { 
    179                                 if (PrimitivesVector[strip].Type == TRIANGLE_STRIP) 
     188 
     189                                //      Adds the current strip size to index count. 
     190                                index_count     +=      PrimitivesVector[strip].Indices.size(); 
     191                        } 
     192                        else 
     193                        { 
     194                                //      For each index. 
     195                                for (   size_t  itri    =       0; 
     196                                                itri    <       PrimitivesVector[strip].Indices.size() / 3; 
     197                                                itri ++) 
    180198                                { 
    181199                                        //      Asigns the beginning of the strip. 
    182                                         geosubmesh->mStrip[strip]       =       &geosubmesh->mIndex[index_count]; 
    183  
    184                                         //      If is not the first strip. 
    185                                         if (strip       != 0) 
    186                                         { 
    187                                                 geosubmesh->mIndex[index_count++]       = PrimitivesVector[strip].Indices[0]; 
    188                                         } 
    189  
    190                                         //      Fill up the index array. 
    191                                         for (   size_t  index   =       0; 
    192                                                         index < PrimitivesVector[strip].Indices.size(); 
    193                                                         index++) 
    194                                         { 
    195                                                 geosubmesh->mIndex[index + index_count] =       PrimitivesVector[strip].Indices[index]; 
    196                                         } 
    197  
    198                                         //      Adds the current strip size to index count. 
    199                                         index_count     +=      PrimitivesVector[strip].Indices.size(); 
    200  
    201                                         if ((strip + 1) != strip_count) 
    202                                         { 
    203                                                 //      Degenerate triangle. 
    204                                                 geosubmesh->mIndex[index_count++]       =       geosubmesh->mIndex[index_count - 1]; 
    205                                         } 
     200                                        geosubmesh->mStrip[strip + itri]        =       &geosubmesh->mIndex[index_count]; 
     201 
     202                                        //      Triangle indeces. 
     203                                        geosubmesh->mIndex[index_count++]       =       PrimitivesVector[strip].Indices[itri*3+0]; 
     204                                        geosubmesh->mIndex[index_count++]       =       PrimitivesVector[strip].Indices[itri*3+1]; 
     205                                        geosubmesh->mIndex[index_count++] =     PrimitivesVector[strip].Indices[itri*3+2]; 
     206 
    206207                                } 
    207                                 else 
    208                                 { 
    209                                         //      For each index. 
    210                                         for (   size_t  itri    =       0; 
    211                                                         itri    <       PrimitivesVector[strip].Indices.size() / 3; 
    212                                                         itri ++) 
    213                                         { 
    214                                                 //      Asigns the beginning of the strip. 
    215                                                 geosubmesh->mStrip[strip + itri]        =       &geosubmesh->mIndex[index_count]; 
    216  
    217                                                 //      Degenerate triangle. 
    218                                                 geosubmesh->mIndex[index_count++]       =       PrimitivesVector[strip].Indices[itri*3+0]; 
    219  
    220                                                 //      Triangle indeces. 
    221                                                 geosubmesh->mIndex[index_count++]       =       PrimitivesVector[strip].Indices[itri*3+0]; 
    222                                                 geosubmesh->mIndex[index_count++]       =       PrimitivesVector[strip].Indices[itri*3+1]; 
    223                                                 geosubmesh->mIndex[index_count++] =     PrimitivesVector[strip].Indices[itri*3+2]; 
    224  
    225                                                 //      If is not the last strip. 
    226                                                 if ((strip + itri + 1) != strip_count) 
    227                                                 { 
    228                                                         geosubmesh->mIndex[index_count++]       =       geosubmesh->mIndex[index_count - 1]; 
    229                                                 } 
    230                                         } 
    231  
    232                                 } 
    233                         } 
    234  
    235                         //      Sets the actual submesh type to triangle strips. 
    236                         geosubmesh->mType       =       GEO_TRIANGLE_STRIPS; 
    237  
     208                        } 
    238209                } 
     210                 
     211                //      Sets the actual submesh type to triangle strips. 
     212                geosubmesh->mType       =       GEO_TRIANGLE_STRIPS; 
    239213        } 
    240214 
     
    245219        } 
    246220 
    247  
    248221        //      All wright. 
    249222        return  1; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/SimplificationMethod.cpp

    r774 r891  
    963963        *mesh=new Geometry::Mesh(); 
    964964        (*mesh)->mVertexBuffer  =       new     Geometry::VertexBuffer(); 
    965         (*mesh)->mType=objmesh->mType; 
     965        //(*mesh)->mType=objmesh->mType; 
    966966 
    967967        (*mesh)->mSubMeshCount = objmesh->mSubMeshCount; 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h

    r826 r891  
    166166 
    167167                        //      Writes the strips list. 
    168                         SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh); 
     168                        SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh   *geoSubMesh); 
     169 
     170                        //      Remove degenerate triangles of a submesh given. 
     171                        SubMesh *       removeDegenerateTriangles(SubMesh       *geoSubMesh); 
    169172                         
    170173                public: 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp

    r826 r891  
    858858        } 
    859859 
     860        //      Remove degenerate triangles of a submesh given. 
     861        geoSubMesh      =       removeDegenerateTriangles(geoSubMesh); 
     862 
     863        return  geoSubMesh; 
     864} 
     865 
     866//      Remove degenerate triangles of a submesh given. 
     867SubMesh *       GeoMeshLoader::removeDegenerateTriangles(SubMesh        *geoSubMesh) 
     868{ 
     869        Index           *indices; 
     870        Index           *index; 
     871        Index           *indexBegin; 
     872        Index           *indexEnd; 
     873        Index           *new_strip_starts; 
     874        size_t  new_index_count; 
     875        size_t  current_index; 
     876 
     877        //      Stores the new starts of strips. 
     878        new_strip_starts        =       new     Index[geoSubMesh->mStripCount]; 
     879         
     880        //      Calculate the new index count. 
     881        new_index_count =       geoSubMesh->mIndexCount  
     882                - 
     883                (2 * geoSubMesh->mStripCount) 
     884                + 
     885                2; 
     886 
     887        //      Auxiliar index array. 
     888        indices =       new     Index[new_index_count]; 
     889 
     890        //      Initialize the current index; 
     891        current_index   =       0; 
     892         
     893        //      For each one of the strips. 
     894        for (int strip = 0; strip < geoSubMesh->mStripCount; strip++) 
     895        { 
     896                //      Stars of strip without degenerate triangles. 
     897                new_strip_starts[strip] =       current_index; 
     898                 
     899                //      First index of the strip. 
     900                indexBegin      =       geoSubMesh->mStrip[strip]; 
     901 
     902                //      If is the final strip 
     903                if (strip       == (geoSubMesh->mStripCount - 1)) 
     904                { 
     905                        //      The end of the index array. 
     906                        indexEnd        = &geoSubMesh->mIndex[geoSubMesh->mIndexCount]; 
     907                } 
     908                else 
     909                { 
     910                        //      The beginning of the next strip. 
     911                        indexEnd        = geoSubMesh->mStrip[strip + 1]; 
     912                } 
     913 
     914                int i; 
     915                i       = 0; 
     916 
     917                //      If is not the first strip. 
     918                if (strip != 0) 
     919                { 
     920                        indexBegin++; 
     921                } 
     922 
     923                //      If is not the last strip. 
     924                if (strip       != (geoSubMesh->mStripCount - 1)) 
     925                { 
     926                        indexEnd--; 
     927                } 
     928 
     929                //      For each index of the strip. 
     930                for (index = indexBegin; index < indexEnd; index++) 
     931                { 
     932                        indices[current_index++]        =       indexBegin[i]; 
     933 
     934                        //      Increments i. 
     935                        i++; 
     936                } 
     937 
     938        } 
     939 
     940        //      Free Index memory. 
     941        delete  []geoSubMesh->mIndex; 
     942 
     943        //      Update index count. 
     944        geoSubMesh->mIndexCount =       new_index_count; 
     945 
     946        geoSubMesh->mIndex      =       new     Index[new_index_count]; 
     947 
     948        //      Store new index array without degenerate triangles. 
     949        for (size_t     i       =       0;      i       <       geoSubMesh->mIndexCount; i++) 
     950        { 
     951                geoSubMesh->mIndex[i]   =       indices[i]; 
     952        } 
     953 
     954        //      Free auxiliar index array; 
     955        delete  []indices; 
     956 
     957        //      Update start of the strip. 
     958        for (int        strip   =       0; strip < geoSubMesh->mStripCount; strip++) 
     959        { 
     960                geoSubMesh->mStrip[strip]       =       &geoSubMesh->mIndex[new_strip_starts[strip]]; 
     961        } 
     962 
     963        //      Free auxiliar strip starts. 
     964        delete  []new_strip_starts; 
     965         
    860966        return  geoSubMesh; 
    861967} 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp

    r826 r891  
    194194        unsigned        long    indexCount; 
    195195        String                                  materialName; 
     196        Index                                           *index; 
     197        Index                                           *indexBegin; 
     198        Index                                           *indexEnd; 
    196199         
    197200        //      Debug. 
     
    219222        indexCount      =       geoSubMesh->mIndexCount; 
    220223 
     224        //      If the submesh is in triangle strips. 
     225        if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 
     226        { 
     227                indexCount      +=      2 * geoSubMesh->mStripCount - 2; 
     228        } 
     229         
    221230        writeInts(indexCount, 1); 
    222231 
     
    229238                                <<      endl; 
    230239 
    231         //      Write the index array. 
    232         for (int i = 0; i < geoSubMesh->mIndexCount; i++) 
    233         { 
    234                 writeInts(geoSubMesh->mIndex[i], 1); 
     240        //      If the submesh is in triangle strips. 
     241        if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 
     242        { 
     243                //      Debug. 
     244                cout    <<      "Write triangle strips" 
     245                                        <<      endl; 
     246                 
     247                //      For each one of the strips. 
     248                for (int strip = 0; strip < geoSubMesh->mStripCount; strip++) 
     249                { 
     250                        //      First index of the strip. 
     251                        indexBegin      =       geoSubMesh->mStrip[strip]; 
     252 
     253                        //      If is the final strip 
     254                        if (strip       == (geoSubMesh->mStripCount - 1)) 
     255                        { 
     256                                //      The end of the index array. 
     257                                indexEnd        = &geoSubMesh->mIndex[geoSubMesh->mIndexCount]; 
     258                        } 
     259                        else 
     260                        { 
     261                                //      The beginning of the next strip. 
     262                                indexEnd        = geoSubMesh->mStrip[strip + 1]; 
     263                        } 
     264 
     265                        int i; 
     266                        i       = 0; 
     267 
     268                        if (strip != 0) 
     269                        { 
     270                                writeInts(indexBegin[i], 1); 
     271                        } 
     272                         
     273                        //      For each index of the strip. 
     274                        for (index = indexBegin; index < indexEnd; index++) 
     275                        { 
     276                                writeInts(indexBegin[i], 1); 
     277                                 
     278                                //      Increments i. 
     279                                i++; 
     280                        } 
     281 
     282                        if (strip       != (geoSubMesh->mStripCount - 1)) 
     283                        { 
     284                                writeInts(indexBegin[i - 1], 1); 
     285                        } 
     286 
     287                } 
     288        } 
     289        //      If the submesh is in triangle list. 
     290        else 
     291        { 
     292                //      Write the index array. 
     293                for (int i = 0; i < geoSubMesh->mIndexCount; i++) 
     294                { 
     295                        writeInts(geoSubMesh->mIndex[i], 1); 
     296                } 
    235297        } 
    236298 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r842 r891  
    1717        //      Loads a mesh file. 
    1818        openMeshFile(); 
    19          
    20         //      Debug. 
    21         cout    <<      "Vertex Count SubMesh 0:        " 
    22                                 <<      mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount 
    23                                 <<      endl; 
    24         //---------------------------------------------------------- 
    2519         
    2620        //      Deactive Lod strip visualization. 
     
    854848inline void GeoMeshViewUI::cb_mButtonProcess_i(fltk::Button*, void*) 
    855849{ 
     850        bool    error; 
    856851        Mesh    *mesh_aux; 
    857852         
     
    860855        mProcessBar->position(0); 
    861856 
     857        //      Initialize error flag. 
     858        error   =       false; 
     859         
    862860        //      If there is a mesh object. 
    863861        if (mGeoMesh != NULL) 
     
    877875                        case    EDGE_COLLAPSE: 
    878876 
     877                                //      Check submeshes for triangles strips. 
     878                                for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 
     879                                { 
     880                                        //      If current submesh is in triangle strips. 
     881                                        if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 
     882                                        { 
     883                                                error   =       true; 
     884                                        } 
     885                                } 
     886                                 
    879887                                //      if the mesh is stripified. 
    880                                 if (mGeoMesh->mType == GEO_TRIANGLE_STRIPS) 
     888                                if (error) 
    881889                                { 
    882890                                        fltk::alert("Can't simplify a mesh in triagle strips."); 
     
    903911                        case    LODSTRIPS_AUTO: 
    904912 
     913                                //      Check submeshes for triangles strips. 
     914                                for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 
     915                                { 
     916                                        //      If current submesh is in triangle strips. 
     917                                        if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 
     918                                        { 
     919                                                error   =       true; 
     920                                        } 
     921                                } 
     922                                 
    905923                                //      if the mesh is stripified. 
    906                                 if (mGeoMesh->mType == GEO_TRIANGLE_STRIPS) 
     924                                if (error) 
    907925                                { 
    908926                                        fltk::alert("Can't simplify a mesh in triagle strips."); 
     
    16171635                        geoSubMesh      =       &geoMesh->mSubMesh[submesh]; 
    16181636 
    1619                         switch (geoMesh->mType) 
     1637                        switch (geoSubMesh->mType) 
    16201638                        { 
    16211639                                case    GEO_TRIANGLE_LIST: 
     
    16431661        strip_count     =       0; 
    16441662         
    1645         if (geoMesh->mType == GEO_TRIANGLE_STRIPS) 
    1646         { 
    1647                 //      For each submesh. 
    1648                 for (int submesh        =       0; submesh < geoMesh->mSubMeshCount; submesh++) 
     1663        //      For each submesh. 
     1664        for (int submesh        =       0; submesh < geoMesh->mSubMeshCount; submesh++) 
     1665        { 
     1666                //      Gets the actual submesh. 
     1667                geoSubMesh      =       &geoMesh->mSubMesh[submesh]; 
     1668 
     1669                if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 
    16491670                { 
    1650                         //      Gets the actual submesh. 
    1651                         geoSubMesh      =       &geoMesh->mSubMesh[submesh]; 
    1652  
    16531671                        strip_count     +=      geoSubMesh->mStripCount; 
    16541672                }        
    16551673        } 
     1674 
    16561675        return  strip_count; 
    16571676} 
     
    16991718        simplificacionState     =       QSLIM; 
    17001719 
    1701         mMeshSimplifier = new ImageBasedSimplifier(mGeoMesh,    progress_function); 
     1720        mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, progress_function); 
    17021721 
    17031722        mMeshSimplifier->setMeshLeaves(idMeshLeaves); 
     
    17651784void    GeoMeshViewUI::simplifyLeavesCollapse() 
    17661785{ 
    1767         uint32                                          vi; 
    1768  
     1786        bool            error; 
     1787        uint32  vi; 
     1788 
     1789        //      Initialize      error flag. 
     1790        error   =       false; 
     1791         
     1792        //      Check submeshes for triangles strips. 
     1793        for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 
     1794        { 
     1795                //      If current submesh is in triangle strips. 
     1796                if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 
     1797                { 
     1798                        error   =       true; 
     1799                } 
     1800        } 
     1801                                 
    17691802        //      if the mesh is stripified. 
    1770         if (mGeoMesh->mType == GEO_TRIANGLE_STRIPS) 
     1803        if (error) 
    17711804        { 
    17721805                fltk::alert("Can't simplify a tree in triagle strips."); 
     
    18421875void    GeoMeshViewUI::stripify() 
    18431876{        
     1877        bool                                                    error; 
    18441878        char                                                    char_value[10]; 
    18451879        CustomStripifier        *geoStripifier; 
    18461880 
     1881        //      Initialize error flag. 
     1882        error   =       false; 
     1883 
     1884        //      Check submeshes for triangles strips. 
     1885        for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 
     1886        { 
     1887                //      If current submesh is in triangle strips. 
     1888                if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 
     1889                { 
     1890                        error   =       true; 
     1891                } 
     1892        } 
     1893                                 
    18471894        //      if the mesh is stripified. 
    1848         if (mGeoMesh->mType == GEO_TRIANGLE_STRIPS) 
     1895        if (error) 
    18491896        { 
    18501897                fltk::alert("The mesh is already in strips."); 
Note: See TracChangeset for help on using the changeset viewer.