Changeset 568


Ignore:
Timestamp:
01/23/06 15:44:19 (18 years ago)
Author:
mattausch
Message:

debug version for testing shuffling and visualizing neighbors

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
3 edited

Legend:

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

    r565 r568  
    251251                maxCostRatio 0.005 
    252252                minViewCells 1000 
    253                 maxPvsSize   50000 
     253                maxPvsSize   5000 
    254254        } 
    255255         
     
    305305                #maxAccRayLength        100 
    306306                 
    307                 maxViewCells            50000 
     307                maxViewCells            5000 
    308308                 
    309309                # used for pvs criterium 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r567 r568  
    20972097        //-- refines the merged view cells 
    20982098        RefineViewCells(postProcessRays, objects); 
    2099         // collapse sibling leaves that share the same view cell 
    2100         mVspBspTree->CollapseTree(); 
    2101  
    2102         ResetViewCells(); 
    2103  
    2104         // real meshes are only contructed only at this stage 
    2105         FinalizeViewCells(true); 
    2106  
    2107         // write view cells to disc 
    2108         if (mExportViewCells) 
    2109         { 
    2110                 char buff[100]; 
    2111                 environment->GetStringValue("ViewCells.filename", buff); 
    2112                 string vcFilename(buff); 
    2113  
    2114                 ExportViewCells(buff); 
    2115         } 
    2116  
    2117         return 0; 
    2118 } 
    2119  
    2120  
    2121 int VspBspViewCellsManager::GetType() const 
    2122 { 
    2123         return VSP_BSP; 
    2124 } 
    2125  
    2126  
    2127 bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 
    2128 { 
    2129         if (!ViewCellsConstructed()) 
    2130                 return ViewCellsManager::GetViewPoint(viewPoint); 
    2131  
    2132         // TODO: set reasonable limit 
    2133         const int limit = 20; 
    2134  
    2135         for (int i = 0; i < limit; ++ i) 
    2136         { 
    2137                 viewPoint = mViewSpaceBox.GetRandomPoint(); 
    2138                 if (mVspBspTree->ViewPointValid(viewPoint)) 
    2139                 { 
    2140                         return true; 
    2141                 } 
    2142         } 
    2143         Debug << "failed to find valid view point, taking " << viewPoint << endl; 
    2144         return false; 
    2145 } 
    2146  
    2147  
    2148 bool VspBspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    2149 { 
    2150         return mViewSpaceBox.IsInside(viewPoint) && 
    2151                    mVspBspTree->ViewPointValid(viewPoint); 
    2152 } 
    2153  
    2154  
    2155 void VspBspViewCellsManager::Visualize(const ObjectContainer &objects, 
    2156                                                                            const VssRayContainer &sampleRays) 
    2157 { 
    2158         if (!ViewCellsConstructed()) 
    2159                 return; 
    2160  
    2161         VssRayContainer visRays; 
    2162         GetRaySets(sampleRays, mVisualizationSamples, visRays); 
    2163  
    2164         if (1) // export view cells 
    2165         { 
    2166                 cout << "exporting view cells after post process ... "; 
    2167                 Exporter *exporter = Exporter::GetExporter("final_view_cells.x3d"); 
    2168  
     2099 
     2100        //-- export shuffled view cells 
     2101        if (1) 
     2102        { 
     2103                cout << "exporting shuffled view cells ... "; 
     2104 
     2105                Exporter *exporter = Exporter::GetExporter("shuffled_view_cells.x3d"); 
    21692106                if (exporter) 
    21702107                { 
     
    21812118                        } 
    21822119 
    2183                         // export rays 
    2184                         if (mExportRays) 
     2120                        ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
     2121 
     2122                        Material vm, lm; 
     2123 
     2124                        for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    21852125                        { 
    2186                                 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 
     2126                                BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     2127 
     2128                                vm = RandomMaterial(); 
     2129 
     2130                                lm = vm; 
     2131 
     2132                                vm.mDiffuseColor.r -= 0.45f; 
     2133                                vm.mDiffuseColor.g -= 0.45f; 
     2134                                vm.mDiffuseColor.b -= 0.45f; 
     2135 
     2136                                vector<BspLeaf *>::const_iterator lit, lit_end = vc->mLeaves.end(); 
     2137 
     2138                                for (lit = vc->mLeaves.begin(); lit != lit_end; ++ lit) 
     2139                                { 
     2140                                        BspLeaf *leaf = *lit; 
     2141 
     2142                                        if (leaf->Mailed()) 
     2143                                                exporter->SetForcedMaterial(lm); 
     2144                                        else 
     2145                                                exporter->SetForcedMaterial(vm); 
     2146 
     2147                                        BspNodeGeometry geom; 
     2148                                        mVspBspTree->ConstructGeometry(leaf, geom); 
     2149                                        exporter->ExportPolygons(geom.mPolys); 
     2150                                } 
    21872151                        } 
    21882152 
    2189                         ExportViewCellsForViz(exporter); 
    21902153                        delete exporter; 
    21912154                } 
    2192         } 
    2193  
    2194         // export shuffled view cells 
    2195         if (1) 
    2196         { 
    2197                 cout << "exporting shuffled view cells ..."; 
    2198  
    2199                 Exporter *exporter = Exporter::GetExporter("shuffled_view_cells.x3d"); 
     2155 
     2156 
     2157                cout << "finished" << endl; 
     2158        } 
     2159 
     2160        // collapse sibling leaves that share the same view cell 
     2161        mVspBspTree->CollapseTree(); 
     2162 
     2163        ResetViewCells(); 
     2164 
     2165        // real meshes are only contructed only at this stage 
     2166        FinalizeViewCells(true); 
     2167 
     2168        // write view cells to disc 
     2169        if (mExportViewCells) 
     2170        { 
     2171                char buff[100]; 
     2172                environment->GetStringValue("ViewCells.filename", buff); 
     2173                string vcFilename(buff); 
     2174 
     2175                ExportViewCells(buff); 
     2176        } 
     2177 
     2178        return 0; 
     2179} 
     2180 
     2181 
     2182int VspBspViewCellsManager::GetType() const 
     2183{ 
     2184        return VSP_BSP; 
     2185} 
     2186 
     2187 
     2188bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 
     2189{ 
     2190        if (!ViewCellsConstructed()) 
     2191                return ViewCellsManager::GetViewPoint(viewPoint); 
     2192 
     2193        // TODO: set reasonable limit 
     2194        const int limit = 20; 
     2195 
     2196        for (int i = 0; i < limit; ++ i) 
     2197        { 
     2198                viewPoint = mViewSpaceBox.GetRandomPoint(); 
     2199                if (mVspBspTree->ViewPointValid(viewPoint)) 
     2200                { 
     2201                        return true; 
     2202                } 
     2203        } 
     2204        Debug << "failed to find valid view point, taking " << viewPoint << endl; 
     2205        return false; 
     2206} 
     2207 
     2208 
     2209bool VspBspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
     2210{ 
     2211        return mViewSpaceBox.IsInside(viewPoint) && 
     2212                   mVspBspTree->ViewPointValid(viewPoint); 
     2213} 
     2214 
     2215 
     2216void VspBspViewCellsManager::Visualize(const ObjectContainer &objects, 
     2217                                                                           const VssRayContainer &sampleRays) 
     2218{ 
     2219        if (!ViewCellsConstructed()) 
     2220                return; 
     2221 
     2222        VssRayContainer visRays; 
     2223        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
     2224 
     2225        if (1) // export view cells 
     2226        { 
     2227                cout << "exporting view cells after post process ... "; 
     2228                Exporter *exporter = Exporter::GetExporter("final_view_cells.x3d"); 
     2229 
    22002230                if (exporter) 
    22012231                { 
     
    22122242                        } 
    22132243 
    2214                         ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
    2215  
    2216                         Material vm, lm; 
    2217  
    2218                         for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
     2244                        // export rays 
     2245                        if (mExportRays) 
    22192246                        { 
    2220                                 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
    2221  
    2222                                 vm = RandomMaterial(); 
    2223  
    2224                                 lm = vm; 
    2225  
    2226                                 vm.mDiffuseColor.r -= 0.45f; 
    2227                                 vm.mDiffuseColor.g -= 0.45f; 
    2228                                 vm.mDiffuseColor.b -= 0.45f; 
    2229  
    2230                                 vector<BspLeaf *>::const_iterator lit, lit_end = vc->mLeaves.end(); 
    2231  
    2232                                 for (lit = vc->mLeaves.begin(); lit != lit_end; ++ lit) 
    2233                                 { 
    2234                                         BspLeaf *leaf = *lit; 
    2235  
    2236                                         if (leaf->Mailed()) 
    2237                                                 exporter->SetForcedMaterial(lm); 
    2238                                         else 
    2239                                                 exporter->SetForcedMaterial(vm); 
    2240  
    2241                                         BspNodeGeometry geom; 
    2242                                         mVspBspTree->ConstructGeometry(leaf, geom); 
    2243                                         exporter->ExportPolygons(geom.mPolys); 
    2244                                 } 
     2247                                exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 
    22452248                        } 
    22462249 
     2250                        ExportViewCellsForViz(exporter); 
    22472251                        delete exporter; 
    22482252                } 
    2249  
    2250  
    2251                 cout << "finished" << endl; 
    22522253        } 
    22532254 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r566 r568  
    19801980                                bool isAdjacent = true; 
    19811981 
    1982                                 if (1) 
     1982                        /*      if (1) 
    19831983                                { 
    19841984                                        // test all planes of current node if still adjacent 
     
    20142014                                                } 
    20152015                                        } 
    2016                                 } 
     2016                                }*/ 
    20172017                                // neighbor was found 
    20182018                                if (isAdjacent) 
     
    30923092int VspBspTree::RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects) 
    30933093{ 
    3094         int shuffled = 0; 
    3095  
    30963094        Debug << "refining " << (int)mMergeQueue.size() << " candidates " << endl; 
     3095         
    30973096        BspLeaf::NewMail(); 
    30983097 
     
    31163115        queue<BspMergeCandidate> *backQueue = &queue2; 
    31173116 
     3117#if 1 
    31183118    Exporter *exporter = Exporter::GetExporter("neighors.x3d"); 
    31193119 
     
    31253125 
    31263126        // HACK for visualization 
    3127         /*ViewCellContainer viewCells; 
    3128         ViewCell::NewMail(); 
    3129         CollectViewCells(mRoot, true, viewCells, true); 
    3130         for (int i = 0; i < viewCells.size(); ++i) 
    3131                 viewCells[i]->SetId((int)RandomValue(0, Real(256*256*256))); 
    3132         */ 
    3133         Material m; 
    3134         m.mDiffuseColor.r = 0; 
    3135         m.mDiffuseColor.g = 0; 
    3136         m.mDiffuseColor.b = 0; 
    3137  
     3127        //ViewCellContainer viewCells; 
     3128        //ViewCell::NewMail(); 
     3129        //CollectViewCells(mRoot, true, viewCells, true); 
     3130        //for (int i = 0; i < viewCells.size(); ++i) 
     3131        //      viewCells[i]->SetId((int)RandomValue(0, Real(256*256*256))); 
     3132         
     3133         
    31383134        while (!mMergeQueue.empty()) 
    31393135        { 
     
    31423138                mMergeQueue.pop(); 
    31433139 
    3144  
    31453140                // visualize neighbors 
    3146                 m = RandomMaterial(); 
     3141                Material m = RandomMaterial(); 
    31473142                exporter->SetForcedMaterial(m); 
    3148                  
    3149                 BspNodeGeometry geom1, geom2; 
    3150  
    3151                 ConstructGeometry(mc.GetLeaf1(), geom1); 
    3152                 ConstructGeometry(mc.GetLeaf1(), geom2); 
    3153  
    3154                 //m.mDiffuseColor.r = (mc.GetLeaf1()->GetViewCell()->GetId() & 256)/ 255.0f; 
    3155                 //m.mDiffuseColor.g = ((mc.GetLeaf1()->GetViewCell()->GetId()>>8) & 256)/ 255.0f; 
    3156                 //m.mDiffuseColor.b = ((mc.GetLeaf1()->GetViewCell()->GetId()>>16) & 256)/ 255.0f; 
    3157                 exporter->SetForcedMaterial(m); 
    3158                 exporter->ExportPolygons(geom1.mPolys); 
    3159                  
    3160                 //m.mDiffuseColor.r = (mc.GetLeaf2()->GetViewCell()->GetId() & 256)/ 255.0f; 
    3161                 //m.mDiffuseColor.g = ((mc.GetLeaf2()->GetViewCell()->GetId()>>8) & 256)/ 255.0f; 
    3162                 //m.mDiffuseColor.b = ((mc.GetLeaf2()->GetViewCell()->GetId()>>16) & 256)/ 255.0f; 
    3163                 //exporter->SetForcedMaterial(m); 
    3164                 exporter->ExportPolygons(geom2.mPolys); 
     3143         
     3144 
     3145                if (!mc.GetLeaf1()->Mailed()) 
     3146                { 
     3147                        BspNodeGeometry geom1; 
     3148                        ConstructGeometry(mc.GetLeaf1(), geom1); 
     3149                        //m.mDiffuseColor.r = (mc.GetLeaf1()->GetViewCell()->GetId() & 256)/ 255.0f; 
     3150                        //m.mDiffuseColor.g = ((mc.GetLeaf1()->GetViewCell()->GetId()>>8) & 256)/ 255.0f; 
     3151                        //m.mDiffuseColor.b = ((mc.GetLeaf1()->GetViewCell()->GetId()>>16) & 256)/ 255.0f; 
     3152                        //exporter->SetForcedMaterial(m); 
     3153                        exporter->ExportPolygons(geom1.mPolys); 
     3154                        mc.GetLeaf1()->Mail(); 
     3155                } 
     3156 
     3157                if (!mc.GetLeaf2()->Mailed()) 
     3158                { 
     3159                        BspNodeGeometry geom2; 
     3160                        ConstructGeometry(mc.GetLeaf2(), geom2); 
     3161                        //m.mDiffuseColor.r = (mc.GetLeaf2()->GetViewCell()->GetId() & 256)/ 255.0f; 
     3162                        //m.mDiffuseColor.g = ((mc.GetLeaf2()->GetViewCell()->GetId()>>8) & 256)/ 255.0f; 
     3163                        //m.mDiffuseColor.b = ((mc.GetLeaf2()->GetViewCell()->GetId()>>16) & 256)/ 255.0f; 
     3164                        //exporter->SetForcedMaterial(m); 
     3165                        exporter->ExportPolygons(geom2.mPolys); 
     3166                        mc.GetLeaf2()->Mail(); 
     3167                }                
    31653168        } 
    31663169 
     
    31703173                delete exporter; 
    31713174        } 
    3172  
     3175#else 
     3176        while (!mMergeQueue.empty()) 
     3177        { 
     3178                BspMergeCandidate mc = mMergeQueue.top(); 
     3179                shuffleQueue->push(mc); 
     3180                mMergeQueue.pop(); 
     3181        } 
     3182#endif 
    31733183        const int numPasses = 5; 
    31743184        int pass = 0; 
    31753185        int passShuffled = 0; 
    3176  
     3186        int shuffled = 0; 
     3187 
     3188        BspLeaf::NewMail(); 
    31773189 
    31783190        do 
     
    32203232} 
    32213233 
    3222 /*inline int SubtractedPvsSize(BspViewCell *vc, BspLeaf *l, const ObjectPvs &pvs2) 
     3234 
     3235// recomputes pvs size minus pvs of leaf l 
     3236#if 0 
     3237inline int SubtractedPvsSize(BspViewCell *vc, BspLeaf *l, const ObjectPvs &pvs2) 
    32233238{ 
    32243239        ObjectPvs pvs; 
     
    32283243                        pvs.AddPvs(*(*it)->mPvs); 
    32293244        return pvs.GetSize(); 
    3230 }*/ 
    3231  
     3245} 
     3246#endif 
     3247 
     3248// computes pvs1 minus pvs2 
    32323249inline int SubtractedPvsSize(ObjectPvs pvs1, const ObjectPvs &pvs2) 
    32333250{ 
     
    32403257        //const int pvs1 = SubtractedPvsSize(vc1, leaf, *leaf->mPvs); 
    32413258        const int pvs1 = SubtractedPvsSize(vc1->GetPvs(), *leaf->mPvs); 
     3259         
    32423260        const int pvs2 = AddedPvsSize(vc2->GetPvs(), *leaf->mPvs); 
    32433261 
    3244         // dont' shuffle leaves with pvs > max 
     3262        // don't shuffle leaves with pvs > max 
    32453263        if (pvs1 + pvs2 > mViewCellsManager->GetMaxPvsSize()) 
    32463264                return 1e15f; 
Note: See TracChangeset for help on using the changeset viewer.