Changeset 829


Ignore:
Timestamp:
04/26/06 16:00:29 (18 years ago)
Author:
gumbau
Message:

Added LodTreeLibrary? working only for trunks

Location:
GTP/trunk/Lib/Geom/shared
Files:
9 edited

Legend:

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

    r774 r829  
    286286                        </File> 
    287287                        <File 
    288                                 RelativePath=".\src\libs\GeoLodStripsConstructor.h"> 
    289                         </File> 
    290                         <File 
    291                                 RelativePath=".\src\libs\GeoLodStripsLibrary.h"> 
    292                         </File> 
    293                         <File 
    294                                 RelativePath=".\src\libs\GeoLodTreeConstructor.h"> 
    295                         </File> 
    296                         <File 
    297                                 RelativePath=".\src\libs\GeoLodTreeLibrary.h"> 
    298                         </File> 
    299                         <File 
    300                                 RelativePath=".\src\libs\GeoMesh.h"> 
    301                         </File> 
    302                         <File 
    303                                 RelativePath=".\src\libs\GeoMeshSimplifier.h"> 
    304                         </File> 
    305                         <File 
    306                                 RelativePath=".\src\libs\GeoMeshSimpSequence.h"> 
    307                         </File> 
    308                         <File 
    309                                 RelativePath=".\src\libs\GeoMeshStripifier.h"> 
    310                         </File> 
    311                         <File 
    312                                 RelativePath=".\src\libs\GeoSerializable.h"> 
    313                         </File> 
    314                         <File 
    315                                 RelativePath=".\src\libs\GeoSerializer.h"> 
    316                         </File> 
    317                         <File 
    318                                 RelativePath=".\src\libs\GeoSubMesh.h"> 
    319                         </File> 
    320                         <File 
    321                                 RelativePath=".\src\libs\GeoTreeSimplifier.h"> 
    322                         </File> 
    323                         <File 
    324                                 RelativePath=".\src\libs\GeoTreeSimpSequence.h"> 
    325                         </File> 
    326                         <File 
    327                                 RelativePath=".\src\libs\GeoVector2.h"> 
    328                         </File> 
    329                         <File 
    330                                 RelativePath=".\src\libs\GeoVector3.h"> 
    331                         </File> 
    332                         <File 
    333                                 RelativePath=".\src\libs\GeoVertexBuffer.h"> 
    334                         </File> 
    335                         <File 
    336                                 RelativePath=".\src\libs\hoja.h"> 
     288                                RelativePath=".\include\GeoLodStripsConstructor.h"> 
     289                        </File> 
     290                        <File 
     291                                RelativePath=".\include\GeoLodStripsLibrary.h"> 
     292                        </File> 
     293                        <File 
     294                                RelativePath=".\include\GeoLodTreeConstructor.h"> 
     295                        </File> 
     296                        <File 
     297                                RelativePath=".\include\GeoLodTreeLibrary.h"> 
     298                        </File> 
     299                        <File 
     300                                RelativePath=".\include\GeoMesh.h"> 
     301                        </File> 
     302                        <File 
     303                                RelativePath=".\include\GeoMeshSimplifier.h"> 
     304                        </File> 
     305                        <File 
     306                                RelativePath=".\include\GeoMeshSimpSequence.h"> 
     307                        </File> 
     308                        <File 
     309                                RelativePath=".\include\GeoMeshStripifier.h"> 
     310                        </File> 
     311                        <File 
     312                                RelativePath=".\include\GeoSerializable.h"> 
     313                        </File> 
     314                        <File 
     315                                RelativePath=".\include\GeoSerializer.h"> 
     316                        </File> 
     317                        <File 
     318                                RelativePath=".\include\GeoSubMesh.h"> 
     319                        </File> 
     320                        <File 
     321                                RelativePath=".\include\GeoTreeSimplifier.h"> 
     322                        </File> 
     323                        <File 
     324                                RelativePath=".\include\GeoTreeSimpSequence.h"> 
     325                        </File> 
     326                        <File 
     327                                RelativePath=".\include\GeoVector2.h"> 
     328                        </File> 
     329                        <File 
     330                                RelativePath=".\include\GeoVector3.h"> 
     331                        </File> 
     332                        <File 
     333                                RelativePath=".\include\GeoVertexBuffer.h"> 
     334                        </File> 
     335                        <File 
     336                                RelativePath=".\include\hoja.h"> 
    337337                        </File> 
    338338                        <File 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h

    r774 r829  
    99        *       @file   GeoLodStripsLibrary.h 
    1010/*===========================================================================*/ 
     11 
     12#ifndef _GEOLODSTRIPSLIBRARY 
     13#define _GEOLODSTRIPSLIBRARY 
    1114 
    1215#include        "GeoMesh.h" 
     
    150153 
    151154                        //      (New)   Get the number of strips. 
    152                         uint32  GetStripCount(); 
     155                        uint32  GetStripCount() const; 
     156                        uint32  GetIndexCountByStrip(uint32) const; 
    153157        }; 
    154158} 
    155159 
     160 
     161#endif 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h

    r774 r829  
    1 #include "GeoBase.h" 
     1//#include <string> 
     2//#include <exception> 
     3//#include "vertexdata.h" 
    24 
     5#ifndef _GEOLODSTREELIBRARY 
     6#define _GEOLODSTREELIBRARY 
     7 
     8#include "GeoMesh.h" 
     9#include "GeoLodStripsLibrary.h" 
     10 
     11/*class LodStrip; 
     12class Arbol; 
     13class Foliage; 
     14class Point3D; 
     15*/ 
    316namespace Geometry 
    4 { 
    5         /// LodTreeLibrary interface class. 
    6         /** This module contains functions that handle the levels of detail of the input multiresolution trees. 
    7         For Any given resolution and object this module returns two thins: a set of triangle strips representing the trunk  
    8         and the branches at that resolution, and a triangle list representing the leaves at the same resolution.  
    9         \n\n 
    10  
    11 Inputs:\n 
    12         - The module receives a file describing a multiresolution tree object. 
    13         . 
    14  
    15 Outputs:\n 
    16         - The module returns a strip set that represents the level of deatil demanded for the trunk and a triangle list  
    17         that representes the level of detail for leaves. 
    18         . 
    19  
    20         */ 
     17{        
    2118        class LodTreeLibrary 
    2219        { 
    2320        public: 
    24                 /// Constructor, receives as a parameter the name of the file including the multiresolution object. 
    25                 LodTreeLibrary (std::string); 
     21/*              LodTreeLibrary( const LodTreeLibrary &); 
     22                LodTreeLibrary(LodTreeLibrary*);*/ 
     23                LodTreeLibrary( std::string trunkSimpSeqFile, 
     24                                                Geometry::Mesh *treeGeoMesh 
     25                                                /*, 
     26                                                std::string foliage_verts, 
     27                                                std::string foliage_leafs, 
     28                                                std::string foliage_simpl, 
     29                                                uint32 leafSubMeshID, 
     30                                                CREATEVERTEXDATAFUNC vdfun=NULL,  
     31                                                CREATEINDEXDATAFUNC idfun=NULL, 
     32                                                CREATEMULTIINDEXDATAFUNC midfun=NULL*/); // throws a FileNotFound exception 
     33                ~LodTreeLibrary(void); 
     34                uint32 GetUniqueID(void) const { return  uniqueID; } 
    2635 
    27                 /// Destructor. 
    28                 ~LodTreeLibrary (void); 
     36                // funciones ya descritas en la API 
     37                uint32 GoToTrunkLod(uint32 newlod); 
     38                uint32 MinTrunkLod(void) const; 
     39                uint32 MaxTrunkLod(void) const; 
     40/*              uint32 GoToFoliageLod(uint32 newlod); 
     41                uint32 MinFoliageLod(void) const; 
     42                uint32 MaxFoliageLod(void) const;*/ 
    2943 
    30                 /// Copy constructor 
    31                 //LodTreeLibrary(const LodTreeLibrary&); 
     44                // funciones nuevas propuestas 
     45//              uint32 Get_Trunk_VertexCount(void) const; 
     46//              uint32 Get_Trunk_MaxIndexCount(uint32 istrip) const; 
     47                uint32 CurrentLOD_Trunk_StripCount(void) const; 
     48//              uint32 CurrentLOD_Trunk_IndexCount(void) const; 
     49                uint32 CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const; 
     50/*              const VertexData* Get_Trunk_VertexData(void) const; 
     51//              const MultiIndexData* CurrentLOD_Trunk_Indices(void) const;*/ 
    3252 
    33                 /// Assignment operator 
    34                 //LodTreeLibrary& operator =(const LodTreeLibrary&); 
     53//              uint32 Get_Foliage_VertexCount(void) const; 
     54//              uint32 Get_Foliage_MaxIndexCount(void) const; 
     55//              uint32 CurrentLOD_Foliage_IndexCount(void) const; 
     56/*              const IndexData* CurrentLOD_Foliage_Indices(void) const; 
     57                const VertexData* Get_Foliage_VertexData(void) const; 
     58*/ 
     59//              Geometry::IndexData *trunk_all_indices; 
     60//              unsigned int *indices_offsets; 
    3561 
    36                 /// Returns the highest LOD of the foliage. 
    37                 uint32 MaxFoliageLod(); 
     62                const Geometry::SmallIntVector & GetStrip(uint32 istrip) const { return trunk->mStrips[istrip]; } 
    3863 
    39                 /// Returns the highest LOD of the trunk. 
    40                 uint32 MaxTrunkLod(); 
    41  
    42                 /// Returns the lowest LOD of the foliage. 
    43                 uint32 MinFoliageLod(); 
    44  
    45                 /// Returns the lowest LOD of the trunk. 
    46                 uint32 MinTrunkLod(); 
    47  
    48                 /// Returns de current foliage LOD and changes to the specified LOD. 
    49                 uint32 GoToFoliageLod(uint32); 
    50  
    51                 /// Returns de current trunk LOD and changes to the specified LOD. 
    52                 uint32 GoToTrunkLod(uint32); 
    53  
    54                 /// Establishes the new LOD range. 
    55                 /// Only the LODs in that range are stored and used. 
    56                 void TrimFoliageByLod(uint32, uint32); 
    57  
    58                 /// Establishes the new LOD range. 
    59                 /// Only the LODs in that range are stored and used. 
    60                 void TrimTrunkByLod(uint32, uint32); 
    61  
    62                 /// Returns the number of triangles of the foliage at the highest LOD. 
    63                 uint32 MaxFoliageFaces(); 
    64  
    65                 /// Returns the number of triangles of the trunk at the highest LOD. 
    66                 uint32 MaxTrunkFaces(); 
    67  
    68                 /// Returns the number of triangles of the foliage at the lowest LOD. 
    69                 uint32 MinFoliageFaces(); 
    70  
    71                 /// Returns the number of triangles of the trunk at the lowest LOD. 
    72                 uint32 MinTrunkFaces(); 
    73  
    74                 /// Returns the number of vertices of the foliage at the highest LOD. 
    75                 uint32 MaxFoliageVertices(); 
    76  
    77                 /// Returns the number of vertices of the trunk at the highest LOD. 
    78                 uint32 MaxTrunkVertices(); 
    79  
    80                 /// Returns the number of vertices of the foliage at the lowest LOD. 
    81                 uint32 MinFoliageVertices(); 
    82  
    83                 /// Returns the number of vertices of the trunk at the lowest LOD. 
    84                 uint32 MinTrunkVertices(); 
     64        private: 
     65                uint32 uniqueID; 
     66                Geometry::LodStripsLibrary *trunk; 
     67//              Arbol *arbol; 
     68//              Foliage *foliage; 
    8569 
    8670        }; 
    8771} 
     72 
     73#endif 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r774 r829  
    406406} 
    407407 
    408 uint32  LodStripsLibrary::GetStripCount() 
     408uint32  LodStripsLibrary::GetStripCount() const 
    409409{ 
    410410        return  (uint32)        mTotalStrips; 
     411} 
     412 
     413uint32  LodStripsLibrary::GetIndexCountByStrip(uint32 istrip) const 
     414{ 
     415        return (uint32) mStrips[istrip].size(); 
    411416} 
    412417 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp

    r774 r829  
     1//#include "defs.h" 
     2#include <assert.h> 
    13#include "GeoLodTreeLibrary.h" 
     4//#include "ArbolesInma/Arbol.h" 
     5//#include "ArbolesInma/Foliage.h" 
     6 
     7using namespace Geometry; 
     8 
     9uint32 uniqueIDgen = 0; 
     10 
     11Geometry::LodTreeLibrary::LodTreeLibrary(std::string trunkSimpSeqFile, 
     12                                                           Geometry::Mesh *treeGeoMesh  
     13                                                           /*, 
     14                                                           std::string foliage_verts,  
     15                                                           std::string foliage_leafs,  
     16                                                           std::string foliage_simpl, 
     17                                                           uint32 leafSubMeshID, 
     18                                                           CREATEVERTEXDATAFUNC vdfun, 
     19                                                           CREATEINDEXDATAFUNC idfun, 
     20                                                           CREATEMULTIINDEXDATAFUNC midfun*/) 
     21{ 
     22        uniqueID = uniqueIDgen++; 
     23 
     24        // Cargar el tronco 
     25/*      trunk=new LodStrip(vdfun,midfun); 
     26        trunk->ED_NUEVA=1; 
     27        trunk->RESVARIABLE=0; 
     28        trunk->MODOTEST=0; //0: No test 1: plano  2: esfera 
     29        trunk->bTextures=0; 
     30        if (trunk->RecuperarModeloEFFICIENT((char*)trunkfile.c_str())==0) 
     31                throw FileNotFound(trunkfile); 
     32 
     33//      trunk->LodsDisp=(int) (trunk->cVerts.size()*0.99); 
     34        trunk->LodsDisp=(int) (trunk->TOTALCAMBIOS*0.95); 
     35        trunk->CopiarVectors2ArraysNUEVAED(); 
     36        trunk->LodActual=0; 
     37        trunk->CalculaNormalesVertice();*/ 
     38 
     39        trunk = new LodStripsLibrary(trunkSimpSeqFile,treeGeoMesh); 
     40 
     41        // Cargar la copa del árbol 
     42/*      arbol = new Arbol(foliage_verts.c_str(),foliage_leafs.c_str(),foliage_simpl.c_str(),vdfun,idfun); 
     43        foliage = new Foliage(arbol);*/ 
     44 
     45} 
     46/* 
     47LodTreeLibrary::LodTreeLibrary(const LodTreeLibrary &t) 
     48{ 
     49        uniqueID = uniqueIDgen++; 
     50        assert( 
     51//      trunk=new LodStrip(t.trunk); 
     52        arbol=new Arbol(t.arbol); 
     53        foliage=new Foliage(arbol); 
     54} 
     55 
     56LodTreeLibrary::LodTreeLibrary(LodTreeLibrary *t) 
     57{ 
     58        uniqueID = uniqueIDgen++; 
     59        trunk=new LodStrip(t->trunk);  
     60        arbol=new Arbol(t->arbol); 
     61        foliage=new Foliage(arbol); 
     62} 
     63*/ 
     64 
     65LodTreeLibrary::~LodTreeLibrary(void) 
     66{ 
     67        if (trunk) delete trunk; 
     68//      if (arbol) delete arbol; 
     69//      if (foliage) delete foliage; 
     70/*      if (trunk_all_indices) delete trunk_all_indices; 
     71        if (indices_offsets) delete[] indices_offsets; 
     72//      if (current_foliage_indices) delete[] current_foliage_indices;*/ 
     73} 
     74 
     75uint32 LodTreeLibrary::CurrentLOD_Trunk_StripCount(void) const 
     76{ 
     77        assert(trunk); 
     78//      return trunk->TOTALTIRAS; 
     79        return trunk->GetStripCount(); 
     80} 
     81 
     82 
     83uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const 
     84{ 
     85        assert(trunk); 
     86//      return trunk->lStripsV[istrip].size(); 
     87        return trunk->GetIndexCountByStrip(istrip); 
     88} 
     89/* 
     90uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCount(void) const 
     91{ 
     92        assert(trunk); 
     93        return trunk->num_indices_current_lod; 
     94} 
     95*/ 
     96 
     97uint32 LodTreeLibrary::GoToTrunkLod(uint32 newlod) 
     98{ 
     99        return trunk->GoToLod(newlod); 
     100/*      uint32 previouslod = trunk->LodActual; 
     101        trunk->VerModeloVBO(newlod); 
     102        return previouslod;*/ 
     103} 
     104 
     105uint32 LodTreeLibrary::MinTrunkLod(void) const 
     106{ 
     107//      return 3; // un polígono: preguntar a francisco 
     108//      return (trunk->TOTALCAMBIOS*0.95f); 
     109        return trunk->MinLod(); 
     110} 
     111uint32 LodTreeLibrary::MaxTrunkLod(void) const 
     112{ 
     113//      return (trunk->cVerts.size()*0.99); 
     114//      return (trunk->TOTALCAMBIOS*0.95f); 
     115//      return 0; 
     116        return trunk->MaxLod(); 
     117} 
     118 
     119/* 
     120uint32 LodTreeLibrary::GoToFoliageLod(uint32 newlod) 
     121{ 
     122        foliage->AjusteHojas(newlod); 
     123 
     124        arbol->indexdata->Begin(); 
     125        arbol->vertexdata->Begin(); 
     126        int i = foliage->ppio; 
     127        int auxnumhojas = 0; 
     128        while(i!=-1) 
     129        { 
     130                auxnumhojas++; 
     131                i=foliage->Acth[i].next; 
     132        } 
     133 
     134        assert(auxnumhojas*6<=arbol->indexdata->GetNumMaxIndices()); 
     135        arbol->indexdata->SetNumValidIndices(auxnumhojas*6); 
     136        i = foliage->ppio; 
     137        int kkkk=0; 
     138        while(i!=-1) 
     139        { 
     140                unsigned int v0,v1,v2,v3; 
     141                v0 = arbol->Hojas[i].Vert_Hoja[0]; 
     142                v1 = arbol->Hojas[i].Vert_Hoja[1]; 
     143                v2 = arbol->Hojas[i].Vert_Hoja[2]; 
     144                v3 = arbol->Hojas[i].Vert_Hoja[3]; 
     145 
     146                arbol->indexdata->SetIndex(kkkk+0,v0); 
     147                arbol->indexdata->SetIndex(kkkk+1,v1); 
     148                arbol->indexdata->SetIndex(kkkk+2,v2); 
     149                arbol->indexdata->SetIndex(kkkk+3,v2); 
     150                arbol->indexdata->SetIndex(kkkk+4,v1); 
     151                arbol->indexdata->SetIndex(kkkk+5,v3); 
     152 
     153                arbol->vertexdata->SetVertexTexCoord(v0,0,0); 
     154                arbol->vertexdata->SetVertexTexCoord(v1,0,1); 
     155                arbol->vertexdata->SetVertexTexCoord(v2,1,0); 
     156                arbol->vertexdata->SetVertexTexCoord(v3,1,1);  
     157 
     158                kkkk+=6; 
     159                i=foliage->Acth[i].next; 
     160        } 
     161        arbol->indexdata->End(); 
     162        arbol->vertexdata->End(); 
     163 
     164        return 0; 
     165} 
     166 
     167uint32 LodTreeLibrary::MinFoliageLod(void) const 
     168{ 
     169        return arbol->minHojas; // una hoja: preguntar a francisco 
     170} 
     171uint32 LodTreeLibrary::MaxFoliageLod(void) const 
     172{ 
     173//      return arbol->TotHojas; 
     174        return arbol->nHojas; 
     175} 
     176*/ 
     177/*const VertexData* LodTreeLibrary::Get_Trunk_VertexData(void) const  
     178{  
     179        return trunk->vertices;  
     180} 
     181const MultiIndexData* LodTreeLibrary::CurrentLOD_Trunk_Indices(void) const  
     182{  
     183//      return (uint32*)trunk->vStrips[istrip];  
     184//      return trunk->indices_x_tira[istrip]; 
     185        return trunk->indices; 
     186}*/ 
     187 
     188/* 
     189const VertexData* LodTreeLibrary::Get_Foliage_VertexData(void) const 
     190{ 
     191        return arbol->vertexdata; 
     192} 
     193 
     194const IndexData* LodTreeLibrary::CurrentLOD_Foliage_Indices(void) const 
     195{ 
     196//      return current_foliage_indices; 
     197        return arbol->indexdata; 
     198}*/ 
     199 
     200 
     201/*void ThrowFileNotFoundError(const char *text) 
     202{ 
     203        throw Geometry::FileNotFound(text); 
     204}*/ 
     205/* 
     206uint32 LodTreeLibrary::CurrentLOD_Foliage_IndexCount(void) const 
     207{ 
     208//      return current_foliage_indexcount; 
     209        return arbol->indexdata->GetNumValidIndices(); 
     210} 
     211 
     212uint32 LodTreeLibrary::Get_Trunk_VertexCount(void) const 
     213{ 
     214        return trunk->TOTALVERTS; 
     215} 
     216 
     217uint32 LodTreeLibrary::Get_Trunk_MaxIndexCount(uint32 istrip) const 
     218{ 
     219//      return trunk->indices_x_tira[istrip]->GetNumMaxIndices(); 
     220        return trunk->indices->GetNumMaxIndices(istrip); 
     221} 
     222 
     223uint32 LodTreeLibrary::Get_Foliage_VertexCount(void) const 
     224{ 
     225        return arbol->vertexdata->GetNumVertices(); 
     226} 
     227uint32 LodTreeLibrary::Get_Foliage_MaxIndexCount(void) const 
     228{ 
     229        return arbol->indexdata->GetNumMaxIndices(); 
     230} 
     231*/ 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h

    r826 r829  
    1414#include        <GeoMeshSaver.h> 
    1515#include        <GeoMeshViewUI.h> 
    16 //#include      <GeoLodStripsLibrary.h> 
     16 
    1717//#endif 
     18namespace Geometry{ class LodTreeLibrary; } 
    1819 
    1920class GeoMeshView : public fltk::GlWindow 
     
    3334        bool            mRotate; 
    3435        bool            mLodStrip; 
     36        bool            mLodTree; 
    3537 
    3638        GeoMeshView(int                                         x, 
     
    9496 
    9597        //      Counter Clockwise mode. 
    96         void    activeCCW(){mCCW        =       true;}; 
    97         void    deactiveCCW(){mCCW      =       false;}; 
     98        void    activeCCW(){mCCW        =       true;} 
     99        void    deactiveCCW(){mCCW      =       false;} 
    98100 
    99101        //      Pan mode. 
    100         void    activePan(){mPan        =       true;}; 
    101         void    deactivePan(){mPan      =       false;}; 
     102        void    activePan(){mPan        =       true;} 
     103        void    deactivePan(){mPan      =       false;} 
    102104 
    103105        //      Rotate mode. 
    104         void    activeRotate(){mRotate  =       true;}; 
    105         void    deactiveRotate(){mRotate        =       false;}; 
     106        void    activeRotate(){mRotate  =       true;} 
     107        void    deactiveRotate(){mRotate        =       false;} 
    106108 
    107109        //      LodStrip mode. 
    108         void    activeLodStrip(){mLodStrip      =       true;}; 
    109         void    deactiveLodStrip(){mLodStrip    =       false;}; 
     110        void    activeLodStrip(){mLodStrip      =       true;} 
     111        void    deactiveLodStrip(){mLodStrip    =       false;} 
     112 
     113        //      LodTree mode. 
     114        void    activeLodTree(){mLodTree        =       true;} 
     115        void    deactiveLodTree(){mLodTree      =       false;} 
     116 
    110117 
    111118        //      Ilumination modes. 
     
    158165        //      Sets the lodstripslibrary object. 
    159166        void    setLodStripsLibrary(Geometry::LodStripsLibrary *lodstrips); 
     167        //      Sets the lodtreeslibrary object. 
     168        void    setLodTreesLibrary(Geometry::LodTreeLibrary *lodtrees); 
    160169 
    161170        //      Change de Level of detail of the object. 
     
    174183        //      LodStrips library object. 
    175184        Geometry::LodStripsLibrary      *lodStripsLib; 
     185        //      LodTree library object. 
     186        Geometry::LodTreeLibrary        *lodTreeLib; 
    176187         
    177188        //      Flag tha activate / deactivate the color strips. 
     
    206217        void    drawTriangleStrip(int submesh); 
    207218        void    drawLodStrip(); 
     219        void    drawLodTree(); 
    208220        void    enableColorStrips(); 
    209221        void    disableColorStrips(); 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h

    r774 r829  
    4242#include        "GeoTreeSimpSequence.h" 
    4343#include        "GeoLodStripsConstructor.h" 
     44#include        "GeoLodTreeLibrary.h" 
    4445 
    4546//      About Dialog. 
     
    5859        LODTREES, 
    5960        SELECT_LEAVES, 
    60         VISUALIZE_LODSTRIPS 
     61        VISUALIZE_LODSTRIPS, 
     62        VISUALIZE_LODTREES 
    6163}; 
    6264 
     
    9698        //      Lod strips object. 
    9799        LodStripsLibrary        *lodStripsLib; 
     100        //      Lod tree object. 
     101        LodTreeLibrary  *lodTreeLib; 
    98102         
    99103        //      Mesh Bounds. 
     
    170174        inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); 
    171175        static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); 
     176        inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); 
     177        static void cb_menuLodTreesVisualize(fltk::Item*, void*); 
    172178        inline void cb_menuHelpAbout_i(fltk::Item*, void*); 
    173179        static void cb_menuHelpAbout(fltk::Item*, void*); 
     
    206212         
    207213        //      Show the LodStrips visulization panel. 
    208         void    showVisualizeLodStrips(); 
     214        void    showSlider(); 
    209215 
    210216        void    hideStripify(); 
     
    218224 
    219225        //      Hide the LodStrips visualization panel. 
    220         void    hideVisualizeLodStrips(); 
     226        void    hideSlider(); 
    221227         
    222228        //      Get the number of vertices. 
     
    292298        fltk::Item                                      *menuLodStripsVisualize; 
    293299        fltk::ItemGroup                 *menuLodTrees; 
     300        fltk::Item                                      *menuLodTreesVisualize; 
    294301 
    295302        fltk::Item                                      *menuSelectLeaves; 
     
    333340        //      Initialize the lodstripslibrary for visualization. 
    334341        void    setLodStripsLibrary(std::string lodfile, Mesh   *geomesh); 
     342        //      Initialize the lodtreelibrary for visualization. 
     343        void    setLodTreesLibrary(std::string lodfile, Mesh    *geomesh); 
    335344 
    336345        // 26-12-2005 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r826 r829  
    586586                        drawLodStrip(); 
    587587                } 
     588                else if (mLodTree) 
     589                { 
     590                        drawLodTree(); 
     591                } 
    588592                else 
    589593                { 
     
    892896}//End drawTriangleStrip. 
    893897 
     898 
     899//--------------------------------------------------------------------------- 
     900//      Paint lodtree object. 
     901//--------------------------------------------------------------------------- 
     902void GeoMeshView::drawLodTree() 
     903{ 
     904        SubMesh                         *geosubmesh; 
     905        Index                                   position; 
     906        Vector3                         vector3; 
     907        float                                   x,y,z; 
     908        float                                   r,g,b; 
     909        int                                             color_index; 
     910        int                                             current_strip; 
     911 
     912        //      Initialize current strip. 
     913        current_strip   =       0; 
     914 
     915        //      For each submesh. 
     916        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     917        { 
     918                 
     919                color_index     =       0; 
     920 
     921                //      Gets the actual submesh. 
     922                geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
     923 
     924                //      For each one of the strips. 
     925                for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 
     926                { 
     927                        //      Paint the current strip. 
     928                        glBegin(GL_TRIANGLE_STRIP); 
     929 
     930                        if (getColorStrips()) 
     931                        { 
     932                                //      Gets the color of the strip. 
     933                                r       =       mStripColors[submesh][color_index].r; 
     934                                g       =       mStripColors[submesh][color_index].g; 
     935                                b       =       mStripColors[submesh][color_index].b; 
     936 
     937                                //      Change to the next color. 
     938                                color_index++; 
     939 
     940                                //      Paint a new color. 
     941                                glColor3f(r,g,b); 
     942                        } 
     943 
     944                        //      For each index of the strip. 
     945                        for (int index = 0; index < lodTreeLib->GetStrip(current_strip).size(); index++) 
     946                        { 
     947                                position        =       lodTreeLib->GetStrip(current_strip)[index]; 
     948 
     949                                //      Gets the vertex normal. 
     950                                vector3 =       geosubmesh->mVertexBuffer->mNormal[position]; 
     951 
     952                                x                               =       vector3[0]; 
     953                                y                               =       vector3[1]; 
     954                                z                               =       vector3[2]; 
     955 
     956                                //      Sets the vertex normal. 
     957                                glNormal3f(x,y,z); 
     958 
     959                                //      Gets the vertex coordinates. 
     960                                vector3 =       geosubmesh->mVertexBuffer->mPosition[position]; 
     961 
     962                                x                               =       vector3[0]; 
     963                                y                               =       vector3[1]; 
     964                                z                               =       vector3[2]; 
     965 
     966                                //      Sets the vertex position. 
     967                                glVertex3f(x,y,z); 
     968                        } 
     969 
     970                        //      Increments current strip. 
     971                        current_strip++; 
     972 
     973                        //      A strip is generated. 
     974                        glEnd(); 
     975 
     976                } 
     977        } 
     978         
     979}//End drawTriangleStrip. 
     980 
     981 
     982 
    894983//--------------------------------------------------------------------------- 
    895984//      Sets the lodstripslibrary object. 
     
    902991 
    903992//--------------------------------------------------------------------------- 
     993//      Sets the lodtreeslibrary object. 
     994//--------------------------------------------------------------------------- 
     995void    GeoMeshView::setLodTreesLibrary(LodTreeLibrary *lodtrees) 
     996{ 
     997        lodTreeLib      =       lodtrees; 
     998        activeLodTree(); 
     999} 
     1000 
     1001 
     1002//--------------------------------------------------------------------------- 
    9041003//      Change de Level of detail of the object. 
    9051004//--------------------------------------------------------------------------- 
    9061005void    GeoMeshView::GoToLod(unsigned int       lod) 
    9071006{ 
    908         lodStripsLib->GoToLod(lod); 
     1007        if (mLodStrip) 
     1008                lodStripsLib->GoToLod(lod); 
     1009        if (mLodTree) 
     1010                lodTreeLib->GoToTrunkLod(lod); 
    9091011        draw(); 
    9101012} 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r826 r829  
    682682        //      Deactive Lod strip visualization. 
    683683        geoMeshView->deactiveLodStrip(); 
     684        geoMeshView->deactiveLodTree(); 
    684685 
    685686        //      Loads a mesh file. 
     
    717718 
    718719        //      Show the Visulize LodStrips panel. 
    719         showVisualizeLodStrips(); 
     720        showSlider(); 
    720721         
    721722        //      Repaint the window. 
     
    723724} 
    724725 
    725 void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) 
    726 { 
    727   ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
    728                                                                                 -> 
    729                                                                                 cb_menuLodStripsVisualize_i(o,v); 
    730 } 
    731  
    732 //--------------------------------------------------------------------------- 
    733 //      Open LodStrip trunk Callback 
    734 //--------------------------------------------------------------------------- 
    735 inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) 
    736 { 
    737 } 
    738  
    739 void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) 
    740 { 
    741   ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
    742                                                                                 -> 
    743                                                                                 cb_menuLodTreesOpenLodStripTrunk_i(o,v); 
    744 } 
    745  
    746 //--------------------------------------------------------------------------- 
    747 //      Open leaves simplification Callback 
    748 //--------------------------------------------------------------------------- 
    749 inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) 
    750 { 
     726 
     727inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) 
     728{ 
     729        fltk::FileChooser *fcho; 
     730        const   char                            *lod_file; 
     731         
     732        //      Sets menus application state to NONE. 
     733        mApplicationState       =       NONE; 
     734 
     735        //      Deactive Lod strip visualization. 
     736        geoMeshView->deactiveLodTree(); 
     737        geoMeshView->deactiveLodStrip(); 
     738 
     739        //      Loads a mesh file. 
     740        openMeshFile(); 
     741         
     742        //      Show title. 
     743        mProcessTitle->label("Visualize LodTrees"); 
     744 
     745        //      If an object is loaded. 
     746        if (mGeoMesh != NULL) 
     747        { 
     748                fcho    =       new fltk::FileChooser("", 
     749                                "*.lod", 
     750                                fltk::FileChooser::CREATE, 
     751                                "Open Lod file"); 
     752 
     753                fcho->exec(); 
     754 
     755                //      If a file was selected. 
     756                if (fcho->value()) 
     757                { 
     758                        //      Build lod strips library. 
     759                        setLodTreesLibrary(string(fcho->value()), mGeoMesh); 
     760 
     761                        //      Sets the aplication mode. 
     762                        mApplicationState       =       VISUALIZE_LODTREES; 
     763                } 
     764 
     765                //      Free memory. 
     766                delete  fcho; 
     767        } 
     768 
    751769        //      Hide the right panel. 
    752770        hideRightPanel(); 
    753771 
     772        //      Show the Visulize LodTree panel. 
     773        showSlider(); 
     774         
     775        //      Repaint the window. 
     776        mMainWindow->redraw(); 
     777} 
     778void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) 
     779{ 
     780  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     781                                                                                -> 
     782                                                                                cb_menuLodTreesVisualize_i(o,v); 
     783} 
     784 
     785void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) 
     786{ 
     787  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     788                                                                                -> 
     789                                                                                cb_menuLodStripsVisualize_i(o,v); 
     790} 
     791 
     792//--------------------------------------------------------------------------- 
     793//      Open LodStrip trunk Callback 
     794//--------------------------------------------------------------------------- 
     795inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) 
     796{ 
     797} 
     798 
     799void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) 
     800{ 
     801  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     802                                                                                -> 
     803                                                                                cb_menuLodTreesOpenLodStripTrunk_i(o,v); 
     804} 
     805 
     806//--------------------------------------------------------------------------- 
     807//      Open leaves simplification Callback 
     808//--------------------------------------------------------------------------- 
     809inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) 
     810{ 
     811        //      Hide the right panel. 
     812        hideRightPanel(); 
     813 
    754814        //      Show the LodTrees panel. 
    755815        showOpenLeavesSimplification(); 
     
    768828                                                                                cb_menuLodTreesOpenLeavesSimplification_i(o,v); 
    769829} 
     830 
     831 
    770832 
    771833//--------------------------------------------------------------------------- 
     
    13381400//      Show the LodStrips visulization panel 
    13391401//--------------------------------------------------------------------------- 
    1340 void    GeoMeshViewUI::showVisualizeLodStrips() 
     1402void    GeoMeshViewUI::showSlider() 
    13411403{ 
    13421404        mLodSlider->set_visible(); 
     
    13471409//      Hide the LodStrips visualization panel 
    13481410//--------------------------------------------------------------------------- 
    1349 void    GeoMeshViewUI::hideVisualizeLodStrips() 
     1411void    GeoMeshViewUI::hideSlider() 
    13501412{ 
    13511413        mLodSlider->hide(); 
    13521414        mLodSlider->deactivate(); 
    13531415} 
     1416 
    13541417 
    13551418//--------------------------------------------------------------------------- 
     
    14951558        hideOpenMeshSimplification(); 
    14961559        hideOpenLeavesSimplification(); 
    1497         hideVisualizeLodStrips(); 
     1560        hideSlider(); 
    14981561        hideMeshInfo(); 
    14991562} 
     
    19141977 
    19151978//--------------------------------------------------------------------------- 
     1979//      Initialize the lodTreelibrary for visualization. 
     1980//--------------------------------------------------------------------------- 
     1981void    GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh     *geomesh) 
     1982{ 
     1983        //      If there is no lod strips object. 
     1984        if (lodTreeLib) 
     1985        { 
     1986                delete  lodTreeLib; 
     1987        } 
     1988 
     1989        //      New lod strips object. 
     1990        lodTreeLib      =       new     Geometry::LodTreeLibrary(lodfile, geomesh); 
     1991 
     1992        //      Sets the slider range. 
     1993        mLodSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); 
     1994 
     1995        //      Pass to geomeshview the lod strips object. 
     1996        geoMeshView->setLodTreesLibrary(lodTreeLib); 
     1997         
     1998        //      Puts the slider in the max position. 
     1999        mLodSlider->value(lodTreeLib->MinTrunkLod()); 
     2000} 
     2001 
     2002//--------------------------------------------------------------------------- 
    19162003//      Open a mesh file. 
    19172004//--------------------------------------------------------------------------- 
     
    20262113        //      Initialize the lod strip object. 
    20272114        lodStripsLib    =       NULL; 
     2115        lodTreeLib      =       NULL; 
    20282116 
    20292117        //      Identify the mesh that stores the leaves 
     
    24452533 
    24462534                        //      Menu LodTrees. 
    2447                         /* 
     2535                         
    24482536                        { 
    24492537                                fltk::ItemGroup* o; 
     
    24532541                                { 
    24542542                                        fltk::Item* o; 
    2455                                         o = menuLodTreesOpenLodStripTrunk = new fltk::Item("Open LodStrip trunk"); 
    2456                                         o->callback((fltk::Callback*)cb_menuLodTreesOpenLodStripTrunk); 
    2457                                 } 
    2458  
    2459                                 { 
    2460                                         fltk::Item* o; 
    2461                                         o = menuLodTreesOpenLeavesSimplification = new fltk::Item("Open leaves simplification"); 
    2462                                         o->callback((fltk::Callback*)cb_menuLodTreesOpenLeavesSimplification); 
    2463                                 } 
     2543                                        o = menuLodTreesVisualize = new fltk::Item("Visualize Trunk"); 
     2544                                        o->callback((fltk::Callback*)cb_menuLodTreesVisualize); 
     2545                                } 
     2546 
    24642547                                o->end(); 
    24652548                        } 
    2466                         */ 
     2549                         
    24672550                         
    24682551                        { 
Note: See TracChangeset for help on using the changeset viewer.