Changeset 2696 for GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Timestamp:
- 05/23/08 05:19:59 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2695 r2696 290 290 291 291 // some error happened 292 if ( 1)//pixelCount > pixelThres)292 if (pixelCount > pixelThres) 293 293 { 294 294 cout << "f " << mFrame << " id " << viewcell->GetId() << " pvs " << pvsSize … … 313 313 im.save(qstr, "PNG"); 314 314 315 #if 1 316 /////////// 317 //-- output computed pvs 318 319 //mUseFalseColors = false; 320 mUseFalseColors = true; 321 glPushAttrib(GL_CURRENT_BIT); 322 glColor3f(0, 1, 0); 323 324 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 325 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 326 327 KdNode::NewMail2(); 328 Intersectable::NewMail(); 329 330 ++ mCurrentFrame; 331 332 // render pvs once 333 //RenderPvs(pvs); 334 RenderTrianglePvs(); 335 336 glFlush(); 337 338 mUseFalseColors = false; 339 340 im = toImage(); 341 sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 342 str = mSnapPrefix + filename; 343 qstr = str.c_str(); 344 im.save(qstr, "PNG"); 345 346 glPopAttrib(); 347 #endif 315 if (0) 316 { 317 /////////// 318 //-- output computed pvs 319 320 //mUseFalseColors = false; 321 mUseFalseColors = true; 322 glPushAttrib(GL_CURRENT_BIT); 323 glColor3f(0, 1, 0); 324 325 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 326 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 327 328 KdNode::NewMail2(); 329 Intersectable::NewMail(); 330 331 ++ mCurrentFrame; 332 333 // render pvs once 334 //RenderPvs(pvs); 335 RenderTrianglePvs(); 336 337 glFlush(); 338 339 mUseFalseColors = false; 340 341 im = toImage(); 342 sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 343 str = mSnapPrefix + filename; 344 qstr = str.c_str(); 345 im.save(qstr, "PNG"); 346 347 glPopAttrib(); 348 } 348 349 } 349 350 } … … 2602 2603 } 2603 2604 2604 /* 2605 2606 int ExampleRenderThread::faceAtPosition(const QPoint &pos) 2605 2606 int QtGlRendererWidget::FindDynamicObject(const Vector3 &pos) 2607 2607 { 2608 2608 // we need to lock the rendering context 2609 glw.lockGLContext(); 2609 //glw.lockGLContext(); 2610 2610 2611 // this is the same as in every OpenGL picking example 2611 const int MaxSize = 512; 2612 const int maxSize = 512; 2613 2612 2614 // see below for an explanation on the buffer content 2613 GLuint buffer[ MaxSize];2615 GLuint buffer[maxSize]; 2614 2616 GLint viewport[4]; 2617 2615 2618 glGetIntegerv(GL_VIEWPORT, viewport); 2616 glSelectBuffer(MaxSize, buffer); 2619 glSelectBuffer(maxSize, buffer); 2620 2617 2621 // enter select mode 2618 2622 glRenderMode(GL_SELECT); 2619 2623 glInitNames(); 2620 2624 glPushName(0); 2625 2621 2626 glMatrixMode(GL_PROJECTION); 2622 2627 glPushMatrix(); 2623 2628 glLoadIdentity(); 2624 gluPickMatrix((GLdouble)pos.x(), 215 (GLdouble)(viewport[3] - pos.y()), 216 5.0, 5.0, viewport); 2625 GLfloat x = (GLfloat)viewport_size.width() / viewport_size.height(); 2629 gluPickMatrix((GLdouble)pos.x, (GLdouble)(viewport[3] - pos.y), 5.0f, 5.0f, viewport); 2630 2631 GLfloat x = (GLfloat)width() / height(); 2626 2632 glFrustum(-x, x, -1.0, 1.0, 4.0, 15.0); 2627 draw(); 2633 2634 glLoadName(1); 2635 2636 _RenderDynamicObject(mPendingDynamicObject); 2637 2628 2638 glMatrixMode(GL_PROJECTION); 2629 2639 glPopMatrix(); 2640 2630 2641 // finally release the rendering context again 2631 2642 if (!glRenderMode(GL_RENDER)) 2632 2643 { 2633 glw.unlockGLContext();2644 //glw.unlockGLContext(); 2634 2645 return -1; 2635 2646 } 2636 2647 2637 glw.unlockGLContext();2648 //glw.unlockGLContext(); 2638 2649 2639 2650 // Each hit takes 4 items in the buffer. … … 2649 2660 return buffer[3]; 2650 2661 } 2651 */ 2652 } 2662 2663 void processHits (GLint hits, GLuint buffer[]) 2664 { 2665 unsigned int i, j; 2666 GLuint names, *ptr; 2667 2668 cout << "hits = %d" << endl;; 2669 ptr = (GLuint *) buffer; 2670 2671 for (i = 0; i < hits; i++) 2672 { 2673 /* for each hit */ 2674 names = *ptr; 2675 2676 printf (" number of names for hit = %d\n", names); ptr++; 2677 printf(" z1 is %g;", (float) *ptr/0x7fffffff); ptr++; 2678 printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++; 2679 printf (" the name is "); 2680 2681 for (j = 0; j < names; j++) { /* for each name */ 2682 printf ("%d ", *ptr); ptr++; 2683 } 2684 printf ("\n"); 2685 } 2686 } 2687 2688 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2695 r2696 80 80 void RenderTrianglePvs(); 81 81 82 82 83 public: 83 84 … … 248 249 249 250 #if DYNAMIC_OBJECTS_HACK 250 251 251 252 SceneGraphLeaf *mPendingDynamicObject; 252 253 253 DynamicObjectsContainer mDynamicObjects; 254 254 255 #endif 255 256 … … 324 325 325 326 void WriteViewCellInfos(); 326 327 327 /** Unproject x/y screen coordinates. 328 328 */ 329 329 Vector3 Unproject(int x, int y); 330 330 331 int FindDynamicObject(const Vector3 &pos); 332 331 333 332 334 public slots:
Note: See TracChangeset
for help on using the changeset viewer.