Changeset 2571


Ignore:
Timestamp:
12/18/07 17:40:35 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_arena

    r2567 r2571  
    1313 
    1414$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    15 -rss_distributions=spatial \ 
     15-rss_distributions=mutation+object_direction+spatial \ 
    1616-view_cells_use_kd_pvs+ -af_use_kd_pvs+ \ 
    1717-preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \ 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna

    r2534 r2571  
    1919#PREFIX=../work/plots/atlanta2-rss9 
    2020 
     21#-rss_distributions=mutation+object_direction+spatial \ 
    2122 
    2223$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    23 -rss_distributions=mutation+object_direction+spatial \ 
     24-rss_distributions=object_direction \ 
    2425-view_cells_use_kd_pvs+ -af_use_kd_pvs+ \ 
    2526-preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2564 r2571  
    211211                const float importance = log10(1e3*ray->mWeightedPvsContribution)/3.0f; 
    212212                 
    213                 glColor3f(importance, importance, importance); 
     213                glColor3f(1.0f, 0.0f, 0.0f); 
     214                //glColor3f(importance, importance, importance); 
    214215                glVertex3fv(&ray->mOrigin.x); 
    215216                glVertex3fv(&ray->mTermination.x); 
     
    14551456           
    14561457          if (mPvsErrorBuffer[i].mError > 0.0f)  
    1457                 { 
     1458          { 
    14581459                  int pvsSize; 
    1459                    
     1460 
    14601461                  // compute the pixel error 
    14611462                  float error = GetPixelError(pvsSize); 
    1462                    
     1463 
    14631464                  mPvsErrorBuffer[i].mError = error; 
    14641465                  mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    1465                    
     1466 
    14661467                  cout << "(" << i << "," << mPvsErrorBuffer[i].mError <<")"; 
    1467                 } 
    1468            
     1468          } 
     1469 
    14691470          err = mPvsErrorBuffer[i].mError; 
    1470            
     1471 
    14711472          if (err >= 0.0f)  
    1472                 { 
     1473          { 
    14731474                  if (err > mPvsStat.maxError) 
    1474                         mPvsStat.maxError = err; 
    1475                    
     1475                          mPvsStat.maxError = err; 
     1476 
    14761477                  mPvsStat.sumError += err; 
    1477                         mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
    1478                          
    1479                         if (err == 0.0f) 
     1478                  mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
     1479 
     1480                  if (err == 0.0f) 
    14801481                          ++ mPvsStat.errorFreeFrames; 
    1481                          
    1482                         ++ mPvsStat.frames; 
    1483                 } 
     1482 
     1483                  ++ mPvsStat.frames; 
     1484          } 
    14841485        } 
    14851486   
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp

    r2570 r2571  
    132132 
    133133KdIntersectable::KdIntersectable(KdNode *item, const AxisAlignedBox3 &box) : 
    134   IntersectableWrapper<KdNode *>(item), mNumTriangles(-1) 
     134  IntersectableWrapper<KdNode *>(item), mNumTriangles(-1), mBox(box) 
    135135{ 
    136136} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r2569 r2571  
    14101410                // not in map => create new entry 
    14111411                const int id = (int)mKdIntersectables.size(); 
    1412                 KdIntersectable *kdObj = new KdIntersectable(node, GetBox(node));; 
     1412                KdIntersectable *kdObj = new KdIntersectable(node, GetBox(node)); 
    14131413                node->mIntersectable = kdObj; 
    14141414                 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2570 r2571  
    303303        glEnable(GL_LIGHT1); 
    304304 
    305  
    306305        // set position of the light 
    307306        GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  }; 
     
    313312 
    314313        glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
    315         //   glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR); 
     314        // glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR); 
    316315        glEnable(GL_COLOR_MATERIAL); 
    317316 
    318         glShadeModel( GL_FLAT ); 
     317        glShadeModel(GL_FLAT); 
    319318} 
    320319 
     
    712711                        glColor3f(0.6f, 0.6f, 0.6f); 
    713712                        RenderPvs(); 
     713                } 
     714 
     715                if (1 && mShowRays)  
     716                { 
     717                        RenderRays(mViewCellsManager->mVizBuffer.GetRays()); 
    714718                } 
    715719        } 
     
    11511155        if (mViewCellsManager)  
    11521156        { 
     1157                const float f = number / 1000.0f; 
    11531158                AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); 
    1154                 Vector3 p = box.Min() + (number/1000.0f)*box.Max(); 
     1159                Vector3 p = (1.0f - f) * box.Min() + f * box.Max(); 
    11551160                mSceneCutPlane.mNormal = Vector3(0,-1,0); 
    11561161                mSceneCutPlane.mD = -DotProd(mSceneCutPlane.mNormal, p); 
     
    12781283                ViewCell *vc = viewcells[i]; 
    12791284 
    1280                 if (mShowPvsSizes) // pv 
     1285                if (mShowPvsSizes) // pvs size 
    12811286                { 
    12821287                        //const int p = vc->GetPvs().CountObjectsInPvs(); 
     
    13361341        { 
    13371342                //glDisable(GL_CULL_FACE); 
    1338                 //glEnable(GL_CULL_FACE); 
    1339                 //glFrontFace(GL_CCW);   
    13401343                //glCullFace(GL_BACK); 
     1344 
    13411345                if (!mUseTransparency) 
    13421346                { 
     
    13461350                else 
    13471351                { 
    1348                         //glCullFace(GL_BACK); 
    1349                         //cout << "here29 " << mTransparency << endl; 
    13501352                        glDisable(GL_DEPTH_TEST); 
    13511353                        glEnable(GL_BLEND); 
     
    14101412                glEnable(GL_DEPTH_TEST);         
    14111413        } 
     1414         
     1415        glEnable(GL_CULL_FACE); 
     1416        glDisable(GL_CULL_FACE); 
     1417 
     1418        glDisable(GL_CLIP_PLANE0); 
    14121419 
    14131420        mUseFalseColors = false; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2569 r2571  
    1616#include "RssPreprocessor.h" 
    1717#include "SceneGraph.h" 
     18#include "ViewCellsManager.h" 
    1819 
    1920 
     
    5051   
    5152// This method has to be rendefined by all renderer implementations 
    52 void 
    53 QtGlViewer::RenderScene() 
    54 { 
     53void QtGlViewer::RenderScene() 
     54{ 
     55        GLfloat mat_ambient[] = {0.1, 0.1, 0.1, 1.0}; 
     56 
     57        // mat_specular and mat_shininess are NOT default values 
     58        GLfloat mat_diffuse[] = {0.5, 1.0, 0.5, 1.0}; 
     59        GLfloat mat_specular[] = {0.3, 0.3, 0.3, 1.0}; 
     60        GLfloat mat_shininess[] = {1.0}; 
     61 
     62        GLfloat light_ambient[] = {0.1, 0.1, 0.1, 1.0}; 
     63        GLfloat light_diffuse[] = {0.5, 0.5, 0.5, 1.0}; 
     64        GLfloat light_specular[] = {0.0, 0.0, 0.0, 1.0}; 
     65 
     66        GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0}; 
     67 
     68 
     69        // default material 
     70        /*glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); 
     71        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); 
     72        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); 
     73        glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); 
     74*/ 
     75        // a light 
     76        glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
     77        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
     78        glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
     79        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
     80 
     81         
     82        //GLfloat infinite_light2[] = {-0.3, 1.5f, 1.0f, 0.0f}; 
     83        //glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
     84        glColor3f(0.8f, 0.8f, 0.8f); 
     85         
     86        glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
     87        glDisable(GL_COLOR_MATERIAL); 
     88        //glEnable(GL_COLOR_MATERIAL); 
     89 
    5590        ++ mRenderer->mFrame; 
    5691         
    57         //glDisable(GL_DEPTH_TEST); 
     92        glEnable(GL_DEPTH_TEST); 
     93        glDepthMask(GL_TRUE); 
     94 
     95        glCullFace(GL_BACK); 
     96        glShadeModel(GL_FLAT); 
     97 
     98        glDisable(GL_BLEND); 
    5899 
    59100        mRenderer->mDummyViewPoint = mDummyViewPoint; 
    60         glColor3f(0.8f, 0.8f, 0.8f); 
     101         
     102        //glEnable(GL_LIGHTING); 
     103 
    61104        mRenderer->RenderPvs(); 
    62105         
    63 //      if (mRenderer->mShowRays) { 
    64 //        RssPreprocessor *p = (RssPreprocessor *) 
    65 //                      mRenderer->mViewCellsManager->GetPreprocessor(); 
    66 //        if (p->mRssTree) { 
    67 //                      VssRayContainer rays; 
    68 //                      p->mRssTree->CollectRays(rays, 10000); 
    69 //                      mRenderer->RenderRays(rays); 
    70 //        } 
    71 //      } 
     106        glDisable(GL_LIGHTING); 
     107 
     108        if (0 && mRenderer->mShowRays)  
     109        { 
     110                mRenderer->RenderRays(mRenderer->mViewCellsManager->mVizBuffer.GetRays()); 
     111        } 
    72112 
    73113        if (mRenderer->mShowRenderCost)  
     
    101141        << "Info: GL Extensions = "<<extString<<endl<<flush; 
    102142 
     143 
     144        glEnable(GL_LIGHTING); 
     145        glEnable(GL_LIGHT0); 
     146        //glEnable(GL_LIGHT1); 
     147 
     148        // set position of the light 
     149        GLfloat infinite_light[] = {0, -1.0, 0, 1.0f}; 
     150        glLightfv(GL_LIGHT0, GL_POSITION, infinite_light); 
    103151 
    104152  return; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r2559 r2571  
    1717class SimpleRayContainer; 
    1818class AxisAlignedBox3; 
    19 //class Vector3; 
    2019struct VssRayContainer; 
    2120class Preprocessor; 
     
    107106                        return mRays + mIndex ++; 
    108107                } 
     108 
    109109        protected: 
     110 
    110111                VssRay *mRays; 
    111112                int mIndex; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2570 r2571  
    26712671void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj) 
    26722672{ 
    2673                 KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 
    2674  
    2675         const AxisAlignedBox3 box = kdObj->GetBox(); 
    2676                 const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
    2677  
    2678                 float f; 
    2679  
    2680                 const float radius = mViewSpaceBox.Radius(); 
    2681                 const float fullRadius = mViewSpaceBox.Radius(); 
    2682  
    2683                 const float minVal = 0.1f; 
    2684                 const float maxVal = 1.0f; 
    2685  
    2686                 if (dist <= radius)  
    2687                         f = maxVal; 
    2688                 else if (dist >= fullRadius) 
    2689                         f = minVal; 
    2690                 else // linear blending 
    2691                 { 
    2692                         f = minVal * (dist - radius) + maxVal * (fullRadius - radius - dist); 
    2693                 } 
    2694  
    2695                 const int numTriangles = kdObj->ComputeNumTriangles(); 
    2696  
    2697                 vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles;  
    2698                 vc->GetPvs().mStats.mDistanceWeightedPvs += f; 
    2699                 vc->GetPvs().mStats.mWeightedTriangles += numTriangles; 
     2673        KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 
     2674 
     2675        const AxisAlignedBox3 box = kdObj->GetBox(); 
     2676        const float dist = Distance(vc->GetBox().Center(), box.Center()); 
     2677 
     2678        float f; 
     2679 
     2680        const float radius = box.Radius(); 
     2681        const float fullRadius = max(0.2f * mViewSpaceBox.Radius(), radius); 
     2682 
     2683        const float minVal = 0.01f; 
     2684        const float maxVal = 1.0f; 
     2685 
     2686        if (dist <= radius)  
     2687                f = maxVal; 
     2688        else if (dist >= fullRadius) 
     2689                f = minVal; 
     2690        else // linear blending 
     2691        { 
     2692                f = minVal * (dist - radius) / (fullRadius - radius) +  
     2693                        maxVal * (fullRadius - radius - dist) / (fullRadius - radius); 
     2694        } 
     2695 
     2696        //cout << "x " << radius << " " << dist << " " << fullRadius << " " << f << " " << f * f << endl; 
     2697 
     2698        const int numTriangles = kdObj->ComputeNumTriangles(); 
     2699 
     2700        vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles;  
     2701        vc->GetPvs().mStats.mDistanceWeightedPvs += f ; 
     2702        vc->GetPvs().mStats.mWeightedTriangles += numTriangles; 
    27002703} 
    27012704 
     
    27252728                //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 
    27262729#if 1 
    2727                 UpdateStatsForViewCell(viewCell, obj); 
     2730                if (hasAbsContribution) 
     2731                { 
     2732                        UpdateStatsForViewCell(viewCell, obj); 
     2733                        mVizBuffer.AddRay(&ray); 
     2734                } 
    27282735#endif 
    27292736 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2570 r2571  
    7979typedef pair<ViewCell *, SimpleRayContainer> ViewCellPoints; 
    8080 
     81struct VizBuffer 
     82{ 
     83        VizBuffer(): mIndex(0), mMaxSize(10000) 
     84        { 
     85        } 
     86 
     87        int GetSize() const {return (int)mVizRays.size();} 
     88 
     89        void AddRay(VssRay *ray) 
     90        { 
     91                if (mVizRays.size() < mMaxSize) 
     92                        mVizRays.push_back(ray); 
     93                else 
     94                        mVizRays[mIndex] = ray; 
     95                 
     96                mIndex = (mIndex + 1) % mMaxSize; 
     97        } 
     98 
     99        VssRayContainer &GetRays() { return mVizRays;} 
     100 
     101        VssRay *GetRay(int i) { return mVizRays[i % 100];} 
     102 
     103protected: 
     104 
     105        const int mMaxSize; 
     106        int mIndex; 
     107        VssRayContainer mVizRays; 
     108}; 
     109 
     110 
    81111/**     Manages different higher order operations on the view cells. 
    82112*/ 
     
    600630        void ResetPvs(); 
    601631 
    602         Preprocessor *GetPreprocessor() const { 
     632        Preprocessor *GetPreprocessor() const  
     633        { 
    603634                return mPreprocessor; 
    604635        } 
    605636 
    606         void SetPreprocessor(Preprocessor *p) { 
     637        void SetPreprocessor(Preprocessor *p)  
     638        { 
    607639                mPreprocessor = p; 
    608640        } 
     
    614646 
    615647        void UpdatePvsForEvaluation(); 
     648 
     649 
     650        VizBuffer mVizBuffer; 
     651 
    616652 
    617653protected: 
     
    810846 
    811847 
     848 
    812849        ////////////////// 
    813850        //-- visualization options 
Note: See TracChangeset for help on using the changeset viewer.