Ignore:
Timestamp:
06/05/06 23:14:04 (18 years ago)
Author:
mattausch
Message:

added mesh instance support
improved support for occlusion queries + other extensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r997 r1001  
    1717#include "BoundingBoxConverter.h" 
    1818#include "GlRenderer.h" 
    19  
     19#include "ResourceManager.h" 
    2020 
    2121 
     
    211211        else 
    212212                DEL_PTR(mViewCellsTree); 
    213  
    214         CLEAR_CONTAINER(mMeshContainer); 
    215213} 
    216214 
     
    942940        mEnvironment->GetIntValue("ViewCells.Evaluation.histoStepSize", histoStepSize); 
    943941 
    944         Debug << "here21 " << histoStepSize << endl; 
    945942        const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 
    946943 
     
    14421439                        viewCells.push_back(viewCell); 
    14431440                } 
    1444                 //TODO: transformed meshes 
     1441                else if (object->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 
     1442                { 
     1443                        TransformedMeshInstance *mi = dynamic_cast<TransformedMeshInstance *>(object); 
     1444 
     1445                        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
     1446 
     1447                        // copy mesh 
     1448                        *mesh = *mi->GetMesh(); 
     1449 
     1450                        // transform mesh 
     1451                        Matrix4x4 m; 
     1452                        mi->GetWorldTransform(m); 
     1453                        mesh->ApplyTransformation(m); 
     1454                         
     1455                        // create bb + kd tree 
     1456                        mesh->Preprocess(); 
     1457 
     1458                        ViewCell *viewCell = GenerateViewCell(mi->GetMesh()); 
     1459                        viewCells.push_back(viewCell); 
     1460 
     1461                        break; 
     1462                } 
    14451463        } 
    14461464} 
     
    14511469{ 
    14521470        // one mesh per view cell 
    1453         Mesh *mesh = new Mesh(); 
     1471        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    14541472 
    14551473        //-- construct prism 
     
    15011519        // implemented in subclasses 
    15021520} 
     1521 
    15031522 
    15041523// fast way of merging 2 view cells 
     
    19641983        { 
    19651984                if (!(*it)->GetMesh()) 
     1985                { 
    19661986                        CreateMesh(*it); 
     1987                } 
    19671988        } 
    19681989} 
     
    20102031} 
    20112032 
     2033 
    20122034static const bool USE_ASCII = true; 
     2035 
    20132036 
    20142037bool ViewCellsManager::ExportBoundingBoxes(const string filename,  
     
    27762799        mBspTree->ConstructGeometry(vc, geom); 
    27772800 
    2778         Mesh *mesh = new Mesh(); 
     2801        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    27792802 
    27802803        IncludeNodeGeomInMesh(geom, *mesh); 
    27812804        vc->SetMesh(mesh); 
    2782  
    2783         // put mesh into mesh container so we can savely delete it 
    2784         mMeshContainer.push_back(mesh); 
    27852805} 
    27862806 
     
    47124732        cout << "starting sampling of render cost ... "; 
    47134733         
    4714         preprocessor->GetRenderer()->SampleRenderCost(numSamples, samples); 
     4734        preprocessor->GetRenderer()->SampleRenderCost(numSamples, samples, true); 
    47154735 
    47164736        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    47254745        { 
    47264746                RenderCostSample sample = *rit; 
    4727                  
     4747 
    47284748                ViewCell *vc = GetViewCell(sample.mPosition); 
    47294749                 
    47304750                AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 
    4731          
    47324751                Mesh *hMesh = CreateMeshFromBox(box); 
    47334752                 
     
    47914810        { 
    47924811                // export mesh if available 
    4793         /*      if (vc->GetMesh()) 
     4812                // TODO: some bug here? 
     4813                if (0 && vc->GetMesh()) 
    47944814                { 
    47954815                        exporter->ExportMesh(vc->GetMesh()); 
    47964816                } 
    47974817                else 
    4798                 {*/ 
     4818                { 
    47994819                        BspNodeGeometry geom; 
    48004820                        mVspBspTree->ConstructGeometry(vc, geom); 
    48014821                        exporter->ExportPolygons(geom.GetPolys()); 
    4802                 //} 
     4822                } 
    48034823        } 
    48044824} 
     
    48144834        // compute max height difference 
    48154835        for (int i = 0; i < (int)leaves.size(); ++ i) 
     4836        { 
    48164837                for (int j = 0; j < (int)leaves.size(); ++ j) 
    4817         { 
    4818                 BspLeaf *leaf = dynamic_cast<BspViewCell *>(leaves[i])->mLeaf; 
    4819  
    4820                 if (i != j) 
    4821                 { 
    4822                         BspLeaf *leaf2 =dynamic_cast<BspViewCell *>(leaves[j])->mLeaf; 
    4823                         int dist = mVspBspTree->TreeDistance(leaf, leaf2); 
    4824                         if (dist > maxDist) 
    4825                                 maxDist = dist; 
     4838                { 
     4839                        BspLeaf *leaf = dynamic_cast<BspViewCell *>(leaves[i])->mLeaf; 
     4840 
     4841                        if (i != j) 
     4842                        { 
     4843 
     4844                                BspLeaf *leaf2 =dynamic_cast<BspViewCell *>(leaves[j])->mLeaf; 
     4845                                 
     4846                                int dist = mVspBspTree->TreeDistance(leaf, leaf2); 
     4847                                 
     4848                                if (dist > maxDist) 
     4849                                        maxDist = dist; 
     4850                        } 
    48264851                } 
    48274852        } 
     
    48504875        mVspBspTree->ConstructGeometry(vc, geom); 
    48514876         
    4852         Mesh *mesh = new Mesh(); 
     4877        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    48534878        IncludeNodeGeomInMesh(geom, *mesh); 
    48544879 
    48554880        vc->SetMesh(mesh); 
    4856         // put mesh into mesh container so we can savely delete it 
    4857         mMeshContainer.push_back(mesh); 
    48584881} 
    48594882 
Note: See TracChangeset for help on using the changeset viewer.