Ignore:
Timestamp:
09/28/06 17:49:37 (18 years ago)
Author:
gumbau
Message:

Updated modules to the new interface and the new simplification algorithm improvements.

Location:
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Leaf.cpp

    r1026 r1526  
    1010        vertsLeaf[0] = vertsLeaf[1] = vertsLeaf[2] = vertsLeaf[3] =0;  
    1111        center[0] = center[1] = center[2] = 0; 
    12         normal[0] = normal[1] = normal[2] = 0; 
     12//      normal[0] = normal[1] = normal[2] = 0; 
    1313        leafNear=-1; 
    1414        parentLeafCount = 1; 
     
    4040        for ( int i=0;i<3;i++){ 
    4141                center[i] = aLeaf.center[i]; 
    42                 normal[i] = aLeaf.normal[i]; 
     42//              normal[i] = aLeaf.normal[i]; 
    4343        } 
    4444        for (i = 0L; i < 4; i++) 
     
    5353 
    5454 
     55RuntimeLeaf::RuntimeLeaf(void)  
     56{        
     57        vertsLeaf[0] = vertsLeaf[1] = vertsLeaf[2] = vertsLeaf[3] = 0; 
     58        parent = root = childLeft = childRight = -1; 
     59} 
    5560 
    5661//-------------------------------------------------------------------------------------------------------------------------------- 
    57 // Destructor. We must deallocate the memory allocated for pointers to vertices and edges 
     62// Copy constructor 
    5863//-------------------------------------------------------------------------------------------------------------------------------- 
    59 Leaf::~Leaf (void) 
     64RuntimeLeaf::RuntimeLeaf (const RuntimeLeaf& aLeaf) 
    6065{ 
     66        for (int i = 0L; i < 4; i++) 
     67                vertsLeaf[i] = aLeaf.vertsLeaf[i];  
     68        parent = aLeaf.parent; 
     69        childLeft = aLeaf.childLeft; 
     70        childRight = aLeaf.childRight; 
     71        root = aLeaf.root; 
    6172} 
    6273 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/VertexData.cpp

    r1105 r1526  
    11#include "VertexData.h" 
    22 
    3 Geometry::DefaultVertexData::DefaultVertexData(unsigned int numv):Geometry::VertexData(numv) 
     3/* 
     4void Geometry::DefaultIndexData::Init(unsigned int numi) 
    45{ 
    5         v = new float[numv*3]; 
    6         n = new float[numv*3]; 
    7         t = new float[numv*2]; 
    8 } 
    9 Geometry::DefaultVertexData::~DefaultVertexData(void) 
    10 { 
    11 /*      delete[] v; 
    12         delete[] n; 
    13         delete[] t;*/ 
    14 } 
    15  
    16 Geometry::VertexData *Geometry::DefaultVertexDataCreator(unsigned int numv) 
    17 {  
    18         return new DefaultVertexData(numv);  
    19 } 
    20  
    21  
    22 Geometry::DefaultIndexData::DefaultIndexData(unsigned int numi):Geometry::IndexData(numi) 
    23 { 
    24         indices = new unsigned int[numi];        
     6        indices = new unsigned int[numi]; 
    257} 
    268Geometry::DefaultIndexData::~DefaultIndexData(void) 
    279{ 
    28 /*      delete[] indices;*/ 
    2910} 
    3011 
    3112Geometry::IndexData *Geometry::DefaultIndexDataCreator(unsigned int numi) 
    3213{  
    33         return new DefaultIndexData(numi);  
     14        IndexData *ret = new DefaultIndexData(); 
     15//      ret->Init(numi); 
     16        return ret; 
    3417} 
    3518 
    36  
    37 /*Geometry::DefaultMultiIndexData::DefaultMultiIndexData(unsigned int numprims, unsigned int *numi):Geometry::MultiIndexData(numprims,numi) 
    38 { 
    39         indices = new unsigned int*[numprims];   
    40         for (unsigned int i=0; i<numprims; i++) 
    41                 indices[i]=new unsigned int[numi[i]]; 
    42 } 
    43 Geometry::DefaultMultiIndexData::~DefaultMultiIndexData(void) 
    44 { 
    45         for (unsigned int i=0; i<GetNumPrims(); i++) 
    46                 delete[] indices[i]; 
    47         delete[] indices; 
    48 } 
    49  
    50 Geometry::MultiIndexData *Geometry::DefaultMultiIndexDataCreator(unsigned int numprims, unsigned int *numi) 
    51 {  
    52         return new DefaultMultiIndexData(numprims,numi);  
    53 } 
    5419*/ 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp

    r1083 r1526  
    1010// Parameters --> None 
    1111//-------------------------------------------------------------------------------------------------------------------------------- 
    12 Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const Geometry::TreeSimplificationSequence * simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):  
     12Foliage::Foliage(int leavessubmeshID,  
     13                                 const Geometry::SubMesh *leavesSubMesh,  
     14                                 const Geometry::TreeSimplificationSequence * simpSeq/*, 
     15                                 Geometry::CREATEVERTEXDATAFUNC vdfun*/):  
    1316Acth(NULL), 
    14 create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 
    15 create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun), 
    16 vertexdata(NULL), Leaves(NULL), MinDet(NULL) 
     17//create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 
     18//create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun), 
     19/*vertexdata(NULL),*/ Leaves(NULL), MinDet(NULL) 
    1720{ 
    1821        begin = final = -1; 
    19  
    20         ReadVertices(leavesSubMesh); 
     22//      indexdata=NULL; 
     23 
     24//      ReadVertices(leavesSubMesh); 
     25        int countv= int(leavesSubMesh->mVertexBuffer->mVertexCount); 
     26        Leaves = new RuntimeLeaf[countv*2]; 
     27        TotalVerts = countv; 
     28 
    2129        ReadLeafs(leavesSubMesh); 
    2230        if (!ReadSimpSeq(simpSeq)) exit(1); 
    2331        FillRoot(); 
    24         CalculateTexCoordsAndNorms(); 
    25  
    26         indexdata->SetNumValidIndices(0); 
     32//      CalculateTexCoordsAndNorms(); 
     33 
     34//      indexdata->SetNumValidIndices(0); 
    2735 
    2836        int h=0; 
     
    4452        final = leafCount-1; 
    4553        active_leaf_count = leafCount; 
     54        leavesSubMeshID=leavessubmeshID; 
    4655} 
    4756 
     
    5160Foliage::~Foliage (void) 
    5261{ 
    53         if (vertexdata) delete vertexdata; 
    54         if (indexdata) delete indexdata; 
     62//      if (vertexdata) delete vertexdata; 
     63//      if (indexdata) delete indexdata; 
    5564        delete[] Leaves; 
    5665        delete MinDet; 
     
    222231 
    223232 } 
    224  
     233/* 
    225234void Foliage::ReadVertices(const Geometry::SubMesh *submesh) 
    226235{ 
     
    228237        vertexdata = create_vertex_data_func(2*countv); 
    229238        Leaves = new Leaf[countv*2]; 
    230         indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja 
     239        //indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja 
    231240         
    232241        vertexdata->Begin(); 
     
    249258        float twox, twoy, twoz; 
    250259        float threex, threey, threez; 
    251  
    252 /*      Vertices[aHoja.vertsLeaf[0]].GetCoordinates (onex, oney, onez); 
    253         Vertices[aHoja.vertsLeaf[1]].GetCoordinates(twox, twoy, twoz); 
    254         Vertices[aHoja.vertsLeaf[2]].GetCoordinates (threex, threey, threez);*/ 
    255260 
    256261        vertexdata->GetVertexCoord(aleaf.vertsLeaf[0],onex,oney,onez); 
     
    286291        res[2]=v[2]/module; 
    287292} 
    288  
     293*/ 
    289294void Foliage::ReadLeafs(const Geometry::SubMesh *submesh) 
    290295{ 
     
    297302                Leaves[h].vertsLeaf[2] = submesh->mIndex[h*6+2]; 
    298303                Leaves[h].vertsLeaf[3] = submesh->mIndex[h*6+5]; 
    299                 Leaves[h].visible = 0; 
    300  
    301                 GetNormalH ( Leaves[h]); 
     304//              Leaves[h].visible = 0; 
     305 
     306//              GetNormalH ( Leaves[h]); 
    302307        } 
    303308} 
     
    316321                Leaves[tn].vertsLeaf[3] = it->mNewQuad[3]; 
    317322 
    318                 Leaves[tn].visible = 0; 
    319  
    320                 GetNormalH  (Leaves[tn]); 
     323//              Leaves[tn].visible = 0; 
     324 
     325//              GetNormalH  (Leaves[tn]); 
    321326 
    322327                tv1 = it->mV0/2; 
     
    433438} 
    434439 
    435 void Foliage::CalculateTexCoordsAndNorms(void) 
     440/*void Foliage::CalculateTexCoordsAndNorms(void) 
    436441{        
    437442        vertexdata->Begin(); 
     
    453458        vertexdata->End(); 
    454459} 
    455  
     460*/ 
    456461Foliage::Foliage(const Foliage *ar) 
    457462{ 
     
    465470        TotalVerts=ar->TotalVerts; 
    466471 
    467         create_vertex_data_func=ar->create_vertex_data_func; 
    468         create_index_data_func=ar->create_index_data_func; 
     472/*      create_vertex_data_func=ar->create_vertex_data_func; 
     473//      create_index_data_func=ar->create_index_data_func; 
    469474        vertexdata=create_vertex_data_func(ar->vertexdata->GetNumVertices()); 
    470475        vertexdata->Begin();  
     
    477482                vertexdata->SetVertexNormal(i,va,vb,vc); 
    478483        } 
    479         vertexdata->End(); 
    480         indexdata=create_index_data_func(ar->indexdata->GetNumMaxIndices()); 
    481         indexdata->Begin();  
     484        vertexdata->End();*/ 
     485/*      indexdata=create_index_data_func(ar->indexdata->GetNumMaxIndices()); 
     486        indexdata->Begin(ar->leavesSubMeshID,indexdata->GetNumMaxIndices()); 
    482487        for (unsigned int i=0; i<indexdata->GetNumMaxIndices(); i++)  
    483488                indexdata->SetIndex(i,ar->indexdata->GetIndex(i)); 
    484         indexdata->End(); 
    485  
    486         Leaves=new Leaf[vertexdata->GetNumVertices()]; 
     489        indexdata->End();*/ 
     490 
     491        Leaves=new RuntimeLeaf[TotalVerts]; 
    487492//      for (unsigned int i=0; i<vertexdata->GetNumVertices(); i++)  
    488493//              Leaves[i]=ar->Leaves[i]; 
    489         memcpy(Leaves,ar->Leaves,sizeof(Leaf)*vertexdata->GetNumVertices()); 
     494        memcpy(Leaves,ar->Leaves,sizeof(Leaf)*TotalVerts); 
    490495 
    491496        // esto no sé si devería haber akí 
    492         indexdata->SetNumValidIndices(0); 
     497//      indexdata->SetNumValidIndices(0); 
    493498 
    494499        int h=0; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h

    r1083 r1526  
    2626                int begin, final; 
    2727                int active_leaf_count; 
     28                int leavesSubMeshID; 
    2829 
    29                 Foliage (const Geometry::SubMesh *, const Geometry::TreeSimplificationSequence *, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); 
     30                Foliage (       int leavesSubMeshID,  
     31                                        const Geometry::SubMesh *,  
     32                                        const Geometry::TreeSimplificationSequence *    ); 
     33 
    3034                Foliage (const Foliage *); 
    3135                virtual ~Foliage (void); // Destructor 
     
    3337                void CalculateLOD(int nhojas); 
    3438 
    35                 Geometry::VertexData *vertexdata; 
    36                 Geometry::IndexData *indexdata; 
    37  
    38                 Leaf   *Leaves; 
     39                RuntimeLeaf   *Leaves; 
    3940                ActiveLeafNode  *MinDet; // first active leaf 
    4041                int leafCount; 
     
    4546 
    4647        private: 
    47                 Geometry::CREATEVERTEXDATAFUNC create_vertex_data_func;          
    48                 Geometry::CREATEINDEXDATAFUNC create_index_data_func; 
    4948 
    5049                bool IsActive( int num) const; 
     
    5958                bool ReadSimpSeq(const Geometry::TreeSimplificationSequence *); /// returns true when successful 
    6059                void FillRoot(void); 
    61  
    62                 void GetNormalH (Leaf&); 
    63  
    64                 void CrossProduct(const float *v1, const float *v2, float *res); 
    65                 void Normalize(const float *v, float *res); 
    66 //              void CalculaNormalesVertice(void); 
    67                 void CalculateTexCoordsAndNorms(void); 
    68  
    6960}; 
    7061 
Note: See TracChangeset for help on using the changeset viewer.