Changeset 1982


Ignore:
Timestamp:
01/15/07 18:33:00 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh

    r1744 r1982  
    1717############################################################################ 
    1818 
    19  METHOD=gradient 
     19 METHOD=interleaved 
    2020 echo "$SCENE $METHOD" 
    2121 
     
    2828  -hierarchy_construction_type=2 \ 
    2929  -hierarchy_construction_consider_memory=true 
     30 
     31############################################################################ 
     32 
     33#  METHOD=fast 
     34#  echo "$SCENE $METHOD" 
     35 
     36#  $PROGRAM $ENVIRONMENT \ 
     37#  -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \ 
     38#   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     39#   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     40#   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     41#   -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     42#   -hierarchy_construction_type=0 \ 
     43#   -hierarchy_construction_consider_memory=true \ 
     44#   -bvh_term_max_leaves=10000 \ 
     45#   -hierarchy_term_max_leaves=20000  
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1981 r1982  
    2828GvsPreprocessor::GvsPreprocessor():  
    2929Preprocessor(),  
    30 //mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION), 
    31 mSamplingType(SamplingStrategy::DIRECTION_BOX_BASED_DISTRIBUTION) 
     30mSamplingType(SamplingStrategy::DIRECTION_BOX_BASED_DISTRIBUTION), 
     31mNumViewCells(0), 
     32mCurrentViewCell(NULL) 
    3233{ 
    3334        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); 
     
    5556                mOnlyRandomSampling = false; 
    5657 
    57         //mGvsStatsStream.open("gvspreprocessor.log"); 
    5858        mGvsStats.Reset(); 
     59} 
     60 
     61 
     62bool GvsPreprocessor::NextViewCell() 
     63{ 
     64        if (mViewCellsManager->GetNumViewCells() == mNumViewCells) 
     65                return false; // no more view cells 
     66 
     67        mCurrentViewCell = mViewCellsManager->GetViewCell(mNumViewCells); 
     68        mViewCellsManager->CreateMesh(mCurrentViewCell); 
     69 
     70        ++ mNumViewCells; 
     71     
     72        return true; 
    5973} 
    6074 
     
    350364 
    351365 
    352 /*Vector3 GvsPreprocessor::GetPassingPoint(const VssRay &currentRay, 
    353                                                                                  const Triangle3 &hitTriangle, 
    354                                                                                  const VssRay &oldRay) const 
    355 { 
    356         //-- intersect triangle plane with plane spanned by current samples 
    357         Plane3 plane(currentRay.GetOrigin(), currentRay.GetTermination(), oldRay.GetTermination()); 
    358         Plane3 triPlane(hitTriangle.GetNormal(), hitTriangle.mVertices[0]); 
    359  
    360         SimpleRay intersectLine = GetPlaneIntersection(plane, triPlane); 
    361  
    362         // Evaluate new hitpoint just outside the triangle 
    363         const float factor = 0.95f; 
    364         const float t = triPlane.FindT(intersectLine); 
    365         const Vector3 newPoint = intersectLine.mOrigin + t * factor * intersectLine.mDirection; 
    366  
    367         return newPoint; 
    368 }*/ 
    369  
    370  
    371366Vector3 GvsPreprocessor::GetPassingPoint(const VssRay &currentRay, 
    372367                                                                                 const Triangle3 &occluder, 
     
    532527         
    533528        return castSamples; 
     529} 
     530 
     531 
     532void GvsPreprocessor::VisualizeViewCells() 
     533{ 
     534        char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mNumViewCells, mPass); 
     535                         
     536        // visualization 
     537        if (mGvsStats.mPassContribution > 0) 
     538        { 
     539                const bool exportRays = true; 
     540                const bool exportPvs = true; 
     541 
     542                mViewCellsManager->ExportSingleViewCells(mObjects,  
     543                                                                                                 10,  
     544                                                                                                 false,  
     545                                                                                                 exportPvs,  
     546                                                                                                 exportRays,  
     547                                                                                                 1000,  
     548                                                                                                 str); 
     549        } 
     550 
     551        // remove pass samples 
     552        ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 
     553 
     554        for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 
     555        { 
     556                (*vit)->DelRayRefs(); 
     557        } 
     558} 
     559 
     560 
     561void GvsPreprocessor::PerViewCellComputation() 
     562{ 
     563        const int maxViewCells = 5; 
     564 
     565        while (NextViewCell() && mNumViewCells < maxViewCells) 
     566        { 
     567                cout << "processing view cell " << mNumViewCells << endl; 
     568 
     569                while (mGvsStats.mTotalSamples < mTotalSamples)  
     570                { 
     571                        ++ mPass; 
     572 
     573                        mGvsStats.mTotalSamples += Pass(); 
     574                                 
     575                        //////// 
     576                        //-- stats 
     577 
     578                        cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples  
     579                                 << " of " << mTotalSamples << endl; 
     580 
     581                        mGvsStats.mPass = mPass; 
     582                        mGvsStats.Stop(); 
     583                        mGvsStats.Print(mGvsStatsStream); 
     584                        //mViewCellsManager->PrintPvsStatistics(mGvsStats); 
     585 
     586                        if (GVS_DEBUG) 
     587                                VisualizeViewCells(); 
     588                } 
     589 
     590                // ComputeRenderError(); 
     591        } 
     592} 
     593 
     594 
     595void GvsPreprocessor::GlobalComputation() 
     596{ 
     597        while (mGvsStats.mTotalSamples < mTotalSamples)  
     598        { 
     599                ++ mPass; 
     600 
     601                mGvsStats.mTotalSamples += Pass(); 
     602                                 
     603                //////// 
     604                //-- stats 
     605 
     606                cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples  
     607                         << " of " << mTotalSamples << endl; 
     608 
     609                mGvsStats.mPass = mPass; 
     610                mGvsStats.Stop(); 
     611                mGvsStats.Print(mGvsStatsStream); 
     612                //mViewCellsManager->PrintPvsStatistics(mGvsStats); 
     613 
     614                if (GVS_DEBUG) 
     615                        VisualizeViewCells(); 
     616        } 
    534617} 
    535618 
     
    564647        mGvsStats.Print(mGvsStatsStream); 
    565648 
    566         while (mGvsStats.mTotalSamples < mTotalSamples)  
    567         { 
    568                 ++ mPass; 
    569  
    570                 mGvsStats.mTotalSamples += Pass(); 
    571                                  
    572                 //////// 
    573                 //-- stats 
    574  
    575                 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples << " of " << mTotalSamples << endl; 
    576                 mGvsStats.mPass = mPass; 
    577                 mGvsStats.Stop(); 
    578                 mGvsStats.Print(mGvsStatsStream); 
    579                 //mViewCellsManager->PrintPvsStatistics(mGvsStats); 
    580  
    581                 if (GVS_DEBUG) 
    582                 { 
    583                         char str[64]; sprintf(str, "tmp/pass%04d-", mPass); 
    584                  
    585                         // visualization 
    586                         if (mGvsStats.mPassContribution > 0) 
    587                         { 
    588                                 const bool exportRays = true; 
    589                                 const bool exportPvs = true; 
    590  
    591                                 mViewCellsManager->ExportSingleViewCells(mObjects,  
    592                                                                                                                  10,  
    593                                                                                                                  false,  
    594                                                                                                                  exportPvs,  
    595                                                                                                                  exportRays,  
    596                                                                                                                  1000,  
    597                                                                                                                  str); 
    598                         } 
    599  
    600                         // remove pass samples 
    601                         ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 
    602                         for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 
    603                         { 
    604                                 (*vit)->DelRayRefs(); 
    605                         } 
    606                 } 
    607  
    608                 // ComputeRenderError(); 
     649        if (mPerViewCell) 
     650        { 
     651                PerViewCellComputation(); 
     652        } 
     653        else 
     654        { 
     655                GlobalComputation(); 
    609656        } 
    610657 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r1977 r1982  
    172172                                                        const VssRay &oldRay) const; 
    173173 
     174        bool NextViewCell(); 
     175 
     176        void GlobalComputation(); 
     177 
     178        void PerViewCellComputation(); 
     179 
     180        void VisualizeViewCells(); 
     181 
     182 
    174183        ////////////////////// 
    175184 
     
    203212 
    204213        ViewCell *mCurrentViewCell; 
     214 
     215        int mNumViewCells; 
    205216}; 
    206217 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r1980 r1982  
    194194                                OptimizeForWindowsApplication="TRUE" 
    195195                                AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\Qt&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include&quot;;QtInterface" 
    196                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;TRY_GLOBAL_LINES" 
     196                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT" 
    197197                                RuntimeLibrary="2" 
    198198                                RuntimeTypeInfo="TRUE" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1981 r1982  
    22822282 
    22832283 
     2284int ViewCellsManager::GetNumViewCells() const 
     2285{ 
     2286        return (int)mViewCells.size(); 
     2287} 
     2288 
     2289 
    22842290float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 
    22852291                                                                                                  const bool addRays, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1981 r1982  
    171171                                                   const VssRayContainer &sampleRays) = 0; 
    172172 
    173   /** collect objects intersecting a given spatial box */ 
    174   virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
     173        /** collect objects intersecting a given spatial box. 
     174        */ 
     175        virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
    175176 
    176177        /** type of the view cell container. 
     
    185186                @param filename file to load 
    186187                @return true on success 
    187     */ 
    188     virtual bool LoadViewCellsGeometry(const string filename, const bool extrudeBaseTriangle); 
     188        */ 
     189        virtual bool LoadViewCellsGeometry(const string filename, const bool extrudeBaseTriangle); 
    189190         
    190191        /** Merges two view cells. 
     
    210211        ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const; 
    211212 
    212  
    213   virtual Intersectable * 
    214   GetIntersectable(const VssRay &ray, const bool isTermination) const; 
     213        virtual Intersectable *GetIntersectable(const VssRay &ray, const bool isTermination) const; 
    215214 
    216215        /** Sets maximal number of samples used for the  
     
    272271        virtual ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const = 0; 
    273272   
     273        ViewCell *GetViewCell(const int idx) const {return mViewCells[idx];} 
     274 
    274275        virtual void PrintPvsStatistics(ostream &s); 
    275276 
     
    324325        virtual bool GetViewPoint(Vector3 &viewPoint) const; 
    325326   
    326   virtual bool GetViewPoint(Vector3 &viewPoint, const Vector3 &params) const; 
     327        virtual bool GetViewPoint(Vector3 &viewPoint, const Vector3 &params) const; 
    327328 
    328329        /** Returns true if this view point is in the valid view space. 
     
    489490 
    490491        virtual void CompressViewCells(); 
     492 
     493        int GetNumViewCells() const; 
    491494 
    492495        ///////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.