Changeset 1057


Ignore:
Timestamp:
06/26/06 12:37:41 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared/GTGeometry
Files:
2 deleted
4 edited

Legend:

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

    r1056 r1057  
    257257                                Filter=""> 
    258258                                <File 
    259                                         RelativePath=".\src\libs\leaves\activas.cpp"> 
    260                                 </File> 
    261                                 <File 
    262259                                        RelativePath=".\src\libs\leaves\foliage.cpp"> 
    263260                                </File> 
     
    329326                        Filter="h;hpp;hxx;hm;inl;inc;xsd" 
    330327                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
    331                         <File 
    332                                 RelativePath=".\src\libs\leaves\activas.h"> 
    333                         </File> 
    334328                        <File 
    335329                                RelativePath=".\src\libs\AdjModel.cxx"> 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp

    r1056 r1057  
    213213        return foliage->indexdata->GetNumMaxIndices(); 
    214214} 
     215 
     216 
     217// changes the lod of the entire object (trunk and leaves) 
     218uint32 LodTreeLibrary::GoToLod(uint32 lod) 
     219{ 
     220        return 0; 
     221} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp

    r1019 r1057  
    3333 
    3434 
    35         Acth  = new Activas[nHojas*8]; 
     35        Acth  = new ActiveLeafNode[nHojas*8]; 
    3636 
    3737        for ( h=0; h < nHojas; h++) { 
    3838 
    39                 Acth[h].indice = h; 
     39                Acth[h].index = h; 
    4040                if ( h != 0) 
    4141                { 
     
    273273 
    274274        i = 0; 
    275         while ( MinDet[i].indice != -1) 
    276         { 
    277                 j = MinDet[i].indice; 
     275        while ( MinDet[i].index != -1) 
     276        { 
     277                j = MinDet[i].index; 
    278278                if (LeafinFrustum ( j, frustum) == true) { 
    279279                //      printf("dentro %i y el padre es %i\n", j, MiArbol->Hojas[MiArbol->MinDet[i].indice].parent); 
     
    333333//--------------------------------------------------------------------------------------------------------- 
    334334 
    335 bool Foliage::EsActivo (  int num) 
     335bool Foliage::IsActive (int num) const 
    336336{ 
    337337        return ( (Acth[num].prev != -1) || (Acth[num].next != -1)); 
    338338} 
    339339 
    340  
    341  
    342  
    343 //------- 
    344 // si está delante devolverá 1. Si está detrás -1 
    345 //------------ 
    346  
    347 int Foliage::DondeEsta (  float x, float y, float z, float rva, float rvb,float rvc, float rvd) 
    348 { 
    349         // el plano sería pa x + pb y + pc z + pd = 0 
    350         float donde; 
    351         int   esta; 
    352  
    353         donde = (rva * x) + (rvb * y) + (rvc * z) + rvd; 
    354          
    355         if ( donde <0) esta = -1;  //delante 
    356          else if ( donde > 0) esta =1; //detrás 
    357                         else esta = 0; 
    358  
    359                         return esta; 
    360  
    361 } 
    362  
    363  
    364  
    365 //---------------------------- 
    366 // EXPLICACION DE LOS PARAMETROS:: 
    367 // ch --> criterio a aplicar: 
    368 //                      si es p --> plano 
    369 //                      si es d --> plano y esfera 
    370 //                      si es e --> esfera 
    371 //DEVUELVE true cuando está en la zona de interes y debe estar a maximo detalle 
    372 //---------------------------- 
    373  
    374  
    375 bool Foliage::Criterio ( Leaf &aLeaf,  char ch, float rva, float rvb,float rvc, float rvd, float radio) 
    376 { 
    377         float a,b,c; // coordenadas del primero de los vertices en la hoja 
    378         float d,e,f; // coords vertice 2 
    379         float g,h,i; // coords vertice 3 
    380         float j,k,l; // coords vertice 4 
    381         float dist; 
    382         bool inter=false, inter2=false; 
    383         float ccx, ccy, ccz; 
    384  
    385         vertexdata->GetVertexCoord(aLeaf.vertsLeaf[0],a,b,c); 
    386  
    387         ccx = cx; 
    388         ccy = cy; 
    389         ccz = cz; 
    390  
    391         if ( (ch == 'p') || (ch == 'd')) 
    392         { 
    393         //plano siempre  
    394         if (DondeEsta (a,b,c, rva,rvb,rvc,rvd) == 1) 
    395         { 
    396 //              MiArbol->Vertices[aHoja.vertsLeaf[1]].GetCoordinates (d,e,f); 
    397                 vertexdata->GetVertexCoord(aLeaf.vertsLeaf[1],d,e,f); 
    398                 if (DondeEsta (d,e,f, rva,rvb,rvc,rvd) == 1) 
    399                 { 
    400 //                      MiArbol->Vertices[aHoja.vertsLeaf[2]].GetCoordinates (g,h,i); 
    401                         vertexdata->GetVertexCoord(aLeaf.vertsLeaf[2],g,h,i); 
    402                         if (DondeEsta (g,h,i, rva,rvb,rvc,rvd) == 1) 
    403                         { 
    404 //                              Vertices[aHoja.vertsLeaf[3]].GetCoordinates (j,k,l); 
    405                                 vertexdata->GetVertexCoord(aLeaf.vertsLeaf[3],j,k,l); 
    406                                 if (DondeEsta (j,k,l, rva,rvb,rvc,rvd) == 1) inter = true; 
    407                         } 
    408                 } 
    409  
    410         } 
    411          
    412  
    413         } 
    414          
    415                  
    416         if (( ch == 'e') || (( ch == 'd') && (inter == true))) //CRITERIO DE LA ESFERA 
    417         { 
    418          
    419         dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz)); 
    420         if (dist >  radio) 
    421  
    422         { 
    423 //              MiArbol->Vertices[aHoja.vertsLeaf[1]].GetCoordinates (a,b,c); 
    424                 vertexdata->GetVertexCoord(aLeaf.vertsLeaf[1],a,b,c); 
    425                 dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz)); 
    426  
    427                 if (dist >  radio) 
    428                 { 
    429 //                      MiArbol->Vertices[aHoja.vertsLeaf[2]].GetCoordinates (a,b,c); 
    430                         vertexdata->GetVertexCoord(aLeaf.vertsLeaf[2],a,b,c); 
    431                         dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz)); 
    432  
    433                         if (dist >  radio) 
    434                         { 
    435 //                              MiArbol->Vertices[aHoja.vertsLeaf[3]].GetCoordinates (a,b,c); 
    436                                 vertexdata->GetVertexCoord(aLeaf.vertsLeaf[3],a,b,c); 
    437                                 dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz)); 
    438  
    439                                 if (dist >  radio) inter2 = true; 
    440                         } 
    441                 } 
    442         } 
    443                 inter =  inter2; 
    444         } 
    445  
    446  
    447         return inter; 
    448 } 
    449  
    450  
    451  
    452  
    453  
    454 /******************************************   RESOLUCIÓN VARIABLE **************************************************/ 
    455  
    456 //----------------------------------------- 
    457 // 
    458 //      RECORDAR!!! 
    459 //              NO cumple el criterio ------------>  POCO  DETALLE ( COLAPSAR ) 
    460 //              SI cumple el criterio ------------>  MUCHO DETALLE ( SPLITEAR ) 
    461 // 
    462 // el ch se le pasa a Criterio y es allí donde se evalua 
    463 //          e --> esfera 
    464 //      p --> plano 
    465 //      d --> los dos criterios 
    466 //------------------------------------------ 
    467  
    468 int Foliage::ResolucionV (char ch, float rva, float rvb,float rvc, float rvd, float radio) 
    469 { 
    470         bool lista=false; 
    471     int i, hpost, spli; 
    472         float renvol, centroz; 
    473          
    474         i = ppio; 
    475         spli = -1; 
    476  
    477         renvol = rad; 
    478         centroz = cz; 
    479 //      printf (" el centro en %f y el radio es de %f\n", centroz, renvol); 
    480  
    481 // fijo el máximo del plano de RV 
    482  
    483         if (rvd < centroz -renvol ) 
    484                   rvd = (centroz -renvol ); 
    485         else if (rvd > centroz +renvol ) 
    486                   rvd = (centroz +renvol ); 
    487  
    488 //      printf (" el plano está en %f\n", rvd); 
    489  
    490  
    491         //para que fije el valor máximo del radio 
    492  
    493         if  (( ch == 'e') || ( ch == 'd'))  
    494         {       if (radio> renvol)      radio = renvol; 
    495                 else if (radio <0)  radio =0.0; 
    496         } 
    497  
    498 //      printf (" el radio vale %f\n", radio); 
    499          
    500         //empieza a buscar las hojas activas 
    501  
    502         while ( i != -1){ 
    503                  
    504                 hpost = Acth[i].next; 
    505  
    506                 //COLAPSAR 
    507  
    508                 if (( Criterio ( Leaves[i], ch, rva,rvb,rvc,rvd, radio )== false) && (Leaves[i].parent != -1))  
    509                 { 
    510                         // SI ESTA FUESE LA HOJA IZQUIERDA Y LA DERECHA NO CUMPLE TAMPOCO EL CRITERIO 
    511                         if ((Leaves[Leaves[i].parent].childLeft == i) && 
    512                                 ( Criterio (Leaves[Leaves[Leaves[i].parent].childRight] , ch, rva,rvb,rvc,rvd, radio )== false)) 
    513                         {       //hay que colapsar 
    514                                 if (EsActivo(Leaves[Leaves[i].parent].childRight) == false) 
    515                                         lista = Forzar_Colapse (Leaves[Leaves[i].parent].childRight, hpost, ch, rva,rvb,rvc,rvd, radio); // para activarla 
    516                                 else lista = true; 
    517                                                                          
    518                         } 
    519                         else 
    520                         // SI ESTA FUESE LA HOJA DERECHA Y LA IZQUIERDA NO CUMPLE TAMPOCO EL CRITERIO 
    521                         if ((Leaves[Leaves[i].parent].childRight == i) && 
    522                                 ( Criterio (Leaves[Leaves[Leaves[i].parent].childLeft] , ch, rva,rvb,rvc,rvd, radio )== false)) 
    523                         {//hay que colapsar 
    524                                 if (EsActivo(Leaves[Leaves[i].parent].childLeft) == false) 
    525                                          lista = Forzar_Colapse (Leaves[Leaves[i].parent].childLeft, hpost,  ch, rva,rvb,rvc,rvd, radio); // para activarla 
    526                                 else  lista = true; 
    527                                          
    528                         } 
    529                          
    530                          //estan activas preparadas para subir un nivel en la zona de no detalle. 
    531                          
    532                         if ( lista == true) 
    533                         { 
    534                                 lista = false; 
    535                                  
    536                                         ColapsaHoja ( Leaves[i].parent, hpost); 
    537                         } 
    538                                          
    539                 } 
    540         i = hpost; 
    541  
    542         } 
    543          
    544         //ahora veo lo de splitear 
    545         i = ppio; 
    546         spli = -1; 
    547  
    548         while ( i != -1){ 
    549                 hpost = Acth[i].next; 
    550                 spli = Chequea_Split (i, ch, rva,rvb,rvc,rvd, radio); 
    551                         if ( spli != -1)  
    552                                 {       Forzar_Split ( spli, i, hpost); 
    553                                         spli = -1; 
    554                                 } 
    555                         i = hpost; 
    556         } 
    557  
    558         return (1); 
    559                  
    560 } 
    561340 
    562341//-------------------------------------------------------------------------------------------------------------------------------- 
     
    605384         
    606385} 
    607  
    608  
    609  
    610  
    611 //-------------------------------------------------------------------------------------------------- 
    612 // Forzar colapse  
    613 // la hoja que paso en el parametro hoja es la que quiero que se active al final 
    614 //-------------------------------------------------------------------------------------------------- 
    615  
    616  
    617 bool Foliage::Forzar_Colapse(int hoja,  int &hpost,  char ch, float rva, float rvb,float rvc, float rvd, float radio) 
    618 { 
    619          
    620         int h; 
    621         lista <int> listah; 
    622         bool fin; 
    623  
    624         fin = false; 
    625         listah.Inserta (hoja); // Inserta un dato en la lista 
    626  
    627         while  (listah.NDatos () != 0)  
    628         { 
    629                  
    630                 h = listah.GetCola ();//coger la cola 
    631                 if (Leaves[h].childLeft != -1)  
    632  
    633                 { if (!EsActivo (Leaves[h].childLeft )) 
    634                         listah.Inserta (Leaves[h].childLeft); 
    635                          
    636                   if ( (!EsActivo (Leaves[h].childRight)) )      
    637                         listah.Inserta (Leaves[h].childRight); 
    638                  
    639                   if (EsActivo (Leaves[h].childLeft) && EsActivo (Leaves[h].childRight ))  
    640                           if((Criterio ( Leaves[Leaves[h].childLeft] ,ch, rva,rvb,rvc,rvd, radio )== false) && 
    641                                   (Criterio ( Leaves[Leaves[h].childRight], ch, rva,rvb,rvc,rvd, radio ) == false)) 
    642                         { 
    643                         ColapsaHoja ( h, hpost); 
    644                                 listah.Borra(h); 
    645                         } 
    646                           else fin = true; 
    647                 } 
    648                 else 
    649                 {  fin = true; 
    650                    listah.Borra(h); 
    651                 } 
    652  
    653                 if ( fin == true ) 
    654                         while ( listah.NDatos () != 0) 
    655                                 listah.BorraCola(); 
    656          
    657         } 
    658  
    659         return (EsActivo (hoja)); 
    660                  
    661 } 
    662  
    663386 
    664387//-------------------------------------------------------------------------------------------------------------------------------- 
     
    697420 
    698421 
    699 //------------------------------------------------------------------------------------------- 
    700 // chequear si tengo que splitear. Devuelve el primero de los nodos que cumple la condicion 
    701 //------------------------------------------------------------------------------------------- 
    702  
    703 int Foliage::Chequea_Split(int h,  char ch, float rva, float rvb,float rvc, float rvd, float radio) 
    704 { 
    705          
    706         int  nodo; 
    707          
    708  
    709         nodo = -1; 
    710  
    711         if (Leaves[h].childLeft != -1)  
    712  
    713         {  // si el hijo derecho o el izquierdo están en la zona de máximo detalle, haré que estos se activen    
    714                   if ( (Criterio (Leaves[Leaves[h].childLeft],  ch, rva,rvb,rvc,rvd, radio ) == true) || 
    715                           (Criterio (Leaves[Leaves[h].childRight], ch, rva,rvb,rvc,rvd, radio ) == true)) 
    716                          
    717                                 nodo = Leaves[h].childLeft;  
    718                          
    719                         else // si no, bajo un nivel más hasta encontrar algún descendiente que se encuentre en la zona de + detalle 
    720                         { 
    721                                 nodo = Chequea_Split (Leaves[h].childLeft,  ch, rva,rvb,rvc,rvd, radio); 
    722                                 if ( nodo == -1 ) nodo = Chequea_Split (Leaves[h].childRight, ch, rva,rvb,rvc,rvd, radio); 
    723                         } 
    724                                    
    725                 } 
    726                  
    727         return (nodo); 
    728                  
    729 } 
    730422 
    731423//------------------------------------------------------------------------------------------- 
     
    824516} 
    825517 
    826 //----------------------------------------- 
    827 // 
    828 //      RECORDAR!!! 
    829 //              NO cumple el criterio ------------>  POCO  DETALLE ( COLAPSAR ) 
    830 //              SI cumple el criterio ------------>  MUCHO DETALLE ( SPLITEAR ) 
    831 // 
    832 // el ch se le pasa a Criterio y es allí donde se evalua 
    833 //------------------------------------------ 
    834  
    835 /* 
    836 void Foliage::RCecol (  int nhojas) 
    837 { 
    838         int i, hpost; 
    839  
    840         i = ppio; 
    841          
    842         while (( i != -1) && (nhojas>0)){ 
    843                 hpost = Acth[i].next; 
    844  
    845                         if ( MiArbol->Hojas[i].parent != -1)  
    846                                 if ( MiArbol->Hojas[MiArbol->Hojas[i].parent].childLeft == i) 
    847                                 {if ( EsActivo (MiArbol->Hojas[MiArbol->Hojas[i].parent].childRight ) ) 
    848                                 {  
    849                                         ColapsaHoja ( MiArbol->Hojas[i].parent, hpost); 
    850                                         nhojas --; } 
    851                                 } 
    852                                 else  
    853                                 {if ( EsActivo (MiArbol->Hojas[MiArbol->Hojas[i].parent].childLeft ) ) 
    854                                 { 
    855                                         ColapsaHoja ( MiArbol->Hojas[i].parent, hpost);  
    856                                         nhojas --; } 
    857                                 } 
    858  
    859  
    860                 i = hpost; 
    861                  
    862         } 
    863 } 
    864 */ 
    865518 
    866519void Foliage::RCecol ( int num) 
     
    948601                i = h--; 
    949602         
    950                 while (EsActivo (i) == false)    
     603                while (IsActive(i) == false)     
    951604                        i--; 
    952605        } 
     
    960613        i = h++; 
    961614         
    962         while ((EsActivo (i) == false) || (i> TotHojas)) 
     615        while ((IsActive(i) == false) || (i> TotHojas)) 
    963616                i++; 
    964617 
     
    1173826        cont =-1; 
    1174827 
    1175         MinDet  = new Activas[nHojas*2]; 
     828        MinDet  = new ActiveLeafNode[nHojas*2]; 
    1176829         
    1177830        while (i<TotHojas) 
     
    1185838                if ( k == -1){ 
    1186839                        k++; 
    1187                         MinDet[k].indice = j; 
     840                        MinDet[k].index = j; 
    1188841                        cont =k; 
    1189842                } 
     
    1195848 
    1196849                        while (( fin == false) && (esta == false)) 
    1197                         {       if ( MinDet[t].indice == j) esta = true; 
     850                        {       if ( MinDet[t].index == j) esta = true; 
    1198851                                        else t++; 
    1199                                 if (MinDet[t].indice == -1) fin = true; 
     852                                if (MinDet[t].index == -1) fin = true; 
    1200853                        } 
    1201854 
     
    1203856                        { 
    1204857                                cont++; 
    1205                                 MinDet[cont].indice = j; 
     858                                MinDet[cont].index = j; 
    1206859                        } 
    1207860                } 
     
    1251904{ 
    1252905        nHojas=ar->nHojas; 
    1253         MinDet  = new Activas[nHojas*2]; 
     906        MinDet  = new ActiveLeafNode[nHojas*2]; 
    1254907//      for (unsigned int i=0; i<nHojas*2; i++) 
    1255908//              MinDet[i]=ar->MinDet[i]; 
    1256         memcpy(MinDet,ar->MinDet,sizeof(Activas)*nHojas*2); 
     909        memcpy(MinDet,ar->MinDet,sizeof(ActiveLeafNode)*nHojas*2); 
    1257910        TotHojas=ar->TotHojas; 
    1258911        cx=ar->cx; 
     
    1292945        int h=0; 
    1293946 
    1294         Acth  = new Activas[nHojas*8]; 
     947        Acth  = new ActiveLeafNode[nHojas*8]; 
    1295948 
    1296949        for ( h=0; h < nHojas; h++) { 
    1297950 
    1298                 Acth[h].indice = h; 
     951                Acth[h].index = h; 
    1299952                if ( h != 0) 
    1300953                { 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h

    r1019 r1057  
    22#define FOLIAGE_H 
    33 
    4  
    5 #include "Activas.h" 
    64#include "GeoSubMesh.h" 
    75#include "tlista.h" 
     
    108#include "Leaf.h" 
    119 
     10class ActiveLeafNode 
     11{ 
     12        public : 
     13                // Variable members 
     14        int  index;// Array of pointers to vertices 
     15                int  prev; 
     16                int  next; 
     17                 
     18                ActiveLeafNode (void){ index = prev = next = -1; } // Constructor 
     19}; 
     20 
    1221class Foliage 
    1322{ 
    1423        public : 
    1524 
    16                 Activas  *Acth; // primera hoja activa 
     25                ActiveLeafNode  *Acth; // first active leaf 
    1726                int ppio, final; 
    1827                int nhactivas; 
     
    2635                void Culling (float frustum[6][4]); 
    2736                bool LeafinFrustum ( int i, float frustum[6][4]); 
    28                  
    29                 // resolucion variable 
    30                 bool EsActivo (  int num); 
    31                 int  DondeEsta (  float x, float y, float z, float rva, float rvb,float rvc, float rvd); 
    32                 bool Criterio ( Leaf &, char ch, float rva, float rvb,float rvc, float rvd, float radio); 
     37 
     38                bool IsActive( int num) const; 
    3339                int  ResolucionV ( char c, float rva, float rvb,float rvc, float rvd, float radio); 
    3440                void ColapsaHoja (int, int&); 
    35                 bool Forzar_Colapse (int hoja,  int &hpost,  char ch, float rva, float rvb,float rvc, float rvd, float radio); 
    3641                void SplitHoja (int, int&); 
    37                 int  Chequea_Split(int, char, float rva, float rvb,float rvc, float rvd, float radio); 
    3842                bool Forzar_Split(int, int, int&); 
    3943                int  AnteriorActivo (int h); 
     
    5155 
    5256                Leaf   *Leaves; 
    53                 Activas  *MinDet; // primera hoja activa 
     57                ActiveLeafNode  *MinDet; // primera hoja activa 
    5458                int nHojas; 
    5559                int TotHojas; 
Note: See TracChangeset for help on using the changeset viewer.