Ignore:
Timestamp:
01/22/08 18:59:25 (16 years ago)
Author:
mattausch
Message:

added new view cell
deleted other view cell generation stuff (please use generate_viewcells.sh script)
added visualizaton method for gvs

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
10 edited

Legend:

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

    r2620 r2625  
    208208  void SetViewDirection(const Vector3 &vd) { mViewDirection = vd; } 
    209209 
     210  Vector3 GetViewPoint() const { return mViewPoint; } 
    210211public: 
    211212 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2615 r2625  
    3535mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 
    3636mProcessedViewCells(0), 
    37 mCurrentViewCell(NULL) 
     37mCurrentViewCell(NULL), 
     38mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)) 
    3839{ 
    3940        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); 
     
    9697 
    9798 
    98 bool GvsPreprocessor::NextViewCell() 
     99ViewCell *GvsPreprocessor::NextViewCell() 
    99100{ 
    100101        //if (mViewCellsManager->GetNumViewCells() == mProcessedViewCells) 
     
    102103 
    103104        if (mProcessedViewCells == (int)mViewCells.size()) 
    104                 return false; // no more view cells 
    105  
    106         mCurrentViewCell = mViewCells[mProcessedViewCells]; 
    107  
    108    if (!mCurrentViewCell->GetMesh()) 
    109                 mViewCellsManager->CreateMesh(mCurrentViewCell); 
    110  
    111         mGvsStats.mViewCellId = mCurrentViewCell->GetId(); 
    112  
    113         Debug << "vc: " << mCurrentViewCell->GetId() << endl; 
     105                return NULL; // no more view cells 
     106 
     107        ViewCell *vc = mViewCells[mProcessedViewCells]; 
     108 
     109   if (!vc->GetMesh()) 
     110                mViewCellsManager->CreateMesh(vc); 
     111 
     112        mGvsStats.mViewCellId = vc->GetId(); 
     113 
     114        Debug << "vc: " << vc->GetId() << endl; 
    114115 
    115116        ++ mProcessedViewCells; 
    116117     
    117         return true; 
     118        return vc; 
    118119} 
    119120 
     
    178179                result = ray.mPvsContribution > 0; 
    179180        } 
    180         else 
     181        else // original per view cell gvs 
    181182        { 
    182183                Intersectable *obj = ray.mTerminationObject; 
     
    187188                        mTrianglePvs.push_back(obj); 
    188189                 
     190                        // if using kd pvs, exchange the triangle with the node in the pvs 
    189191                        if (mUseKdPvs) 
    190192                        { 
     
    194196                                { 
    195197                                        node->Mail(); 
    196                                         mKdPvs.push_back(mKdTree->GetOrCreateKdIntersectable(node)); 
     198                                        KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 
     199                                        mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
     200                                        mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
    197201                                }                        
    198202                        } 
     
    478482        // the point is chosen to be on the side closer to the original ray 
    479483        if (Distance(pt1, pt3) < Distance(pt2, pt3)) 
    480         { 
    481484                newPoint = pt1 + eps * (pt1 - pt2); 
    482         }        
    483485        else 
    484         { 
    485486                newPoint = pt2 + eps * (pt2 - pt1); 
    486         } 
    487487 
    488488        //cout << "passing point: " << newPoint << endl << endl; 
     
    874874        KdLeaf *leaf = *lit; 
    875875                 
     876                // add to kdnode pvs 
    876877                if (mUseKdPvs) 
    877                         mKdPvs.push_back(mKdTree->GetOrCreateKdIntersectable(leaf)); 
     878                { 
     879                        leaf->Mail(); 
     880                        KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(leaf); 
     881                        mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
     882         
     883                        mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
     884                } 
    878885 
    879886                ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
     
    898905void GvsPreprocessor::PerViewCellComputation() 
    899906{ 
    900         // hack: reset counter 
    901         ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 
    902  
    903         for (oit = mObjects.begin(); oit != oit_end; ++ oit) 
    904         { 
    905                 (*oit)->mCounter = 0; 
    906         } 
    907          
    908          
    909         while (NextViewCell())// && (dummy < 3)) 
    910         { 
    911                 //++ dummy; 
    912                 //if (mProcessedViewCells < 53) continue; 
    913          
    914                 if (mUseKdPvs) 
    915                 { 
    916                         KdNode::NewMail(); 
    917                         mKdPvs.clear(); 
    918                 } 
    919  
    920                 long startTime = GetTime(); 
    921                 cout << "\n***********************\n"  
    922                          << "processing view cell " << mProcessedViewCells  
    923                          << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 
    924  
    925                 // compute the pvs of the current view cell 
    926                 ProcessViewCell(); 
    927  
    928                 //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 
    929                 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 
    930                 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 
    931  
    932                 if (!mUseKdPvs) 
    933                 { 
    934                         ObjectContainer objectPvs; 
    935  
    936                         // optain object pvs 
    937                         GetObjectPvs(objectPvs); 
    938  
    939                         // add pvs 
    940                         ObjectContainer::const_iterator it, it_end = objectPvs.end(); 
    941  
    942                         for (it = objectPvs.begin(); it != it_end; ++ it) 
    943                         { 
    944                                 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 
    945                         } 
    946  
    947                         cout << "triangle pvs of " << (int)mTrianglePvs.size()  
    948                                 << " was converted to object pvs of " << (int)objectPvs.size() << endl; 
    949  
    950                         mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 
    951                 } 
    952                 else 
    953                 { 
    954                         // add pvs 
    955                         ObjectContainer::const_iterator it, it_end = mKdPvs.end(); 
    956  
    957                         for (it = mKdPvs.begin(); it != it_end; ++ it) 
    958                         { 
    959                                 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 
    960                         } 
    961  
    962                         mGvsStats.mPerViewCellPvs = mKdPvs.size(); 
    963                 } 
    964  
    965                 //////// 
    966                 //-- stats 
    967                  
    968                 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 
    969                  
    970  
    971                 mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 
    972                 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 
    973  
    974                 // timing 
    975                 const long currentTime = GetTime(); 
    976          
    977                 mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 
    978                 mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 
    979  
    980                 //lastTime = currentTime; 
    981  
    982                 mGvsStats.Stop(); 
    983                 mGvsStats.Print(mGvsStatsStream); 
    984  
    985         mTrianglePvs.clear(); 
    986 #if 0 
    987                 if (GVS_DEBUG) 
    988                 { 
    989                         //VisualizeViewCell(mCurrentViewCell); 
    990                         VisualizeViewCell(objectPvs); 
    991                         CLEAR_CONTAINER(mVssRays); 
    992                 } 
    993                 cout << "finished" << endl; 
    994  
    995                 if (mEvaluatePixelError || mExportVisibility) 
    996                 { 
    997                         StorePvs(objectPvs); 
    998                 } 
    999 #endif 
    1000         } 
    1001 } 
     907        ViewCell *vc; 
     908 
     909        while (vc = NextViewCell()) 
     910        { 
     911                // hack: reset counters 
     912                ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 
     913 
     914                for (oit = mObjects.begin(); oit != oit_end; ++ oit) 
     915                        (*oit)->mCounter = 0; 
     916 
     917                ComputeViewCell(vc); 
     918        } 
     919} 
     920 
     921 
     922void GvsPreprocessor::PerViewCellComputation2() 
     923{ 
     924        ViewCell *vc; 
     925 
     926        while (1) 
     927        { 
     928                if (!mRendererWidget) 
     929                        continue; 
     930 
     931        //ViewCell *vc = mViewCellsManager->GetViewCell(mCurrentViewPoint); 
     932        ViewCell *vc = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 
     933 
     934                //cout << "v " << mRendererWidget->GetViewPoint() << " "; 
     935 
     936                // no valid view cell or view cell already computed 
     937                if (!vc || !vc->GetPvs().Empty()) 
     938                        continue; 
     939 
     940                //cout << "computing new view cell: " << vc->GetId() << endl; 
     941 
     942                // hack: reset counters 
     943                ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 
     944 
     945                for (oit = mObjects.begin(); oit != oit_end; ++ oit) 
     946                        (*oit)->mCounter = 0; 
     947 
     948                ComputeViewCell(vc); 
     949                ++ mProcessedViewCells; 
     950        } 
     951} 
     952 
     953 
    1002954 
    1003955 
     
    11551107                cout << "finished view cell construction" << endl; 
    11561108        } 
    1157         else if (0) 
     1109#if 0 
     1110        else 
    11581111        {        
    11591112                //-- test successful view cells loading by exporting them again 
     
    11621115                mViewCellsManager->ExportViewCells("test.xml.gz", mViewCellsManager->GetExportPvs(), mObjects); 
    11631116        } 
     1117#endif 
    11641118 
    11651119        mGvsStats.Stop(); 
     
    11681122        if (mPerViewCell) 
    11691123        { 
     1124#if 0 
    11701125                // provide list of view cells to compute 
    11711126                CompileViewCellsList(); 
     
    11781133                        ComputeRenderError(); 
    11791134                } 
     1135#else 
     1136                PerViewCellComputation2(); 
     1137 
     1138#endif 
    11801139        } 
    11811140        else 
     
    12721231 
    12731232 
    1274 } 
     1233void GvsPreprocessor::ComputeViewCell(ViewCell *vc) 
     1234{ 
     1235        mCurrentViewCell = vc; 
     1236 
     1237        if (mUseKdPvs) 
     1238        { 
     1239                KdNode::NewMail(); 
     1240                //mKdPvs.clear(); 
     1241        } 
     1242 
     1243        long startTime = GetTime(); 
     1244        cout << "\n***********************\n"  
     1245                << "processing view cell " << mProcessedViewCells  
     1246                << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 
     1247 
     1248        // compute the pvs of the current view cell 
     1249        ProcessViewCell(); 
     1250 
     1251        //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 
     1252        mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 
     1253        mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 
     1254 
     1255        if (!mUseKdPvs) 
     1256        { 
     1257                ObjectContainer objectPvs; 
     1258 
     1259                // optain object pvs 
     1260                GetObjectPvs(objectPvs); 
     1261 
     1262                // add pvs 
     1263                ObjectContainer::const_iterator it, it_end = objectPvs.end(); 
     1264 
     1265                for (it = objectPvs.begin(); it != it_end; ++ it) 
     1266                { 
     1267                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 
     1268                } 
     1269 
     1270                cout << "triangle pvs of " << (int)mTrianglePvs.size()  
     1271                        << " was converted to object pvs of " << (int)objectPvs.size() << endl; 
     1272 
     1273                mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 
     1274        } 
     1275        else 
     1276        { 
     1277                /*// add pvs 
     1278                ObjectContainer::const_iterator it, it_end = mKdPvs.end(); 
     1279 
     1280                for (it = mKdPvs.begin(); it != it_end; ++ it) 
     1281                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 
     1282                */ 
     1283                mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();; 
     1284        } 
     1285 
     1286 
     1287        //////// 
     1288        //-- stats 
     1289 
     1290        mGvsStats.mViewCells = mProcessedViewCells;//mPass; 
     1291 
     1292 
     1293        mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 
     1294        mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 
     1295 
     1296        // timing 
     1297        const long currentTime = GetTime(); 
     1298 
     1299        mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 
     1300        mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 
     1301 
     1302        //lastTime = currentTime; 
     1303 
     1304        mGvsStats.Stop(); 
     1305        mGvsStats.Print(mGvsStatsStream); 
     1306 
     1307        mTrianglePvs.clear(); 
     1308#if 0 
     1309        if (GVS_DEBUG) 
     1310        { 
     1311                //VisualizeViewCell(mCurrentViewCell); 
     1312                VisualizeViewCell(objectPvs); 
     1313                CLEAR_CONTAINER(mVssRays); 
     1314        } 
     1315        cout << "finished" << endl; 
     1316 
     1317        if (mEvaluatePixelError || mExportVisibility) 
     1318        { 
     1319                StorePvs(objectPvs); 
     1320        } 
     1321#endif 
     1322} 
     1323 
     1324} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2615 r2625  
    8484        based on heuristical sampling of view space. 
    8585*/ 
    86 class GvsPreprocessor : public Preprocessor { 
     86class GvsPreprocessor : public Preprocessor  
     87{ 
    8788 
    8889public: 
     
    190191                                                 Vector3 &newPoint) const; 
    191192 
    192         bool NextViewCell(); 
     193        ViewCell *NextViewCell(); 
    193194 
    194195        void GlobalComputation(); 
    195196 
     197        /** Loops over aall view cellls. 
     198        */ 
    196199        void PerViewCellComputation(); 
     200        void PerViewCellComputation2(); 
    197201 
    198202        void VisualizeViewCells(); 
     
    205209        void UpdatePvs(ViewCell *currentViewCell); 
    206210 
     211        void ClearRayQueue(); 
     212 
     213        void CompileViewCellsList(); 
     214 
     215        void GetObjectPvs(ObjectContainer &trianglePvs) const; 
     216 
     217        bool HasContribution(VssRay &ray); 
     218 
     219        void IntersectWithViewCell(); 
     220 
     221        void DeterminePvsObjects(VssRayContainer &rays); 
     222 
     223        void StorePvs(const ObjectContainer &objectPvs); 
     224 
     225        void ComputeViewCell(ViewCell *vc); 
     226        /** Runs gvs on the current view cell. 
     227        */ 
    207228        void ProcessViewCell(); 
    208         void ClearRayQueue(); 
    209  
    210         void CompileViewCellsList(); 
    211  
    212         void GetObjectPvs(ObjectContainer &trianglePvs) const; 
    213  
    214         bool HasContribution(VssRay &ray); 
    215  
    216         void IntersectWithViewCell(); 
    217  
    218         void DeterminePvsObjects(VssRayContainer &rays); 
    219  
    220         //virtual void ComputeRenderError(); 
    221  
    222         void StorePvs(const ObjectContainer &objectPvs); 
     229 
    223230 
    224231 
     
    266273 
    267274        bool mEvaluatePixelError; 
     275 
     276        Vector3 mCurrentViewPoint; 
    268277}; 
    269278 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2621 r2625  
    3232class GlobalLinesRenderer; 
    3333class SceneGraphLeaf; 
     34class GlRendererWidget; 
    3435 
    3536 
     
    258259 
    259260        GlRendererBuffer *renderer; 
     261        GlRendererWidget *mRendererWidget; 
    260262 
    261263        int mTotalSamples; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h

    r2617 r2625  
    88//-- typedefs 
    99//$$ 19.1. 2008 test for speed 
    10 #define USE_BIT_PVS 
     10//#define USE_BIT_PVS 
    1111 
    1212 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2622 r2625  
    800800                { 
    801801                        float dist = Magnitude(mSceneGraph->GetBox().Diagonal()) * mTopDistance; 
    802                         Vector3 pos = mViewPoint  + dist*Vector3(0, 
    803                                 1, 
    804                                 0); 
     802                        Vector3 pos = mViewPoint  + dist * Vector3(0,   1, 0); 
    805803 
    806804                        Vector3 target = mViewPoint; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2619 r2625  
    474474inline void disposeRays(VssRayContainer &rays, VssRayContainer *outRays) 
    475475{ 
     476        // hack matt 
     477        return; 
     478 
    476479        cout << "disposing samples ... "; 
    477480        long startTime = GetTime(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2614 r2625  
    584584 
    585585 
     586        void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj); 
     587 
    586588 
    587589        ////////////////////////////////////////////////////////////////// 
     
    689691        void EvaluateViewCellsStats(); 
    690692         
    691  
    692         void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj); 
    693693 
    694694 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r2609 r2625  
    117117        Environment::GetSingleton()->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    118118         
     119         
    119120        ////////////////////// 
    120121        //-- termination criteria for axis aligned split 
     122 
    121123        Environment::GetSingleton()->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",  
    122124                                                                mTermMaxRayContriForAxisAligned); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2615 r2625  
    305305 
    306306        if (evalPixelError && (importRandomViewCells || frames)) 
    307           { 
     307        { 
    308308                QGLFormat f; 
    309309                f.setStencil(true); 
    310310                QGLFormat::setDefaultFormat(f); 
     311 
    311312                // NOTE: render texture should be power of 2 and square 
    312313                // renderer must be initialised 
    313314                // $$matt 
    314315                preprocessor->renderer =  
    315                   new QtGlRendererBuffer(512, 512, 
    316                                                                  preprocessor->mSceneGraph, 
    317                                                                  preprocessor->mViewCellsManager, 
    318                                                                  preprocessor->mKdTree); 
    319                  
    320           } 
     316                        new QtGlRendererBuffer(512, 512, 
     317                        preprocessor->mSceneGraph, 
     318                        preprocessor->mViewCellsManager, 
     319                        preprocessor->mKdTree); 
     320 
     321        } 
    321322         
    322323        if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
     
    343344                        rendererWidget =  
    344345                                new QtGlRendererWidget(preprocessor->mSceneGraph, 
    345                                 preprocessor->mViewCellsManager, 
    346                                 preprocessor->mKdTree); 
     346                                                                           preprocessor->mViewCellsManager, 
     347                                                                           preprocessor->mKdTree); 
    347348 
    348349                        rendererWidget->Show(); 
    349350 
     351                        // hack matt 
     352                        preprocessor->mRendererWidget = rendererWidget; 
    350353                        //rendererWidget->SetWindowTitle("Global Visualization"); 
    351354 
Note: See TracChangeset for help on using the changeset viewer.