Changeset 538


Ignore:
Timestamp:
01/14/06 01:41:57 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r535 r538  
    3030        samplesPerPass  100000 
    3131        initialSamples 300000 
    32         vssSamples 800000 
     32        vssSamples 300000 
    3333        vssSamplesPerPass 100000 
    3434        useImportanceSampling true 
  • trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp

    r534 r538  
    5555                Include(*it); 
    5656} 
     57 
     58void 
     59AxisAlignedBox3::Include(Mesh *mesh) 
     60{ 
     61        VertexContainer::const_iterator it, it_end = mesh->mVertices.end(); 
     62 
     63        for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
     64                Include(*it); 
     65} 
     66 
    5767 
    5868void 
  • trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.h

    r534 r538  
    105105  void Include(const Polygon3 &newpoly); 
    106106  void Include(const AxisAlignedBox3 &bbox); 
     107  void Include(Mesh *mesh); 
    107108  // Expand the axis-aligned box to include given values in particular axis 
    108109  void Include(const int &axis, const float &newBound); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r534 r538  
    14341434                                        "false"); 
    14351435 
     1436        RegisterOption("Preprocessor.useGlDebugger", 
     1437                                        optBool, 
     1438                                        "useGlDebugger", 
     1439                                        "false"); 
     1440 
    14361441        RegisterOption("Preprocessor.detectEmptyViewSpace", 
    14371442                                   optBool, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r535 r538  
    2121 
    2222GlRendererWidget *rendererWidget = NULL; 
     23GlDebuggerWidget *debuggerWidget = NULL; 
    2324 
    2425 
     
    446447{ 
    447448  static int glList = -1; 
    448   if (glList != -1) { 
    449         glCallList(glList); 
    450   } else { 
     449  if (glList == -1) 
     450  { 
    451451        glList = glGenLists(1); 
    452         glNewList(glList, GL_COMPILE_AND_EXECUTE); 
     452        glNewList(glList, GL_COMPILE); 
    453453        ObjectContainer::const_iterator oi = mObjects.begin(); 
    454454        for (; oi != mObjects.end(); oi++) 
     
    456456        glEndList(); 
    457457  } 
     458   
     459  glCallList(glList); 
     460   
    458461  return true; 
    459462} 
     
    565568GlRendererWidget::paintGL() 
    566569{ 
    567   RenderErrors(); 
    568   mFrame++; 
     570        RenderErrors(); 
     571         
     572        mFrame++; 
    569573} 
    570574 
     
    780784        GenQueries((int)beam.mViewCells.size()); 
    781785 
    782         // now check whether any backfacing polygon would pass the depth test 
     786        // now check whether any backfacing polygon would pass the depth test? 
    783787        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
    784788        glDepthMask(GL_FALSE); 
     
    799803 
    800804        // at this point, if possible, go and do some other computation 
    801         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    802         glDepthMask(GL_TRUE); 
    803         glEnable(GL_CULL_FACE); 
     805 
     806        queryIdx = 0; 
     807        unsigned int pixelCount; 
    804808 
    805809        // 8. The number of visible pixels is the number of sample rays which see the source 
    806         //    object from the corresponding viewcell -> rember these values for later update 
    807         //   of the viewcell pvs - or update immediatelly? 
    808  
    809         //  In general it is not neccessary to rember to extract all the rays cast. I hope it 
     810        //    object from the corresponding viewcell -> remember these values for later update 
     811        //   of the viewcell pvs - or update immediately? 
     812 
     813        for (vit = beam.mViewCells.begin(); vit != vit_end; ++ vit) 
     814        { 
     815                // fetch queries 
     816                glGetOcclusionQueryuivNV(sQueries[queryIdx ++], 
     817                                                                 GL_PIXEL_COUNT_NV, 
     818                                                                 &pixelCount); 
     819 
     820                Debug << "visble pixels: " << pixelCount << endl; 
     821        } 
     822         
     823 
     824        //  In general it is not neccessary to remember to extract all the rays cast. I hope it 
    810825        // would be sufficient to gain only the intergral statistics about the new contributions 
    811826        // and so the rss tree would actually store no new rays (only the initial ones) 
     
    815830        // (new viewcell has been discovered) or relative contribution greater than a threashold ...  
    816831 
     832        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     833        glDepthMask(GL_TRUE); 
     834        glEnable(GL_CULL_FACE); 
     835 
     836 
    817837        cgGLDisableProfile(sCgFragmentProfile); 
    818838        glDisable(GL_TEXTURE_2D); 
     
    838858} 
    839859 
     860 
    840861void GlRendererBuffer::SetupProjectionForViewPoint(const Vector3 &viewPoint,  
    841862                                                                                                 const Beam &beam,  
     
    855876                          viewPoint.x, viewPoint.y, viewPoint.z,  
    856877                          up.x, up.y, up.z); 
    857 }                          
     878}                
     879 
     880   
     881  
     882 
     883/***************************************************************/ 
     884/*             GlDebuggerWidget implementation                             */ 
     885/***************************************************************/ 
     886 
     887 
     888GlDebuggerWidget::GlDebuggerWidget(QWidget *parent, GlRendererBuffer *buf) 
     889      : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf) 
     890{ 
     891        // create the pbuffer 
     892    //pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this); 
     893    timerId = startTimer(20); 
     894    setWindowTitle(("OpenGL pbuffers")); 
     895} 
     896 
     897 
     898GlDebuggerWidget::~GlDebuggerWidget() 
     899{ 
     900        mRenderBuffer->releaseFromDynamicTexture(); 
     901        glDeleteTextures(1, &dynamicTexture); 
     902         
     903        DEL_PTR(mRenderBuffer); 
     904} 
     905 
     906 
     907void GlDebuggerWidget::initializeGL() 
     908{ 
     909        glMatrixMode(GL_PROJECTION); 
     910        glLoadIdentity(); 
     911 
     912        glFrustum(-1, 1, -1, 1, 10, 100); 
     913        glTranslatef(-0.5f, -0.5f, -0.5f); 
     914        glTranslatef(0.0f, 0.0f, -15.0f); 
     915        glMatrixMode(GL_MODELVIEW); 
     916 
     917        glEnable(GL_CULL_FACE); 
     918        initCommon(); 
     919        initPbuffer(); 
     920 
     921} 
     922 
     923 
     924void GlDebuggerWidget::resizeGL(int w, int h) 
     925{ 
     926        glViewport(0, 0, w, h); 
     927} 
     928 
     929 
     930void GlDebuggerWidget::paintGL() 
     931{ 
     932        // draw a spinning cube into the pbuffer.. 
     933        mRenderBuffer->makeCurrent(); 
     934        //mRenderBuffer->SampleBeamContributions(); 
     935        glFlush(); 
     936 
     937    // rendering directly to a texture is not supported on X11, unfortunately 
     938    mRenderBuffer->updateDynamicTexture(dynamicTexture); 
     939    
     940    // ..and use the pbuffer contents as a texture when rendering the 
     941    // background and the bouncing cubes 
     942    makeCurrent(); 
     943    glBindTexture(GL_TEXTURE_2D, dynamicTexture); 
     944    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     945 
     946    // draw the background 
     947    glMatrixMode(GL_MODELVIEW); 
     948    glPushMatrix(); 
     949    glLoadIdentity(); 
     950    glMatrixMode(GL_PROJECTION); 
     951    glPushMatrix(); 
     952    glLoadIdentity(); 
     953 
     954        glPopMatrix(); 
     955        glMatrixMode(GL_MODELVIEW); 
     956        glPopMatrix(); 
     957} 
     958 
     959 
     960void GlDebuggerWidget::initPbuffer() 
     961{ 
     962        // set up the pbuffer context 
     963    mRenderBuffer->makeCurrent(); 
     964        initCommon(); 
     965 
     966        glViewport(0, 0, mRenderBuffer->size().width(), mRenderBuffer->size().height()); 
     967        glMatrixMode(GL_PROJECTION); 
     968        glLoadIdentity(); 
     969        glOrtho(-1, 1, -1, 1, -99, 99); 
     970        glTranslatef(-0.5f, -0.5f, 0.0f); 
     971        glMatrixMode(GL_MODELVIEW); 
     972        glLoadIdentity(); 
     973 
     974        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 
     975 
     976        // generate a texture that has the same size/format as the pbuffer 
     977    dynamicTexture = mRenderBuffer->generateDynamicTexture(); 
     978 
     979        // bind the dynamic texture to the pbuffer - this is a no-op under X11 
     980        mRenderBuffer->bindToDynamicTexture(dynamicTexture); 
     981        makeCurrent(); 
     982} 
     983 
     984void GlDebuggerWidget::initCommon() 
     985{ 
     986        glEnable(GL_TEXTURE_2D); 
     987        glEnable(GL_DEPTH_TEST); 
     988 
     989        glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 
     990} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h

    r535 r538  
    1919class Beam; 
    2020class KdTree; 
    21  
     21class QWidget; 
     22class GlRendererBuffer; 
    2223class BeamSampleStatistics; 
    2324 
     
    214215extern GlRendererWidget *rendererWidget; 
    215216 
     217class GlDebuggerWidget : public QGLWidget 
     218{ 
     219public: 
     220    GlDebuggerWidget(QWidget *parent, GlRendererBuffer *buf); 
     221    ~GlDebuggerWidget(); 
     222    void initializeGL(); 
     223    void resizeGL(int w, int h); 
     224    void paintGL(); 
     225    void timerEvent(QTimerEvent *) { update(); } 
     226    void mousePressEvent(QMouseEvent *) { killTimer(timerId); } 
     227    void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); } 
     228 
     229    void initCommon(); 
     230    void initPbuffer(); 
     231 
     232         GlRendererBuffer *mRenderBuffer; 
     233 
     234private: 
     235    GLuint dynamicTexture; 
     236    int timerId; 
     237}; 
     238 
     239extern GlDebuggerWidget *debuggerWidget; 
     240 
    216241#endif 
    217242 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r508 r538  
    133133        else if (classification == FRONT_SIDE) 
    134134                return 1; 
    135  
     135        // plane splits polygon 
    136136        return 0; 
    137137} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r534 r538  
    2323{ 
    2424  environment->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); 
     25   
    2526  // renderer will be constructed when the scene graph and viewcell manager will be known 
    2627  renderer = NULL; 
    2728   
     29  environment->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger); 
    2830} 
    2931 
     
    256258                mViewCellsFilename = buf; 
    257259        } 
    258         if (mUseGlRenderer) 
     260        if (mUseGlRenderer || mUseGlDebugger) 
    259261          renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 
    260262 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r534 r538  
    125125 
    126126  bool mUseGlRenderer; 
    127    
     127  bool mUseGlDebugger; 
     128 
    128129  bool mLoadViewCells; 
    129130 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r535 r538  
    14801480        stack<BspNode *> nodeStack; 
    14811481 
    1482         if (!mRoot) 
     1482        if (!root) 
    14831483                return; 
    14841484 
    1485         nodeStack.push(mRoot); 
     1485        nodeStack.push(root); 
    14861486         
    14871487        while (!nodeStack.empty())  
     
    21822182                geom->IncludeInBox(box); 
    21832183 
    2184                 Debug << "box:\n " << box << endl;; 
    21852184                const int side = beam.ComputeIntersection(box); 
    21862185                 
     
    21882187                { 
    21892188                case -1: 
    2190                         Debug << "here999" << endl; 
    21912189                        CollectViewCells(node, beam.mViewCells, true); 
    21922190                        break; 
     
    21952193                        if (node->IsLeaf()) 
    21962194                        { 
    2197                                 Debug << "here2" << endl; 
    21982195                                BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
    21992196                         
     
    22062203                        else  
    22072204                        { 
    2208                                 Debug << "here77" << endl; 
    22092205                                BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    22102206                         
    2211                                 BspNode *first = interior->GetBack(); 
    2212                                 BspNode *second = interior->GetFront(); 
     2207                                BspNode *first = interior->GetFront(); 
     2208                                BspNode *second = interior->GetBack(); 
    22132209             
    22142210                                BspNodeGeometry *firstGeom = new BspNodeGeometry(); 
    22152211                                BspNodeGeometry *secondGeom = new BspNodeGeometry(); 
    22162212 
    2217                                 ConstructGeometry(first, *firstGeom); 
    2218                                 ConstructGeometry(second, *secondGeom); 
     2213                                geom->SplitGeometry(*firstGeom, 
     2214                                                                        *secondGeom, 
     2215                                                                        interior->GetPlane(), 
     2216                                                                        mBox, 
     2217                                                                        mEpsilon); 
    22192218 
    22202219                                // decide on the order of the nodes 
     
    22312230                         
    22322231                        break; 
    2233                         Debug << "culling!!" << endl; 
     2232                default: 
    22342233                        // default: cull 
    2235                 } 
    2236                 Debug << "here4" << endl; 
     2234                        break; 
     2235                } 
     2236                 
    22372237                DEL_PTR(geom); 
    22382238                 
    22392239        } 
    22402240 
    2241         return beam.mViewCells.size(); 
     2241        return (int)beam.mViewCells.size(); 
    22422242} 
    22432243 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r536 r538  
    366366 
    367367        exporter->SetWireframe(); 
    368         exporter->ExportGeometry(objects); 
     368        //exporter->ExportGeometry(objects); 
    369369        exporter->SetFilled(); 
    370370        //Randomize(); 
     
    389389                Intersectable *sourceObj = mObjects[5]; 
    390390                BeamSampleStatistics stats; 
     391 
    391392                renderer->SampleBeamContributions(sourceObj, 
    392393                                                                                  beam, 
     
    403404                exporter->ExportBeam(beam, vbox); 
    404405 
    405                 bool exportViewCells = false; 
     406                bool exportViewCells = true; 
    406407                 
    407408                if (exportViewCells) 
    408409                { 
    409                         exporter->SetWireframe(); 
    410                          
    411410                        ViewCellContainer::const_iterator it, it_end = beam.mViewCells.end(); 
    412411                         
     
    416415                                AxisAlignedBox3 vbox; 
    417416                                vbox.Initialize(); 
    418                                 Mesh *mesh = (*it)->GetMesh(); 
    419  
     417                                vbox.Include((*it)->GetMesh()); 
     418                         
     419                                exporter->SetWireframe(); 
    420420                                exporter->ExportBox(vbox); 
    421                                 //exporter->ExportViewCell(*it); 
     421                                exporter->SetFilled(); 
     422                                exporter->ExportViewCell(*it); 
    422423                        } 
     424 
     425                        /*vector<KdNode *>::const_iterator it, it_end = beam.mKdNodes.end(); 
     426                         
     427                        for (it = beam.mKdNodes.begin(); it != beam.mKdNodes.end(); ++ it) 
     428                        { 
     429                                exporter->ExportBox(mKdTree->GetBox((*it))); 
     430                        }*/ 
    423431                } 
    424432        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r532 r538  
    101101        pt->start(QThread::LowPriority); 
    102102         
    103   } else { 
     103  } else if (0 /*p->UseGlDebugger*/) { 
     104            //debuggerWidget = new GlDebuggerWidget(*, (p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 
     105                //  renderer->resize(640, 480); 
     106        //      debuggerWidget->resize(640, 480); 
     107        //      debuggerWidget->show(); 
     108 
     109        pt->start(QThread::LowPriority); 
     110  } else 
     111  { 
    104112        // just call the mail method -> will be executed in the main thread 
    105113        pt->Main(); 
Note: See TracChangeset for help on using the changeset viewer.