Ignore:
Timestamp:
12/10/07 18:43:33 (17 years ago)
Author:
mattausch
Message:

worked on visualization

File:
1 edited

Legend:

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

    r2560 r2562  
    5050} 
    5151 
     52 
     53inline static bool nearerThan(ViewCell *vc1, ViewCell *vc2) 
     54{ 
     55        return vc1->GetDistance() > vc2->GetDistance(); 
     56} 
     57 
     58 
    5259#if USE_CG 
    5360static void handleCgError()  
     
    322329                glMatrixMode(GL_PROJECTION); 
    323330                glLoadIdentity(); 
    324                 gluPerspective(angle, ww/(float)hh, 0.1, 2.0*Magnitude(mSceneGraph->GetBox().Diagonal())); 
     331                gluPerspective(angle, ww/(float)hh, 0.1, 2.0 * Magnitude(mSceneGraph->GetBox().Diagonal())); 
    325332                glMatrixMode(GL_MODELVIEW); 
    326333        } else { 
     
    330337                glMatrixMode(GL_PROJECTION); 
    331338                glLoadIdentity(); 
    332                 gluPerspective(50.0, ww/(float)hh, 0.1, 20.0*Magnitude(mSceneGraph->GetBox().Diagonal())); 
     339                gluPerspective(50.0, ww / (float)hh, 0.1, 20.0 * Magnitude(mSceneGraph->GetBox().Diagonal())); 
    333340                glMatrixMode(GL_MODELVIEW); 
    334341        } 
     
    830837        mRenderFilter = true; 
    831838        mRenderVisibilityEstimates = false; 
     839 
     840        mHideByCost = false; 
     841 
    832842        mTransferFunction = 0.2f; 
    833843        mIndexBufferSize = 0; 
     
    835845        //mCurrentFrame = 0; 
    836846 
    837         const int delay = 500; // half a second 
     847        const int delay = 250; // in milliseconds 
    838848        timerId = startTimer(delay); 
    839849 
     
    873883        connect(mControlWidget, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetVisibilityFilterSize(int))); 
    874884        connect(mControlWidget, SIGNAL(SetSpatialFilterSize(int)), this, SLOT(SetSpatialFilterSize(int))); 
     885        connect(mControlWidget, SIGNAL(SetHidingCost(int)), this, SLOT(SetHidingCost(int))); 
    875886 
    876887        connect(mControlWidget, SIGNAL(SetShowViewCells(bool)), this, SLOT(SetShowViewCells(bool))); 
     
    879890        connect(mControlWidget, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool))); 
    880891        connect(mControlWidget, SIGNAL(SetCutViewCells(bool)), this, SLOT(SetCutViewCells(bool))); 
     892        connect(mControlWidget, SIGNAL(SetHideByCost(bool)), this, SLOT(SetHideByCost(bool))); 
    881893        connect(mControlWidget, SIGNAL(SetCutScene(bool)), this, SLOT(SetCutScene(bool))); 
    882894        connect(mControlWidget, SIGNAL(SetRenderErrors(bool)), this, SLOT(SetRenderErrors(bool))); 
     
    11191131        // shift it along y according to number, which is percentage of the bounding 
    11201132        // box position 
    1121         if (mViewCellsManager) { 
     1133        if (mViewCellsManager)  
     1134        { 
    11221135                AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); 
    11231136                Vector3 p = box.Min() + (number/1000.0f)*box.Max(); 
    11241137                mSceneCutPlane.mNormal = Vector3(0,-1,0); 
    11251138                mSceneCutPlane.mD = -DotProd(mSceneCutPlane.mNormal, p); 
     1139 
    11261140                updateGL(); 
    11271141        } 
    11281142} 
     1143 
     1144void 
     1145QtGlRendererWidget::SetHidingCost(int number) 
     1146{ 
     1147        mHidingCost = (float)number / 1000.0f; 
     1148        cout << "hiding cost " << mHidingCost << endl; 
     1149} 
     1150 
    11291151 
    11301152void 
     
    11441166        glEnable(GL_CULL_FACE); 
    11451167        glCullFace(GL_FRONT); 
    1146  
    1147         glDisable(GL_CULL_FACE); 
     1168        //glDisable(GL_CULL_FACE); 
     1169 
    11481170        double eq[4]; 
    11491171        eq[0] = mSceneCutPlane.mNormal.x; 
     
    11591181 
    11601182        int i; 
     1183 
    11611184        ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 
    11621185        int maxPvs = -1; 
    1163         int maxPiercingRays = 0; 
     1186        int maxPiercingRays = 1; // for savety 
    11641187 
    11651188        for (i = 0; i < viewcells.size(); ++ i)  
     
    11711194                if (p > maxPvs) 
    11721195                        maxPvs = p; 
     1196 
    11731197                const int piercingRays = vc->GetNumPiercingRays(); 
     1198                 
    11741199                if (piercingRays > maxPiercingRays) 
    11751200                        maxPiercingRays = piercingRays; 
    11761201        } 
    11771202 
    1178  
    1179         for (i = 0; i < viewcells.size(); ++ i)  
     1203        cout << "here22 " << mHideByCost << " " << mHidingCost << endl; 
     1204 
     1205        if (!mShowPvsSizes && !mShowPiercingRays) 
    11801206        { 
    1181                 ViewCell *vc = viewcells[i]; 
    1182                 //      Mesh *m = vc->GetMesh(); 
     1207                for (i = 0; i < viewcells.size(); ++ i)  
     1208                { 
     1209                        ViewCell *vc = viewcells[i]; 
     1210                        RgbColor c; 
     1211 
     1212                        if (!mShowPvsSizes && !mShowPiercingRays) 
     1213                        { 
     1214                                mWireFrame = true; 
     1215                                c = vc->GetColor(); 
     1216                        }  
     1217 
     1218                        glColor3f(c.r, c.g, c.b); 
     1219 
     1220                        if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays))  
     1221                        { 
     1222                RenderViewCell(vc); 
     1223                        } 
     1224                } 
     1225        } 
     1226        else 
     1227        { 
     1228                //glDisable(GL_CULL_FACE); 
     1229                //glEnable(GL_CULL_FACE); 
     1230                //glFrontFace(GL_CCW);   
     1231                //glCullFace(GL_BACK); 
     1232                glEnable(GL_DEPTH_TEST); 
     1233                glDisable(GL_BLEND); 
     1234 
     1235                //glDisable(GL_DEPTH_TEST); 
     1236                //glEnable(GL_BLEND); 
     1237         
     1238                //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
     1239                glBlendFunc(GL_SRC_ALPHA, GL_ONE); 
     1240 
     1241                for (i = 0; i < viewcells.size(); ++ i)  
     1242                { 
     1243                        ViewCell *vc = viewcells[i]; 
     1244                        const float dist = SqrDistance(mViewPoint, vc->GetBox().Center()); 
     1245 
     1246                        vc->SetDistance(dist); 
     1247                } 
     1248 
     1249                sort(viewcells.begin(), viewcells.end(), nearerThan); 
    11831250 
    11841251                RgbColor c; 
    11851252 
    1186                 if (!mShowPvsSizes && !mShowPiercingRays) 
     1253        for (i = 0; i < viewcells.size(); ++ i)  
    11871254                { 
    1188                         mWireFrame = true; 
    1189                         c = vc->GetColor(); 
    1190                 }  
    1191                 else if (mShowPiercingRays) 
    1192                 { 
    1193                         // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    1194                         const float importance = 5.0f * mTransferFunction * 
    1195                                 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 
    1196                         // c = RgbColor(importance, 1.0f - importance, 0.0f); 
    1197                         c = RainbowColorMapping(importance); 
     1255            ViewCell *vc = viewcells[i]; 
     1256                         
     1257                        //cout << "dist: " << vc->GetDistance() << " "; 
     1258 
     1259                        if (mShowPiercingRays) 
     1260                        { 
     1261                                // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
     1262                                const float importance = 5.0f * mTransferFunction * 
     1263                                        ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 
     1264                                // c = RgbColor(importance, 1.0f - importance, 0.0f); 
     1265                                c = RainbowColorMapping(importance); 
     1266                        } 
     1267                        else 
     1268                        { 
     1269                                // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
     1270                                const float importance = 5.0f * mTransferFunction * 
     1271                                        ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
     1272                                // c = RgbColor(importance, 1.0f - importance, 0.0f); 
     1273                                c = RainbowColorMapping(importance); 
     1274                        } 
     1275                         
     1276                        const float alpha = 0.2f; 
     1277                        glColor4f(c.r, c.g, c.b, alpha); 
     1278                         
     1279                        if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays))  
     1280                        { 
     1281                RenderViewCell(vc); 
     1282                        } 
    11981283                } 
    1199                 else 
    1200                 { 
    1201                         // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 
    1202                         const float importance = 5.0f * mTransferFunction * 
    1203                                 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 
    1204                         // c = RgbColor(importance, 1.0f - importance, 0.0f); 
    1205                         c = RainbowColorMapping(importance); 
    1206                 } 
    1207  
    1208                 glColor3f(c.r, c.g, c.b); 
    1209  
    1210                 RenderViewCell(vc); 
     1284 
     1285                glEnable(GL_DEPTH_TEST);         
    12111286        } 
    12121287 
     
    14741549                connect(button, SIGNAL(clicked(void)), SLOT(FocusNextPvsErrorFrame(void))); 
    14751550        } 
     1551 
     1552        // the render cost visualization 
     1553        slider = new QSlider(Qt::Horizontal, vbox); 
     1554        vbox->layout()->addWidget(slider); 
     1555        slider->show(); 
     1556        slider->setRange(0, 1000); 
     1557        slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 
     1558        slider->setValue(100); 
     1559        connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetHidingCost(int))); 
     1560         
     1561        cb = new QCheckBox("Hide view cells by render cost ", vbox); 
     1562        vbox->layout()->addWidget(cb); 
     1563        cb->setChecked(false); 
     1564        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetHideByCost(bool))); 
    14761565 
    14771566        setWindowTitle("Preprocessor Control Widget"); 
Note: See TracChangeset for help on using the changeset viewer.