Ignore:
Timestamp:
09/19/06 09:41:23 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1415 r1416  
    356356         
    357357        ResetViewCells(); 
    358         if (0) Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 
    359  
    360         //-- optionally export initial view cell partition 
    361         if (0)  
    362         { 
     358                 
     359        if (0) //-- optionally export initial view cell partition 
     360        { 
     361        Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 
     362 
    363363                const string filename("viewcells.wrl"); 
    364364                Exporter *exporter = Exporter::GetExporter(filename.c_str()); 
     
    374374 
    375375                        exporter->SetWireframe(); 
    376                         ExportViewCellsForViz(exporter); 
     376                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    377377 
    378378                        delete exporter; 
     
    429429         
    430430#if 0 
    431         //////////////////////////////////////////////// 
    432         //-- get stats after the additional sampling step 
     431        /////////////// 
     432        //-- Get stats after the additional sampling step 
    433433        //-- and before the bottom-up merge step 
    434434 
     
    445445 
    446446 
    447         /////////////////////////////////////////////// 
     447        //////////////////// 
    448448        // 
    449449        //-- post processing of the initial construction 
     
    476476 
    477477         
    478         ////////////////////////////////////////////////////////////// 
     478        //////////////// 
    479479        //-- Evaluation of the resulting view cell partition.  
    480480        //-- We cast a number of new samples and measure the render cost 
     
    486486 
    487487         
    488         /////////////////////////////////// 
     488        ///////////////// 
    489489        //-- Finally, we do some visualization 
    490490 
     
    508508 
    509509        return numSamples; 
     510} 
     511 
     512 
     513AxisAlignedPlane * ViewCellsManager::GetClipPlane() 
     514{ 
     515        return mUseClipPlaneForViz ? &mClipPlaneForViz : NULL; 
    510516} 
    511517 
     
    16921698 
    16931699        Environment::GetSingleton()->GetFloatValue("ViewCells.Visualization.clipPlanePos", pos); 
    1694  
    1695         Vector3 point = mViewSpaceBox.Min() +  mViewSpaceBox.Size() * pos; 
    1696  
    1697         if (mUseClipPlaneForViz) 
    1698         Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 
    1699  
    1700         mClipPlane = AxisAlignedPlane(axis, point[axis]); 
     1700        Vector3 absPos = mViewSpaceBox.Min() +  mViewSpaceBox.Size() * pos; 
     1701         
     1702        Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 
     1703 
     1704        mClipPlaneForViz = AxisAlignedPlane(axis, absPos[axis]); 
    17011705} 
    17021706 
     
    19461950} 
    19471951 
    1948 // matt: todo 
    1949 void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter) const 
     1952 
     1953void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter, 
     1954                                                                                         const AxisAlignedBox3 *sceneBox, 
     1955                                                                                         const AxisAlignedPlane *clipPlane 
     1956                                                                                         ) const 
    19501957{ 
    19511958        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     
    19561963                { 
    19571964                        ExportColor(exporter, *it);      
    1958  
    1959                         ExportViewCellGeometry(exporter, *it,  
    1960                                 mUseClipPlaneForViz ? &mClipPlane : NULL); 
     1965                        ExportViewCellGeometry(exporter, *it, sceneBox, clipPlane); 
    19611966                } 
    19621967        } 
     
    26702675        const int savedColorCode = mColorCode; 
    26712676         
    2672         //BspLeaf::NewMail(); 
    26732677        if (1) // export merged view cells 
    26742678        { 
    2675                 mColorCode = 0; 
    2676                  
     2679                mColorCode = 0; // hack color code 
    26772680                Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 
    26782681                 
     
    26832686                { 
    26842687                        if (mExportGeometry) 
     2688                        { 
    26852689                                exporter->ExportGeometry(objects); 
    2686  
    2687                         //exporter->SetWireframe(); 
     2690                        } 
     2691 
    26882692                        exporter->SetFilled(); 
    2689                         ExportViewCellsForViz(exporter); 
    2690  
     2693                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    26912694 
    26922695                        delete exporter; 
     
    26952698        } 
    26962699 
    2697         if (1) // export merged view cells using pvs color coding 
    2698         { 
     2700        if (1)  
     2701        { 
     2702                // export merged view cells using pvs color coding 
    26992703                mColorCode = 1; 
    27002704 
    27012705                Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 
    2702          
    27032706                cout << "exporting view cells after merge (pvs size) ... ";      
    27042707 
    27052708                if (exporter) 
    27062709                { 
    2707                         //exporter->SetWireframe(); 
    2708                         //exporter->SetForcedMaterial(RandomMaterial()); 
    2709  
    27102710                        if (mExportGeometry) 
     2711                        { 
    27112712                                exporter->ExportGeometry(objects); 
    2712  
    2713                         //exporter->SetWireframe(); 
     2713                        } 
     2714                         
    27142715                        exporter->SetFilled(); 
    2715                         ExportViewCellsForViz(exporter); 
     2716                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    27162717 
    27172718                        delete exporter; 
     
    27692770                if (exporter) 
    27702771                { 
    2771                         //exporter->SetWireframe(); 
    2772                          
    27732772                        if (mExportGeometry) 
     2773                        { 
    27742774                                exporter->ExportGeometry(objects); 
    2775  
    2776                         //exporter->SetFilled(); 
    2777                         const bool b = mUseClipPlaneForViz; 
    2778                         mUseClipPlaneForViz = false; 
    2779  
    2780                         ExportViewCellsForViz(exporter); 
    2781                          
    2782                         mUseClipPlaneForViz = b; 
     2775                        } 
     2776 
     2777                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    27832778                        delete exporter; 
    27842779                } 
     
    27882783        mColorCode = savedColorCode; 
    27892784 
     2785 
     2786        ////////////////// 
    27902787        //-- visualization of the BSP splits 
     2788 
    27912789        bool exportSplits = false; 
    27922790        Environment::GetSingleton()->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); 
     
    28902888                exporter->SetForcedMaterial(m); 
    28912889 
    2892                 ExportViewCellGeometry(exporter, vc); 
     2890                ExportViewCellGeometry(exporter, vc, NULL, NULL); 
    28932891                 
    28942892                // export rays piercing this view cell 
     
    29622960void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    29632961                                                                                                 ViewCell *vc, 
    2964                                                                                                  const AxisAlignedPlane *clipPlane) const 
     2962                                                                                                 const AxisAlignedBox3 *sceneBox, 
     2963                                                                                                 const AxisAlignedPlane *clipPlane 
     2964                                                                                                ) const 
    29652965{ 
    29662966        // export mesh if available 
     
    34373437void KdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    34383438                                                                                                ViewCell *vc, 
    3439                                                                                                 const AxisAlignedPlane *clipPlane) const 
     3439                                                                                                const AxisAlignedBox3 *sceneBox, 
     3440                                                                                                const AxisAlignedPlane *clipPlane 
     3441                                                                                                ) const 
    34403442{ 
    34413443        ViewCellContainer leaves; 
    3442  
    34433444        mViewCellsTree->CollectLeaves(vc, leaves); 
    34443445        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     
    34473448        { 
    34483449                KdViewCell *kdVc = dynamic_cast<KdViewCell *>(*it); 
    3449          
    34503450                exporter->ExportBox(mKdTree->GetBox(kdVc->mLeaf)); 
    34513451        } 
     
    37183718                                exporter->SetFilled(); 
    37193719 
    3720                         ExportViewCellsForViz(exporter); 
     3720                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    37213721 
    37223722                        if (mExportGeometry) 
     
    37373737        if (1)  
    37383738        { 
    3739                 mColorCode = 1; // export merged view cells using pvs coding 
     3739                // use pvs size for color coding 
     3740                mColorCode = 1; 
    37403741                Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 
    37413742 
     
    37443745                if (exporter) 
    37453746                { 
    3746                         if (0) 
    3747                                 exporter->SetWireframe(); 
    3748                         else 
    3749                                 exporter->SetFilled(); 
    3750  
    3751                         ExportViewCellsForViz(exporter); 
     3747                        exporter->SetFilled(); 
     3748 
     3749                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    37523750 
    37533751                        if (mExportGeometry) 
     
    40334031        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
    40344032 
    4035         //-- export final view cell partition 
    4036  
     4033         
    40374034        if (0)  
    40384035        {        
    4039                 // hack pvs 
    4040                 //const int savedColorCode = mColorCode; 
    4041                 //mColorCode = 1; 
    4042          
     4036                ////////////////// 
     4037                //-- export final view cell partition 
     4038 
    40434039                Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    40444040                 
     
    40744070                        } 
    40754071 
    4076                         //exporter->SetFilled(); 
    4077  
    4078                         // HACK: export without clip plane 
    4079                         const bool b = mUseClipPlaneForViz; 
    4080                         //mUseClipPlaneForViz = false; 
    4081  
    4082                         ExportViewCellsForViz(exporter); 
    4083                          
    4084                         mUseClipPlaneForViz = b; 
     4072                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
     4073 
    40854074                        delete exporter; 
    4086  
    40874075                        cout << "finished" << endl; 
    40884076                } 
    4089  
    4090                 //mColorCode = savedColorCode; 
    4091         } 
    4092  
     4077        } 
    40934078 
    40944079        if (0) 
     
    43164301                } 
    43174302                 
    4318  
     4303                //////////////// 
    43194304                //-- export view cell geometry 
     4305 
    43204306                exporter->SetWireframe(); 
    43214307 
     
    43244310                exporter->SetForcedMaterial(m); 
    43254311 
    4326                 ExportViewCellGeometry(exporter, vc); 
    4327          
     4312                ExportViewCellGeometry(exporter, vc, NULL, NULL); 
    43284313                exporter->SetFilled(); 
    43294314 
    4330  
    4331                 //-- export pvs 
    43324315                if (1) 
    43334316                { 
     4317                        //////// 
     4318                        //-- export pvs 
    43344319                        ObjectPvsMap::const_iterator oit, 
    43354320                                oit_end = pvs.mEntries.end(); 
     
    43964381 
    43974382                exporter->SetForcedMaterial(RgbColor(0,1,0)); 
    4398                 ExportViewCellGeometry(exporter, GetViewCell(viewPoint)); 
     4383                ExportViewCellGeometry(exporter, GetViewCell(viewPoint), NULL, NULL); 
    43994384 
    44004385                //exporter->ResetForcedMaterial(); 
    44014386                exporter->SetForcedMaterial(RgbColor(0,0,1)); 
    4402                 ExportViewCellGeometry(exporter, testPrVs.mViewCell); 
     4387                ExportViewCellGeometry(exporter, testPrVs.mViewCell, NULL, NULL); 
    44034388 
    44044389        exporter->SetForcedMaterial(RgbColor(1,0,0)); 
     
    44914476                m.mDiffuseColor.b = 1.0f; 
    44924477                //exporter->SetForcedMaterial(m); 
    4493                 //ExportViewCellGeometry(exporter, vc, mClipPlane); 
     4478                //ExportViewCellGeometry(exporter, vc, mClipPlaneForViz); 
    44944479 
    44954480                /*      // counting the pvss 
     
    45104495 
    45114496void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    4512                                                     ViewCell *vc, 
    4513                                                                                                         const AxisAlignedPlane *clipPlane) const 
     4497                                                                                                        ViewCell *vc, 
     4498                                                                                                        const AxisAlignedBox3 *sceneBox, 
     4499                                                                                                        const AxisAlignedPlane *clipPlane 
     4500                                                                                                        ) const 
    45144501{ 
    45154502        if (clipPlane) 
     
    50135000void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    50145001                                                                                                        ViewCell *vc, 
    5015                                                                                                         const AxisAlignedPlane *clipPlane) const 
     5002                                                                                                        const AxisAlignedBox3 *sceneBox, 
     5003                                                                                                        const AxisAlignedPlane *clipPlane 
     5004                                                                                                        ) const 
    50165005{ 
    50175006        ViewCellContainer leaves; 
     
    50215010 
    50225011        Plane3 plane; 
    5023          
     5012 
    50245013        if (clipPlane) 
    5025         { 
    50265014                plane = clipPlane->GetPlane(); 
    5027         } 
    5028  
    5029         AxisAlignedBox3 bbox = GetViewSpaceBox(); 
    5030         bbox.Scale(Vector3(0.5, 1, 0.5));                        
    50315015 
    50325016        for (it = leaves.begin(); it != it_end; ++ it) 
     
    50355019                VspLeaf *l = vspVc->mLeaf; 
    50365020 
    5037                 const AxisAlignedBox3 box = mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 
     5021                const AxisAlignedBox3 box =  
     5022                        mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 
    50385023                 
    5039                 if (!Overlap(box, bbox)) 
     5024                if (!Overlap(*sceneBox, box)) 
    50405025                        continue; 
    50415026 
     
    50495034                        { 
    50505035                                AxisAlignedBox3 fbox, bbox; 
    5051                                 box.Split(clipPlane->mAxis, clipPlane->mPosition, fbox, bbox); 
     5036                                bbox.Split(clipPlane->mAxis, clipPlane->mPosition, fbox, bbox); 
    50525037 
    50535038                                exporter->ExportBox(bbox); 
     
    50845069        if (1)  
    50855070        {        
    5086                 ///////////////////////////// 
     5071                //////////// 
    50875072                //-- export final view cells 
    50885073 
     
    50985083                        cout << "exporting final view cells (after initial construction + post process) ... "; 
    50995084 
     5085                        // matt: hack 
     5086                        AxisAlignedBox3 bbox = mHierarchyManager->GetViewSpaceBox(); 
     5087                        bbox.Scale(Vector3(0.5, 1, 0.5)); 
     5088 
    51005089                        if (mExportGeometry) 
    51015090                        { 
    5102                                 exporter->ExportGeometry(objects, true); 
     5091                                exporter->ExportGeometry(objects, true, &bbox); 
    51035092                        } 
    51045093 
     
    51095098                        } 
    51105099 
    5111                         // HACK: export without clip plane 
    5112                         const bool b = mUseClipPlaneForViz; 
    5113                         if (0) mUseClipPlaneForViz = false; 
    5114  
    5115                         ExportViewCellsForViz(exporter); 
    5116                          
    5117                         mUseClipPlaneForViz = b; 
     5100                        ExportViewCellsForViz(exporter, &bbox, GetClipPlane()); 
     5101                 
    51185102                        delete exporter; 
    5119  
    51205103                        cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 
    51215104                } 
     
    51325115                { 
    51335116                        const long starttime = GetTime(); 
     5117                         
     5118                        // matt: hack 
     5119                        AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 
     5120                        bbox.Scale(Vector3(0.5, 1, 0.5)); 
    51345121 
    51355122                        cout << "exporting object space hierarchy ... "; 
    5136                         mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects); 
     5123                        mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, &bbox); 
    51375124                 
    51385125                        delete exporter; 
     
    51875174                mViewCellsTree->GetPvs(vc, pvs); 
    51885175 
    5189                 //bspLeaves[j]->Mail(); 
    51905176                char s[64]; sprintf(s, "bsp-pvs%04d.wrl", i); 
    51915177                Exporter *exporter = Exporter::GetExporter(s); 
     
    52665252                exporter->SetWireframe(); 
    52675253 
    5268                 Material m;//= RandomMaterial(); 
     5254                Material m; 
    52695255                m.mDiffuseColor = RgbColor(0, 1, 0); 
    52705256                exporter->SetForcedMaterial(m); 
    52715257 
    5272                 ExportViewCellGeometry(exporter, vc); 
    5273          
     5258                ExportViewCellGeometry(exporter, vc, NULL, NULL); 
    52745259                exporter->SetFilled(); 
    52755260 
Note: See TracChangeset for help on using the changeset viewer.