Changeset 538 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/14/06 01:41:57 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r534 r538 55 55 Include(*it); 56 56 } 57 58 void 59 AxisAlignedBox3::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 57 67 58 68 void -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.h
r534 r538 105 105 void Include(const Polygon3 &newpoly); 106 106 void Include(const AxisAlignedBox3 &bbox); 107 void Include(Mesh *mesh); 107 108 // Expand the axis-aligned box to include given values in particular axis 108 109 void Include(const int &axis, const float &newBound); -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r534 r538 1434 1434 "false"); 1435 1435 1436 RegisterOption("Preprocessor.useGlDebugger", 1437 optBool, 1438 "useGlDebugger", 1439 "false"); 1440 1436 1441 RegisterOption("Preprocessor.detectEmptyViewSpace", 1437 1442 optBool, -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r535 r538 21 21 22 22 GlRendererWidget *rendererWidget = NULL; 23 GlDebuggerWidget *debuggerWidget = NULL; 23 24 24 25 … … 446 447 { 447 448 static int glList = -1; 448 if (glList != -1) { 449 glCallList(glList); 450 } else { 449 if (glList == -1) 450 { 451 451 glList = glGenLists(1); 452 glNewList(glList, GL_COMPILE _AND_EXECUTE);452 glNewList(glList, GL_COMPILE); 453 453 ObjectContainer::const_iterator oi = mObjects.begin(); 454 454 for (; oi != mObjects.end(); oi++) … … 456 456 glEndList(); 457 457 } 458 459 glCallList(glList); 460 458 461 return true; 459 462 } … … 565 568 GlRendererWidget::paintGL() 566 569 { 567 RenderErrors(); 568 mFrame++; 570 RenderErrors(); 571 572 mFrame++; 569 573 } 570 574 … … 780 784 GenQueries((int)beam.mViewCells.size()); 781 785 782 // now check whether any backfacing polygon would pass the depth test 786 // now check whether any backfacing polygon would pass the depth test? 783 787 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 784 788 glDepthMask(GL_FALSE); … … 799 803 800 804 // 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; 804 808 805 809 // 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 810 825 // would be sufficient to gain only the intergral statistics about the new contributions 811 826 // and so the rss tree would actually store no new rays (only the initial ones) … … 815 830 // (new viewcell has been discovered) or relative contribution greater than a threashold ... 816 831 832 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 833 glDepthMask(GL_TRUE); 834 glEnable(GL_CULL_FACE); 835 836 817 837 cgGLDisableProfile(sCgFragmentProfile); 818 838 glDisable(GL_TEXTURE_2D); … … 838 858 } 839 859 860 840 861 void GlRendererBuffer::SetupProjectionForViewPoint(const Vector3 &viewPoint, 841 862 const Beam &beam, … … 855 876 viewPoint.x, viewPoint.y, viewPoint.z, 856 877 up.x, up.y, up.z); 857 } 878 } 879 880 881 882 883 /***************************************************************/ 884 /* GlDebuggerWidget implementation */ 885 /***************************************************************/ 886 887 888 GlDebuggerWidget::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 898 GlDebuggerWidget::~GlDebuggerWidget() 899 { 900 mRenderBuffer->releaseFromDynamicTexture(); 901 glDeleteTextures(1, &dynamicTexture); 902 903 DEL_PTR(mRenderBuffer); 904 } 905 906 907 void 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 924 void GlDebuggerWidget::resizeGL(int w, int h) 925 { 926 glViewport(0, 0, w, h); 927 } 928 929 930 void 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 960 void 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 984 void 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 19 19 class Beam; 20 20 class KdTree; 21 21 class QWidget; 22 class GlRendererBuffer; 22 23 class BeamSampleStatistics; 23 24 … … 214 215 extern GlRendererWidget *rendererWidget; 215 216 217 class GlDebuggerWidget : public QGLWidget 218 { 219 public: 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 234 private: 235 GLuint dynamicTexture; 236 int timerId; 237 }; 238 239 extern GlDebuggerWidget *debuggerWidget; 240 216 241 #endif 217 242 -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r508 r538 133 133 else if (classification == FRONT_SIDE) 134 134 return 1; 135 135 // plane splits polygon 136 136 return 0; 137 137 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r534 r538 23 23 { 24 24 environment->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); 25 25 26 // renderer will be constructed when the scene graph and viewcell manager will be known 26 27 renderer = NULL; 27 28 29 environment->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger); 28 30 } 29 31 … … 256 258 mViewCellsFilename = buf; 257 259 } 258 if (mUseGlRenderer )260 if (mUseGlRenderer || mUseGlDebugger) 259 261 renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 260 262 -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r534 r538 125 125 126 126 bool mUseGlRenderer; 127 127 bool mUseGlDebugger; 128 128 129 bool mLoadViewCells; 129 130 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r535 r538 1480 1480 stack<BspNode *> nodeStack; 1481 1481 1482 if (! mRoot)1482 if (!root) 1483 1483 return; 1484 1484 1485 nodeStack.push( mRoot);1485 nodeStack.push(root); 1486 1486 1487 1487 while (!nodeStack.empty()) … … 2182 2182 geom->IncludeInBox(box); 2183 2183 2184 Debug << "box:\n " << box << endl;;2185 2184 const int side = beam.ComputeIntersection(box); 2186 2185 … … 2188 2187 { 2189 2188 case -1: 2190 Debug << "here999" << endl;2191 2189 CollectViewCells(node, beam.mViewCells, true); 2192 2190 break; … … 2195 2193 if (node->IsLeaf()) 2196 2194 { 2197 Debug << "here2" << endl;2198 2195 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 2199 2196 … … 2206 2203 else 2207 2204 { 2208 Debug << "here77" << endl;2209 2205 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2210 2206 2211 BspNode *first = interior->Get Back();2212 BspNode *second = interior->Get Front();2207 BspNode *first = interior->GetFront(); 2208 BspNode *second = interior->GetBack(); 2213 2209 2214 2210 BspNodeGeometry *firstGeom = new BspNodeGeometry(); 2215 2211 BspNodeGeometry *secondGeom = new BspNodeGeometry(); 2216 2212 2217 ConstructGeometry(first, *firstGeom); 2218 ConstructGeometry(second, *secondGeom); 2213 geom->SplitGeometry(*firstGeom, 2214 *secondGeom, 2215 interior->GetPlane(), 2216 mBox, 2217 mEpsilon); 2219 2218 2220 2219 // decide on the order of the nodes … … 2231 2230 2232 2231 break; 2233 Debug << "culling!!" << endl;2232 default: 2234 2233 // default: cull 2235 } 2236 Debug << "here4" << endl; 2234 break; 2235 } 2236 2237 2237 DEL_PTR(geom); 2238 2238 2239 2239 } 2240 2240 2241 return beam.mViewCells.size();2241 return (int)beam.mViewCells.size(); 2242 2242 } 2243 2243 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r536 r538 366 366 367 367 exporter->SetWireframe(); 368 exporter->ExportGeometry(objects);368 //exporter->ExportGeometry(objects); 369 369 exporter->SetFilled(); 370 370 //Randomize(); … … 389 389 Intersectable *sourceObj = mObjects[5]; 390 390 BeamSampleStatistics stats; 391 391 392 renderer->SampleBeamContributions(sourceObj, 392 393 beam, … … 403 404 exporter->ExportBeam(beam, vbox); 404 405 405 bool exportViewCells = false;406 bool exportViewCells = true; 406 407 407 408 if (exportViewCells) 408 409 { 409 exporter->SetWireframe();410 411 410 ViewCellContainer::const_iterator it, it_end = beam.mViewCells.end(); 412 411 … … 416 415 AxisAlignedBox3 vbox; 417 416 vbox.Initialize(); 418 Mesh *mesh = (*it)->GetMesh(); 419 417 vbox.Include((*it)->GetMesh()); 418 419 exporter->SetWireframe(); 420 420 exporter->ExportBox(vbox); 421 //exporter->ExportViewCell(*it); 421 exporter->SetFilled(); 422 exporter->ExportViewCell(*it); 422 423 } 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 }*/ 423 431 } 424 432 } -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r532 r538 101 101 pt->start(QThread::LowPriority); 102 102 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 { 104 112 // just call the mail method -> will be executed in the main thread 105 113 pt->Main();
Note: See TracChangeset
for help on using the changeset viewer.