Changeset 591


Ignore:
Timestamp:
02/05/06 03:07:32 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r590 r591  
    3636        loadInitialSamples  false 
    3737        storeInitialSamples false 
    38         useViewSpaceBox true 
     38        useViewSpaceBox false 
    3939#       testBeamSampling true 
    4040} 
     
    181181 
    182182        #number of active view cells 
    183         active 169 
     183        active 256 
    184184        maxStaticMemory 40 
    185185 
    186186        exportToFile false 
    187         loadFromFile true 
     187        loadFromFile false 
    188188 
    189189        #type kdTree 
     
    225225                exportGeometry true 
    226226                exportMergedViewCells false 
     227                useCuttingPlane true 
     228                cuttingPlaneAxis 1 
    227229        } 
    228230         
     
    300302         
    301303        # maximal candidates for split planes 
    302         maxPolyCandidates 100 
    303         #maxRayCandidates 100 
     304        maxPolyCandidates 0 
     305 
    304306         
    305307        # maximal tested rays for split cost heuristics 
     
    340342        } 
    341343         
    342         splitUseOnlyDrivingAxis false 
     344        splitUseOnlyDrivingAxis true 
    343345         
    344346        Visualization { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r587 r591  
    13301330                "view_cells_post_process_use_rays_for_merge=",  
    13311331                "false"); 
     1332         
     1333        RegisterOption("ViewCells.PostProcess.merge",  
     1334                optBool, 
     1335                "view_cells_post_merge=",  
     1336                "true"); 
    13321337 
    13331338        RegisterOption("ViewCells.Visualization.exportMergedViewCells", 
     
    13401345                "view_cells_max_static_mem=",  
    13411346                "8.0"); 
     1347 
     1348        RegisterOption("ViewCells.Visualization.useCuttingPlane", 
     1349                optBool,  
     1350                "view_cells_viz_use_cutting_plane=",  
     1351                "false"); 
     1352 
     1353         
     1354        RegisterOption("ViewCells.Visualization.cuttingPlaneAxis", 
     1355                optInt,  
     1356                "view_cells_viz_cutting_plane_axis=",  
     1357                "0"); 
    13421358 
    13431359 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r590 r591  
    5454        environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass); 
    5555        environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 
    56         environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge); 
     56        environment->GetBoolValue("ViewCells.PostProcess.e", mUseMerge); 
    5757         
    5858        environment->GetIntValue("ViewCells.active", mNumMergedViewCells); 
    5959        environment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells); 
     60        environment->GetBoolValue("ViewCells.Visualization.useCuttingPlane", mUseCuttingPlaneForViz); 
     61 
     62        environment->GetBoolValue("ViewCells.Visualization.", mUseCuttingPlaneForViz); 
     63 
     64        environment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells); 
    6065 
    6166        mMinPvsSize = emptyViewCells ? 1 : 0; 
     
    673678{ 
    674679        mViewSpaceBox = box; 
     680 
     681        CreateCuttingPlane(); 
     682         
    675683        mTotalAreaValid = false; 
     684} 
     685 
     686 
     687void ViewCellsManager::CreateCuttingPlane() 
     688{ 
     689        int axis = 0; 
     690 
     691        Vector3 point = mViewSpaceBox.Center(); 
     692 
     693        if (mUseCuttingPlaneForViz) 
     694        environment->GetIntValue("ViewCells.Visualization.cuttingPlaneAxis", axis); 
     695 
     696        Vector3 normal(0,0,0); 
     697        normal[axis] = 1; 
     698 
     699        mCuttingPlane = Plane3(normal, point); 
    676700} 
    677701 
     
    872896                { 
    873897                        ExportColor(exporter, *it);              
    874                         ExportViewCellGeometry(exporter, *it);           
     898                        ExportViewCellGeometry(exporter, *it,  
     899                                mUseCuttingPlaneForViz ? &mCuttingPlane : NULL); 
    875900                } 
    876901        } 
     
    10271052        // view cells tree constructed 
    10281053        if (!ViewCellsTreeConstructed()) 
    1029         { 
    1030                  
     1054        {                
    10311055                mBspTree->CollectViewCells(mViewCells); 
    10321056        } 
    10331057        else  
    10341058        { 
    1035                  
    10361059                // we can use the view cells tree hierarchy to get the right set 
    1037                 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 
     1060                mViewCellsTree->CollectBestViewCellSet(mViewCells,  
     1061                                                                                           mNumMergedViewCells); 
    10381062        } 
    10391063} 
     
    10431067{ 
    10441068        // compute view cell area as subsititute for probability 
    1045 #if 1 
    1046         return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 
    1047 #else 
    1048         return GetArea(viewCell) / GetAccVcArea(); 
    1049 #endif 
     1069        if (1) 
     1070                return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 
     1071        else 
     1072                return GetArea(viewCell) / GetAccVcArea(); 
    10501073} 
    10511074 
     
    11251148        } 
    11261149 
    1127         cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 
    1128  
    1129         long startTime = GetTime(); 
    11301150         
    1131         VssRayContainer postProcessRays; 
    1132         GetRaySets(rays, mPostProcessSamples, postProcessRays); 
    1133  
    1134         //-- merge or subdivide view cells 
    1135         int merged = mViewCellsTree->ConstructMergeTree(rays, objects); 
    1136  
    1137         //-- stats and visualizations 
    1138         cout << "finished" << endl; 
    1139         cout << "merged " << merged << " view cells in " 
    1140                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
    1141  
    1142         Debug << "Postprocessing: Merged " << merged << " view cells in " 
    1143                   << TimeDiff(startTime, GetTime()) *1e-3 << " secs" 
    1144                   << "using " << (int)rays.size() << " samples" << endl << endl; 
    1145  
     1151 
     1152        //-- merge view cells 
     1153        int merged; 
     1154         
     1155        const bool mergeBspLeaves = false; 
     1156        if (mergeBspLeaves) 
     1157        { 
     1158                cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 
     1159                long startTime = GetTime(); 
     1160         
     1161                VssRayContainer postProcessRays; 
     1162                GetRaySets(rays, mPostProcessSamples, postProcessRays); 
     1163 
     1164                merged = mViewCellsTree->ConstructMergeTree(rays, objects); 
     1165 
     1166                //-- stats and visualizations 
     1167                cout << "finished" << endl; 
     1168                cout << "merged " << merged << " view cells in " 
     1169                         << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     1170 
     1171                Debug << "Postprocessing: Merged " << merged << " view cells in " 
     1172                        << TimeDiff(startTime, GetTime()) *1e-3 << " secs" 
     1173                        << "using " << (int)rays.size() << " samples" << endl << endl; 
     1174        } 
    11461175 
    11471176        // reset view cells and stats 
     
    14151444 
    14161445void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    1417                                                                                                  ViewCell *vc) const 
     1446                                                                                                 ViewCell *vc, 
     1447                                                                                                 const Plane3 *cuttingPlane) const 
    14181448{ 
    14191449        if (vc->GetMesh()) 
    14201450        { 
    14211451                exporter->ExportMesh(vc->GetMesh()); 
     1452         
    14221453                return; 
    14231454        } 
     
    14251456        BspNodeGeometry geom; 
    14261457        mBspTree->ConstructGeometry(vc, geom); 
    1427         exporter->ExportPolygons(geom.mPolys); 
     1458 
     1459 
     1460        if (cuttingPlane) 
     1461        { 
     1462                BspNodeGeometry front; 
     1463                BspNodeGeometry back; 
     1464 
     1465                geom.SplitGeometry(front, 
     1466                                                   back, 
     1467                                                   *cuttingPlane, 
     1468                                                   mViewSpaceBox,  
     1469                                                   0.005); 
     1470 
     1471                exporter->ExportPolygons(back.mPolys); 
     1472        } 
     1473        else 
     1474        { 
     1475                exporter->ExportPolygons(geom.mPolys); 
     1476        } 
    14281477} 
    14291478 
     
    18281877 
    18291878void KdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    1830                                                                                                 ViewCell *vc) const 
     1879                                                                                                ViewCell *vc, 
     1880                                                                                                const Plane3 *cuttingPlane) const 
    18311881{ 
    18321882        ViewCellContainer leaves; 
     
    22152265 
    22162266void VspKdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    2217                                                                                    ViewCell *vc) const 
     2267                                                                                                   ViewCell *vc, 
     2268                                                                                                   const Plane3 *cuttingPlane) const 
    22182269{ 
    22192270        VspKdViewCell *kdVc = dynamic_cast<VspKdViewCell *>(vc); 
     
    25422593        } 
    25432594 
    2544         //-- merge the individual view cells 
    2545         MergeViewCells(postProcessRays, objects); 
    2546  
    2547         //-- refines the merged view cells 
    2548         if (0) 
    2549                 RefineViewCells(postProcessRays, objects); 
    2550  
    2551         if (mCompressViewCells) 
    2552         { 
    2553                 int pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
    2554                 Debug << "number of entries before compress: " << pvsEntries << endl; 
    2555  
    2556                 mViewCellsTree->CompressViewCellsPvs(); 
    2557  
    2558                 pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
    2559                 Debug << "number of entries after compress: " << pvsEntries << endl; 
     2595        if (mMergeViewCells) 
     2596        { 
     2597                //-- merge the individual view cells 
     2598                MergeViewCells(postProcessRays, objects); 
     2599         
     2600 
     2601                //-- refines the merged view cells 
     2602                if (0) 
     2603                        RefineViewCells(postProcessRays, objects); 
     2604 
     2605                if (mCompressViewCells) 
     2606                { 
     2607                        int pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
     2608                        Debug << "number of entries before compress: " << pvsEntries << endl; 
     2609 
     2610                        mViewCellsTree->CompressViewCellsPvs(); 
     2611 
     2612                        pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
     2613                        Debug << "number of entries after compress: " << pvsEntries << endl; 
     2614                } 
    25602615        } 
    25612616 
     
    30053060                        if (vcValid) 
    30063061                        { 
    3007                                 m = RandomMaterial(); 
     3062                                m.mDiffuseColor.r = RandomValue(0.3f, 1.0f); 
     3063                                m.mDiffuseColor.g = RandomValue(0.3f, 1.0f); 
     3064                                m.mDiffuseColor.b = RandomValue(0.3f, 1.0f); 
    30083065                        } 
    30093066                        else 
     
    30133070                                m.mDiffuseColor.b = 0.0f; 
    30143071                        } 
    3015                 } 
    3016                 return; 
     3072 
     3073                        exporter->SetForcedMaterial(m); 
     3074                        return; 
     3075                } 
     3076                 
    30173077        case 1: // pvs 
    30183078                { 
     
    30513111 
    30523112void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    3053                                                                                                         ViewCell *vc) const 
     3113                                                    ViewCell *vc, 
     3114                                                                                                        const Plane3 *cuttingPlane) const 
    30543115{ 
    30553116        if (vc->GetMesh()) 
     
    30603121        } 
    30613122 
    3062         BspNodeGeometry geom; 
    3063         mVspBspTree->ConstructGeometry(vc, geom); 
    3064         exporter->ExportPolygons(geom.mPolys); 
     3123         
     3124        if (cuttingPlane) 
     3125        { 
     3126                ViewCellContainer leaves; 
     3127                mViewCellsTree->CollectLeaves(vc, leaves); 
     3128                ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     3129 
     3130                for (it = leaves.begin(); it != it_end; ++ it) 
     3131                { 
     3132                        BspNodeGeometry geom; 
     3133 
     3134                        BspNodeGeometry front; 
     3135                        BspNodeGeometry back; 
     3136 
     3137         
     3138                        BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     3139 
     3140                        mVspBspTree->ConstructGeometry(leaf, geom); 
     3141                         
     3142                        geom.SplitGeometry(front, 
     3143                                                           back, 
     3144                                                           *cuttingPlane, 
     3145                                                           mViewSpaceBox,  
     3146                                                           0.005); 
     3147 
     3148                        exporter->ExportPolygons(back.mPolys); 
     3149                } 
     3150        } 
     3151        else 
     3152        { 
     3153                BspNodeGeometry geom; 
     3154                mVspBspTree->ConstructGeometry(vc, geom); 
     3155                         
     3156                exporter->ExportPolygons(geom.mPolys); 
     3157        } 
    30653158} 
    30663159 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r590 r591  
    9393                @returns number of sample contributions 
    9494        */ 
    95         virtual float ComputeSampleContributions(VssRay &ray, const bool addRays, const bool storeViewCells); 
    96  
    97   virtual void AddSampleContributions(VssRay &ray); 
     95        virtual float ComputeSampleContributions(VssRay &ray,  
     96                                                                                         const bool addRays,  
     97                                                                                         const bool storeViewCells); 
     98 
     99        virtual void AddSampleContributions(VssRay &ray); 
    98100 
    99101        /** Prints out statistics of the view cells. 
     
    318320        /** Exports view cell geometry. 
    319321        */ 
    320         virtual void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const = 0; 
     322        virtual void ExportViewCellGeometry(Exporter *exporter,  
     323                                                                                ViewCell *vc, 
     324                                                                                const Plane3 *cuttingPlane = NULL) const = 0; 
    321325 
    322326        virtual void FinalizeViewCells(const bool createMesh); 
    323327 
    324328 
    325         /** Loads view cells from file. The view cells manager is created with respect to the loaded 
    326                 view cells. 
     329        /** Loads view cells from file. The view cells manager is created with  
     330                respect to the loaded view cells. 
    327331 
    328332                @returns the view cells manager if loading was successful, false otherwise 
    329333        */ 
    330         static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 
     334        static ViewCellsManager *LoadViewCells(const string filename,  
     335                                                                                   ObjectContainer *objects); 
    331336 
    332337        /** Evaluates statistics values on view cells. 
     
    351356protected: 
    352357 
     358 
    353359        /** 
    354360                if the view cells tree was already constructed or not. 
     
    411417        */ 
    412418        virtual void PrepareLoadedViewCells() {}; 
     419 
     420 
     421        void CreateCuttingPlane(); 
     422 
     423        Plane3 mCuttingPlane; 
     424        bool mUseCuttingPlaneForViz; 
     425 
    413426 
    414427        /// Renders the view cells. 
     
    446459        bool mExportViewCells; 
    447460 
     461        //bool mMarchTree); 
    448462        bool mOnlyValidViewCells; 
    449463 
     
    451465        bool mUseRaysForMerge; 
    452466         
    453  
     467         
    454468        //-- visualization options 
    455469         
     
    507521        void CreateMesh(ViewCell *vc); 
    508522 
    509         void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 
     523        void ExportViewCellGeometry(Exporter *exporter,  
     524                                                                ViewCell *vc,  
     525                                                                const Plane3 *cuttingPlane = NULL) const; 
    510526         
    511527        void CollectMergeCandidates(const VssRayContainer &rays,  
     
    584600        void CreateMesh(ViewCell *vc); 
    585601 
    586         void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 
    587  
    588         void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 
     602        void ExportViewCellGeometry(Exporter *exporter,  
     603                                                                ViewCell *vc, 
     604                                                                const Plane3 *cuttingPlane = NULL) const; 
     605 
     606        void CollectMergeCandidates(const VssRayContainer &rays,  
     607                                                                vector<MergeCandidate> &candidates); 
    589608 
    590609protected: 
     
    647666        void CreateMesh(ViewCell *vc); 
    648667 
    649         void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 
     668        void ExportViewCellGeometry(Exporter *exporter,  
     669                                                                ViewCell *vc, 
     670                                                                const Plane3 *cuttingPlane = NULL) const; 
    650671 
    651672        void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 
     
    715736        int CastBeam(Beam &beam); 
    716737 
    717         void ExportViewCellGeometry(Exporter *exporter, ViewCell *vc) const; 
     738        void ExportViewCellGeometry(Exporter *exporter,  
     739                                                                ViewCell *vc, 
     740                                                                const Plane3 *cuttingPlane = NULL) const; 
    718741 
    719742        //float GetVolume(ViewCell *viewCell) const; 
     
    748771        void PrepareLoadedViewCells(); 
    749772 
     773         
    750774        /// the view space partition BSP tree. 
    751775        VspBspTree *mVspBspTree; 
    752776 
     777 
    753778private: 
    754779 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r590 r591  
    123123                float GetCost() const 
    124124                { 
     125#if 0 
     126                        return mPvs * mProbability; 
     127#endif 
    125128#if 1 
    126                         return mPvs * mProbability; 
     129                        return - mDepth; 
    127130#endif 
    128131#if 0 
Note: See TracChangeset for help on using the changeset viewer.