Changeset 2538


Ignore:
Timestamp:
07/09/07 09:58:07 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h

    r2455 r2538  
    9898        virtual void CollectLeaves(HierarchyNode *root, HierarchyNodeContainer &nodes) = 0; 
    9999 
     100        /** Collects leaves that are visible by some algorithm, e.g., view frustum culling. 
     101        */ 
     102        virtual void CollectVisibleLeaves(HierarchyNode *root, HierarchyNodeContainer &nodes) = 0; 
     103 
    100104        virtual void RenderNodeRecursive(HierarchyNode *node) = 0; 
    101105 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp

    r2532 r2538  
    106106                                        int nodesTested = 0; 
    107107 
    108                                         // use different algorithm for finding random candidates 
     108                                        // use different algorithm to find random candidates 
    109109#if 1 
    110110                                        HierarchyNodeContainer mynodes; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r2530 r2538  
    14171417                                        "50"); 
    14181418 
    1419         RegisterOption("ViewCells.renderCostEvaluationType", 
    1420                                         optString, 
    1421                                         "view_cells_render_cost_evaluation=", 
    1422                                         "perobject"); 
    1423  
    14241419        RegisterOption("ViewCells.active", 
    14251420                                        optInt, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2530 r2538  
    3333const int depthMapSize = 512; 
    3434 
     35 
    3536static void InitExtensions()  
    3637{ 
     
    4950        if (GLEW_NV_occlusion_query)  
    5051                nvQuerySupport = true; 
    51          
    5252 
    5353        if  (!arbQuerySupport && !nvQuerySupport) 
     
    5555                cout << "I require the GL_ARB_occlusion_query or the GL_NV_occlusion_query OpenGL extension to work.\n"; 
    5656                exit(1); 
     57        } 
     58 
     59        if (!GLEW_ARB_vertex_buffer_object)  
     60        { 
     61                cout << "vbos not supported" << endl; 
     62        } 
     63        else 
     64        { 
     65                cout << "vbos supported" << endl; 
    5766        } 
    5867} 
     
    6473  Renderer(sceneGraph, viewCellsManager), 
    6574  mKdTree(tree), 
    66   mUseFalseColors(false) 
     75  mUseFalseColors(false), 
     76  mVboId(-1), 
     77  mData(NULL), 
     78  mIndices(NULL), 
     79  mUseVbos(true) 
     80  //mUseVbos(false) 
    6781{ 
    6882  mSceneGraph->CollectObjects(&mObjects); 
     
    90104  mUseForcedColors = false; 
    91105  mRenderBoxes = false; 
    92  // mUseGlLists = true; 
    93   mUseGlLists = false; 
     106  mUseGlLists = true; 
     107  //mUseGlLists = false; 
    94108 
    95109  if (mViewCellsManager->GetViewCellPoints()->size()) 
     
    103117} 
    104118 
     119 
    105120GlRenderer::~GlRenderer() 
    106121{ 
    107122  cerr<<"gl renderer destructor..\n"; 
    108123  
    109   //CLEAR_CONTAINER(sQueries); 
    110124  CLEAR_CONTAINER(mOcclusionQueries); 
    111125 
     126  DeleteVbos(); 
     127 
     128  if (mData) delete [] mData; 
     129  if (mIndices) delete [] mIndices; 
     130 
     131  glDeleteBuffersARB(1, &mVboId); 
    112132  cerr<<"done."<<endl; 
    113133} 
     
    338358   
    339359  OcclusionQuery::GenQueries(mOcclusionQueries, 10); 
     360 
     361  CreateVertexArrays(); 
    340362} 
    341363 
     
    373395GlRenderer::_RenderScene() 
    374396{ 
    375   ObjectContainer::const_iterator oi = mObjects.begin(); 
    376   for (; oi != mObjects.end(); oi++) 
    377         RenderIntersectable(*oi); 
    378 } 
    379  
    380 void 
    381 GlRenderer::_RenderSceneTriangles() 
    382 { 
    383   glBegin(GL_TRIANGLES); 
    384  
    385   ObjectContainer::const_iterator oi = mObjects.begin(); 
    386   for (; oi != mObjects.end(); oi++) { 
    387          
    388         if ((*oi)->Type() == Intersectable::TRIANGLE_INTERSECTABLE) { 
    389           TriangleIntersectable *object = (TriangleIntersectable *)*oi; 
    390           Triangle3 &t = object->GetItem(); 
    391            
    392           Vector3 normal = t.GetNormal(); 
    393           glNormal3f(normal.x, normal.y, normal.z); 
    394           glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z); 
    395           glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z); 
    396           glVertex3f(t.mVertices[2].x, t.mVertices[2].y, t.mVertices[2].z); 
    397            
    398         } 
    399   } 
    400  
    401   glEnd(); 
    402    
    403 } 
     397        ObjectContainer::const_iterator oi = mObjects.begin(); 
     398        for (; oi != mObjects.end(); oi++) 
     399                RenderIntersectable(*oi); 
     400} 
     401 
     402void GlRenderer::_RenderSceneTrianglesWithDrawArrays() 
     403{ 
     404        EnableDrawArrays(); 
     405         
     406        if (mUseVbos) 
     407                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
     408 
     409        int offset = mObjects.size() * 3; 
     410        char *arrayPtr = mUseVbos ? NULL : (char *)mData; 
     411         
     412        glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr); 
     413        glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 
     414         
     415        glDrawArrays(GL_TRIANGLES, 0, mObjects.size() * 3); 
     416        //DisableDrawArrays(); 
     417} 
     418 
     419 
     420void GlRenderer::_RenderSceneTriangles() 
     421{ 
     422        glBegin(GL_TRIANGLES); 
     423 
     424        ObjectContainer::const_iterator oi = mObjects.begin(); 
     425        for (; oi != mObjects.end(); oi++) { 
     426 
     427                if ((*oi)->Type() == Intersectable::TRIANGLE_INTERSECTABLE) { 
     428                        TriangleIntersectable *object = (TriangleIntersectable *)*oi; 
     429                        Triangle3 &t = object->GetItem(); 
     430 
     431                        Vector3 normal = t.GetNormal(); 
     432                        glNormal3f(normal.x, normal.y, normal.z); 
     433                        glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z); 
     434                        glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z); 
     435                        glVertex3f(t.mVertices[2].x, t.mVertices[2].y, t.mVertices[2].z); 
     436 
     437                } 
     438        } 
     439 
     440        glEnd(); 
     441} 
     442 
    404443 
    405444bool 
     
    407446{ 
    408447  Intersectable::NewMail(); 
     448 
     449#if 1 
     450   
     451  _RenderSceneTrianglesWithDrawArrays(); 
     452 
     453#else 
    409454  static int glList = -1; 
    410455  if (mUseGlLists) { 
     
    420465        _RenderSceneTriangles(); 
    421466         
    422    
     467#endif 
    423468  return true; 
    424469} 
     
    426471 
    427472void 
    428 GlRendererBuffer::EvalQueryWithItemBuffer( 
    429                                                                                   //RenderCostSample &sample 
    430                                                                            ) 
     473GlRendererBuffer::EvalQueryWithItemBuffer() 
    431474{ 
    432475        // read back the texture 
     
    466509                                                                   KdTree *tree): 
    467510GlRenderer(sceneGraph, viewcells, tree)   
    468 { 
    469    
    470   mPixelBuffer = NULL; 
    471    
     511{  
     512  mPixelBuffer = NULL;  
    472513  // implement width and height in subclasses 
    473514} 
     
    683724        RenderBvhNode(in->GetFront()); 
    684725  } 
    685  
    686   //cout << "leaf obj " << i << endl; 
    687  
    688726} 
    689727 
     
    691729GlRenderer::RenderKdNode(KdNode *node) 
    692730{ 
    693   if (node->IsLeaf()) { 
    694         KdLeaf *leaf = (KdLeaf *) node; 
    695         for (int i=0; i < leaf->mObjects.size(); i++) { 
    696           RenderIntersectable(leaf->mObjects[i]); 
    697         } 
    698   } else { 
    699         KdInterior *in = (KdInterior *)node; 
    700         RenderKdNode(in->mBack); 
    701         RenderKdNode(in->mFront); 
    702   } 
    703    
    704 } 
    705  
    706  
    707  
     731        if (node->IsLeaf())  
     732        { 
     733#if 1 
     734                RenderKdLeaf(static_cast<KdLeaf *>(node)); 
     735#else 
     736                KdLeaf *leaf = (KdLeaf *)node; 
     737                for (int i=0; i < leaf->mObjects.size(); i++)  
     738                { 
     739                        RenderIntersectable(leaf->mObjects[i]); 
     740                } 
     741#endif 
     742        }  
     743        else  
     744        { 
     745                KdInterior *in = (KdInterior *)node; 
     746                RenderKdNode(in->mBack); 
     747                RenderKdNode(in->mFront); 
     748        } 
     749} 
    708750 
    709751 
     
    814856#endif 
    815857#endif 
     858         
    816859} 
    817860 
     
    11261169        { 
    11271170                mOcclusionQueries[queryIdx ++]->BeginQuery(); 
    1128  
    11291171                RenderIntersectable(*vit); 
    1130                  
    11311172                mOcclusionQueries[queryIdx]->EndQuery(); 
    11321173 
     
    15191560GlRenderer::RenderViewPoint() 
    15201561{ 
    1521   mWireFrame = true; 
    1522   glPushMatrix(); 
    1523   glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z); 
    1524   glScalef(5.0f,5.0f,5.0f); 
    1525   glPushAttrib(GL_CURRENT_BIT); 
    1526   glColor3f(1.0f, 0.0f, 0.0f); 
    1527   gluSphere((::GLUquadric *)mSphere, 
    1528                         1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
    1529   glPopAttrib(); 
    1530   glPopMatrix(); 
    1531   mWireFrame = false; 
    1532 } 
    1533  
    1534  
    1535  
    1536  
    1537  
    1538 } 
     1562        mWireFrame = true; 
     1563        glPushMatrix(); 
     1564        glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z); 
     1565        glScalef(5.0f,5.0f,5.0f); 
     1566        glPushAttrib(GL_CURRENT_BIT); 
     1567        glColor3f(1.0f, 0.0f, 0.0f); 
     1568        gluSphere((::GLUquadric *)mSphere, 
     1569                1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
     1570        glPopAttrib(); 
     1571        glPopMatrix(); 
     1572        mWireFrame = false; 
     1573} 
     1574 
     1575 
     1576void GlRenderer::EnableDrawArrays() 
     1577{ 
     1578        glEnableClientState(GL_VERTEX_ARRAY); 
     1579        glEnableClientState(GL_NORMAL_ARRAY); 
     1580} 
     1581 
     1582 
     1583void GlRenderer::DisableDrawArrays() 
     1584{ 
     1585        glDisableClientState(GL_VERTEX_ARRAY); 
     1586        glDisableClientState(GL_NORMAL_ARRAY); 
     1587} 
     1588 
     1589 
     1590#if 0 
     1591 
     1592void GlRenderer::RenderKdLeaf(KdLeaf *leaf) 
     1593{ 
     1594        int bufferSize = 0; 
     1595 
     1596        // count #new triangles 
     1597        for (size_t i = 0; i < leaf->mObjects.size(); ++ i) 
     1598        { 
     1599                TriangleIntersectable *obj = static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 
     1600 
     1601                // check if already rendered 
     1602                if (!obj->Mailed()) 
     1603                        bufferSize += 3; 
     1604                //else cout << obj->mMailbox << " " << obj->sMailId << " "; 
     1605        } 
     1606 
     1607        Vector3 *vertices = new Vector3[bufferSize]; 
     1608        Vector3 *normals = new Vector3[bufferSize]; 
     1609 
     1610        int j = 0; 
     1611 
     1612        for (size_t i = 0; i < leaf->mObjects.size(); ++ i) 
     1613        { 
     1614                TriangleIntersectable *obj = static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 
     1615 
     1616                // check if already rendered 
     1617                if (obj->Mailed()) 
     1618                        continue; 
     1619 
     1620                obj->Mail(); 
     1621 
     1622                Triangle3 tri = obj->GetItem(); 
     1623 
     1624                vertices[j * 3 + 0] = tri.mVertices[0]; 
     1625                vertices[j * 3 + 1] = tri.mVertices[1]; 
     1626                vertices[j * 3 + 2] = tri.mVertices[2]; 
     1627 
     1628                Vector3 n = tri.GetNormal(); 
     1629 
     1630                normals[j * 3 + 0] = n; 
     1631                normals[j * 3 + 1] = n; 
     1632                normals[j * 3 + 2] = n; 
     1633 
     1634                ++ j; 
     1635        } 
     1636 
     1637        glVertexPointer(3, GL_FLOAT, 0, vertices); 
     1638        glNormalPointer(GL_FLOAT, 0, normals); 
     1639 
     1640        glDrawArrays(GL_TRIANGLES, 0, bufferSize); 
     1641 
     1642        DEL_PTR(vertices); 
     1643        DEL_PTR(normals); 
     1644} 
     1645 
     1646#else 
     1647 
     1648void GlRenderer::RenderKdLeaf(KdLeaf *leaf) 
     1649{ 
     1650        if (!leaf->mIndexBufferSize) 
     1651                return; 
     1652 
     1653        unsigned int offset = mObjects.size() * 3; 
     1654        char *arrayPtr = mUseVbos ? NULL : (char *)mData; 
     1655         
     1656        glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr); 
     1657        glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 
     1658         
     1659        glDrawElements(GL_TRIANGLES, leaf->mIndexBufferSize, GL_UNSIGNED_INT, mIndices + leaf->mIndexBufferStart); 
     1660} 
     1661 
     1662#endif 
     1663 
     1664void GlRenderer::CreateVertexArrays() 
     1665{ 
     1666        mData = new Vector3[mObjects.size() * 6]; 
     1667        mIndices = new unsigned int[mObjects.size() * 3]; 
     1668 
     1669        const int offset = mObjects.size() * 3; 
     1670 
     1671        for (size_t i = 0; i < mObjects.size(); ++ i) 
     1672        { 
     1673                TriangleIntersectable *obj = static_cast<TriangleIntersectable *>(mObjects[i]); 
     1674 
     1675                Triangle3 tri = obj->GetItem(); 
     1676                const Vector3 n = tri.GetNormal(); 
     1677 
     1678                mData[i * 3 + 0] = tri.mVertices[0]; 
     1679                mData[i * 3 + 1] = tri.mVertices[1]; 
     1680                mData[i * 3 + 2] = tri.mVertices[2]; 
     1681 
     1682                mData[offset + i * 3 + 0] = n; 
     1683                mData[offset + i * 3 + 1] = n; 
     1684                mData[offset + i * 3 + 2] = n; 
     1685        } 
     1686 
     1687        if (mUseVbos) 
     1688        { 
     1689                EnableDrawArrays(); 
     1690 
     1691                glGenBuffersARB(1, &mVboId); 
     1692                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
     1693 
     1694                glVertexPointer(3, GL_FLOAT, 0, (char *)NULL); 
     1695                glNormalPointer(GL_FLOAT, 0, (char *)NULL + offset * sizeof(Vector3)); 
     1696 
     1697                glBufferDataARB(GL_ARRAY_BUFFER_ARB, mObjects.size() * 6 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB); 
     1698                glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
     1699 
     1700                DisableDrawArrays(); 
     1701 
     1702                delete [] mData; 
     1703        } 
     1704 
     1705        cout << "\n**************\ndraw arrays created\n" << endl;       
     1706} 
     1707 
     1708 
     1709void GlRenderer::DeleteVbos() 
     1710{ 
     1711        glDeleteBuffersARB(1, &mVboId); 
     1712 
     1713/* 
     1714        KdLeafContainer leaves; 
     1715        mKdTree->CollectLeaves(leaves); 
     1716 
     1717        KdLeafContainer::const_iterator kit, kit_end = leaves.end(); 
     1718 
     1719        for (kit = leaves.begin(); kit != kit_end; ++ kit) 
     1720        { 
     1721                KdLeaf *leaf = *kit; 
     1722 
     1723                if (leaf->mVboId == -1) 
     1724                { 
     1725                        // delete old vbo 
     1726                        glDeleteBuffersARB(1, &leaf->mVboId); 
     1727                        leaf->mVboId = -1; 
     1728                } 
     1729        } 
     1730*/ 
     1731} 
     1732 
     1733 
     1734 
     1735} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2176 r2538  
    5959 
    6060        struct PvsCache { 
    61                 PvsCache():mViewCell(NULL) {} 
    62                 void Reset() { mViewCell = NULL; mPvs.Clear(); filteredBoxes.clear(); } 
     61                 
     62                PvsCache():mViewCell(NULL), mUnfilteredPvsSize(0) {} 
     63 
     64                void Reset() 
     65                {  
     66                        mViewCell = NULL; mPvs.Clear();  
     67                        filteredBoxes.clear();  
     68                        mUnfilteredPvsSize = 0; 
     69                } 
     70                 
    6371                ViewCell *mViewCell; 
    6472                ObjectPvs mPvs; 
     73                int mUnfilteredPvsSize; 
    6574                vector<AxisAlignedBox3> filteredBoxes; 
    6675        }; 
     
    94103class GlRenderer: public Renderer 
    95104{ 
     105friend class GlobalLinesRenderer; 
     106friend class ViewCellsManager; 
    96107 
    97108public: 
     
    141152  _RenderSceneTriangles(); 
    142153 
     154  void _RenderSceneTrianglesWithDrawArrays(); 
     155 
    143156  void 
    144157  RenderViewPoint(); 
     
    197210          Vector3 mDirection; 
    198211  }; 
    199 friend class GlobalLinesRenderer; 
    200 friend class ViewCellsManager; 
    201212 
    202213  vector<PvsErrorEntry> mPvsErrorBuffer; 
     
    204215protected: 
    205216 
    206    
    207  
    208   PvsCache mPvsCache; 
    209  
    210   vector<OcclusionQuery *> mOcclusionQueries; 
    211  
    212   ObjectContainer mObjects; 
    213     
    214   Vector3 mViewPoint; 
    215   Vector3 mViewDirection; 
    216  
    217   int timerId; 
    218   bool mUseFalseColors; 
    219   bool mUseForcedColors; 
    220  
    221   HaltonSequence halton; 
    222    
    223    
    224   bool mDetectEmptyViewSpace; 
    225   bool mSnapErrorFrames; 
    226  
    227   bool mRenderBoxes; 
    228  
    229   bool mUseGlLists; 
    230    
    231   std::string mSnapPrefix; 
    232  
    233   GLUquadric *mSphere; 
    234    
    235   KdTree *mKdTree; 
    236  
    237 }; 
     217        void CreateVertexArrays(); 
     218        void DeleteVbos(); 
     219        void EnableDrawArrays(); 
     220        void DisableDrawArrays(); 
     221 
     222        void RenderKdLeaf(KdLeaf *leaf); 
     223 
     224 
     225        ////////////////// 
     226 
     227        PvsCache mPvsCache; 
     228 
     229        unsigned int mVboId; 
     230        vector<OcclusionQuery *> mOcclusionQueries; 
     231 
     232        ObjectContainer mObjects; 
     233 
     234        Vector3 mViewPoint; 
     235        Vector3 mViewDirection; 
     236 
     237        int timerId; 
     238        bool mUseFalseColors; 
     239        bool mUseForcedColors; 
     240 
     241        HaltonSequence halton; 
     242 
     243 
     244        bool mDetectEmptyViewSpace; 
     245        bool mSnapErrorFrames; 
     246 
     247        bool mRenderBoxes; 
     248 
     249        bool mUseGlLists; 
     250 
     251        std::string mSnapPrefix; 
     252 
     253        GLUquadric *mSphere; 
     254 
     255        KdTree *mKdTree; 
     256 
     257        Vector3 *mData; 
     258        unsigned int *mIndices; 
     259 
     260        bool mUseVbos; 
     261}; 
     262 
    238263 
    239264/* Class implementing an OpenGl render buffer. 
     
    268293        */ 
    269294        virtual void SampleRenderCost(const int numSamples,  
    270                 vector<RenderCostSample> &samples, 
    271                 const bool useOcclusionQueries, 
    272                 const int threshold = 0); 
    273  
    274  
     295                                                                  vector<RenderCostSample> &samples, 
     296                                                                  const bool useOcclusionQueries, 
     297                                                                  const int threshold = 0); 
    275298        /** Implerment in subclasses. 
    276299        */ 
     
    288311 
    289312        virtual void SampleBeamContributions( 
    290                 Intersectable *sourceObject, 
    291                 Beam &beam, 
    292                 const int samples, 
    293                 BeamSampleStatistics &stat 
    294                 ); 
    295  
    296         virtual void 
    297                 SampleViewpointContributions( 
    298                 Intersectable *sourceObject, 
    299                 const Vector3 viewPoint, 
    300                 Beam &beam, 
    301                 const int desiredSamples, 
    302                 BeamSampleStatistics &stat 
    303                 ); 
     313                                                                                 Intersectable *sourceObject, 
     314                                                                                 Beam &beam, 
     315                                                                                 const int samples, 
     316                                                                                 BeamSampleStatistics &stat 
     317                                                                                 ); 
     318 
     319        virtual void SampleViewpointContributions( 
     320                                                                                          Intersectable *sourceObject, 
     321                                                                                          const Vector3 viewPoint, 
     322                                                                                          Beam &beam, 
     323                                                                                          const int desiredSamples, 
     324                                                                                          BeamSampleStatistics &stat 
     325                                                                                          ); 
    304326 
    305327        virtual void InitGL(); 
    306  
    307328        /** Computes rays from information gained with hw sampling- 
    308329        */ 
     
    321342 
    322343        virtual void SetupProjectionForViewPoint(const Vector3 &viewPoint,  
    323                 const Beam &beam,  
    324  
    325                 Intersectable *sourceObject); 
    326  
     344                                                                                         const Beam &beam,  
     345                                                                                         Intersectable *sourceObject); 
    327346        /** Evaluates query for one direction using item buffer. 
    328347        */ 
    329348        virtual void EvalQueryWithItemBuffer(); 
    330  
    331349        /** Evaluates query for one direction using occlusion queries. 
    332350        */ 
    333351        virtual void EvalQueryWithOcclusionQueries(); 
    334  
    335 public: 
    336         // matt: remove qt dependencies 
    337         // signals: 
    338         //      void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 
    339352}; 
    340353 
     
    353366 
    354367          virtual ~GlRendererWidget() {} 
    355  
    356           //virtual void Create() {} 
     368           
    357369          virtual void Show() {} 
    358  
    359  
    360 protected: 
    361  
    362  
    363         //      SceneGraph *mSceneGraph; 
    364         //      ViewCellsManager *mViewCellsManager; 
    365         //      KdTree *mKdTree; 
    366 }; 
    367  
    368 //extern GlRendererWidget *rendererWidget; 
     370}; 
     371 
    369372 
    370373}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.cpp

    r2231 r2538  
    2828        { 
    2929        case MESH_INSTANCE: 
    30                 return "mesh_instance\n"; 
    31  
     30                return "mesh instance"; 
    3231        case TRANSFORMED_MESH_INSTANCE: 
    33                 return "transformed_mesh_instance\n"; 
    34  
     32                return "transformed mesh instance"; 
    3533        case SPHERE: 
    36                 return "sphere\n"; 
    37  
     34                return "sphere"; 
    3835        case VIEW_CELL: 
    39                 return "view cell\n"; 
    40  
     36                return "view cell"; 
    4137        case OGRE_MESH_INSTANCE: 
    42                 return "ogre_mesh_instance\n"; 
    43  
     38                return "ogre_mesh_instance"; 
    4439        case KD_INTERSECTABLE: 
    45                 return "kd_intersectable\n"; 
    46  
     40                return "kd"; 
     41        case TRIANGLE_INTERSECTABLE: 
     42                return "triangle"; 
     43        case BVH_INTERSECTABLE: 
     44                return "bvh"; 
    4745        default: 
    48                 return "unknown\n"; 
     46                return "unknown"; 
    4947        } 
    5048} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2176 r2538  
    160160{ 
    161161public: 
    162         AxisAlignedBox3 mBox; 
    163          
    164162        KdIntersectable(KdNode *item, const AxisAlignedBox3 &box); 
    165163     
     
    173171                return mBox; 
    174172        } 
     173 
     174        /// the bounding box of this intersectable 
     175        AxisAlignedBox3 mBox; 
    175176}; 
    176177 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2524 r2538  
    183183public: 
    184184  KdLeaf(KdInterior *parent, const int objects): 
    185           KdNode(parent), mViewCell(NULL) { 
     185          KdNode(parent), mViewCell(NULL), mVboId(-1), mIndexBufferStart(0), mIndexBufferSize(0) { 
    186186    mObjects.reserve(objects); 
    187187  } 
     
    209209  /// pointers to occluders contained in this node 
    210210  ObjectContainer mObjects; 
    211  
    212211  /// Ray set description of the rays passing through this node 
    213212  PassingRaySet mPassingRays; 
    214          
    215   /// PVS consisting of visible KdTree nodes 
    216   //KdPvs mKdPvs; 
    217  
    218   /// pvs of view cells seeing this node. 
    219   SubdivisionCandidate *mSubdivisionCandidate; 
    220  
    221213  /// pointer to view cell. 
    222214  KdViewCell *mViewCell; 
    223  
     215  /// rays intersecting this leaf 
    224216  VssRayContainer mVssRays; 
    225  
    226217   /// Objects that are referenced in more than one leaf. 
    227218  ObjectContainer mMultipleObjects; 
    228  
    229219  /// universal counter 
    230220  int mCounter; 
     221 
     222  /// hack 
     223  unsigned int mVboId; 
     224 
     225  unsigned int mIndexBufferStart; 
     226  unsigned int mIndexBufferSize; 
    231227}; 
    232228 
     
    342338 
    343339  /** Returns or creates a new intersectable for use in a kd based pvs. 
    344           The OspTree is responsible for destruction of the intersectable. 
    345340  */ 
    346341  KdIntersectable *GetOrCreateKdIntersectable(KdNode *node); 
     
    348343 
    349344  void 
    350   SetPvsTerminationNodes( 
    351                                                  const float maxArea); 
     345  SetPvsTerminationNodes(const float maxArea); 
    352346   
    353347  KdNode * 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h

    r2224 r2538  
    377377                                                const Vector3 &termination, 
    378378                                                ViewCellContainer &viewcells); 
    379                  
    380379        /** Sets pointer to view cells manager. 
    381380        */ 
    382381        void SetViewCellsManager(ViewCellsManager *vcm); 
    383  
    384382        /** Writes tree to output stream 
    385383        */ 
    386384        bool Export(OUT_STREAM &stream); 
    387  
    388385        /** Returns or creates a new intersectable for use in a kd based pvs. 
    389386                The OspTree is responsible for destruction of the intersectable. 
    390387        */ 
    391388        KdIntersectable *GetOrCreateKdIntersectable(KdNode *node); 
    392  
    393389        /** Collects rays stored in the leaves. 
    394390        */ 
    395391        void CollectRays(VssRayContainer &rays); 
    396  
    397392        /** Intersects box with the tree and returns the number of intersected boxes. 
    398393                @returns number of view cells found 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2530 r2538  
    123123                                EnableFiberSafeOptimizations="TRUE" 
    124124                                WholeProgramOptimization="FALSE" 
    125                                 OptimizeForProcessor="3" 
     125                                OptimizeForProcessor="2" 
    126126                                OptimizeForWindowsApplication="TRUE" 
    127127                                AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;;Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2530 r2538  
    1515#include "QtPreprocessorThread.h" 
    1616#include "Material.h" 
     17#include "IntersectableWrapper.h" 
     18 
    1719 
    1820#define USE_CG 1 
     
    109111   
    110112  ObjectPvs pvs; 
    111   if (1) { 
    112         pvs = viewcell->GetPvs(); 
    113   } else { 
    114         mViewCellsManager->ApplyFilter2(viewcell, 
    115                                                                         false, 
    116                                                                         1.0f, 
    117                                                                         pvs); 
    118   } 
     113   
     114  if (1)  
     115          pvs = viewcell->GetPvs(); 
     116  else  
     117          mViewCellsManager->ApplyFilter2(viewcell,     false, 1.0f, pvs); 
    119118   
    120119  //  cout<<"pvs size"<<pvs.GetSize()<<endl<<flush; 
     
    128127  glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
    129128   
    130   //    // Render PVS 
     129  // Render PVS 
    131130  ObjectPvsIterator it = pvs.GetIterator(); 
    132131   
     
    349348 
    350349 
    351  
    352 void 
    353 QtGlRendererWidget::RenderPvs() 
    354 { 
     350bool QtGlRendererWidget::PvsChanged(ViewCell *viewCell) const 
     351{ 
     352        if (viewCell != mPvsCache.mViewCell) 
     353                return true; 
     354 
     355        if (viewCell->GetPvs().GetSize() != mPvsCache.mUnfilteredPvsSize) 
     356                return true; 
     357 
     358        return false; 
     359} 
     360 
     361 
     362void QtGlRendererWidget::_RenderPvs() 
     363{ 
     364        mUseFalseColors = false; 
     365 
     366        int offset = mObjects.size() * 3; 
     367        char *arrayPtr = mUseVbos ? NULL : (char *)mData; 
    355368         
    356   Intersectable::NewMail(); 
    357  
    358   ViewCell *viewcell = NULL; 
    359  
    360   if (mDetectEmptyViewSpace)  
    361         glEnable( GL_CULL_FACE ); 
    362   else 
    363         glDisable( GL_CULL_FACE ); 
    364    
    365   viewcell = mViewCellsManager->GetViewCell(mViewPoint, true); 
    366    
    367   if (viewcell) { 
    368         // copy the pvs so that it can be filtered... 
    369          
    370         //      mPvsCache.mPvs; 
    371          
    372         if (mPvsCache.mViewCell != viewcell) { 
    373           mPvsCache.Reset(); 
    374           mPvsCache.mViewCell = viewcell; 
    375            
    376           if (mUseSpatialFilter) { 
    377                 // 9.11. 2006 -> experiment with new spatial filter 
     369        glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr); 
     370        glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 
     371        glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 
     372} 
     373 
     374 
     375void QtGlRendererWidget::_UpdatePvsIndices() 
     376{ 
     377        mIndexBufferSize = 0; 
     378        KdNode::NewMail(); 
     379 
     380        mPvsSize = mPvsCache.mPvs.GetSize(); 
     381 
     382        ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
     383 
     384        for (; it.HasMoreEntries(); )  
     385        { 
     386                Intersectable *obj = it.Next(); 
     387                KdNode *node = static_cast<KdIntersectable *>(obj)->GetItem(); 
     388                _UpdatePvsIndices(node); 
     389        } 
     390} 
     391 
     392 
     393void QtGlRendererWidget::_UpdatePvsIndices(KdNode *node) 
     394{ 
     395        if (node->Mailed()) 
     396                return; 
     397 
     398        node->Mail(); 
     399 
     400        if (!node->IsLeaf())  
     401        { 
     402                KdInterior *in = static_cast<KdInterior *>(node); 
     403                 
     404                _UpdatePvsIndices(in->mBack); 
     405                _UpdatePvsIndices(in->mFront); 
     406        }  
     407        else  
     408        { 
     409                KdLeaf *leaf = static_cast<KdLeaf *>(node); 
     410 
     411                leaf->mIndexBufferStart = mIndexBufferSize; 
     412 
     413                for (size_t i = 0; i < leaf->mObjects.size(); ++ i) 
     414                { 
     415                        TriangleIntersectable *obj =  
     416                                static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 
     417 
     418                        // check if already rendered 
     419                        if (!obj->Mailed()) 
     420                        { 
     421                                obj->Mail(); 
     422 
     423                                mIndices[mIndexBufferSize + 0] = (obj->GetId() - 1) * 3 + 0; 
     424                                mIndices[mIndexBufferSize + 1] = (obj->GetId() - 1) * 3 + 1; 
     425                                mIndices[mIndexBufferSize + 2] = (obj->GetId() - 1) * 3 + 2; 
     426 
     427                                mIndexBufferSize += 3; 
     428                        } 
     429                } 
     430 
     431                leaf->mIndexBufferSize = mIndexBufferSize - leaf->mIndexBufferStart; 
     432        } 
     433} 
     434 
     435 
     436void QtGlRendererWidget::RenderPvs() 
     437{ 
     438        if (mUseVbos)  
     439                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
     440 
     441        EnableDrawArrays(); 
     442 
     443        Intersectable::NewMail(); 
     444        ViewCell *viewcell = NULL; 
     445 
     446        if (mDetectEmptyViewSpace)  
     447                glEnable(GL_CULL_FACE); 
     448        else 
     449                glDisable(GL_CULL_FACE); 
     450 
     451        viewcell = mViewCellsManager->GetViewCell(mViewPoint, true); 
     452 
     453        if (viewcell)  
     454        { 
     455                // copy the pvs so that it can be filtered... 
     456                if (PvsChanged(viewcell))  
     457                { 
     458                        mPvsCache.Reset(); 
     459                        mPvsCache.mViewCell = viewcell; 
     460                        mPvsCache.mUnfilteredPvsSize = viewcell->GetPvs().GetSize(); 
     461 
     462                        if (mUseSpatialFilter)  
     463                        { 
     464                                // 9.11. 2006 -> experiment with new spatial filter 
    378465#if 0 
    379                 mViewCellsManager->ApplySpatialFilter(mKdTree, 
    380                                                                                           mSpatialFilterSize* 
    381                                                                                           Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
    382                                                                                           mPvsCache.mPvs); 
     466                                mViewCellsManager->ApplySpatialFilter(mKdTree, 
     467                                        mSpatialFilterSize* 
     468                                        Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
     469                                        mPvsCache.mPvs); 
    383470#else 
    384                 // mSpatialFilter size is in range 0.001 - 0.1 
    385                 mViewCellsManager->ApplyFilter2(viewcell, 
    386                                                                                 mUseFilter, 
    387                                                                                 100*mSpatialFilterSize, 
    388                                                                                 mPvsCache.mPvs, 
    389                                                                                 &mPvsCache.filteredBoxes 
    390                                                                                 ); 
     471                                //cout<<"updating filter" << endl; 
     472                                // mSpatialFilter size is in range 0.001 - 0.1 
     473                                mViewCellsManager->ApplyFilter2(viewcell, 
     474                                        mUseFilter, 
     475                                        100 * mSpatialFilterSize, 
     476                                        mPvsCache.mPvs, 
     477                                        &mPvsCache.filteredBoxes 
     478                                        ); 
    391479#endif 
    392           } else 
    393                 mPvsCache.mPvs = viewcell->GetPvs(); 
    394            
    395           emit PvsUpdated(); 
     480                        }  
     481                        else 
     482                        { 
     483                                mPvsCache.mPvs = viewcell->GetPvs(); 
     484                        } 
     485 
     486                        /// update the indices for rendering 
     487                        _UpdatePvsIndices(); 
     488 
     489                        emit PvsUpdated(); 
     490                } 
     491 
     492                Intersectable::NewMail(); 
     493                PvsData pvsData; 
     494 
     495                // Render PVS 
     496                if (mUseSpatialFilter && mRenderBoxes)  
     497                { 
     498                        for (int i=0; i < mPvsCache.filteredBoxes.size(); i++) 
     499                                RenderBox(mPvsCache.filteredBoxes[i]); 
     500                }  
     501                else  
     502                { 
     503                        if (!mRenderVisibilityEstimates) 
     504                        { 
     505                                _RenderPvs(); 
     506                        } 
     507                        else 
     508                        { 
     509                                ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
     510 
     511                                mPvsSize = mPvsCache.mPvs.GetSize(); 
     512                                for (; it.HasMoreEntries(); )  
     513                                { 
     514                                        Intersectable *object = it.Next(pvsData); 
     515 
     516                                        //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
     517                                        // glColor3f(visibility, 0.0f, 0.0f); 
     518                                        //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
     519                                        RgbColor color = RainbowColorMapping(mTransferFunction*log10(pvsData.mSumPdf + 1)); 
     520                                        glColor3f(color.r, color.g, color.b); 
     521 
     522                                        mUseForcedColors = true; 
     523                                        RenderIntersectable(object); 
     524                                        mUseForcedColors = false; 
     525                                } 
     526                        } 
     527                } 
     528 
     529                if (mRenderFilter)  
     530                { 
     531                        mWireFrame = true; 
     532                        RenderIntersectable(viewcell); 
     533                        glPushMatrix(); 
     534                        glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z); 
     535                        glScalef(5.0f,5.0f,5.0f); 
     536                        glPushAttrib(GL_CURRENT_BIT); 
     537                        glColor3f(1.0f, 0.0f, 0.0f); 
     538                        //        gluSphere((::GLUquadric *)mSphere, 
     539                        //                              1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
     540                        glPopAttrib(); 
     541                        glPopMatrix(); 
     542                        mWireFrame = false; 
     543                } 
     544        }  
     545        else  
     546        { 
     547                /*ObjectContainer::const_iterator oi = mObjects.begin(); 
     548                for (; oi != mObjects.end(); oi++) 
     549                        RenderIntersectable(*oi);*/ 
     550                RenderScene(); 
    396551        } 
    397552 
    398         Intersectable::NewMail(); 
    399  
    400         PvsData pvsData; 
    401  
    402         // Render PVS 
    403         if (mUseSpatialFilter && mRenderBoxes) { 
    404           for (int i=0; i < mPvsCache.filteredBoxes.size(); i++) 
    405                 RenderBox(mPvsCache.filteredBoxes[i]); 
    406         } else { 
    407           ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
    408            
    409           mPvsSize = mPvsCache.mPvs.GetSize(); 
    410           for (; it.HasMoreEntries(); ) { 
    411                 Intersectable *object = it.Next(pvsData); 
    412                  
    413                 if (mRenderVisibilityEstimates) { 
    414                   //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
    415                   //              glColor3f(visibility, 0.0f, 0.0f); 
    416                         //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
    417                   RgbColor color = RainbowColorMapping(mTransferFunction*log10(pvsData.mSumPdf + 1)); 
    418                   glColor3f(color.r, color.g, color.b); 
    419                    
    420                   mUseForcedColors = true; 
    421                   RenderIntersectable(object); 
    422                   mUseForcedColors = false; 
    423                 } else { 
    424                   mUseForcedColors = false; 
    425                   RenderIntersectable(object); 
    426                 } 
    427           } 
    428         } 
    429          
    430         if (mRenderFilter) { 
    431           mWireFrame = true; 
    432           RenderIntersectable(viewcell); 
    433           glPushMatrix(); 
    434           glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z); 
    435           glScalef(5.0f,5.0f,5.0f); 
    436           glPushAttrib(GL_CURRENT_BIT); 
    437           glColor3f(1.0f, 0.0f, 0.0f); 
    438           //      gluSphere((::GLUquadric *)mSphere, 
    439           //                            1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
    440           glPopAttrib(); 
    441           glPopMatrix(); 
    442           mWireFrame = false; 
    443         } 
    444   } else { 
    445         ObjectContainer::const_iterator oi = mObjects.begin(); 
    446         for (; oi != mObjects.end(); oi++) 
    447           RenderIntersectable(*oi); 
    448   } 
     553        //DisableDrawArrays(); 
     554        //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
    449555} 
    450556 
     
    466572  glColor3f(0.0f, 0.8f, 0.2f); 
    467573 
    468   //    // Render PVS 
     574  // Render PVS 
    469575  RenderPvs(); 
    470576   
    471577  glEnable(GL_STENCIL_TEST);  
    472578   
    473   //  mUseFalseColors = true; 
     579  //mUseFalseColors = true; 
    474580   
    475581  glDisable(GL_LIGHTING); 
     
    501607  int pixelCount = query->GetQueryResult(); 
    502608  pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 
    503   cout<<"error pixels="<<pixelCount<<endl; 
     609  if (0) cout<<"error pixels="<<pixelCount<<endl; 
    504610 
    505611  mRenderError = pErrorPixels; 
     
    509615 
    510616 
    511 void 
    512 QtGlRendererWidget::mousePressEvent(QMouseEvent *e) 
     617void QtGlRendererWidget::timerEvent(QTimerEvent *event)  
     618{ 
     619        //std::cout << "Timer ID:" << event->timerId(); 
     620        update(); 
     621} 
     622 
     623 
     624void QtGlRendererWidget::mousePressEvent(QMouseEvent *e) 
    513625{ 
    514626  int x = e->pos().x(); 
     
    523635QtGlRendererWidget::mouseMoveEvent(QMouseEvent *e) 
    524636{ 
    525   float MOVE_SENSITIVITY = Magnitude(mSceneGraph->GetBox().Diagonal())*1e-3; 
    526   float TURN_SENSITIVITY=0.1f; 
    527   float TILT_SENSITIVITY=32.0 ; 
    528   float TURN_ANGLE= M_PI/36.0 ; 
    529  
    530   int x = e->pos().x(); 
    531   int y = e->pos().y(); 
    532  
    533   int diffx = -(mousePoint.x - x); 
    534   int diffy = -(mousePoint.y - y); 
    535    
    536   if (e->modifiers() & Qt::ControlModifier) { 
    537         mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY/2.0; 
    538         mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY/2.0; 
    539   } else { 
    540         mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY); 
    541         float adiff = TURN_ANGLE*(x - mousePoint.x)*-TURN_SENSITIVITY; 
    542         float angle = atan2(mViewDirection.x, mViewDirection.z); 
    543         mViewDirection.x = sin(angle+adiff); 
    544         mViewDirection.z = cos(angle+adiff); 
    545   } 
    546    
    547   mousePoint.x = x; 
    548   mousePoint.y = y; 
    549    
    550   updateGL(); 
     637        float MOVE_SENSITIVITY = Magnitude(mSceneGraph->GetBox().Diagonal())*1e-3; 
     638        float TURN_SENSITIVITY=0.1f; 
     639        float TILT_SENSITIVITY=32.0 ; 
     640        float TURN_ANGLE= M_PI/36.0 ; 
     641 
     642        int x = e->pos().x(); 
     643        int y = e->pos().y(); 
     644 
     645        int diffx = -(mousePoint.x - x); 
     646        int diffy = -(mousePoint.y - y); 
     647 
     648        if (e->modifiers() & Qt::ControlModifier)  
     649        { 
     650                mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY/2.0; 
     651                mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY/2.0; 
     652        }  
     653        else  
     654        { 
     655                mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY); 
     656                float adiff = TURN_ANGLE*(x - mousePoint.x)*-TURN_SENSITIVITY; 
     657                float angle = atan2(mViewDirection.x, mViewDirection.z); 
     658                mViewDirection.x = sin(angle + adiff); 
     659                mViewDirection.z = cos(angle + adiff); 
     660        } 
     661 
     662        mousePoint.x = x; 
     663        mousePoint.y = y; 
     664 
     665        updateGL(); 
    551666} 
    552667 
     
    554669QtGlRendererWidget::mouseReleaseEvent(QMouseEvent *) 
    555670{ 
    556  
    557  
    558671} 
    559672 
     
    584697  RenderInfo(); 
    585698 
    586   mFrame++; 
     699  mFrame ++; 
    587700   
    588701} 
     
    707820  mRenderVisibilityEstimates = false; 
    708821  mTransferFunction = 0.2f; 
     822  mIndexBufferSize = 0; 
     823    
     824  const int delay = 500; // half a second 
     825  timerId = startTimer(delay); 
    709826 
    710827  bool tmp; 
     
    825942          currentCost = costFunction[currentPos]; 
    826943#if 1    
    827         cout<<"costFunction.size()="<<costFunction.size()<<endl; 
     944        cout<<"costFunction.size()="<<(int)costFunction.size()<<endl; 
    828945        cout<<"CP="<<currentPos<<endl; 
    829946        cout<<"MC="<<maxCost<<endl; 
     
    9131030  int vc = 0; 
    9141031  if (mViewCellsManager) 
    915         vc = mViewCellsManager->GetViewCells().size(); 
     1032        vc = (int)mViewCellsManager->GetViewCells().size(); 
    9161033 
    9171034  int filter = 0; 
     
    10701187 
    10711188 
    1072  
    1073  
    1074 /***********************************************************************/ 
    1075 /*                     QtGlDebuggerWidget implementation                                   */ 
    1076 /***********************************************************************/ 
     1189/*********************************************************************/ 
     1190/*                   QtGlDebuggerWidget implementation               */ 
     1191/*********************************************************************/ 
    10771192 
    10781193 
     
    10941209         DEL_PTR(mRenderBuffer); 
    10951210} 
    1096  
    10971211 
    10981212 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r1997 r2538  
    148148  float mTransferFunction; 
    149149 
     150  unsigned int mIndexBufferSize; 
    150151   
    151152  QtRendererControlWidget *mControlWidget; 
     
    177178  void resizeGL(int w, int h); 
    178179  void paintGL(); 
    179   void timerEvent(QTimerEvent *) { 
    180           update(); 
    181   } 
    182  
     180  void timerEvent(QTimerEvent *event); 
    183181  void mousePressEvent(QMouseEvent *); 
    184182  void mouseReleaseEvent(QMouseEvent *); 
    185183  void mouseMoveEvent(QMouseEvent *); 
    186184 
    187   void keyPressEvent ( QKeyEvent * e ) ; 
    188  
    189   void 
    190   RenderPvs(); 
    191  
    192   float 
    193   RenderErrors(); 
    194   void 
    195   RenderInfo(); 
     185  void keyPressEvent(QKeyEvent * e); 
     186 
     187  void RenderPvs(); 
     188 
     189  float RenderErrors(); 
     190  void RenderInfo(); 
    196191 
    197192  virtual int GetWidth() const { return width(); } 
     
    211206        show(); 
    212207  } 
     208 
     209  bool PvsChanged(ViewCell *viewcell) const; 
     210 
    213211 
    214212 public slots: 
     
    306304        updateGL(); 
    307305  } 
     306 
     307  void _RenderPvs(); 
     308 
     309  void _UpdatePvsIndices(); 
     310  void _UpdatePvsIndices(KdNode *node); 
    308311 
    309312  signals: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r1997 r2538  
    100100QtGlViewer::paintGL() 
    101101{ 
    102   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    103   glLoadIdentity(); 
     102        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     103        glLoadIdentity(); 
    104104 
    105   float m[4][4]; 
     105        float m[4][4]; 
    106106 
    107   glLoadIdentity(); 
    108   gluLookAt(0.0, 0.0, 1.0,  /* eye is at (0,0,30) */ 
    109                                                 0.0, 0.0, 0.0,      /* center is at (0,0,0) */ 
    110                                                 0.0, 1.0, 0.);      /* up is in positive Y direction */ 
    111    
    112   build_rotmatrix(m, manipulatorLastQuat); 
    113   glMultMatrixf(&m[0][0]); 
     107        glLoadIdentity(); 
     108        gluLookAt(0.0, 0.0, 1.0,  /* eye is at (0,0,30) */ 
     109                0.0, 0.0, 0.0,      /* center is at (0,0,0) */ 
     110                0.0, 1.0, 0.);      /* up is in positive Y direction */ 
    114111 
    115   float s = scale*20.0f/Magnitude(mRenderer->mSceneGraph->GetBox().Diagonal()); 
    116   glScalef(s, s, s); 
    117    
    118   Vector3 t = -mRenderer->mSceneGraph->GetBox().Center(); 
    119   glTranslatef(t.x, t.y, t.z); 
     112        build_rotmatrix(m, manipulatorLastQuat); 
     113        glMultMatrixf(&m[0][0]); 
     114 
     115        float s = scale*20.0f/Magnitude(mRenderer->mSceneGraph->GetBox().Diagonal()); 
     116        glScalef(s, s, s); 
     117 
     118        Vector3 t = -mRenderer->mSceneGraph->GetBox().Center(); 
     119        glTranslatef(t.x, t.y, t.z); 
    120120 
    121121        RenderScene(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2530 r2538  
    4747 
    4848 
    49 int ViewCellsManager::sRenderCostEvaluationType = 0; 
    50  
    5149 
    5250template <typename T> class myless 
     
    156154        Environment::GetSingleton()->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize); 
    157155        Environment::GetSingleton()->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 
    158         Environment::GetSingleton()->GetIntValue("ViewCells.renderCostEvaluationType", sRenderCostEvaluationType); 
    159156 
    160157        Environment::GetSingleton()->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs); 
     
    251248        } 
    252249 
    253         Environment::GetSingleton()->GetStringValue("ViewCells.renderCostEvaluationType", buf); 
    254          
    255         if (strcmp(buf, "perobject") == 0) 
    256         { 
    257                 sRenderCostEvaluationType = ViewCellsManager::PER_OBJECT; 
    258         } 
    259         else if (strcmp(buf, "pertriangle") == 0) 
    260         { 
    261                 sRenderCostEvaluationType = ViewCellsManager::PER_TRIANGLE; 
    262         } 
    263         else  
    264         { 
    265                 Debug << "error! wrong sampling type" << endl; 
    266                 exit(0); 
    267         } 
    268  
    269     Environment::GetSingleton()->GetStringValue("ViewCells.Visualization.colorCode", buf); 
     250 
     251        /** The color code used during visualization. 
     252        */ 
     253        Environment::GetSingleton()->GetStringValue("ViewCells.Visualization.colorCode", buf); 
    270254 
    271255        if (strcmp(buf, "PVS") == 0) 
     
    300284        Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 
    301285        Debug << "sampling type: " << mSamplingType << endl; 
    302         Debug << "render cost evaluation type: " << sRenderCostEvaluationType << endl; 
    303286        Debug << "evaluation sampling type: " << mEvaluationSamplingType << endl; 
    304287        Debug << "show visualization: " << mShowVisualization << endl; 
     
    686669 
    687670 
    688 Intersectable * 
    689 ViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 
     671Intersectable *ViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 
    690672{ 
    691673        if (mUseKdPvs) 
     
    693675                KdNode *node = GetPreprocessor()-> 
    694676                        mKdTree->GetPvsNode(isTermination ?     ray.mTermination : ray.mOrigin); 
    695           return GetPreprocessor()->mKdTree->GetOrCreateKdIntersectable(node); 
     677 
     678                return GetPreprocessor()->mKdTree->GetOrCreateKdIntersectable(node); 
    696679        } 
    697680        else 
    698           { 
     681        { 
    699682                return isTermination ? ray.mTerminationObject : ray.mOriginObject; 
    700           } 
    701 } 
    702  
    703  
    704 void 
    705 ViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
     683        } 
     684} 
     685 
     686 
     687void ViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
    706688{ 
    707689        GetPreprocessor()->mKdTree->CollectObjects(box, objects); 
    708690} 
    709691 
     692 
    710693AxisAlignedBox3 ViewCellsManager::GetViewCellBox(ViewCell *vc) 
    711694{ 
    712   Mesh *m = vc->GetMesh(); 
    713    
    714   if (m)  
    715   { 
    716           m->ComputeBoundingBox(); 
    717           return m->mBox; 
    718   } 
    719  
    720   AxisAlignedBox3 box; 
    721   box.Initialize(); 
    722    
    723   if (!vc->IsLeaf()) { 
    724         ViewCellInterior *vci = (ViewCellInterior *) vc; 
    725          
    726         ViewCellContainer::iterator it = vci->mChildren.begin(); 
    727         for (; it != vci->mChildren.end(); ++it) { 
    728           box.Include(GetViewCellBox(*it)); 
    729         } 
    730   } 
    731    
    732   return box; 
     695        Mesh *m = vc->GetMesh(); 
     696 
     697        if (m)  
     698        { 
     699                m->ComputeBoundingBox(); 
     700                return m->mBox; 
     701        } 
     702 
     703        AxisAlignedBox3 box; 
     704        box.Initialize(); 
     705 
     706        if (!vc->IsLeaf())  
     707        { 
     708                ViewCellInterior *vci = (ViewCellInterior *) vc; 
     709 
     710                ViewCellContainer::iterator it = vci->mChildren.begin(); 
     711                for (; it != vci->mChildren.end(); ++it)  
     712                { 
     713                        box.Include(GetViewCellBox(*it)); 
     714                } 
     715        } 
     716 
     717        return box; 
    733718} 
    734719 
     
    744729         
    745730        simpleRays.reserve(samplesPerPass); 
    746         passSamples.reserve(samplesPerPass * 2); // always creates double rays 
     731        // reserve 2 times the size because always creates double rays 
     732        passSamples.reserve(samplesPerPass * 2);  
    747733 
    748734        // create one third of each type 
     
    33133299 
    33143300  while (pit.HasMoreEntries()) 
    3315   {              
    33163301      pit.Next()->Mail(); 
    3317   } 
    33183302 
    33193303  ObjectPvs nPvs; 
     
    33923376                                                           ) 
    33933377{ 
    3394   PvsFilterStatistics stats; 
    3395  
    3396   AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 
    3397   Vector3 center = vbox.Center(); 
    3398   // copy the PVS 
    3399   Intersectable::NewMail(); 
    3400   ObjectPvs basePvs = viewCell->GetPvs(); 
    3401   ObjectPvsIterator pit = basePvs.GetIterator(); 
    3402  
    3403   pvs.Reserve(viewCell->GetFilteredPvsSize()); 
    3404  
    3405   if (!mUseKdPvs) 
    3406   { 
    3407           // first mark all objects from this pvs 
    3408           while (pit.HasMoreEntries())   
    3409           { 
    3410                   pit.Next()->Mail(); 
    3411           } 
    3412   } 
    3413    
    3414   int pvsSize = 0; 
    3415   int nPvsSize = 0; 
    3416   float samples = (float)basePvs.GetSamples(); 
    3417    
    3418   Debug<<"f #s="<<samples<<"  pvs size = "<<basePvs.GetSize(); 
    3419   //  cout<<"Filter size = "<<filterSize<<endl; 
    3420   //  cout<<"vbox = "<<vbox<<endl; 
    3421   //  cout<<"center = "<<center<<endl; 
    3422  
    3423  
    3424    // Minimal number of local samples to take into account 
    3425    // the local sampling density. 
    3426    // The size of the filter is a minimum of the conservative 
    3427    // local sampling density estimate (#rays intersecting teh viewcell and 
    3428    // the object) 
    3429    // and gobal estimate for the view cell 
    3430    // (total #rays intersecting the viewcell) 
    3431   int minLocalSamples = 2; 
    3432    
    3433   float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
    3434    
    3435   // now compute the filter box around the current viewCell 
    3436    
    3437   if (useViewSpaceFilter) { 
    3438         //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
    3439         float radius = viewCellRadius/100.0f; 
    3440         vbox.Enlarge(radius); 
    3441         cout<<"vbox = "<<vbox<<endl; 
    3442         ViewCellContainer viewCells; 
    3443         ComputeBoxIntersections(vbox, viewCells); 
    3444          
    3445         ViewCellContainer::const_iterator it = viewCells.begin(), 
    3446           it_end = viewCells.end(); 
    3447         int i = 0; 
    3448         for (i=0; it != it_end; ++ it, ++ i) 
    3449           if ((*it) != viewCell) { 
    3450                 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
    3451                 basePvs.MergeInPlace((*it)->GetPvs()); 
    3452           } 
    3453          
    3454         // update samples and globalC 
    3455         samples = (float)pvs.GetSamples(); 
    3456         //      cout<<"neighboring viewcells = "<<i-1<<endl; 
    3457         //      cout<<"Samples' = "<<samples<<endl; 
    3458   } 
    3459    
    3460   // Minimal number of samples so that filtering takes place 
     3378        PvsFilterStatistics stats; 
     3379 
     3380        AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 
     3381        Vector3 center = vbox.Center(); 
     3382        // copy the PVS 
     3383        Intersectable::NewMail(); 
     3384        ObjectPvs basePvs = viewCell->GetPvs(); 
     3385        ObjectPvsIterator pit = basePvs.GetIterator(); 
     3386 
     3387        pvs.Reserve(viewCell->GetFilteredPvsSize()); 
     3388 
     3389        if (!mUseKdPvs) 
     3390        { 
     3391                // first mark all objects from this pvs 
     3392                while (pit.HasMoreEntries())     
     3393                        pit.Next()->Mail(); 
     3394        } 
     3395 
     3396        int pvsSize = 0; 
     3397        int nPvsSize = 0; 
     3398        float samples = (float)basePvs.GetSamples(); 
     3399 
     3400        Debug<<"f #s="<<samples<<"  pvs size = "<<basePvs.GetSize(); 
     3401        //  cout<<"Filter size = "<<filterSize<<endl; 
     3402        //  cout<<"vbox = "<<vbox<<endl; 
     3403        //  cout<<"center = "<<center<<endl; 
     3404 
     3405 
     3406        // Minimal number of local samples to take into account 
     3407        // the local sampling density. 
     3408        // The size of the filter is a minimum of the conservative 
     3409        // local sampling density estimate (#rays intersecting teh viewcell and 
     3410        // the object) 
     3411        // and gobal estimate for the view cell 
     3412        // (total #rays intersecting the viewcell) 
     3413        int minLocalSamples = 2; 
     3414 
     3415        float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
     3416 
     3417        // now compute the filter box around the current viewCell 
     3418 
     3419        if (useViewSpaceFilter)  
     3420        { 
     3421                //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
     3422                float radius = viewCellRadius/100.0f; 
     3423                vbox.Enlarge(radius); 
     3424                cout<<"vbox = "<<vbox<<endl; 
     3425                ViewCellContainer viewCells; 
     3426                ComputeBoxIntersections(vbox, viewCells); 
     3427 
     3428                ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
     3429 
     3430                for (int i = 0; it != it_end; ++ it, ++ i) 
     3431                { 
     3432                         
     3433                        if ((*it) != viewCell)  
     3434                        { 
     3435                                //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
     3436                                basePvs.MergeInPlace((*it)->GetPvs()); 
     3437                        } 
     3438 
     3439                        // update samples and globalC 
     3440                        samples = (float)pvs.GetSamples(); 
     3441                        //      cout<<"neighboring viewcells = "<<i-1<<endl; 
     3442                        //      cout<<"Samples' = "<<samples<<endl; 
     3443                } 
     3444        } 
     3445 
     3446        // Minimal number of samples so that filtering takes place 
    34613447#define MIN_SAMPLES  50 
    3462    
    3463   if (samples > MIN_SAMPLES) { 
    3464         float globalC = 2.0f*filterSize/sqrt(samples); 
    3465          
    3466         pit = basePvs.GetIterator(); 
    3467          
    3468         ObjectContainer objects; 
    3469          
    3470         PvsData pvsData; 
    3471  
    3472         while (pit.HasMoreEntries()) {           
    3473           Intersectable *object = pit.Next(pvsData); 
    3474            
    3475           // compute filter size based on the distance and the numebr of samples 
    3476           AxisAlignedBox3 box = object->GetBox(); 
    3477            
    3478           float distance = Distance(center, box.Center()); 
    3479           float globalRadius = distance*globalC; 
    3480            
    3481           int objectSamples = (int)pvsData.mSumPdf; 
    3482           float localRadius = MAX_FLOAT; 
    3483            
    3484           localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
    3485                 sqrt((float)objectSamples); 
    3486            
    3487           //      cout<<"os="<<objectSamples<<" lr="<<localRadius<<" gr="<<globalRadius<<endl; 
    3488            
    3489           // now compute the filter size 
    3490           float radius; 
    3491            
     3448 
     3449        if (samples > MIN_SAMPLES)  
     3450        { 
     3451                float globalC = 2.0f * filterSize / sqrt(samples); 
     3452 
     3453                ObjectContainer objects; 
     3454                PvsData pvsData; 
     3455 
     3456                pit = basePvs.GetIterator(); 
     3457 
     3458                while (pit.HasMoreEntries())  
     3459                {                
     3460                        Intersectable *object = pit.Next(pvsData); 
     3461 
     3462                        // compute filter size based on the distance and the numebr of samples 
     3463                        AxisAlignedBox3 box = object->GetBox(); 
     3464 
     3465                        float distance = Distance(center, box.Center()); 
     3466                        float globalRadius = distance*globalC; 
     3467 
     3468                        int objectSamples = (int)pvsData.mSumPdf; 
     3469                        float localRadius = MAX_FLOAT; 
     3470 
     3471                        localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
     3472                                sqrt((float)objectSamples); 
     3473 
     3474                        // cout<<"os="<<objectSamples<<" lr="<<localRadius<<" gr="<<globalRadius<<endl; 
     3475 
     3476                        // now compute the filter size 
     3477                        float radius; 
     3478 
    34923479#if 0 
    3493           if (objectSamples <= 1) { 
    3494                 if (localRadius > globalRadius) { 
    3495                   radius = 0.5flRadius; 
    3496                   stats.mLocalFilterCount++; 
    3497                 } else { 
    3498                   radius = globalRadius; 
    3499                   stats.mGlobalFilterCount++; 
    3500                 } 
    3501           } else { 
    3502                 radius = localRadius; 
    3503                 stats.mLocalFilterCount++; 
    3504           } 
     3480                        if (objectSamples <= 1)  
     3481                        { 
     3482                                if (localRadius > globalRadius)  
     3483                                { 
     3484                                        radius = 0.5flRadius; 
     3485                                        stats.mLocalFilterCount++; 
     3486                                }  
     3487                                else  
     3488                                { 
     3489                                        radius = globalRadius; 
     3490                                        stats.mGlobalFilterCount++; 
     3491                                } 
     3492                        }  
     3493                        else  
     3494                        { 
     3495                                radius = localRadius; 
     3496                                stats.mLocalFilterCount++; 
     3497                        } 
    35053498#else 
    35063499 
    3507           //      radius = 0.5f*globalRadius + 0.5f*localRadius; 
    3508           radius = Min(globalRadius, localRadius); 
    3509            
    3510           if (localRadius > globalRadius)  
    3511                 stats.mLocalFilterCount++; 
    3512           else 
    3513                 stats.mGlobalFilterCount++; 
     3500                        // radius = 0.5f*globalRadius + 0.5f*localRadius; 
     3501                        radius = Min(globalRadius, localRadius); 
     3502 
     3503                        if (localRadius > globalRadius)  
     3504                                ++ stats.mLocalFilterCount; 
     3505                        else 
     3506                                ++ stats.mGlobalFilterCount; 
    35143507#endif 
    3515            
    3516           stats.mAvgFilterRadius += radius; 
    3517            
    3518           // cout<<"box = "<<box<<endl; 
    3519           //    cout<<"distance = "<<distance<<endl; 
    3520           //    cout<<"radiues = "<<radius<<endl; 
    3521            
    3522           box.Enlarge(Vector3(radius)); 
    3523  
    3524           if (filteredBoxes) 
    3525                 filteredBoxes->push_back(box); 
    3526  
    3527           objects.clear(); 
    3528           // $$ warning collect objects takes only unmailed ones! 
    3529           if (mUseKdPvsAfterFiltering) { 
    3530                 GetPreprocessor()->mKdTree->CollectKdObjects(box, objects); 
    3531           } else 
    3532                 CollectObjects(box, objects); 
    3533            
    3534           //    cout<<"collected objects="<<objects.size()<<endl; 
    3535           ObjectContainer::const_iterator noi = objects.begin(); 
    3536           for (; noi != objects.end(); ++ noi) { 
    3537                 Intersectable *o = *noi; 
    3538                 // $$ JB warning: pdfs are not correct at this point!      
    3539                 pvs.AddSampleDirty(o, Limits::Small); 
    3540           } 
    3541         } 
    3542         stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
    3543   } 
    3544    
    3545   Debug<<" nPvs size = "<<pvs.GetSize()<<endl; 
    3546    
    3547   if (!mUseKdPvs) 
    3548   { 
    3549           PvsData pvsData; 
    3550  
    3551           // copy the base pvs to the new pvs 
    3552           pit = basePvs.GetIterator(); 
    3553           while (pit.HasMoreEntries())  
    3554           {              
    3555                   Intersectable *obj = pit.Next(pvsData); 
    3556                   pvs.AddSampleDirty(obj, pvsData.mSumPdf); 
    3557           } 
    3558   } 
    3559    
    3560   pvs.SimpleSort(); 
    3561   viewCell->SetFilteredPvsSize(pvs.GetSize()); 
    3562    
    3563   Intersectable::NewMail(); 
    3564   return stats; 
     3508 
     3509                        stats.mAvgFilterRadius += radius; 
     3510 
     3511                        // cout<<"box = "<<box<<endl; 
     3512                        //      cout<<"distance = "<<distance<<endl; 
     3513                        //      cout<<"radiues = "<<radius<<endl; 
     3514 
     3515                        box.Enlarge(Vector3(radius)); 
     3516 
     3517                        if (filteredBoxes) 
     3518                                filteredBoxes->push_back(box); 
     3519 
     3520                        objects.clear(); 
     3521 
     3522                        // $$ warning collect objects takes only unmailed ones! 
     3523                        if (mUseKdPvs)  
     3524                                GetPreprocessor()->mKdTree->CollectKdObjects(box, objects); 
     3525                        else 
     3526                                CollectObjects(box, objects); 
     3527 
     3528                        //      cout<<"collected objects="<<objects.size()<<endl; 
     3529                        ObjectContainer::const_iterator noi = objects.begin(); 
     3530                        for (; noi != objects.end(); ++ noi)  
     3531                        { 
     3532                                Intersectable *o = *noi; 
     3533                                // $$ JB warning: pdfs are not correct at this point!      
     3534                                pvs.AddSampleDirty(o, Limits::Small); 
     3535                        } 
     3536                } 
     3537                stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
     3538        } 
     3539 
     3540        Debug << " nPvs size = " << pvs.GetSize() << endl; 
     3541 
     3542        if (!mUseKdPvs) 
     3543        { 
     3544                PvsData pvsData; 
     3545 
     3546                // copy the base pvs to the new pvs 
     3547                pit = basePvs.GetIterator(); 
     3548                while (pit.HasMoreEntries())  
     3549                {                
     3550                        Intersectable *obj = pit.Next(pvsData); 
     3551                        pvs.AddSampleDirty(obj, pvsData.mSumPdf); 
     3552                } 
     3553        } 
     3554 
     3555        pvs.SimpleSort(); 
     3556        viewCell->SetFilteredPvsSize(pvs.GetSize()); 
     3557 
     3558        Intersectable::NewMail(); 
     3559        return stats; 
    35653560} 
    35663561 
     
    58985893{ 
    58995894        if (mUseKdPvs) 
    5900         { 
    59015895                return ViewCellsManager::GetIntersectable(ray, isTermination); 
    5902         } 
    59035896        else 
    5904         { 
    59055897                return mHierarchyManager->GetIntersectable(ray, isTermination); 
    5906         } 
    59075898} 
    59085899 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2530 r2538  
    862862        /// if view cells should be exported 
    863863        bool mExportViewCells; 
    864  
    865864        // if only valid view cells should be considered for processing 
    866865        bool mOnlyValidViewCells; 
    867  
    868866        /// if rays should be used to collect merge candidates 
    869867        bool mUseRaysForMerge; 
    870  
    871868        /// if there should be an additional merge step after the subdivision 
    872869        bool mMergeViewCells; 
    873  
    874870        /// the width of the box filter 
    875871        float mFilterWidth; 
    876872        /// Maximal size of the filter in terms of contributing view cells 
    877873        int mMaxFilterSize; 
    878          
    879         // only for debugging 
     874        /// only for debugging: stores some rays used during view cell construction 
    880875        VssRayContainer storedRays; 
    881  
     876        /// if kd node based pvs is used for preprocessing 
    882877        bool mUseKdPvs; 
    883         bool mUseKdPvsAfterFiltering; 
    884  
     878        /// types of distributions used for sampling 
    885879        MixtureDistribution *mMixtureDistribution; 
    886880 
     
    900894        bool mExportPvs; 
    901895 
    902         static int sRenderCostEvaluationType; 
    903  
    904896        /// if view cells geometry should be used from other sources 
    905897        bool mUsePredefinedViewCells; 
    906  
     898        /// the weight for one triangle in the heuristics 
    907899        float mTriangleWeight; 
     900        /// the weight for one object (= one entity issued with one draw call) in the heuristics 
    908901        float mObjectWeight; 
    909902 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2452 r2538  
    365365#endif 
    366366 
    367         if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
     367          if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
    368368          { 
    369369#ifdef USE_QT 
    370                 cout << "using gl widget" << endl; 
    371                 // create and run the preprocessor application in a parallel thread 
    372                  
    373                 pt->InitThread(); 
    374                 pt->RunThread(); 
    375  
    376                 // display the render widget 
    377                 if (!rendererWidget)  
    378                 { 
    379  
    380                   if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 
    381                         QMessageBox::information(0, "OpenGL pbuffers",  
    382                                                                            "This system does not support OpenGL/pbuffers.", 
    383                                                                            QMessageBox::Ok); 
    384                           return NULL; 
    385                         } 
    386  
    387                   rendererWidget =  
    388                         new QtGlRendererWidget(preprocessor->mSceneGraph, 
    389                                                                    preprocessor->mViewCellsManager, 
    390                                                                    preprocessor->mKdTree); 
    391                    
    392                   rendererWidget->Show(); 
    393                    
    394                   QtGlViewer *viewer =  
    395                         new QtGlViewer(NULL, (QtGlRendererWidget *)rendererWidget); 
    396                    
    397                   viewer->show(); 
    398                   guiSupported = true;  
    399                 } 
    400                  
    401                  
    402                 bool exportRandomViewCells; 
    403                 Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells", 
    404                                                                                                   exportRandomViewCells); 
    405  
    406                 if (exportRandomViewCells) 
    407                 { 
    408                         cout << "exporting random view cells" << endl; 
    409                         preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 
    410                         cout << "finished" << endl; 
    411                 } 
    412  
    413                 /*bool evaluatePixelError; 
    414                 Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError",  evaluatePixelError); 
    415  
    416                 if (evaluatePixelError) 
    417                 { 
    418                         cout << "evaluating pixel error" << endl; 
    419                         preprocessor->ComputeRenderError(); 
    420                 }*/ 
    421                  
    422                 qApp->exec(); 
    423 #endif 
    424         } 
    425  
    426         // no gui available 
    427         if (!guiSupported)  
    428         { 
    429                 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
    430                         cout << "warning: gui not supported!" << endl; 
    431                  
    432                 preprocessor->mUseGlRenderer = false; 
    433                 preprocessor->mUseGlDebugger = false; 
    434         } 
    435  
    436         if (!(preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger))  
    437         { 
    438                 cout << "executing main thread" << endl; 
    439                 // just call the mail method -> will be executed in the main thread 
    440                 pt->Main(); 
    441         }        
    442 #endif 
    443  
    444         // release memory 
    445         Cleanup(); 
    446          
    447         delete pt; 
    448  
    449         return returnCode; 
     370 
     371                  //////// 
     372                  // create and run the preprocessor application in a parallel thread 
     373 
     374                  cout << "using gl widget" << endl; 
     375 
     376                  pt->InitThread(); 
     377                  pt->RunThread(); 
     378 
     379                  // display the render widget 
     380                  if (!rendererWidget)  
     381                  { 
     382 
     383                          if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 
     384                                  QMessageBox::information(0, "OpenGL pbuffers",  
     385                                          "This system does not support OpenGL/pbuffers.", 
     386                                          QMessageBox::Ok); 
     387                                  return NULL; 
     388                          } 
     389 
     390                          rendererWidget =  
     391                                  new QtGlRendererWidget(preprocessor->mSceneGraph, 
     392                                  preprocessor->mViewCellsManager, 
     393                                  preprocessor->mKdTree); 
     394 
     395                          rendererWidget->Show(); 
     396 
     397                          if (0) 
     398                          { 
     399                                  QtGlViewer *viewer =  
     400                                          new QtGlViewer(NULL, (QtGlRendererWidget *)rendererWidget); 
     401                                  viewer->show(); 
     402                          } 
     403 
     404                          guiSupported = true;  
     405                  } 
     406 
     407 
     408                  bool exportRandomViewCells; 
     409                  Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells", 
     410                          exportRandomViewCells); 
     411 
     412                  if (exportRandomViewCells) 
     413                  { 
     414                          cout << "exporting random view cells" << endl; 
     415                          preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 
     416                          cout << "finished" << endl; 
     417                  } 
     418 
     419                  /*bool evaluatePixelError; 
     420                  Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError",  evaluatePixelError); 
     421 
     422                  if (evaluatePixelError) 
     423                  { 
     424                  cout << "evaluating pixel error" << endl; 
     425                  preprocessor->ComputeRenderError(); 
     426                  }*/ 
     427 
     428                  qApp->exec(); 
     429#endif 
     430          } 
     431 
     432          // no gui available 
     433          if (!guiSupported)  
     434          { 
     435                  if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
     436                          cout << "warning: gui not supported!" << endl; 
     437 
     438                  preprocessor->mUseGlRenderer = false; 
     439                  preprocessor->mUseGlDebugger = false; 
     440          } 
     441 
     442          if (!(preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger))  
     443          { 
     444                  cout << "executing main thread" << endl; 
     445                  // just call the mail method -> will be executed in the main thread 
     446                  pt->Main(); 
     447          }      
     448#endif 
     449 
     450          // release memory 
     451          Cleanup(); 
     452 
     453          delete pt; 
     454 
     455          return returnCode; 
    450456} 
    451457 
Note: See TracChangeset for help on using the changeset viewer.