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/GTGeometry
Files:
5 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*/ 
Note: See TracChangeset for help on using the changeset viewer.