Ignore:
Timestamp:
11/08/05 19:00:49 (19 years ago)
Author:
mattausch
Message:

changed bsp splitplane choosing functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r389 r390  
    1515  environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 
    1616  environment->GetIntValue("ViewCells.PostProcessing.samples", mPostProcessSamples); 
    17   environment->GetIntValue("BspTree.visualizationSamples", mVisualizationSamples); 
     17  environment->GetIntValue("BspTree.Visualization.samples", mVisualizationSamples); 
    1818 
    1919  mKdPvsDepth = 100; 
     
    728728        } 
    729729        // save rays for post processing 
    730         else if ((int)mSampleRays.size() < mPostProcessSamples) || 
    731                         (((int)mSampleRays.size() < mVisualizationSamples)) 
     730        else if (((int)mSampleRays.size() < mPostProcessSamples) || 
     731                         ((int)mSampleRays.size() < mVisualizationSamples)) 
    732732        { 
    733733                mSampleRays.push_back(new Ray(ray)); 
     
    747747        for (int i = 0; i < limit; ++i) 
    748748        {   
    749                 Ray *ray = mSamplesRays[i]; 
     749                Ray *ray = mSampleRays[i]; 
    750750 
    751751                // traverse leaves stored in the rays and compare and merge consecutive 
     
    842842        //-- some rays for output 
    843843        const int raysOut = min((int)mSampleRays.size(), mVisualizationSamples); 
     844        cout << "visualization using " << mVisualizationSamples << " samples" << endl; 
    844845        vector<Ray *> vcRays[leafOut]; 
    845846 
     
    882883                        ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    883884 
     885                        //exporter->SetWireframe(); 
     886                        exporter->SetFilled(); 
     887 
     888                        Material m;//= RandomMaterial(); 
     889                        m.mDiffuseColor = RgbColor(0, 1, 0); 
     890                        exporter->SetForcedMaterial(m); 
     891 
     892                        if (vc->GetMesh()) 
     893                                exporter->ExportViewCell(vc); 
     894                        else 
     895                        { 
     896                                PolygonContainer cell; 
     897                                // export view cell geometry 
     898                                mBspTree->ConstructGeometry(vc, cell); 
     899                                exporter->ExportPolygons(cell); 
     900                                CLEAR_CONTAINER(cell); 
     901                        } 
     902 
     903                        Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
     904                                        << ", piercing rays=" << (int)vcRays[i].size() << endl; 
     905 
     906                        // export rays piercing this view cell 
     907                        exporter->ExportRays(vcRays[i], 1000, RgbColor(0, 1, 0)); 
     908 
     909                        m.mDiffuseColor = RgbColor(1, 0, 0); 
     910                        exporter->SetForcedMaterial(m); 
     911 
    884912                        exporter->SetWireframe(); 
     913 
     914                        // output PVS of view cell 
     915                        for (; it != vc->GetPvs().mEntries.end(); ++ it)  
     916                        { 
     917                                Intersectable *intersect = (*it).first; 
     918                                if (!intersect->Mailed()) 
     919                                { 
     920                                        exporter->ExportIntersectable(intersect); 
     921                                        intersect->Mail(); 
     922                                }                        
     923                        } 
     924                                 
     925                        // output rest of the objects 
     926                        if (0) 
     927                        { 
     928                                Material m;//= RandomMaterial(); 
     929                                m.mDiffuseColor = RgbColor(0, 0, 1); 
     930                                exporter->SetForcedMaterial(m); 
     931 
     932                                for (int j = 0; j < objects.size(); ++ j) 
     933                                        if (!objects[j]->Mailed()) 
     934                                        { 
     935                                                exporter->SetForcedMaterial(m); 
     936                                                exporter->ExportIntersectable(objects[j]); 
     937                                                objects[j]->Mail(); 
     938                                        } 
     939                        } 
     940                        DEL_PTR(exporter); 
     941                        cout << "finished" << endl; 
     942                } 
     943        } 
     944        else 
     945        { 
     946                ViewCellContainer viewCells; 
     947 
     948                mBspTree->CollectViewCells(viewCells); 
     949                stable_sort(viewCells.begin(), viewCells.end(), vc_gt); 
     950 
     951                int limit = min(leafOut, (int)viewCells.size());  
     952                 
     953                for (int i = 0; i < limit; ++ i) 
     954                { 
     955                        cout << "creating output for view cell " << i << " ... "; 
     956                         
     957            Intersectable::NewMail(); 
     958                        BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]); 
     959 
     960                        cout << "creating output for view cell " << i << " ... "; 
     961                        // check whether we can add the current ray to the output rays 
     962                        for (int k = 0; k < raysOut; ++ k)  
     963                        { 
     964                                Ray *ray = mSampleRays[k]; 
     965 
     966                                for     (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
     967                                { 
     968                                        BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 
     969 
     970                                        if (vc == leaf->GetViewCell())  
     971                                        { 
     972                                                vcRays[i].push_back(ray); 
     973                                        } 
     974                                } 
     975                        } 
     976 
     977                        //bspLeaves[j]->Mail(); 
     978                        char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 
     979 
     980                        Exporter *exporter = Exporter::GetExporter(s); 
     981                        exporter->SetFilled(); 
     982 
     983                        ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
     984 
     985                        exporter->SetFilled();//Wireframe(); 
    885986 
    886987                        Material m;//= RandomMaterial(); 
     
    8991000                        } 
    9001001 
    901                         Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
    902                                         << ", piercing rays=" << (int)vcRays[i].size() << endl; 
    903  
     1002                        Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() << endl; 
     1003 
     1004                         
    9041005                        // export rays piercing this view cell 
    905                         exporter->ExportRays(vcRays[i], 1000, RgbColor(0, 1, 0)); 
     1006                        exporter->ExportRays(vcRays[i], 10000, RgbColor(0, 1, 0)); 
    9061007 
    9071008                        m.mDiffuseColor = RgbColor(1, 0, 0); 
     
    9191020                        } 
    9201021                                 
    921                         // output rest of the objects 
    922                         if (0) 
    923                         { 
    924                                 Material m;//= RandomMaterial(); 
    925                                 m.mDiffuseColor = RgbColor(0, 0, 1); 
    926                                 exporter->SetForcedMaterial(m); 
    927  
    928                                 for (int j = 0; j < objects.size(); ++ j) 
    929                                         if (!objects[j]->Mailed()) 
    930                                         { 
    931                                                 exporter->SetForcedMaterial(m); 
    932                                                 exporter->ExportIntersectable(objects[j]); 
    933                                                 objects[j]->Mail(); 
    934                                         } 
    935                         } 
    936                         DEL_PTR(exporter); 
    937                         cout << "finished" << endl; 
    938                 } 
    939         } 
    940         else 
    941         { 
    942                 ViewCellContainer viewCells; 
    943  
    944                 mBspTree->CollectViewCells(viewCells); 
    945                 stable_sort(viewCells.begin(), viewCells.end(), vc_gt); 
    946  
    947                 int limit = min(leafOut, (int)viewCells.size());  
    948                  
    949                 for (int i = 0; i < limit; ++ i) 
    950                 { 
    951                         cout << "creating output for view cell " << i << " ... "; 
    952                          
    953             Intersectable::NewMail(); 
    954                         BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]); 
    955  
    956                         cout << "creating output for view cell " << i << " ... "; 
    957                         // check whether we can add the current ray to the output rays 
    958                         for (int k = 0; k < raysOut; ++ k)  
    959                         { 
    960                                 Ray *ray = mSampleRays[k]; 
    961  
    962                                 for     (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
    963                                 { 
    964                                         BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 
    965  
    966                                         if (vc == leaf->GetViewCell())  
    967                                         { 
    968                                                 vcRays[i].push_back(ray); 
    969                                         } 
    970                                 } 
    971                         } 
    972  
    973                         //bspLeaves[j]->Mail(); 
    974                         char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 
    975  
    976                         Exporter *exporter = Exporter::GetExporter(s); 
    977                         exporter->SetFilled(); 
    978  
    979                         ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    980  
    981                         exporter->SetWireframe(); 
    982  
    983                         Material m;//= RandomMaterial(); 
    984                         m.mDiffuseColor = RgbColor(0, 1, 0); 
    985                         exporter->SetForcedMaterial(m); 
    986  
    987                         if (vc->GetMesh()) 
    988                                 exporter->ExportViewCell(vc); 
    989                         else 
    990                         { 
    991                                 PolygonContainer cell; 
    992                                 // export view cell 
    993                                 mBspTree->ConstructGeometry(vc, cell); 
    994                                 exporter->ExportPolygons(cell); 
    995                                 CLEAR_CONTAINER(cell); 
    996                         } 
    997  
    998                         Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() << endl; 
    999  
    1000                          
    1001                         // export rays piercing this view cell 
    1002                         exporter->ExportRays(vcRays[i], 10000, RgbColor(0, 1, 0)); 
    1003  
    1004                         m.mDiffuseColor = RgbColor(1, 0, 0); 
    1005                         exporter->SetForcedMaterial(m); 
    1006  
    1007                         // output PVS of view cell 
    1008                         for (; it != vc->GetPvs().mEntries.end(); ++ it)  
    1009                         { 
    1010                                 Intersectable *intersect = (*it).first; 
    1011                                 if (!intersect->Mailed()) 
    1012                                 { 
    1013                                         exporter->ExportIntersectable(intersect); 
    1014                                         intersect->Mail(); 
    1015                                 }                        
    1016                         } 
    1017                                  
    10181022                        DEL_PTR(exporter); 
    10191023                        cout << "finished" << endl; 
Note: See TracChangeset for help on using the changeset viewer.