Changeset 2669


Ignore:
Timestamp:
04/30/08 10:09:52 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

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

    r2667 r2669  
    9696 
    9797        // for sg snapshot 
    98         //mViewPoint = Vector3(18.5133, 10.9818, -1032.24); 
    99         //mViewDirection = Vector3(-0.5373, 0, 0.843391); 
    100  
    101          
    102           //    mViewPoint = Vector3(1213.85, 176.988, -437.364); 
    103           //    mViewDirection = Vector3(0.433884, 0, -0.900969); 
    104          
    105         //mViewPoint = Vector3(1213.85, 176.988, -437.364); 
    106         //mViewDirection = Vector3(0.433884, 0, -0.900969); 
    107  
    10898        mViewPoint = Vector3(32.8596, 9.86079, -1023.79); 
    10999        mViewDirection = Vector3(-0.92196, 0, 0.387286); 
    110  
    111         //mViewPoint = Vector3(1099.9,183.0,-387); 
    112         //mViewDirection = Vector3(-0.6,0,-0.8); 
    113100 
    114101        // inside 
     
    16501637                // drop the first frame (for some reason, the first frame yields wrong pixel error) 
    16511638                 
    1652                 if ((mFrame > 0) && (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0))  
     1639                if (//(mFrame > 0) &&  
     1640                        (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0))  
    16531641                { 
    16541642                        if (err > mPvsStat.maxError) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2667 r2669  
    2020   
    2121#define GVS_DEBUG 0 
    22  
     22#define NOT_ACCOUNTED_OBJECT 0 
     23#define ACCOUNTED_OBJECT 2 
     24#define SHOW_QT_VISUALIZATION 0 
     25 
     26static const float MIN_DIST = 0.001f; 
     27 
     28static ObjectContainer myobjects; 
     29 
     30 
     31/** Visualization structure for the GVS algorithm. 
     32*/ 
    2333struct VizStruct 
    2434{ 
     
    2838}; 
    2939 
    30  
    31 static const float MIN_DIST = 0.001f; 
    32  
    33 static ObjectContainer myobjects; 
    3440static vector<VizStruct> vizContainer; 
     41 
     42 
    3543 
    3644 
     
    153161                //newRay->mFlags |= VssRay::ReverseSample; 
    154162                 
    155                 // if ray is not further processed => delete ray 
    156                 if (!HandleRay(newRay)) 
    157                 { 
    158                         //delete newRay; 
    159                 } 
     163                // check if ray is not further processed (ray not deleted because using ray pool) 
     164                HandleRay(newRay); 
    160165                 
    161166                return 1; 
     
    164169        return 0; 
    165170} 
     171 
     172 
     173void GvsPreprocessor::CountObject(Intersectable *triObj) 
     174{ 
     175        if ((triObj->mCounter != (NOT_ACCOUNTED_OBJECT + 1)) && (triObj->mCounter != (ACCOUNTED_OBJECT + 1))) 
     176        { 
     177                ++ triObj->mCounter; 
     178                ++ mGenericStats2; 
     179        } 
     180} 
     181 
     182 
     183void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt) 
     184{ 
     185        mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
     186 
     187        // count new objects in pvs due to kd node conversion    
     188        myobjects.clear(); 
     189        mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 
     190 
     191        ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 
     192 
     193        for (oit = myobjects.begin(); oit != oit_end; ++ oit) 
     194                CountObject(*oit); 
     195}        
    166196 
    167197 
     
    189219                Intersectable *obj = ray.mTerminationObject; 
    190220 
    191                 if (obj->mCounter < 2) 
     221                // counter < 2 => not accounted for yet 
     222                if (obj->mCounter < ACCOUNTED_OBJECT) 
    192223                { 
    193                         obj->mCounter += 2; 
     224                        obj->mCounter += ACCOUNTED_OBJECT; 
    194225                        mTrianglePvs.push_back(obj); 
    195226                 
    196227                        mGenericStats = mTrianglePvs.size(); 
    197228 
    198                         // if using kd pvs, exchange the triangle with the node in the pvs 
     229                        // exchange the triangle with the node in the pvs for kd pvs 
    199230                        if (mUseKdPvs) 
    200231                        { 
     
    203234                                if (!node->Mailed()) 
    204235                                { 
     236                                        // add to pvs 
    205237                                        node->Mail(); 
    206238                                        KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 
    207239                                        mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
    208                                         //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 
    209                                          
    210                                         mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
    211                                         myobjects.clear(); 
    212                                         mKdTree->CollectObjects(node, myobjects); 
    213  
    214                                         // account for kd object pvs 
    215                                         ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 
    216  
    217                                         for (oit = myobjects.begin(); oit != oit_end; ++ oit) 
    218                                         { 
    219                                                 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 
    220  
    221                                                 if ((triObj->mCounter != 1) && (triObj->mCounter != 3)) 
    222                                                 { 
    223                                                         ++ triObj->mCounter; 
    224                                                         ++ mGenericStats2; 
    225                                                 } 
    226                                         } 
    227                                 }                        
     240                                 
     241                                        if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);   
     242                                } 
    228243                        } 
    229244 
     
    902917        ObjectContainer kdobjects; 
    903918        mKdTree->CollectKdObjects(box, kdobjects); 
    904         //vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 
    905         //for (lit = leaves.begin(); lit != lit_end; ++ lit) 
     919 
    906920        ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 
     921 
    907922        for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 
    908923        { 
     
    912927                //mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
    913928                mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 
     929 
    914930                mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
    915931 
     
    924940                        TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 
    925941             
    926                         // account for the overall pvs 
    927                         if ((triObj->mCounter != 1) && (triObj->mCounter != 3)) 
    928                         { 
    929                                 ++ triObj->mCounter; 
    930                                 ++ mGenericStats2; 
    931                         } 
     942                        CountObject(triObj); 
    932943             
    933944                        // the triangle itself intersects 
    934945                        if (box.Intersects(triObj->GetItem())) 
    935946                        { 
    936                                 if ((triObj->mCounter < 2)) 
     947                                if ((triObj->mCounter < ACCOUNTED_OBJECT)) 
    937948                                { 
    938                                         triObj->mCounter += 2; 
     949                                        triObj->mCounter += ACCOUNTED_OBJECT; 
    939950 
    940951                                        mTrianglePvs.push_back(triObj); 
     
    957968 
    958969                for (oit = mObjects.begin(); oit != oit_end; ++ oit) 
    959                         (*oit)->mCounter = 0; 
     970                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    960971 
    961972        ComputeViewCell(vc); 
     
    986997 
    987998                for (oit = mObjects.begin(); oit != oit_end; ++ oit) 
    988                         (*oit)->mCounter = 0; 
     999                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    9891000 
    9901001                ComputeViewCell(vc); 
     
    10491060 
    10501061                // hack: reset counter 
    1051                 (*oit)->mCounter = 0; 
     1062                (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    10521063 
    10531064                if (!bv || bv->Mailed()) 
     
    12521263        ProcessViewCell(); 
    12531264 
    1254         //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 
    12551265        mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 
    12561266        mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2648 r2669  
    1111class Exporter; 
    1212class VssRay; 
     13class TriangleIntersectable; 
     14class KdIntersectable; 
    1315 
    1416/** View space partition statistics. 
     
    234236        */ 
    235237        void ProcessViewCell(); 
    236  
     238        /** Use this for qt visualization. 
     239        */ 
     240        void UpdateStatsForVisualization(KdIntersectable *kdInt); 
     241        /** Keep count of new objects for stats. 
     242        */ 
     243        void CountObject(Intersectable *triObj); 
    237244 
    238245 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp

    r2663 r2669  
    7979#ifdef _WIN32 
    8080                // VH 
    81                 cout << "issuing arb query" << endl; 
     81                //cout << "issuing arb query" << endl; 
    8282                glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mId); 
    8383#endif 
     
    100100#ifdef _WIN32 
    101101                // VH 
    102                 cout << "ending query" << endl; 
     102                //cout << "ending query" << endl; 
    103103                glEndQueryARB(GL_SAMPLES_PASSED_ARB); 
    104104#endif 
     
    134134        { 
    135135#ifdef _WIN32 
    136           // VH 
    137           glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_AVAILABLE_NV, &available); 
     136                // VH 
     137                glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_AVAILABLE_NV, &available); 
    138138#endif 
    139139        } 
     
    180180                        // VH 
    181181                        glGenQueriesARB(n, (unsigned int *)newQueries); 
    182                         cout << "creating " << n << " arb queries" <<  endl; 
     182                        //cout << "creating " << n << " arb queries" <<  endl; 
    183183#endif 
    184184                } 
     
    188188                        // VH              
    189189                        glGenOcclusionQueriesNV(n, (unsigned int *)newQueries); 
    190                         cout << "creating " << n << " nv queries" <<  endl; 
     190                        //cout << "creating " << n << " nv queries" <<  endl; 
    191191#endif             
    192192                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2667 r2669  
    3131#include <QVBoxLayout> 
    3232 
    33 namespace GtpVisibilityPreprocessor { 
    34  
     33namespace GtpVisibilityPreprocessor  
     34{ 
    3535 
    3636   
     
    4141static CGprofile sCgFragmentProfile; 
    4242 
    43  
    44 //static vector<OcclusionQuery *> sQueries; 
    4543 
    4644QtGlRendererWidget *rendererWidget = NULL; 
     
    8886                                                                           ViewCellsManager *viewcells, 
    8987                                                                           KdTree *tree): 
    90 QGLPixelBuffer(QSize(w, h), QGLFormat(QGL::StencilBuffer | QGL::DirectRendering | QGL::DepthBuffer | QGL::Rgba)), 
     88QGLPixelBuffer(QSize(w, h),  
     89                           QGLFormat(QGL::StencilBuffer |  
     90                                                 QGL::DepthBuffer |  
     91                                                 QGL::DoubleBuffer | 
     92                                                 QGL::Rgba 
     93                                                 )), 
    9194GlRendererBuffer(sceneGraph, viewcells, tree) 
    9295{ 
     
    125128        MakeCurrent(); 
    126129         
    127 /* 
    128 SetupCamera(); 
    129 RenderScene(); 
    130 */ 
     130        cout << "stencil: " << format().stencil() << endl; 
     131        cout << "depth: " << format().depth() << endl; 
     132        cout << "rgba: " << format().rgba() << endl; 
     133        cout << "double: " << format().doubleBuffer() << endl; 
     134 
    131135        float pErrorPixels = -1.0f; 
    132136 
     
    134138        unsigned int pixelCount = 0; 
    135139 
    136  
     140         
    137141        ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
    138142 
    139143        if (viewcell == NULL) 
    140144                return -1.0f; 
     145 
     146        KdNode::NewMail2(); 
     147        Intersectable::NewMail(); 
    141148 
    142149        ObjectPvs pvs; 
     
    150157                mViewCellsManager->ApplyFilter2(viewcell, false, mViewCellsManager->GetFilterWidth(), pvs); 
    151158 
    152  
    153         mUseForcedColors = true; 
    154  
    155         SetupCamera(); 
    156  
    157         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    158         glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); 
    159         glColor3f(0,1,0); 
    160         glDepthFunc(GL_LESS ); 
    161         glEnable(GL_DEPTH_TEST); 
    162  
    163         glDisable(GL_STENCIL_TEST); 
    164  
    165159        pvsSize = pvs.GetSize(); 
    166  
    167         Intersectable::NewMail(); 
    168160         
    169161        if (pvsSize == 0) 
    170162                return 0.0f; 
    171163 
    172         RenderPvs(pvs); 
    173  
    174         //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 
     164        mUseForcedColors = true; 
     165 
     166        SetupCamera(); 
     167 
     168        // use shading 
     169        if (mSnapErrorFrames) 
     170        { 
     171 
     172                GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 
     173                GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 
     174                GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 
     175 
     176                GLfloat light_position[] =  //{278.0f, 548.8f,279.0f, 1.0f}; 
     177                {0.f,0.f,0.f, 1.0f}; 
     178 
     179                glEnable(GL_LIGHT0);  
     180 
     181                // a light 
     182                glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
     183                glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
     184                glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
     185 
     186                glEnable(GL_LIGHTING); 
     187                glLightfv (GL_LIGHT0, GL_POSITION, light_position); 
     188 
     189                glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
     190                glEnable(GL_COLOR_MATERIAL); 
     191 
     192                glShadeModel(GL_SMOOTH); 
     193        } 
     194 
     195        glDisable(GL_ALPHA_TEST); 
     196                 
    175197        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     198        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
     199 
     200        //glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); 
     201        glColor3f(0, 1, 0); 
     202 
     203        glDepthFunc(GL_LESS); 
     204        glDepthMask(GL_TRUE); 
     205        glEnable(GL_DEPTH_TEST); 
    176206 
    177207        glStencilFunc(GL_EQUAL, 0x0, 0x1); 
    178208        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
     209 
     210         
     211        // render pvs once 
     212        RenderPvs(pvs); 
     213 
     214        //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 
     215        //glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 
     216        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     217 
    179218        glEnable(GL_STENCIL_TEST);  
    180  
    181219        glColor3f(1,0,0); 
    182220 
    183221 
    184         OcclusionQuery *query = mOcclusionQueries[1]; 
    185  
     222        // render scene, record differences 
     223        OcclusionQuery *query = mOcclusionQueries[0]; 
     224 
     225        KdNode::NewMail2(); 
    186226        Intersectable::NewMail(); 
    187227 
     
    236276                                } 
    237277                } 
    238  
     278                 
     279 
     280#if 0 
    239281                mUseFalseColors = false; 
     282 
    240283                glPushAttrib(GL_CURRENT_BIT); 
    241                 glColor3f(0,1,0); 
     284                glColor3f(0, 1, 0); 
     285                 
    242286                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    243287                //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    244288                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    245289 
     290                KdNode::NewMail2(); 
     291                Intersectable::NewMail(); 
     292 
    246293                RenderPvs(pvs); 
    247294 
     295                glFinish(); 
     296 
    248297                mUseForcedColors = false; 
     298 
    249299                im = toImage(); 
    250300                sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
     
    252302                qstr = str.c_str(); 
    253303                im.save(qstr, "PNG"); 
     304                 
    254305                glPopAttrib(); 
     306#endif 
    255307        } 
    256308 
     
    449501        int indexBufferSize = 0; 
    450502         
     503        // super hack: mal not working with multiple threads 
    451504        KdNode::NewMail2(); 
    452505        //Intersectable::NewMail(); 
     
    503556 
    504557        EnableDrawArrays(); 
    505         //Intersectable::NewMail(); 
    506          
     558                 
    507559        if (mDetectEmptyViewSpace)  
    508560                glEnable(GL_CULL_FACE); 
Note: See TracChangeset for help on using the changeset viewer.