Changeset 1920


Ignore:
Timestamp:
12/22/06 20:08:48 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1913 r1920  
    308308        */ 
    309309        BvhLeaf(const AxisAlignedBox3 &bbox); 
    310   BvhLeaf(const AxisAlignedBox3 &bbox, BvhInterior *parent); 
     310        BvhLeaf(const AxisAlignedBox3 &bbox, BvhInterior *parent); 
    311311        BvhLeaf(const AxisAlignedBox3 &bbox, BvhInterior *parent, const int numObjects); 
    312312 
     
    349349  /// objects 
    350350  ObjectContainer mObjects; 
     351   
    351352   
    352353protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp

    r1843 r1920  
    105105 
    106106bool Exporter::ExportBvHierarchy(const BvHierarchy &bvHierarchy,  
    107                                                                  const int maxPvs, 
     107                                                                 const float maxPvs, 
    108108                                                                 AxisAlignedBox3 *box, 
    109109                                                                 const bool exportBoundingBoxes) 
     
    135135                } 
    136136 
    137         if (maxPvs) // color code pvs 
     137        if (maxPvs > 0) // color code pvs 
    138138                { 
    139139                        mForcedMaterial.mDiffuseColor.b = 1.0f; 
    140                         const float importance = (float)leaf->mObjects.size() / (float)maxPvs; 
     140                        const float importance = (float)leaf->mRenderCost / (float)maxPvs; 
    141141 
    142142                        mForcedMaterial.mDiffuseColor.r = importance; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h

    r1867 r1920  
    154154  bool ExportBvHierarchy( 
    155155          const BvHierarchy &bvHierarchy,  
    156           const int maxPvs,  
     156          const float maxPvs,  
    157157          AxisAlignedBox3 *box = NULL, 
    158158          const bool exportBoundingBoxes = true); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1919 r1920  
    14991499                                                                                                  const ObjectContainer &objects, 
    15001500                                                                                                  AxisAlignedBox3 *bbox, 
     1501                                                                                                  const float maxRenderCost, 
    15011502                                                                                                  const bool exportBounds) const 
    15021503{ 
     
    15101511        case BV_BASED_OBJ_SUBDIV: 
    15111512                { 
    1512                         exporter->ExportBvHierarchy(*mBvHierarchy, 0, bbox, exportBounds); 
     1513                        exporter->ExportBvHierarchy(*mBvHierarchy, maxRenderCost, bbox, exportBounds); 
    15131514                        break; 
    15141515                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1919 r1920  
    247247        VspTree *GetVspTree(); 
    248248 
    249         /** Returns view space bounding box. 
    250         */ 
    251         //AxisAlignedBox3 GetViewSpaceBox() const; 
    252  
    253249        /** Returns object space bounding box. 
    254250        */ 
     
    260256                                                                        const ObjectContainer &objects, 
    261257                                                                        AxisAlignedBox3 *bbox, 
     258                                                                        const float maxRenderCost, 
    262259                                                                        const bool exportBounds = true) const; 
    263260 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r1919 r1920  
    206206                                Name="VCLinkerTool" 
    207207                                AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtGlRenderer.lib" 
    208                                 OutputFile="../bin/release/Preprocessor.exe" 
     208                                OutputFile="../bin/release/Preprocessor2.exe" 
    209209                                LinkIncremental="1" 
    210210                                AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;"$(QTDIR)\lib";.\QtGlRenderer\Release" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1919 r1920  
    29912991        // special color code for invalid view cells 
    29922992        m.mDiffuseColor.r = importance; 
    2993         m.mDiffuseColor.g = vcValid ? 0.0f : 1.0f; 
    2994         m.mDiffuseColor.b = 1.0f - importance; 
     2993        m.mDiffuseColor.b = 1.0f;//vcValid ? 0.0f : 1.0f; 
     2994        m.mDiffuseColor.g = 1.0f - importance; 
    29952995 
    29962996        //Debug << "importance: " << importance << endl; 
     
    56505650 
    56515651 
     5652float VspOspViewCellsManager::UpdateObjectCosts() 
     5653{ 
     5654        float maxRenderCost = 0; 
     5655 
     5656        cout << "updating object pvs cost ... "; 
     5657        const long startTime = GetTime(); 
     5658 
     5659        ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
     5660 
     5661        Intersectable::NewMail(); 
     5662 
     5663        const float invViewSpaceVol = 1.0f / GetViewSpaceBox().GetVolume(); 
     5664 
     5665        for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
     5666        { 
     5667                ViewCell *vc = *vit; 
     5668 
     5669                ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
     5670 
     5671                // output PVS of view cell 
     5672                while (pit.HasMoreEntries()) 
     5673                {                
     5674                        ObjectPvsEntry entry = pit.Next(); 
     5675                                 
     5676                        BvhNode *node = dynamic_cast<BvhNode *>(entry.mObject); 
     5677                         
     5678                        // hack!! 
     5679                        if (!node->IsLeaf()) 
     5680                        { 
     5681                                cout << "error, can only do leaves" << endl; 
     5682                                return 0; 
     5683                        } 
     5684         
     5685                        if (!node->Mailed()) 
     5686                        { 
     5687                                node->Mail(); 
     5688                                node->mRenderCost = 0; 
     5689                        } 
     5690 
     5691                        const float rc = (float)((BvhLeaf *)node)->mObjects.size(); 
     5692 
     5693                        node->mRenderCost += rc * vc->GetVolume() * invViewSpaceVol; 
     5694 
     5695                        if (node->mRenderCost > maxRenderCost) 
     5696                                maxRenderCost = node->mRenderCost; 
     5697                } 
     5698        } 
     5699 
     5700        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
     5701 
     5702        return maxRenderCost; 
     5703} 
     5704 
     5705 
    56525706void VspOspViewCellsManager::Visualize(const ObjectContainer &objects, 
    56535707                                                                           const VssRayContainer &sampleRays) 
     
    56645718        Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    56655719 
    5666         Vector3 scale(0.9f, 0.9f, 0.9f); 
    5667         //Vector3 scale(1.0f, 1.0f, 1.0f); 
     5720        //Vector3 scale(0.9f, 0.9f, 0.9f); 
     5721        Vector3 scale(1.0f, 1.0f, 1.0f); 
    56685722 
    56695723        if (exporter) 
     
    56835737                bbox.Scale(scale); 
    56845738 
    5685                 if (1 && mExportRays) 
     5739                if (0 && mExportRays) 
    56865740                {        
    56875741                        exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 
    56885742                } 
    56895743 
    5690                 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects,  
    5691                                                                                                           CLAMP_TO_BOX ? &bbox : NULL, false); 
    5692                  
    56935744                // hack color code (show pvs size) 
    56945745                const int savedColorCode = mColorCode; 
    5695                 mColorCode = 1; // export pvs 
     5746 
     5747                const float maxRenderCost = UpdateObjectCosts(); 
     5748                cout << "maxRenderCost: " << maxRenderCost << endl; 
     5749                mColorCode = 0; // 0 = random, 1 = export pvs 
     5750 
     5751                mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects,  
     5752                                                                                                          CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false); 
     5753                 
    56965754 
    56975755                //ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane()); 
     
    57045762        } 
    57055763 
    5706         // export final object partition 
    57075764        exporter = Exporter::GetExporter("final_object_partition.wrl"); 
    57085765 
     
    57145771                } 
    57155772 
     5773                EvaluateViewCellsStats(); 
     5774 
     5775                const long starttime = GetTime(); 
     5776                cout << "exporting final objects (after initial construction + post process) ... "; 
     5777 
     5778                // matt: hack for clamping scene 
     5779                AxisAlignedBox3 bbox = mViewSpaceBox; 
     5780                bbox.Scale(scale); 
     5781 
     5782                // hack color code (show pvs size) 
     5783                const int savedColorCode = mColorCode; 
     5784 
     5785                mColorCode = 1; // 0 = random, 1 = export pvs 
     5786                const float maxRenderCost = -1; 
     5787 
     5788                mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects,  
     5789                                                                                                          CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false); 
     5790                 
     5791 
     5792                //ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane()); 
     5793                ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 
     5794 
     5795                delete exporter; 
     5796 
     5797                cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 
     5798                mColorCode = savedColorCode; 
     5799        } 
     5800 
     5801#if 0 
     5802        // export final object partition 
     5803        exporter = Exporter::GetExporter("final_object_partition.wrl"); 
     5804 
     5805        if (exporter) 
     5806        { 
     5807                if (CLAMP_TO_BOX) 
     5808                {        
     5809                        exporter->mClampToBox = true;    
     5810                } 
     5811 
    57165812                const long starttime = GetTime(); 
    57175813 
     
    57215817 
    57225818                cout << "exporting object space hierarchy ... "; 
    5723                 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL); 
     5819                mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL, -1); 
    57245820 
    57255821                delete exporter; 
    57265822                cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 
    57275823        } 
    5728          
     5824#endif 
     5825 
    57295826        // visualization of the view cells 
    57305827    if (0)  
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1919 r1920  
    10291029                                                           VssRayContainer *visRays = NULL); 
    10301030 
    1031  
     1031         
    10321032protected: 
    10331033 
     
    11621162                                                           const string prefix, 
    11631163                                                           VssRayContainer *visRays = NULL); 
     1164         
     1165        float UpdateObjectCosts(); 
    11641166 
    11651167protected: 
Note: See TracChangeset for help on using the changeset viewer.