Changeset 2709 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 05/26/08 01:05:56 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
r2680 r2709 13 13 #include "CombinedPreprocessor.h" 14 14 #include "RayCaster.h" 15 15 #include <windows.h> 16 16 17 17 … … 79 79 80 80 for (mCurrentSamples =0; mCurrentSamples < mTotalSamples; mCurrentSamples += mSamplesPerPass, mPass++) { 81 while (mSynchronize) 82 { 83 // hack: sleep during walthrough computation 84 Sleep(1000); 85 } 86 81 87 mRayCaster->InitPass(); 82 88 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2706 r2709 447 447 448 448 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 449 450 449 glEnable(GL_NORMALIZE); 451 452 450 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 453 451 … … 916 914 { 917 915 char filename[256]; 918 sprintf (filename, "snap/frame-%04d-%d.png", mFrame, i);916 sprintf_s(filename, "snap/frame-%04d-%d.png", mFrame, i); 919 917 // QImage im = toImage(); 920 918 // im.save(filename, "PNG"); … … 923 921 // evaluate the sample 924 922 if (useOcclusionQueries) 925 {926 923 EvalQueryWithOcclusionQueries(); 927 }928 924 else 929 {930 925 EvalQueryWithItemBuffer(); 931 }932 926 } 933 927 … … 1452 1446 for (int i = 0; i < depthMapSize * depthMapSize; ++ i) 1453 1447 { 1454 // todo glGetTexImage()1448 // TODO (use glGetTexImage()) 1455 1449 } 1456 1450 } … … 1506 1500 int pvsSize; 1507 1501 1508 mPvsErrorBuffer[i].mError = GetPixelError(pvsSize );1502 mPvsErrorBuffer[i].mError = GetPixelError(pvsSize, 0); 1509 1503 mPvsErrorBuffer[i].mPvsSize = pvsSize; 1510 1504 … … 1566 1560 { 1567 1561 mPvsStat.Reset(); 1562 ++ mPvsStat.pass; 1568 1563 1569 1564 SetupProjection(GetWidth(), GetHeight()); … … 1591 1586 { 1592 1587 // compute the pixel error 1593 mPvsErrorBuffer[i].mError = GetPixelError(pvsSize );1588 mPvsErrorBuffer[i].mError = GetPixelError(pvsSize, mPvsStat.pass); 1594 1589 mPvsErrorBuffer[i].mPvsSize = pvsSize; 1595 1590 … … 1700 1695 1701 1696 1702 float GlRenderer::GetPixelError(int &pvsSize )1697 float GlRenderer::GetPixelError(int &pvsSize, int pass) 1703 1698 { 1704 1699 return -1.0f; -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2702 r2709 42 42 int frames; 43 43 int errorFreeFrames; 44 45 PvsRenderStatistics() { Reset(); } 44 int pass; 45 46 PvsRenderStatistics(): pass(0) { Reset(); } 46 47 47 48 void Reset() … … 169 170 virtual bool ValidViewPoint(); 170 171 171 virtual float GetPixelError(int &pvsSize); 172 /** Gets the pixel error of the current view point. 173 returns the size of the pvs for the current view point. pass returns the 174 current pass of the evaluation. 175 */ 176 virtual float GetPixelError(int &pvsSize, int pass); 172 177 173 178 virtual void EvalPvsStat(); … … 185 190 virtual void InitGL(); 186 191 187 virtual int GetWidth() const { return 0;}188 virtual int GetHeight() const { return 0;}192 virtual int GetWidth() const {return 0;} 193 virtual int GetHeight() const {return 0;} 189 194 190 195 unsigned int GetId(const unsigned char r, -
GTP/trunk/Lib/Vis/Preprocessing/src/GtpVisibility05.vcproj
r2705 r2709 898 898 </File> 899 899 <File 900 RelativePath=".\SepPlanesBox3.h" 901 > 902 </File> 903 <File 900 904 RelativePath=".\SimpleRay.h" 901 905 > … … 1081 1085 <File 1082 1086 RelativePath=".\SceneGraph.cpp" 1087 > 1088 </File> 1089 <File 1090 RelativePath=".\SepPlanesBox3.cpp" 1083 1091 > 1084 1092 </File> -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2708 r2709 58 58 mGlobalLinesRenderer(NULL), 59 59 mUseHwGlobalLines(false), 60 mTotalRaysCast(0) 60 mTotalRaysCast(0), 61 mSynchronize(false) 61 62 { 62 63 Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); … … 665 666 // load scene objects which are the entities used as pvs entries 666 667 ObjectContainer pvsObjects; 667 if ( 0) LoadObjects(buf, pvsObjects, mObjects);668 if (1) LoadObjects(buf, pvsObjects, mObjects); 668 669 669 670 const bool finalizeViewCells = true; … … 746 747 747 748 mViewCellsManager->SetRenderer(mRenderSimulator); 748 749 749 mViewCellsManager->SetPreprocessor(this); 750 750 … … 838 838 839 839 Vector3 origin, termination; 840 // HACK: needed only for lower_bound algorithm to find the 841 // intersected objects 840 // HACK: needed only for lower_bound algorithm to find the intersected objects 842 841 MeshInstance sObj(NULL); 843 842 MeshInstance tObj(NULL); … … 1452 1451 Preprocessor::ComputeRenderError() 1453 1452 { 1454 // compute rendering error 1455 1453 // compute rendering error 1456 1454 if (renderer && renderer->mPvsStatFrames) { 1457 1455 … … 1596 1594 mDynamicObjects.push_back(leaf); 1597 1595 1598 // add to scene graph 1599 mSceneGraph->GetRoot()->mChildren.push_back(leaf); 1600 1601 if (mRayCaster) 1602 mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation()); 1596 // tell ray caster to update 1597 ScheduleUpdateDynamicObjects(); 1598 1599 if (0) 1600 { 1601 // add to scene graph 1602 mSceneGraph->GetRoot()->mChildren.push_back(leaf); 1603 // add to ray caster 1604 if (mRayCaster) 1605 mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation()); 1606 } 1603 1607 // $$ JB in order to compile 1604 1608 //return leaf; … … 1646 1650 1647 1651 leaf->UpdateBox(); 1652 1653 float offs = -leaf->GetOriginalBox().Min().y; 1654 1655 // scale so pivot is always on bottom 1656 for (it = leaf->mGeometry.begin(); it != it_end; ++ it) 1657 { 1658 TriangleIntersectable *tri = static_cast<TriangleIntersectable *>(*it); 1659 1660 Triangle3 t = tri->GetItem(); 1661 1662 // hack: scale object appropriately 1663 t.mVertices[0].y += offs; 1664 t.mVertices[1].y += offs; 1665 t.mVertices[2].y += offs; 1666 1667 tri->SetItem(t); 1668 } 1669 1670 leaf->UpdateBox(); 1671 1672 1648 1673 cout<<"Dynamic object loaded successfully: " << leaf->GetBox() << endl; 1649 1674 … … 1709 1734 1710 1735 1736 void Preprocessor::ObjectRemoved(SceneGraphLeaf *leaf) 1737 { 1738 ObjectMoved(leaf); 1739 } 1740 1741 1711 1742 void Preprocessor::UpdateDynamicObjects() 1712 1743 { … … 1716 1747 preprocessor->mRayCaster->DeleteDynamicObjects(); 1717 1748 1718 for (size_t i =0; i < mDynamicObjects.size(); ++ i)1749 for (size_t i = 0; i < mDynamicObjects.size(); ++ i) 1719 1750 { 1720 1751 SceneGraphLeaf *l = mDynamicObjects[i]; 1721 1722 cout<<"Updating dynamic objects in ray caster..."<<endl;1723 1724 mRayCaster->AddDynamicObjecs(l->mGeometry, l->GetTransformation());1725 1726 cout<<"done."<<endl;1727 1728 cerr<<"Updating affected PVSs..."<<endl;1729 preprocessor->ObjectMoved(l);1730 cerr<<"done."<<endl;1752 1753 UpdateObjectInRayCaster(l); 1754 1755 if (l->HasChanged()) 1756 { 1757 cout<<"Updating affected PVSs..."<<endl; 1758 preprocessor->ObjectMoved(l); 1759 cout<<"done."<<endl; 1760 l->SetHasChanged(false); 1761 } 1731 1762 } 1732 1763 1733 1764 mUpdateDynamicObjects = false; 1734 1735 1765 } 1736 1766 } … … 1739 1769 void Preprocessor::ScheduleUpdateDynamicObjects() 1740 1770 { 1741 mUpdateDynamicObjects = true; 1742 } 1743 1744 1745 } 1771 mUpdateDynamicObjects = true; 1772 } 1773 1774 1775 void Preprocessor::UpdateObjectInRayCaster(SceneGraphLeaf *l) 1776 { 1777 cout<<"Updating dynamic objects in ray caster..."<<endl; 1778 1779 mRayCaster->AddDynamicObjecs(l->mGeometry, l->GetTransformation()); 1780 cout<<"done."<<endl; 1781 } 1782 1783 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2702 r2709 200 200 void RegisterDynamicObject(SceneGraphLeaf *leaf); 201 201 202 void UpdateObjectInRayCaster(SceneGraphLeaf *l); 203 204 void ScheduleUpdateDynamicObjects(); 205 void UpdateDynamicObjects(); 206 /** Notify the preprocessor that an object has been deleted 207 */ 208 virtual void ObjectRemoved(SceneGraphLeaf *object); 209 202 210 203 211 204 212 ///////////////////////// 213 214 bool mSynchronize; 205 215 206 216 /// scene graph loaded from file … … 277 287 RayCaster *mRayCaster; 278 288 279 int mGenericStats[2]; 280 281 void ScheduleUpdateDynamicObjects(); 282 void UpdateDynamicObjects(); 283 284 /// triangle pvs for gvs 289 // triangle pvs for gvs 285 290 // hack: should be in gvspreprocessor but pulled 286 291 // out here for visualization purpose 287 292 ObjectContainer mTrianglePvs; 293 294 // generic stats vector that can be used for anything 295 int mGenericStats[2]; 288 296 289 297 //std::vector<int> mDummyBuffer; … … 309 317 */ 310 318 virtual void ObjectMoved(SceneGraphLeaf *object); 311 319 312 320 313 321 -
GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h
r2707 r2709 306 306 // the last part should not be more than log of the sorted part. this 307 307 // way we can achieve logarithmic behaviour for insertion and find 308 const int n = mEntries.size();308 const int n = (int)mEntries.size(); 309 309 const int dirtySize = n - mLastSorted; 310 310 311 311 const double LOG2E = 1.442695040f; 312 312 313 const float logN = (float)log((float) Max(1, n))/LOG2E;314 const float logS = (float)log((float) Max(1, mLastSorted))/LOG2E;315 const float logD = (float)log((float) Max(1, dirtySize))/LOG2E;313 const float logN = log((float) Max(1, n))/ (float)LOG2E; 314 const float logS = log((float) Max(1, mLastSorted))/ (float)LOG2E; 315 const float logD = log((float) Max(1, dirtySize))/ (float)LOG2E; 316 316 317 317 if (8*(n + 2*dirtySize*logD) < -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2707 r2709 50 50 QtGlDebuggerWidget *debuggerWidget = NULL; 51 51 52 const static int SAMPLES_INCR = 2000000;53 52 54 53 55 54 static SimpleRayContainer sViewPointsList; 56 55 static SimpleRayContainer::const_iterator sViewPointsListIt; 57 56 static int sCurrentSamples = 0; 57 static int sNextSamplesThreshold[] = {10000000, 50000000, 100000000, 250000000}; 58 //static int sNextSamplesThreshold[] = {100000000, 200000000}; 59 static int sNumReplays = 4; 60 static int sCurrentSamplesThreshold = 0; 58 61 59 62 … … 125 128 KdTree *tree): 126 129 QGLPixelBuffer(QSize(w, h), 127 QGLFormat(QGL::StencilBuffer | 130 QGLFormat(QGL::SampleBuffers) 131 /*,| 132 QGL::StencilBuffer | 128 133 QGL::DepthBuffer | 129 134 QGL::DoubleBuffer | 130 135 QGL::Rgba) 131 ),136 */), 132 137 GlRendererBuffer(sceneGraph, viewcells, tree) 133 138 { … … 190 195 191 196 // reimplemented here so that we can snap the error windows 192 float QtGlRendererBuffer::GetPixelError(int &pvsSize )197 float QtGlRendererBuffer::GetPixelError(int &pvsSize, int pass) 193 198 { 194 199 MakeLive(); … … 237 242 238 243 // use shading 239 if (mSnapErrorFrames) 240 { 244 if (1)//mSnapErrorFrames) 245 { 246 glEnable(GL_NORMALIZE); 247 248 // mat_specular and mat_shininess are NOT default values 249 GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 250 GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 251 GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 252 GLfloat mat_shininess[] = {1.0f}; 253 254 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 255 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 256 glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); 257 glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 258 241 259 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 260 //GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 242 261 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 243 262 GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 244 263 264 glEnable(GL_LIGHTING); 245 265 //GLfloat light_position[] = {278.0f, 548.8f,279.0f, 1.0f}; 246 GLfloat light_position[] = {0.f,0.f,0.f, 1.0f}; 266 //GLfloat light_position[] = {0.f, 0.f, 0.f, 1.0f}; 267 GLfloat light_position[] = {0.f, 0.0f, 0.f, 1.0f}; 247 268 248 269 glEnable(GL_LIGHT0); … … 252 273 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 253 274 glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 254 255 glEnable(GL_LIGHTING);256 275 glLightfv (GL_LIGHT0, GL_POSITION, light_position); 257 276 258 277 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 259 glEnable(GL_COLOR_MATERIAL); 278 //glEnable(GL_COLOR_MATERIAL); 279 280 GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 281 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 260 282 261 283 glShadeModel(GL_SMOOTH); 262 284 } 263 285 264 glDisable(GL_ALPHA_TEST);286 //glDisable(GL_ALPHA_TEST); 265 287 266 288 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 267 289 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 268 290 269 //glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE);270 glColor3f(0, 1, 0);291 glColor3f(0.6f, 0.6f, 0.6f); 292 //glColor3f(0, 1, 0); 271 293 272 294 glDepthFunc(GL_LESS); … … 274 296 glEnable(GL_DEPTH_TEST); 275 297 298 glFrontFace(GL_CCW); 299 glCullFace(GL_BACK); 300 276 301 glStencilFunc(GL_EQUAL, 0x0, 0x1); 277 302 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); … … 301 326 query->BeginQuery(); 302 327 328 // current frame has to be increased at each rendering pass 303 329 ++ mCurrentFrame; 304 330 … … 317 343 318 344 // some error happened 319 if ( pixelCount > pixelThres)345 if (1) // pixelCount > pixelThres) 320 346 { 321 347 cout << "f " << mFrame << " id " << viewcell->GetId() << " pvs " << pvsSize 322 348 << " e " << pixelCount << " vp " << mViewPoint << " vd " << mViewDirection << endl; 323 349 350 format().setSampleBuffers(true); 351 cout << "here3 " << format().sampleBuffers() << endl; 324 352 if (mSnapErrorFrames) 325 353 { … … 327 355 //glReadBuffer(GL_FRONT); 328 356 329 330 357 ////////////// 331 358 //-- output error visualization 332 359 333 360 char filename[256]; 334 //sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 335 sprintf(filename, "error-frame-%04d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 361 sprintf(filename, "error-frame-%04d-%05d.bmp", pass, mFrame); 362 //sprintf(filename, "error-frame-%05d-%0.5f.png", mFrame, pErrorPixels); 363 //sprintf_s(filename, "error-frame-%05d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 364 336 365 QImage im = toImage(); 337 366 string str = mSnapPrefix + filename; 338 367 QString qstr(str.c_str()); 339 368 340 im.save(qstr, "PNG"); 369 //im.save(qstr, "PNG"); 370 // use bmp for lossless storage (for video) 371 im.save(qstr, "BMP"); 341 372 342 373 if (0) … … 367 398 368 399 im = toImage(); 369 sprintf (filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount);400 sprintf_s(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 370 401 str = mSnapPrefix + filename; 371 402 qstr = str.c_str(); … … 433 464 //glEnable(GL_FOG); 434 465 //glFogi(GL_FOG_MODE, GL_EXP); 466 //glFogf(GL_FOG_DENSITY, .2f); 435 467 glFogi(GL_FOG_MODE, GL_LINEAR); 436 437 // glFogf(GL_FOG_DENSITY, .2f);438 468 glFogf(GL_FOG_START, 50.f); 439 469 glFogf(GL_FOG_END, 500.f); 440 470 441 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 442 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 443 GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 444 GLfloat light_position[] = //{278.0f, 548.8f,279.0f, 1.0f }; 445 { 0.f,0.f,0.f,1.0f }; 446 447 /*glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 448 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 449 glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 450 glLightfv(GL_LIGHT0, GL_POSITION, light_position); 451 */ 452 glEnable(GL_LIGHT0); 453 471 472 // mat_specular and mat_shininess are NOT default values 454 473 GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 455 456 // mat_specular and mat_shininess are NOT default values457 474 GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 458 475 GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 459 476 GLfloat mat_shininess[] = {1.0f}; 460 477 461 /* GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};462 GLfloat light_diffuse[] = {0.4f, 0.4f, 0.4f, 1.0f};463 GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f};464 465 GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};466 */467 468 // default Material469 478 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 470 479 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); … … 472 481 glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 473 482 474 // a light 483 484 glEnable(GL_LIGHTING); 485 486 // a light 487 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 488 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 489 GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 490 GLfloat light_position[] = {0.f, .0f, 0.f, 1.0f}; 491 //GLfloat light_position[] = {600.0f, 250.0f, -500.f, 1.0f}; 492 //GLfloat light_position[] = {278.0f, 548.8f,279.0f, 1.0f}; 493 475 494 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 476 495 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 477 496 glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 478 497 479 /*glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 498 glLightfv(GL_LIGHT0, GL_POSITION, light_position); 499 500 //glDisable(GL_LIGHT0); 501 glEnable(GL_LIGHT0); 502 503 glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 480 504 glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); 481 505 glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); 482 */ 483 //glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 484 485 glEnable(GL_LIGHTING); 486 glEnable(GL_LIGHT0); 487 // glEnable(GL_LIGHT1); 488 489 // set position of the light 490 /*GLfloat infinite_light[] = { 1.0, 0.8, 1.0, 0.0 }; 491 glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); 492 506 493 507 // set position of the light2 494 508 GLfloat infinite_light2[] = { -0.3, 1.5, 1.0, 0.0 }; 495 509 glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 496 */ 497 glLightfv (GL_LIGHT0, GL_POSITION, light_position); 498 499 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 500 // glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR); 510 //glEnable(GL_LIGHT1); 511 512 GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 513 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 514 515 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 516 //glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); 501 517 glEnable(GL_COLOR_MATERIAL); 502 518 … … 568 584 dit, dit_end = p->mDynamicObjects.end(); 569 585 570 for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit) 571 { 572 glColor3f(0, 1, 0); 586 int i = 0; 587 for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit, ++ i) 588 { 589 if (i == mCurrentDynamicObjectIdx) 590 glColor3f(1, 0, 1); 591 else 592 glColor3f(0, 1, 0); 593 573 594 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 574 595 _RenderDynamicObject(*dit); 575 596 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 576 597 } 577 578 //_RenderDynamicObject(mPendingDynamicObject);579 598 } 580 599 … … 692 711 mWireFrame = false; 693 712 } 694 695 //mCurrentPvsCost = viewcell->GetPvs().EvalPvsCost();696 713 } 697 714 else … … 722 739 723 740 glEnable(GL_STENCIL_TEST); 724 725 741 glDisable(GL_LIGHTING); 726 742 … … 770 786 cout << "stopping replay" << endl; 771 787 mReplayMode = false; 788 GetPreprocessor()->mSynchronize = false; 772 789 } 773 790 else … … 781 798 } 782 799 783 784 800 updateGL(); 785 } 786 787 if (timerEvent->timerId() == mUpdateTimerId) 801 802 // output the current frame buffer 803 if (mExportFrameBuffer) 804 { 805 const int dist = sViewPointsListIt - sViewPointsList.begin(); 806 807 char filename[200]; 808 sprintf(filename, "error-frame-%04d-%05d.bmp", sCurrentSamples, dist); 809 //QPixmap img = renderPixmap(0, 0, true); 810 QImage im = grabFrameBuffer(); 811 812 string str = mSnapPrefix + filename; 813 QString qstr(str.c_str()); 814 815 //im.save(qstr, "PNG"); 816 // use bmp for lossless storage (for video) 817 im.save(qstr, "BMP"); 818 } 819 } 820 else if (timerEvent->timerId() == mUpdateTimerId) 821 // update pvss from time to time 788 822 update(); 823 824 // grab frame buffer after a certain number of samples 825 if (!mReplayMode && 826 (sCurrentSamplesThreshold < sNumReplays) && 827 ((GetPreprocessor()->mCurrentSamples > sNextSamplesThreshold[sCurrentSamplesThreshold]))) 828 { 829 ++ sCurrentSamplesThreshold; 830 cout << "replaying at total samples: " << GetPreprocessor()->mCurrentSamples << endl; 831 ReplayViewPoints(); 832 } 833 789 834 } 790 835 … … 803 848 { 804 849 Vector3 pt = Unproject(x, y); 805 cout << "unproject: " << pt << endl;806 850 807 851 mPlacer->PlaceObject(pt); … … 813 857 SceneGraphLeaf *newObj = new SceneGraphLeaf(*leaf); 814 858 815 mViewCellsManager->GetPreprocessor()->RegisterDynamicObject(newObj); 816 //mPendingDynamicObjects.push_back(); 859 // make current object 860 // the object is added at the end of the vector 861 mCurrentDynamicObjectIdx = (int)GetPreprocessor()->mDynamicObjects.size(); 862 863 GetPreprocessor()->RegisterDynamicObject(newObj); 817 864 } 818 865 } … … 828 875 mousePoint.y = y; 829 876 830 if (e->modifiers() & Qt:: AltModifier)877 if (e->modifiers() & Qt::ShiftModifier) 831 878 { 832 879 const Vector3 pt = Unproject(x, y); … … 834 881 int idx = FindDynamicObject(x, y); 835 882 836 Preprocessor *p = GetPreprocessor(); 837 838 swap(p->mDynamicObjects[idx], p->mDynamicObjects.back()); 839 p->mDynamicObjects.pop_back(); 840 //preprocessor->ScheduleUpdateDynamicObjects(); 883 if (idx >= 0) 884 { 885 mCurrentDynamicObjectIdx = idx; 886 } 841 887 } 842 888 } … … 865 911 mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 866 912 } 867 #if 0// DYNAMIC_OBJECTS_HACK868 913 else if (e->modifiers() & Qt::AltModifier) 869 914 { … … 896 941 case 2: 897 942 { 898 899 943 // tm = RotationXMatrix(diffx) * RotationYMatrix(diffy); 944 tm = RotationYMatrix(diffx); 900 945 } 901 946 break; … … 911 956 } 912 957 } 913 #endif914 958 else 915 959 { … … 1043 1087 break; 1044 1088 1045 if (sscanf (text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) {1089 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 1046 1090 text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z); 1047 1091 text = QInputDialog::getText(this, … … 1053 1097 if (!ok) 1054 1098 break; 1055 if (sscanf (text.toAscii(), "%f %f %f", &mViewDirection.x,1099 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewDirection.x, 1056 1100 &mViewDirection.y, &mViewDirection.z) == 3) { 1057 1101 updateGL(); … … 1075 1119 QWidget * parent, 1076 1120 const QGLWidget * shareWidget, 1077 Qt::WFlags f 1078 ) 1079 : 1080 GlRendererWidget(sceneGraph, viewcells, tree), QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget, f) 1121 Qt::WFlags f): 1122 GlRendererWidget(sceneGraph, viewcells, tree), 1123 QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget, f) 1081 1124 { 1082 1125 mPreprocessorThread = NULL; … … 1139 1182 mPlacer = new ObjectPlacer(); 1140 1183 1141 //mPendingDynamicObject = NULL; 1184 mCurrentDynamicObjectIdx = -1; 1185 1186 //mExportFrameBuffer = true; 1187 mExportFrameBuffer = false; 1142 1188 1143 1189 SetSceneCut(1000); … … 1200 1246 connect(mControlWidget, SIGNAL(SetShowRays(bool)), this, SLOT(SetShowRays(bool))); 1201 1247 1202 #if 01248 #if 1 1203 1249 connect(mControlWidget, SIGNAL(SetTranslation(bool)), this, SLOT(SetTranslation(bool))); 1204 1250 connect(mControlWidget, SIGNAL(SetRotation(bool)), this, SLOT(SetRotation(bool))); … … 1206 1252 #endif 1207 1253 connect(mControlWidget, SIGNAL(UpdateDynamicObjects()), this, SLOT(UpdateDynamicObjects())); 1254 connect(mControlWidget, SIGNAL(DeleteDynamicObject()), this, SLOT(DeleteDynamicObject())); 1208 1255 1209 1256 setWindowTitle("PVS Visualization"); 1210 1257 1211 1258 // setting the main window size here 1212 resize(800, 600);1213 //resize(640, 400);1259 //resize(800, 600); 1260 resize(640, 480); 1214 1261 1215 1262 mControlWidget->show(); … … 1428 1475 filter = mViewCellsManager->GetMaxFilterSize(); 1429 1476 1430 glColor3f(0.0f, 0.0f, 1.0f); 1431 1432 #if REMOVE_TEMPORARY 1477 #if 0 //REMOVE_TEMPORARY 1433 1478 s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 1434 1479 mFrame, … … 1447 1492 filter, 1448 1493 mPvsSize, 1449 mRenderError *100.0f);1494 mRenderError * 100.0f); 1450 1495 1451 1496 renderText(20, 40, s); 1452 1497 #endif 1453 1498 1454 QFont font40; font40.setPointSize(30); 1499 glDisable(GL_LIGHTING); 1500 //qglColor(QColor(0, 255, 0)); 1501 glColor3f(0, 1, 0); 1502 QFont font40; font40.setPointSize(25); 1455 1503 //s.sprintf("PVS: %04d", mPvsSize); 1456 1504 //renderText(20, 40, s, font40); … … 1461 1509 //renderText(290, 70, s, font40); 1462 1510 1463 s.sprintf("PVS TRI: %07d", (int)mCurrentPvsCost); 1464 renderText(290, 70, s, font40); 1511 s.sprintf("PVS TRI: %08d", (int)mCurrentPvsCost); 1465 1512 //renderText(290, 70, s, font40); 1513 renderText(325, 40, s, font40); 1514 s.sprintf("error: %3.3f %", mRenderError * 100.0f); 1515 renderText(20, 40, s, font40); 1516 1517 //renderText(290, 70, s, font40); 1518 glEnable(GL_LIGHTING); 1466 1519 1467 1520 } … … 1809 1862 importance = rcCost / maxRcCost; 1810 1863 } 1811 if (importance > 1.0f) importance = 1.0f; 1864 1865 if (importance > 1.0f) importance = 1.0f; 1812 1866 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1813 1867 c = RainbowColorMapping(importance); … … 1962 2016 connect(button, SIGNAL(clicked()), SIGNAL(UpdateDynamicObjects())); 1963 2017 2018 button = new QPushButton("Delete", groupBox); 2019 vbox2->addWidget(button); 2020 connect(button, SIGNAL(clicked()), SIGNAL(DeleteDynamicObject())); 1964 2021 1965 2022 groupBox->setLayout(vbox2); … … 2538 2595 // set up the pbuffer context 2539 2596 mRenderBuffer->makeCurrent(); 2540 2541 2597 // generate a texture that has the same size/format as the pbuffer 2542 2598 dynamicTexture = mRenderBuffer->generateDynamicTexture(); 2543 2544 2599 // bind the dynamic texture to the pbuffer - this is a no-op under X11 2545 2600 mRenderBuffer->bindToDynamicTexture(dynamicTexture); … … 2627 2682 { 2628 2683 cout << "replaying " << (int)sViewPointsList.size() << " view points " << endl; 2629 2684 2630 2685 mReplayMode = true; 2686 2687 if (mExportFrameBuffer) 2688 GetPreprocessor()->mSynchronize = true; 2689 2690 sCurrentSamples = GetPreprocessor()->mCurrentSamples; 2631 2691 sViewPointsListIt = sViewPointsList.begin(); 2632 2692 } … … 2662 2722 int QtGlRendererWidget::FindDynamicObject(float x, float y) 2663 2723 { 2724 2725 if (GetPreprocessor()->mDynamicObjects.empty()) 2726 return -1; 2727 2664 2728 makeCurrent(); 2665 // we need to lock the rendering context2666 //glw.lockGLContext();2667 2729 2668 2730 // this is the same as in every OpenGL picking example … … 2715 2777 glPopMatrix(); 2716 2778 2717 int hits; 2779 int hits = glRenderMode(GL_RENDER); 2780 2718 2781 // finally release the rendering context again 2719 if ( (hits = glRenderMode(GL_RENDER)) < 0)2782 if (!hits) 2720 2783 { 2721 2784 cout << "no object picked" << endl; 2722 //glw.unlockGLContext();2723 2785 return -1; 2724 2786 } 2725 2787 2726 2727 2788 //processHits(hits, buffer); 2728 2729 2730 //glw.unlockGLContext();2731 2789 2732 2790 // Each hit takes 4 items in the buffer. … … 2743 2801 2744 2802 2745 } 2803 void QtGlRendererWidget::DeleteDynamicObject() 2804 { 2805 Preprocessor *p = GetPreprocessor(); 2806 2807 if ((mCurrentDynamicObjectIdx < 0) || 2808 (mCurrentDynamicObjectIdx >= p->mDynamicObjects.size())) 2809 return; 2810 2811 cout << "deleting object" << endl; 2812 2813 SceneGraphLeaf *l = p->mDynamicObjects[mCurrentDynamicObjectIdx]; 2814 2815 // tell the preprocessor that an object was deleted 2816 p->ObjectRemoved(l); 2817 2818 swap(p->mDynamicObjects[mCurrentDynamicObjectIdx], p->mDynamicObjects.back()); 2819 p->mDynamicObjects.pop_back(); 2820 2821 delete l; 2822 2823 mCurrentDynamicObjectIdx = -1; 2824 } 2825 2826 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2704 r2709 72 72 void RenderPvs(const ObjectPvs &pvs); 73 73 74 float GetPixelError(int &pvsSize );74 float GetPixelError(int &pvsSize, int pass); 75 75 76 76 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; … … 114 114 void ReplayViewPoints(); 115 115 void UpdateDynamicObjects(); 116 void DeleteDynamicObject(); 116 117 void ComputeVisibility(); 117 118 void StopComputation(); … … 246 247 ObjectPlacer *mPlacer; 247 248 248 //DynamicObjectsContainer mPendingDynamicObjects; 249 int mCurrentDynamicObjectIdx; 250 251 bool mExportFrameBuffer; 252 249 253 DynamicObjectsContainer mDynamicPvsObjects; 250 254 … … 334 338 void ReplayViewPoints(); 335 339 void UpdateDynamicObjects(); 340 void DeleteDynamicObject(); 336 341 void UpdateAllPvs(); 337 342 void ComputeVisibility(); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2705 r2709 52 52 // set viewer size here 53 53 return QSize(512, 320); 54 55 54 //return QSize(512, 384); 56 55 //return QSize(640, 480); … … 68 67 69 68 GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f}; 70 GLfloat light_diffuse[] = {0. 4f, 0.4f, 0.4f, 1.0f};69 GLfloat light_diffuse[] = {0.6f, 0.6f, 0.6f, 1.0f}; 71 70 GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 72 71 … … 82 81 glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 83 82 84 // default material85 /*glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);86 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);87 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);88 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);89 */90 83 // a light 91 84 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r2666 r2709 12 12 #include "SamplingStrategy.h" 13 13 #include "RayCaster.h" 14 14 #include <windows.h> 15 15 16 16 … … 94 94 while (samples < mTotalSamples) { 95 95 for (int i=0; i < mSamplesPerPass;) { 96 96 while (mSynchronize) 97 { 98 // hack: sleep during walthrough computation 99 Sleep(1000); 100 } 101 97 102 mRayCaster->InitPass(); 98 103 -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
r2702 r2709 278 278 279 279 280 SceneGraphLeaf::SceneGraphLeaf(): mIsDynamic(false) 280 SceneGraphLeaf::SceneGraphLeaf(): mIsDynamic(false), mHasChanged(true) 281 281 { 282 282 mTrafo = IdentityMatrix(); … … 286 286 287 287 288 SceneGraphLeaf::SceneGraphLeaf(bool isDynamic): mIsDynamic(isDynamic) 288 SceneGraphLeaf::SceneGraphLeaf(bool isDynamic): mIsDynamic(isDynamic), mHasChanged(true) 289 289 { 290 290 mTrafo = IdentityMatrix(); … … 294 294 void SceneGraphLeaf::ApplyTransform(const Matrix4x4 &trafo) 295 295 { 296 mHasChanged = true; 296 297 mTrafo = trafo * mTrafo; 297 298 } … … 300 301 void SceneGraphLeaf::LoadTransform(const Matrix4x4 &m) 301 302 { 303 mHasChanged = true; 302 304 mTrafo = m; 303 305 } … … 334 336 mTrafo = copy.mTrafo; 335 337 mIsDynamic = copy.mIsDynamic; 336 } 337 338 } 338 mHasChanged = true; 339 } 340 341 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h
r2702 r2709 76 76 virtual void UpdateBox(); 77 77 78 bool HasChanged() { return mHasChanged; } 79 80 void SetHasChanged(bool hasChanged) {mHasChanged = hasChanged;} 78 81 SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; } 79 82 … … 85 88 ObjectContainer mGeometry; 86 89 87 88 90 protected: 89 91 … … 91 93 92 94 bool mIsDynamic; 95 bool mHasChanged; 96 93 97 Matrix4x4 mTrafo; 94 98 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/SepPlanesBox3.cpp
r2707 r2709 87 87 Vector3 centerOrig = origBox.Center(); 88 88 Vector3 centerShad = shadBox.Center(); 89 const float eps = 1e-3 ;89 const float eps = 1e-3f; 90 90 int cnt = 0; 91 91 … … 111 111 // if (cnt == 17) { cout << "Problem " << endl; } 112 112 113 int centerFlag = pl.Side(pointBACKSIDE, 1e-6 );113 int centerFlag = pl.Side(pointBACKSIDE, 1e-6f); 114 114 if (centerFlag == Plane3:: INTERSECTS) 115 115 continue; // plane crosses the center of the box! … … 141 141 // test all edges of the axis aligned box 142 142 Vector3 a,b; 143 const float eps = 1e-3 ;143 const float eps = 1e-3f; 144 144 Vector3 centerShad = shadBox.Center(); 145 145 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r2707 r2709 171 171 172 172 173 TestSepAxis();173 //TestSepAxis(); 174 174 175 175 Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH); … … 333 333 // NOTE: render texture should be power of 2 and square 334 334 // renderer must be initialised 335 // $$matt 335 const float w = 640; 336 const float h = 480; 337 336 338 QtGlRendererBuffer *glbuf = 337 new QtGlRendererBuffer( 1024, 1024,339 new QtGlRendererBuffer(w, h, 338 340 preprocessor->mSceneGraph, 339 341 preprocessor->mViewCellsManager,
Note: See TracChangeset
for help on using the changeset viewer.