Changeset 2670


Ignore:
Timestamp:
04/30/08 13:24:45 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
6 deleted
9 edited

Legend:

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

    r2669 r2670  
    8686mUseVbos(false), 
    8787mComputeGVS(false), 
    88 mCurrentFrame(-1) 
     88mCurrentFrame(100) 
    8989{ 
    9090        mSceneGraph->CollectObjects(mObjects); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2664 r2670  
    172172  virtual void EvalPvsStat(); 
    173173 
    174   void PreparePvs(const ObjectPvs &pvs); 
     174  /** Prepare the pvs for rendering. 
     175  */ 
     176  virtual void PreparePvs(const ObjectPvs &pvs); 
     177  /** Helper function that recursively prepares the indices for VBO renderin. 
     178  */ 
    175179  void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 
    176180 
     
    207211 
    208212  Vector3 GetViewPoint() const { return mViewPoint; } 
     213 
     214 
    209215public: 
    210216 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2669 r2670  
    12521252void GvsPreprocessor::ComputeViewCell(ViewCell *vc) 
    12531253{ 
     1254        KdNode::NewMail(); 
     1255 
    12541256        mCurrentViewCell = vc; 
    1255         KdNode::NewMail(); 
    1256  
    1257         long startTime = GetTime(); 
     1257         
     1258        const long startTime = GetTime(); 
     1259 
    12581260        cout << "\n***********************\n"  
    12591261                << "computing view cell " << mProcessedViewCells  
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.cpp

    r2660 r2670  
    1515#endif 
    1616 
    17 namespace GtpVisibilityPreprocessor { 
     17namespace GtpVisibilityPreprocessor  
     18{ 
    1819 
    1920 
     
    2425int Intersectable::sReservedMailboxes2 = 1; 
    2526 
     27 
    2628// This is the result of computing intersection 
    2729// static data member 
    28   ALIGN16  IntersectionStr 
    29   SimpleRay::IntersectionRes[32]; 
     30ALIGN16  IntersectionStr 
     31SimpleRay::IntersectionRes[32]; 
     32 
     33 
    3034 
    3135Intersectable::Intersectable():  
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2643 r2670  
    6969  int Leaves() const { return (nodes / 2) + 1; } 
    7070 
    71   void Reset() { 
    72     nodes = 0; 
    73     for (int i=0; i<7; i++) 
    74       splits[i] = 0; 
    75     rays = queryDomains = 0; 
    76     rayRefs = rayRefsNonZeroQuery = objectRefs = 0; 
    77     zeroQueryNodes = 0; 
    78     maxDepthNodes = 0; 
    79     minCostNodes = 0; 
    80     maxObjectRefs = 0; 
    81     addedRayRefs = removedRayRefs = 0; 
     71  void Reset()  
     72  { 
     73          nodes = 0; 
     74          for (int i=0; i<7; i++) 
     75                  splits[i] = 0; 
     76          rays = queryDomains = 0; 
     77          rayRefs = rayRefsNonZeroQuery = objectRefs = 0; 
     78          zeroQueryNodes = 0; 
     79          maxDepthNodes = 0; 
     80          minCostNodes = 0; 
     81          maxObjectRefs = 0; 
     82          addedRayRefs = removedRayRefs = 0; 
    8283  } 
    8384 
     
    9495   
    9596class KdInterior; 
    96 /** Abstract class for kd-tree node */ 
    97 class KdNode { 
     97 
     98/** Abstract class for kd-tree node  
     99*/ 
     100class KdNode  
     101{ 
    98102 
    99103public:   
     
    112116  bool Mailed() const { return mMailbox == sMailId; } 
    113117  
    114   static void NewMail(const int reserve = 1) { 
    115     sMailId += sReservedMailboxes; 
    116     sReservedMailboxes = reserve; 
    117   } 
     118  static void NewMail(const int reserve = 1)  
     119  { 
     120          sMailId += sReservedMailboxes; 
     121          sReservedMailboxes = reserve; 
     122  } 
     123 
    118124  void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
    119125  bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 
    120126 
    121127 
    122   static void NewMail2(const int reserve = 1) { 
    123     sMailId2 += sReservedMailboxes; 
    124     sReservedMailboxes2 = reserve; 
     128  //////////// 
     129  //-- hack!!: second mail for a machine with 2 cores 
     130 
     131  static void NewMail2(const int reserve = 1)  
     132  { 
     133          sMailId2 += sReservedMailboxes; 
     134          sReservedMailboxes2 = reserve; 
    125135  } 
    126136 
     
    130140  void Mail2(const int mailbox) { mMailbox2 = sMailId2 + mailbox; } 
    131141  bool Mailed2(const int mailbox) const { return mMailbox2 == sMailId2 + mailbox; } 
     142 
     143  ///////////////////////////////////// 
    132144 
    133145 
     
    154166}; 
    155167 
    156 /** Implementation of the kd-tree interior node */ 
     168 
     169/** Implementation of the kd-tree interior node.  
     170*/ 
    157171class KdInterior : public KdNode { 
    158172 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp

    r2643 r2670  
    1313#define USE_MULTIPLE_OBJECTS  0 
    1414using namespace std; 
     15 
    1516 
    1617namespace GtpVisibilityPreprocessor { 
     
    155156 
    156157 
    157  
    158158float ObjectPvs::EvalPvsCost() const 
    159159{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2669 r2670  
    123123} 
    124124 
     125 
    125126// reimplemented here so that we can snap the error windows 
    126127float QtGlRendererBuffer::GetPixelError(int &pvsSize) 
     
    128129        MakeCurrent(); 
    129130         
    130         cout << "stencil: " << format().stencil() << endl; 
    131         cout << "depth: " << format().depth() << endl; 
    132         cout << "rgba: " << format().rgba() << endl; 
    133         cout << "double: " << format().doubleBuffer() << endl; 
     131        if (0) 
     132        { 
     133                cout << "stencil: " << format().stencil() << endl; 
     134                cout << "depth: " << format().depth() << endl; 
     135                cout << "rgba: " << format().rgba() << endl; 
     136                cout << "double: " << format().doubleBuffer() << endl; 
     137        } 
     138 
     139        ++ mCurrentFrame; 
    134140 
    135141        float pErrorPixels = -1.0f; 
     
    144150                return -1.0f; 
    145151 
    146         KdNode::NewMail2(); 
    147         Intersectable::NewMail(); 
    148  
    149         ObjectPvs pvs; 
    150  
    151152        bool evaluateFilter; 
    152153        Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluateFilter", evaluateFilter); 
     154 
     155        ObjectPvs pvs; 
    153156 
    154157        if (!evaluateFilter)  
     
    169172        if (mSnapErrorFrames) 
    170173        { 
    171  
    172174                GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
    173175                GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
    174176                GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 
    175177 
    176                 GLfloat light_position[] =  //{278.0f, 548.8f,279.0f, 1.0f}; 
    177                 {0.f,0.f,0.f, 1.0f}; 
     178                //GLfloat light_position[] =  {278.0f, 548.8f,279.0f, 1.0f}; 
     179                GLfloat light_position[] =  {0.f,0.f,0.f, 1.0f}; 
    178180 
    179181                glEnable(GL_LIGHT0);  
     
    208210        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
    209211 
    210          
     212        KdNode::NewMail2(); 
     213        Intersectable::NewMail(); 
     214 
     215KdNode::NewMail2(); 
     216        Intersectable::NewMail(); 
     217        KdNode::NewMail2(); 
     218        Intersectable::NewMail(); 
     219 
    211220        // render pvs once 
    212221        RenderPvs(pvs); 
     
    228237        query->BeginQuery(); 
    229238 
     239        ++ mCurrentFrame; 
     240 
    230241        RenderScene(); 
    231242 
    232243        query->EndQuery(); 
    233244        glDisable(GL_STENCIL_TEST);  
    234  
    235  
    236         // reenable other state 
    237         int wait = 0; 
    238         while (0 && !query->ResultAvailable())  
    239                 wait ++; 
    240245         
    241246        pixelCount = query->GetQueryResult(); 
    242247 
     248        pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     249 
    243250        if (pixelCount > 0)  
    244251        { 
    245252                cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; 
    246         } 
    247  
    248         pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
    249  
    250  
    251         if (mSnapErrorFrames && (pixelCount > 0))  
    252         { 
    253                 glReadBuffer(GL_BACK); 
    254                 //glReadBuffer(GL_FRONT); 
    255  
    256                 char filename[256]; 
    257                 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    258                 QImage im = toImage(); 
    259                 string str = mSnapPrefix + filename; 
    260                 QString qstr(str.c_str()); 
    261  
    262                 im.save(qstr, "PNG"); 
    263                 if (0) { //0 && mFrame == 1543) { 
    264                         int x,y; 
    265                         int lastIndex = -1; 
    266                         for (y=0; y < im.height(); y++) 
    267                                 for (x=0; x < im.width(); x++) { 
    268                                         QRgb p = im.pixel(x,y); 
    269                                         int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
    270                                         if (qGreen(p) != 255 && index!=0) { 
    271                                                 if (index != lastIndex) { 
    272                                                         //                              Debug<<"ei="<<index<<" "; 
    273                                                         lastIndex = index; 
    274                                                 } 
    275                                         } 
    276                                 } 
    277                 } 
    278                  
    279  
    280 #if 0 
    281                 mUseFalseColors = false; 
    282  
    283                 glPushAttrib(GL_CURRENT_BIT); 
    284                 glColor3f(0, 1, 0); 
    285                  
    286                 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    287                 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    288                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    289  
    290                 KdNode::NewMail2(); 
    291                 Intersectable::NewMail(); 
    292  
    293                 RenderPvs(pvs); 
    294  
    295                 glFinish(); 
    296  
    297                 mUseForcedColors = false; 
    298  
    299                 im = toImage(); 
    300                 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
    301                 str = mSnapPrefix + filename; 
    302                 qstr = str.c_str(); 
    303                 im.save(qstr, "PNG"); 
    304                  
    305                 glPopAttrib(); 
    306 #endif 
     253         
     254                if (mSnapErrorFrames)  
     255                { 
     256                        glReadBuffer(GL_BACK); 
     257                        //glReadBuffer(GL_FRONT); 
     258 
     259                        ////////////// 
     260                        //-- output error visualization 
     261 
     262                        char filename[256]; 
     263                        sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
     264                        QImage im = toImage(); 
     265                        string str = mSnapPrefix + filename; 
     266                        QString qstr(str.c_str()); 
     267 
     268                        im.save(qstr, "PNG"); 
     269 
     270 
     271                        /////////// 
     272                        //-- output computed pvs 
     273 
     274                        mUseFalseColors = false; 
     275 
     276                        glPushAttrib(GL_CURRENT_BIT); 
     277                        glColor3f(0, 1, 0); 
     278 
     279                        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     280                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
     281 
     282                        KdNode::NewMail2(); 
     283                        Intersectable::NewMail(); 
     284 
     285                        ++ mCurrentFrame; 
     286                        // render pvs once 
     287                        RenderPvs(pvs); 
     288 
     289                        mUseForcedColors = false; 
     290 
     291                        im = toImage(); 
     292                        sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
     293                        str = mSnapPrefix + filename; 
     294                        qstr = str.c_str(); 
     295                        im.save(qstr, "PNG"); 
     296 
     297                        glPopAttrib(); 
     298                } 
    307299        } 
    308300 
     
    497489 
    498490 
    499 void QtGlRendererWidget::PreparePvs2(const ObjectPvs &pvs) 
     491void QtGlRendererWidget::PreparePvs(const ObjectPvs &pvs) 
    500492{ 
    501493        int indexBufferSize = 0; 
    502494         
    503         // super hack: mal not working with multiple threads 
     495        // hack: mail not working with multiple threads 
    504496        KdNode::NewMail2(); 
    505         //Intersectable::NewMail(); 
    506497 
    507498        mPvsSize = pvs.GetSize(); 
     
    546537 
    547538 
    548  
    549  
    550 void QtGlRendererWidget::RenderPvs() 
     539void QtGlRendererWidget::VisualizePvs() 
    551540{ 
    552541        if (mUseVbos)  
     
    600589#else 
    601590         
    602                 PreparePvs2(viewcell->GetPvs()); 
     591                PreparePvs(viewcell->GetPvs()); 
    603592                emit PvsUpdated(); 
    604593 
    605594#endif 
    606  
    607595 
    608596                // Render PVS 
     
    662650 
    663651        // Render PVS 
    664         RenderPvs(); 
     652        VisualizePvs(); 
    665653 
    666654        glEnable(GL_STENCIL_TEST);  
     
    696684        int pixelCount = query->GetQueryResult(); 
    697685        pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     686         
    698687        if (0) cout << "error pixels=" << pixelCount << endl; 
    699688 
     
    826815} 
    827816 
    828 void 
    829 QtGlRendererWidget::paintGL() 
     817 
     818void QtGlRendererWidget::paintGL() 
    830819{ 
    831820        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    843832                { 
    844833                        glColor3f(0.6f, 0.6f, 0.6f); 
    845                         RenderPvs(); 
     834                        VisualizePvs(); 
    846835                } 
    847836 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2664 r2670  
    269269        void keyPressEvent(QKeyEvent * e); 
    270270 
    271         void RenderPvs(); 
     271        void VisualizePvs(); 
    272272 
    273273        float RenderErrors(); 
     
    544544        } 
    545545 
    546         void PreparePvs2(const ObjectPvs &pvs); 
    547  
     546 
     547        /** Prepare pvs for rendering. 
     548        */ 
     549        virtual void PreparePvs(const ObjectPvs &pvs); 
     550        /** Internal method rendering the pvs if it has been properly prepared. 
     551        */ 
    548552        void _RenderPvs(); 
    549553        /** Render pvs using false colors. 
    550554        */ 
    551555        void _RenderColoredPvs(); 
    552  
    553   //    void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 
    554556 
    555557        float ComputeRenderCost(ViewCell *vc); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2664 r2670  
    124124        glEnable(GL_LIGHT1); 
    125125 
    126         mRenderer->RenderPvs(); 
     126        mRenderer->VisualizePvs(); 
    127127         
    128128        glDisable(GL_LIGHTING); 
Note: See TracChangeset for help on using the changeset viewer.