Changeset 1083


Ignore:
Timestamp:
07/05/06 20:18:06 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
4 added
4 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj

    r1071 r1083  
    130130                        </File> 
    131131                        <File 
     132                                RelativePath=".\src\GeoMeshLoader.cpp"> 
     133                        </File> 
     134                        <File 
     135                                RelativePath=".\src\GeoMeshSaver.cpp"> 
     136                        </File> 
     137                        <File 
    132138                                RelativePath=".\src\GeoMeshSimplifier.cpp"> 
    133139                        </File> 
     
    370376                        <File 
    371377                                RelativePath=".\include\GeoMesh.h"> 
     378                        </File> 
     379                        <File 
     380                                RelativePath=".\include\GeoMeshLoader.h"> 
     381                        </File> 
     382                        <File 
     383                                RelativePath=".\include\GeoMeshSaver.h"> 
    372384                        </File> 
    373385                        <File 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h

    r1078 r1083  
    133133 
    134134                        //      Loads Mesh. 
    135                         void    LoadStripMesh(const LodStripsLibraryData &, Mesh *geomesh); 
     135                        void    LoadStripMesh(const LodStripsLibraryData *, Mesh *geomesh); 
    136136 
    137137                        Geometry::CREATEINDEXDATAFUNC create_index_data_func; 
     
    139139                        //      Strips vector. 
    140140                        SmallIntVector  *mStrips; 
     141                        int *indices_x_submesh; 
     142                        int *offsets_x_submesh; 
    141143 
    142144                        void UpdateDataRetrievalInterface(void);                         
     
    149151                         *      including the multiresolution object. 
    150152                        */ 
    151                         LodStripsLibrary(const LodStripsLibraryData &, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL); 
     153                        LodStripsLibrary(const LodStripsLibraryData *, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL); 
    152154 
    153155                        /// Destructor. 
     
    173175                        uint32  MinVertices(); 
    174176 
    175                         int *indices_x_submesh; 
     177                        uint32 GetValidIndexCount(int submeshid) const { return indices_x_submesh[submeshid]; } 
     178                        uint32 GetValidOffset(int submeshid) const { return offsets_x_submesh[submeshid]; } 
    176179        }; 
    177180} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h

    r1078 r1083  
    2222/*              LodTreeLibrary( const LodTreeLibrary &); 
    2323                LodTreeLibrary(LodTreeLibrary*);*/ 
    24                 LodTreeLibrary( const LodStripsLibraryData &, 
    25                                                 const TreeSimplificationSequence &, 
     24                LodTreeLibrary( const LodStripsLibraryData *, 
     25                                                const TreeSimplificationSequence *, 
    2626                                                Geometry::Mesh *treeGeoMesh, 
    2727                                                uint32 leafSubMeshID 
     
    5757/*              const VertexData* Get_Trunk_VertexData(void) const;*/ 
    5858                const IndexData* CurrentLOD_Trunk_Indices(void) const; 
     59                uint32 GetValidTrunkIndexCount(int isubmesh) const { return trunk->GetValidIndexCount(isubmesh); } 
     60                uint32 GetValidTrunkOffset(int isubmesh) const { return trunk->GetValidOffset(isubmesh); } 
    5961 
    6062//              uint32 Get_Foliage_VertexCount(void) const; 
     
    6466                const VertexData* Get_Foliage_VertexData(void) const; 
    6567 
    66 //              Geometry::IndexData *trunk_all_indices; 
    67 //              unsigned int *indices_offsets; 
    68  
    69 //              const Geometry::SmallIntVector & GetStrip(uint32 istrip) const { return trunk->mStrips[istrip]; } 
    70                 Geometry::LodStripsLibrary *trunk; 
    71  
    7268        private: 
    7369                Foliage *foliage; 
    74  
     70                Geometry::LodStripsLibrary *trunk; 
    7571        }; 
    7672} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r1078 r1083  
    1717//      Constructors. 
    1818//----------------------------------------------------------------------------- 
    19 LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData &lodstripsdata, Mesh *geomesh, CREATEINDEXDATAFUNC idfun) 
     19LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh, CREATEINDEXDATAFUNC idfun) 
    2020:create_index_data_func(idfun?idfun:DefaultIndexDataCreator) 
    2121{ 
     
    3333        dataRetrievalInterface=NULL; 
    3434        indices_x_submesh = NULL; 
     35        offsets_x_submesh = NULL; 
    3536         
    3637        //      Loads the Level Of Detail file. 
     
    5859        if (indices_x_submesh) 
    5960                delete[] indices_x_submesh; 
     61        if (offsets_x_submesh) 
     62                delete[] offsets_x_submesh; 
    6063} 
    6164 
     
    430433//      LoadStripMesh 
    431434//----------------------------------------------------------------------------- 
    432 void LodStripsLibrary::LoadStripMesh(const LodStripsLibraryData &lodstripsdata, Mesh *geomesh) 
     435void LodStripsLibrary::LoadStripMesh(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh) 
    433436{ 
    434437        FILE                                                                                                                    *fp; 
     
    451454        //      For each one of the submeshes. 
    452455        indices_x_submesh = new int[geomesh->mSubMeshCount]; 
     456        offsets_x_submesh = new int[geomesh->mSubMeshCount]; 
    453457        for (unsigned int submesh       =       0; submesh < geomesh->mSubMeshCount; submesh++) 
    454458        { 
     
    492496                        i       = 0; 
    493497                        indices_x_submesh[submesh] = 0; 
     498                        if (submesh==0) 
     499                                offsets_x_submesh[submesh] = 0; 
     500                        else 
     501                                offsets_x_submesh[submesh] = indices_x_submesh[submesh-1]; 
     502 
    494503                        //      For each index of the strip. 
    495504                        for (index = indexBegin; index < indexEnd; index++) 
     
    498507                                indices_x_submesh[submesh]++; 
    499508                                i++; 
    500                         } 
     509                        }                        
    501510                } 
    502511        } 
     
    559568                fclose(fp);*/ 
    560569 
    561         mFileVertices = lodstripsdata.mFileVertices; 
    562         mFileChangesLOD = lodstripsdata.mFileChangesLOD; 
    563         mData = lodstripsdata.mData; 
    564         p_changes = lodstripsdata.p_changes; 
     570        mFileVertices = lodstripsdata->mFileVertices; 
     571        mFileChangesLOD = lodstripsdata->mFileChangesLOD; 
     572        mData = lodstripsdata->mData; 
     573        p_changes = lodstripsdata->p_changes; 
    565574                 
    566575                 
     
    602611                { 
    603612                        indices_x_submesh[target_submesh] = counter; 
     613                        if (target_submesh==0) 
     614                                offsets_x_submesh[target_submesh] = 0; 
     615                        else 
     616                                offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 
     617 
    604618                        counter = 0; 
    605619                        strip_count = 0; 
     
    617631        { 
    618632                indices_x_submesh[target_submesh] = counter; 
     633                if (target_submesh==0) 
     634                        offsets_x_submesh[target_submesh] = 0; 
     635                else 
     636                        offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 
     637 
    619638                counter = 0; 
    620639                strip_count = 0; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp

    r1078 r1083  
    55using namespace Geometry; 
    66 
    7 Geometry::LodTreeLibrary::LodTreeLibrary(const LodStripsLibraryData &lodstripsdata, 
    8                                                                                  const TreeSimplificationSequence &simpseq, 
     7Geometry::LodTreeLibrary::LodTreeLibrary(const LodStripsLibraryData *lodstripsdata, 
     8                                                                                 const TreeSimplificationSequence *simpseq, 
    99                                                                                 Geometry::Mesh *treeGeoMesh, 
    1010                                                                                 uint32 leafSubMeshID/* 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp

    r1078 r1083  
    1010// Parameters --> None 
    1111//-------------------------------------------------------------------------------------------------------------------------------- 
    12 Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const Geometry::TreeSimplificationSequence & simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):  
     12Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const Geometry::TreeSimplificationSequence * simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):  
    1313Acth(NULL), 
    1414create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 
     
    304304 
    305305/// returns the number of total leafs 
    306 bool Foliage::ReadSimpSeq(const Geometry::TreeSimplificationSequence & simpSeq) 
     306bool Foliage::ReadSimpSeq(const Geometry::TreeSimplificationSequence * simpSeq) 
    307307{ 
    308308        int tn, tv1,tv2, e=0; 
    309309 
    310310        tn = leafCount; 
    311         for (std::vector<Geometry::TreeSimplificationSequence::Step>::const_iterator it = simpSeq.mSteps.begin(); it != simpSeq.mSteps.end(); it++) 
     311        for (std::vector<Geometry::TreeSimplificationSequence::Step>::const_iterator it = simpSeq->mSteps.begin(); it != simpSeq->mSteps.end(); it++) 
    312312        { 
    313313                Leaves[tn].vertsLeaf[0] = it->mNewQuad[0]; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h

    r1078 r1083  
    2727                int active_leaf_count; 
    2828 
    29                 Foliage (const Geometry::SubMesh *, const Geometry::TreeSimplificationSequence &, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); 
     29                Foliage (const Geometry::SubMesh *, const Geometry::TreeSimplificationSequence *, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); 
    3030                Foliage (const Foliage *); 
    3131                virtual ~Foliage (void); // Destructor 
     
    5757                void ReadLeafs(const Geometry::SubMesh *); 
    5858                void ReadVertices(const Geometry::SubMesh *); 
    59                 bool ReadSimpSeq(const Geometry::TreeSimplificationSequence &); /// returns true when successful 
     59                bool ReadSimpSeq(const Geometry::TreeSimplificationSequence *); /// returns true when successful 
    6060                void FillRoot(void); 
    6161 
  • GTP/trunk/Lib/Geom/shared/GeoTool/GeoTool.vcproj

    r1024 r1083  
    141141                        </File> 
    142142                        <File 
    143                                 RelativePath=".\src\GeoMeshLoader.cpp"> 
    144                         </File> 
    145                         <File 
    146                                 RelativePath=".\src\GeoMeshSaver.cpp"> 
    147                         </File> 
    148                         <File 
    149143                                RelativePath=".\src\GeoMeshView.cpp"> 
    150144                        </File> 
     
    165159                        <File 
    166160                                RelativePath=".\include\GeoMaterialLoader.h"> 
    167                         </File> 
    168                         <File 
    169                                 RelativePath=".\include\GeoMeshLoader.h"> 
    170                         </File> 
    171                         <File 
    172                                 RelativePath=".\include\GeoMeshSaver.h"> 
    173161                        </File> 
    174162                        <File 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h

    r1078 r1083  
    372372 
    373373        //      Initialize the lodstripslibrary for visualization. 
    374         void    setLodStripsLibrary(const Geometry::LodStripsLibraryData &, Mesh        *geomesh); 
     374        void    setLodStripsLibrary(const Geometry::LodStripsLibraryData *, Mesh        *geomesh); 
    375375        //      Initialize the lodtreelibrary for visualization. 
    376         void    setLodTreesLibrary(const Geometry::LodStripsLibraryData &, const Geometry::TreeSimplificationSequence &, Mesh   *geomesh, uint32 ileafSubMesh); 
     376        void    setLodTreesLibrary(const Geometry::LodStripsLibraryData *, const Geometry::TreeSimplificationSequence *, Mesh   *geomesh, uint32 ileafSubMesh); 
    377377 
    378378        // Indentify the mesh of leaves. 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r1078 r1083  
    892892        current_strip = 0; 
    893893 
    894         int begin_index = 0; 
    895  
    896894        //      For each submesh. 
    897895        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     
    968966                }*/ 
    969967 
    970                 int indices_to_render = lodStripsLib->indices_x_submesh[submesh]; 
    971  
     968                int indices_to_render = lodStripsLib->GetValidIndexCount(submesh); 
     969                int offset = lodStripsLib->GetValidOffset(submesh); 
    972970 
    973971                glBegin(GL_TRIANGLE_STRIP); 
    974972                //for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 
    975                 for (int index = begin_index; index < indices_to_render+begin_index; index ++) 
     973                for (int index = offset; index < indices_to_render+offset; index ++) 
    976974                { 
    977975                        position = lodStripsLib->dataRetrievalInterface->GetIndex(index); 
     
    10071005                } 
    10081006                glEnd(); 
    1009                 begin_index += indices_to_render; 
    10101007 
    10111008        } 
     
    10321029 
    10331030        // DRAW THE TRUNK AS A LODSTRIP OBJECT 
    1034  
    1035         int begin_index = 0; 
    1036  
    10371031        //      For each submesh. 
    10381032        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     
    11121106                }*/ 
    11131107         
    1114                 int indices_to_render = lodTreeLib->trunk->indices_x_submesh[submesh]; 
     1108//              int indices_to_render = lodTreeLib->trunk->GetValidIndexCount(submesh); 
     1109                int indices_to_render = lodTreeLib->GetValidTrunkIndexCount(submesh); 
     1110                int begin_index = lodTreeLib->GetValidTrunkOffset(submesh); 
    11151111                         
    11161112                glBegin(GL_TRIANGLE_STRIP); 
    1117                 for (int index = begin_index; index < lodTreeLib->trunk->indices_x_submesh[submesh]; index ++) 
     1113                for (int index = begin_index; index < indices_to_render+begin_index; index ++) 
    11181114                { 
    11191115                        position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); 
     
    11491145                } 
    11501146                glEnd(); 
    1151                 begin_index += indices_to_render; 
    1152  
    11531147        } 
    11541148 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r1078 r1083  
    795795inline void GeoMeshViewUI::cb_menuLodStripsVisualize_i(fltk::Item*, void*) 
    796796{ 
    797         fltk::FileChooser *fcho; 
    798         const   char                            *lod_file; 
    799          
    800797        //      Sets menus application state to NONE. 
    801798        mApplicationState       =       NONE; 
     
    811808        if (mGeoMesh != NULL) 
    812809        { 
    813 /*              fcho    =       new fltk::FileChooser("", 
    814                                 "*.lod", 
    815                                 fltk::FileChooser::CREATE, 
    816                                 "Open Lod file"); 
    817  
    818                 fcho->exec(); 
    819  
    820                 //      If a file was selected. 
    821                 if (fcho->value()) 
    822                 {*/ 
     810                if (geoMeshLoader->GetLodStripsData()) 
     811                { 
    823812                        //      Build lod strips library. 
    824                         setLodStripsLibrary(geoMeshLoader->lodstripsdata, mGeoMesh); 
     813                        setLodStripsLibrary(geoMeshLoader->GetLodStripsData(), mGeoMesh); 
    825814 
    826815                        //      Sets the aplication mode. 
    827816                        mApplicationState       =       VISUALIZE_LODSTRIPS; 
    828         /*      } 
    829  
    830                 //      Free memory. 
    831                 delete  fcho;*/ 
    832  
    833                 //      Hide the right panel. 
    834                 hideRightPanel(); 
    835  
    836                 //      Show title. 
    837                 mProcessTitle->label("Visualize LodStrips"); 
    838  
    839                 //      Show the Visulize LodStrips panel. 
    840                 showLodStripSlider(); 
    841  
    842                 //      Repaint the window. 
    843                 mMainWindow->redraw(); 
    844  
     817                 
     818                        //      Hide the right panel. 
     819                        hideRightPanel(); 
     820 
     821                        //      Show title. 
     822                        mProcessTitle->label("Visualize LodStrips"); 
     823 
     824                        //      Show the Visulize LodStrips panel. 
     825                        showLodStripSlider(); 
     826 
     827                        //      Repaint the window. 
     828                        mMainWindow->redraw(); 
     829                } 
     830                else 
     831                { 
     832                        fltk::alert("The loaded mesh does not contain LOD information.\nNothing will be done."); 
     833                } 
    845834        } 
    846835} 
     
    848837inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) 
    849838{ 
    850         fltk::FileChooser *fcho; 
    851         const   char                            *lod_file; 
    852  
    853839        //      Sets menus application state to NONE. 
    854840        mApplicationState       =       NONE; 
     
    861847        openMeshFile(); 
    862848 
    863         /*if (geoMeshView->getLeavesSubmesh()==-1) 
    864                 { 
    865                 fltk::alert("No se ha seleccionado el submesh de hojas!"); 
    866                 return; 
    867                 }*/ 
    868  
    869849        //      If an object is loaded. 
    870850        if (mGeoMesh != NULL) 
    871851        { 
    872                 // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS 
    873                 int leafsSubMeshID = -1; 
    874  
    875                 for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 
     852                if (geoMeshLoader->GetTreeSimpSeq() && geoMeshLoader->GetLodStripsData()) 
    876853                { 
    877                         if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 
     854                        // select the first triangle-list submesh as leaves submesh 
     855                        int leafsSubMeshID = -1; 
     856 
     857                        for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 
    878858                        { 
    879                                 leafsSubMeshID=i; 
    880                                 break; 
     859                                if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 
     860                                { 
     861                                        leafsSubMeshID=i; 
     862                                        break; 
     863                                } 
    881864                        } 
    882                 } 
    883  
    884                 //      If an object is loaded. 
    885 /*              if (mGeoMesh != NULL) 
    886                 { 
    887                         fcho    =       new fltk::FileChooser("", 
    888                                         "*.mesh", 
    889                                         fltk::FileChooser::CREATE, 
    890                                         "Open Lod file"); 
    891  
    892                         fcho->exec(); 
    893  
    894                         //      If a file was selected. 
    895                         if (fcho->value()) 
    896                         { 
    897                                 //      Build lod strips library. 
    898  
    899                                 std::string lodstripFile(fcho->value()); 
    900                                 delete fcho; 
    901                                 fcho    =       new fltk::FileChooser("", 
    902                                                 "*.leafseq", 
    903                                                 fltk::FileChooser::CREATE, 
    904                                                 "Open LeafSeq file"); 
    905  
    906                                 fcho->exec(); 
    907  
    908                                 if (fcho->value()) 
    909                                 { 
    910                                         std::string leafseqFile(fcho->value());*/ 
    911  
    912                                         //setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 
    913                                         setLodTreesLibrary(geoMeshLoader->lodstripsdata, geoMeshLoader->treesimpseq, mGeoMesh, leafsSubMeshID); 
    914  
    915                                         //      Sets the aplication mode. 
    916                                         mApplicationState       =       VISUALIZE_LODTREES; 
    917 /*                              } 
    918                         } 
    919  
    920                         //      Free memory. 
    921                         delete  fcho; 
    922 */ 
     865 
     866                        setLodTreesLibrary(geoMeshLoader->GetLodStripsData(), geoMeshLoader->GetTreeSimpSeq(), mGeoMesh, leafsSubMeshID); 
     867 
     868                        //      Sets the aplication mode. 
     869                        mApplicationState       =       VISUALIZE_LODTREES; 
     870 
    923871                        //      Hide the right panel. 
    924872                        hideRightPanel(); 
     
    933881                        //      Repaint the window. 
    934882                        mMainWindow->redraw(); 
    935 /*              }*/ 
     883                } 
     884                else 
     885                        fltk::alert("The loaded mesh does not contain LOD information.\nNothing will be done."); 
    936886        } 
    937887} 
     
    23672317//      Initialize the lodstripslibrary for visualization. 
    23682318//--------------------------------------------------------------------------- 
    2369 void    GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData &loddata, Mesh  *geomesh) 
     2319void    GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData *loddata, Mesh  *geomesh) 
    23702320{ 
    23712321        //      If there is no lod strips object. 
     
    23922342//      Initialize the lodTreelibrary for visualization. 
    23932343//--------------------------------------------------------------------------- 
    2394 void    GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData &lodstripsdata, const TreeSimplificationSequence &treesimpseq, Mesh *geomesh, uint32 ileafSubMesh) 
     2344void    GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData *lodstripsdata, const TreeSimplificationSequence *treesimpseq, Mesh *geomesh, uint32 ileafSubMesh) 
    23952345{ 
    23962346        //      If there is no lod strips object. 
    23972347        if (lodTreeLib) 
    2398         { 
    23992348                delete  lodTreeLib; 
    2400         } 
    24012349 
    24022350        //      New lod strips object. 
Note: See TracChangeset for help on using the changeset viewer.