Changeset 532 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/13/06 02:44:57 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h
r531 r532 56 56 57 57 public: 58 enum {STORE_KD_NODES=1, STORE_OBJECTS=2, VALID=4};58 enum {STORE_KD_NODES=1, STORE_OBJECTS=2, STORE_VIEW_CELLS, VALID=8}; 59 59 int mFlags; 60 60 … … 90 90 bool SetValid() { return mFlags |= VALID; } 91 91 92 Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0) 92 Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0), mViewCells(0) 93 93 { 94 94 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r517 r532 1155 1155 "100000"); 1156 1156 1157 RegisterOption("VssPreprocessor.testBeamSampling", optBool, "beam_sampling", "false"); 1158 1157 1159 RegisterOption("VssPreprocessor.vssSamples", 1158 1160 optInt, … … 1574 1576 RegisterOption("VssTree.queryType", optString, "qtype=", "static"); 1575 1577 1576 1578 1579 1577 1580 RegisterOption("VssTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1578 1581 RegisterOption("VssTree.useRefDirSplits", optBool, "refdir", "false"); -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r530 r532 6 6 #include "Viewcell.h" 7 7 #include "Beam.h" 8 #include "KdTree.h" 8 9 9 10 #include <GL/glext.h> … … 30 31 31 32 GlRenderer::GlRenderer(SceneGraph *sceneGraph, 32 ViewCellsManager *viewCellsManager): 33 Renderer(sceneGraph, viewCellsManager) 33 ViewCellsManager *viewCellsManager, 34 KdTree *tree): 35 Renderer(sceneGraph, viewCellsManager), 36 mKdTree(tree) 34 37 { 35 38 mSceneGraph->CollectObjects(&mObjects); … … 43 46 GlRenderer::~GlRenderer() 44 47 { 48 cgDestroyProgram(sCgFragmentProgram); 49 cgDestroyContext(sCgContext); 45 50 } 46 51 … … 152 157 sCgContext = cgCreateContext(); 153 158 154 sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); 159 if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1)) 160 sCgFragmentProfile = CG_PROFILE_ARBFP1; 161 else { 162 // try FP30 163 if (cgGLIsProfileSupported(CG_PROFILE_FP30)) 164 sCgFragmentProfile = CG_PROFILE_FP30; 165 else { 166 fprintf(stderr, "Neither arbfp1 or fp30 fragment profiles supported on this system.\n"); 167 exit(1); 168 } 169 } 155 170 156 171 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext, 157 172 CG_SOURCE, "../src/dual_depth.cg", 158 173 sCgFragmentProfile, 159 "dual_depth",174 NULL, 160 175 NULL); 176 177 if (!cgIsProgramCompiled(sCgFragmentProgram)) 178 cgCompileProgram(sCgFragmentProgram); 179 180 cgGLLoadProgram(sCgFragmentProgram); 181 cgGLBindProgram(sCgFragmentProgram); 182 // Debug << "LAST LISTING----" << cgGetLastListing(sCgContext) << "----\n"; 183 184 Debug << "---- PROGRAM BEGIN ----\n" << 185 cgGetProgramString(sCgFragmentProgram, CG_COMPILED_PROGRAM) << "---- PROGRAM END ----\n"; 161 186 } 162 187 … … 683 708 // this beam is fast - the same hold for step 3) 684 709 710 if (beam.mFlags & !Beam::STORE_OBJECTS) 711 { 712 vector<KdNode *>::const_iterator it, it_end = beam.mKdNodes.end(); 713 714 Intersectable::NewMail(); 715 for (it = beam.mKdNodes.begin(); it != it_end; ++ it) 716 { 717 mKdTree->CollectObjects(*it, beam.mObjects); 718 } 719 } 720 685 721 // list of objects intersected by the frustum 686 722 #if 0 … … 704 740 #endif 705 741 742 // remove objects again 743 if (beam.mFlags & !Beam::STORE_OBJECTS) 744 beam.mObjects.clear(); 745 706 746 // bind ray origin depth buffer 707 747 glBindTexture(GL_TEXTURE_2D, depthMap); … … 719 759 // stencil buffer bit at step 3) 720 760 glStencilFunc(GL_EQUAL, 0x1, 0x1); 721 722 // compare with second depth buffer: done in pixel shader 723 cgGLBindProgram(sCgFragmentProgram); 761 762 //cgGLBindProgram(sCgFragmentProgram); 724 763 cgGLEnableProfile(sCgFragmentProfile); 725 764 -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r531 r532 18 18 class Material; 19 19 class Beam; 20 class KdTree; 20 21 21 22 class BeamSampleStatistics; … … 66 67 bool mWireFrame; 67 68 69 KdTree *mKdTree; 70 68 71 QWaitCondition mRenderingFinished; 69 72 70 73 71 74 GlRenderer(SceneGraph *sceneGraph, 72 ViewCellsManager *viewcells); 75 ViewCellsManager *viewcells, 76 KdTree *tree); 73 77 74 78 ~GlRenderer(); … … 103 107 class GlRendererBuffer : public QGLPixelBuffer, public GlRenderer 104 108 { 105 106 109 public: 107 int mPvsStatFrames; 108 vector<float> mPvsErrorBuffer; 109 110 PvsRenderStatistics mPvsStat; 111 112 113 GlRendererBuffer(const int w, 114 const int h, 115 SceneGraph *sceneGraph, 116 ViewCellsManager *viewcells): 117 QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells) { 110 GlRendererBuffer(const int w, 111 const int h, 112 SceneGraph *sceneGraph, 113 ViewCellsManager *viewcells, 114 KdTree *tree): 115 QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 118 116 119 117 mPvsStatFrames = 10000; … … 125 123 doneCurrent(); 126 124 127 125 } 128 126 129 127 void … … 154 152 ); 155 153 154 PvsRenderStatistics mPvsStat; 155 156 int mPvsStatFrames; 157 vector<float> mPvsErrorBuffer; 158 156 159 private: 157 160 static void GenQueries(const int numQueries); … … 175 178 GlRendererWidget(SceneGraph *sceneGraph, 176 179 ViewCellsManager *viewcells, 180 KdTree *tree, 177 181 QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0 178 182 ): 179 GlRenderer(sceneGraph, viewcells ), QGLWidget(parent, shareWidget, f)183 GlRenderer(sceneGraph, viewcells, tree), QGLWidget(parent, shareWidget, f) 180 184 { 181 185 mTopView = false; … … 204 208 virtual int GetWidth() const { return width(); } 205 209 virtual int GetHeight() const { return height(); } 206 207 210 }; 208 211 -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r512 r532 1005 1005 } 1006 1006 1007 if (beam.mFlags & Beam::STORE_OBJECTS) 1008 { 1009 vector<KdNode *>::const_iterator it, it_end = beam.mKdNodes.end(); 1010 1011 Intersectable::NewMail(); 1012 for (it = beam.mKdNodes.begin(); it != it_end; ++ it) 1013 { 1014 CollectObjects(*it, beam.mObjects); 1015 } 1016 } 1017 1007 1018 return beam.mKdNodes.size(); 1008 1019 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r520 r532 256 256 } 257 257 if (mUseGlRenderer) 258 renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager );258 renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 259 259 260 260 return true; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r508 r532 44 44 const float epsilon) const; 45 45 46 /** Computes bounding box of the node.46 /** Computes bounding box of the geometry. 47 47 */ 48 48 void ComputeBoundingBox(AxisAlignedBox3 &box); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r527 r532 12 12 #include "VspBspTree.h" 13 13 #include "ViewCellsParser.h" 14 #include "Beam.h" 15 16 14 17 15 18 … … 311 314 } 312 315 316 317 int ViewCellsManager::CastBeam(Beam &beam) 318 { 319 return 0; 320 } 313 321 314 322 ViewCellContainer &ViewCellsManager::GetViewCells() … … 2431 2439 return true; 2432 2440 } 2441 2442 2443 int VspBspViewCellsManager::CastBeam(Beam &beam) 2444 { 2445 return 0; 2446 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r527 r532 25 25 class ViewCellsStatistics; 26 26 class Exporter; 27 class Beam; 27 28 28 29 struct BspRay; … … 246 247 virtual bool ExportViewCells(const string filename); 247 248 249 /** Casts beam to collect view cells. 250 */ 251 virtual int CastBeam(Beam &beam); 252 248 253 protected: 249 254 … … 566 571 bool ExportViewCells(const string filename); 567 572 573 int CastBeam(Beam &beam); 574 568 575 protected: 569 576 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r517 r532 16 16 #include "ViewCellBsp.h" 17 17 #include "ViewCellsManager.h" 18 18 #include "Beam.h" 19 19 20 20 //-- static members … … 1464 1464 } 1465 1465 1466 1466 1467 void VspBspTree::CollectViewCells(ViewCellContainer &viewCells) const 1468 { 1469 ViewCell::NewMail(); 1470 CollectViewCells(mRoot, viewCells, true); 1471 } 1472 1473 1474 void VspBspTree::CollectViewCells(BspNode *root, 1475 ViewCellContainer &viewCells, 1476 bool onlyUnmailed) const 1467 1477 { 1468 1478 stack<BspNode *> nodeStack; … … 1472 1482 1473 1483 nodeStack.push(mRoot); 1474 1475 ViewCell::NewMail();1476 1484 1477 1485 while (!nodeStack.empty()) … … 1486 1494 ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 1487 1495 1488 if (! viewCell->Mailed())1496 if (!onlyUnmailed || !viewCell->Mailed()) 1489 1497 { 1490 1498 viewCell->Mail(); … … 2146 2154 } 2147 2155 } 2156 } 2157 2158 2159 typedef pair<BspNode *, BspNodeGeometry *> bspNodePair; 2160 2161 int VspBspTree::CastBeam(Beam &beam) 2162 { 2163 stack<bspNodePair> nodeStack; 2164 BspNodeGeometry *rgeom = new BspNodeGeometry(); 2165 ConstructGeometry(mRoot, *rgeom); 2166 2167 nodeStack.push(bspNodePair(mRoot, rgeom)); 2168 2169 ViewCell::NewMail(); 2170 2171 while (!nodeStack.empty()) 2172 { 2173 BspNode *node = nodeStack.top().first; 2174 BspNodeGeometry *geom = nodeStack.top().second; 2175 nodeStack.pop(); 2176 2177 AxisAlignedBox3 box; 2178 geom->ComputeBoundingBox(box); 2179 2180 int side = beam.ComputeIntersection(box); 2181 2182 switch (side) 2183 { 2184 case -1: 2185 CollectViewCells(node, beam.mViewCells, true); 2186 break; 2187 case 0: 2188 if (node->IsLeaf()) 2189 { 2190 BspLeaf *leaf = dynamic_cast<BspLeaf *>(leaf); 2191 if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) 2192 beam.mViewCells.push_back(leaf->GetViewCell()); 2193 } 2194 else 2195 { 2196 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2197 BspNode *first = interior->GetBack(); 2198 BspNode *second = interior->GetFront(); 2199 2200 // decide on the order of the nodes 2201 if (DotProd(beam.mPlanes[0].mNormal, 2202 interior->GetPlane().mNormal) > 0) 2203 { 2204 swap(first, second); 2205 } 2206 2207 BspNodeGeometry *leftGeom = new BspNodeGeometry(); 2208 BspNodeGeometry *rightGeom = new BspNodeGeometry(); 2209 2210 ConstructGeometry(first, *leftGeom); 2211 ConstructGeometry(second, *rightGeom); 2212 2213 nodeStack.push(bspNodePair(first, leftGeom)); 2214 nodeStack.push(bspNodePair(second, rightGeom)); 2215 } 2216 break; 2217 // default: cull 2218 } 2219 DEL_PTR(geom); 2220 } 2221 2222 return beam.mViewCells.size(); 2148 2223 } 2149 2224 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r520 r532 22 22 class ViewCellsManager; 23 23 class BspMergeCandidate; 24 class Beam; 25 24 26 struct BspRay; 25 27 … … 286 288 bool Export(ofstream &stream); 287 289 290 /** Casts beam, i.e. a 5D frustum of rays, into tree. 291 Tests conservative using the bounding box of the nodes. 292 @returns number of view cells it intersected 293 */ 294 int CastBeam(Beam &beam); 295 296 void CollectViewCells(BspNode *root, 297 ViewCellContainer &viewCells, 298 bool onlyUnmailed = false) const; 288 299 protected: 289 300 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r531 r532 32 32 environment->GetBoolValue("VssPreprocessor.storeInitialSamples", mStoreInitialSamples); 33 33 environment->GetBoolValue("VssPreprocessor.useViewSpaceBox", mUseViewSpaceBox); 34 environment->GetBoolValue("VssPreprocessor.testBeamSampling", mTestBeamSampling); 35 34 36 useViewspacePlane = mUseViewSpaceBox; //hack 35 37 … … 349 351 350 352 351 void VssPreprocessor::TestBeamCasting(VssTree *tree) 352 { 353 353 void VssPreprocessor::TestBeamCasting(VssTree *tree, ViewCellsManager *vm) 354 { 354 355 vector<VssTreeLeaf *> leaves; 355 356 tree->CollectLeaves(leaves); … … 363 364 AxisAlignedBox3 dirBox =tree->GetDirBBox(leaf); 364 365 AxisAlignedBox3 box = tree->GetBBox(leaf); 366 365 367 beam.Construct(dirBox, box); 368 369 // collect kd leaves and view cells 370 mKdTree->CastBeam(beam); 371 vm->CastBeam(beam); 372 373 Debug << "found " << beam.mViewCells.size() << " view cells and " 374 << beam.mKdNodes.size() << " kd nodes" << endl; 375 366 376 Intersectable *sourceObj = mObjects[5]; 367 377 BeamSampleStatistics stats; … … 371 381 stats); 372 382 373 Debug << "beam statistics: " << stats << endl; 374 375 383 Debug << "beam statistics: " << stats << endl << endl; 376 384 } 377 385 … … 581 589 int pass = 0; 582 590 591 if (mTestBeamSampling) 592 TestBeamCasting(vssTree, mViewCellsManager); 593 583 594 // cast view cell samples 584 595 while (1) { -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h
r531 r532 105 105 void CastRay(const BspTree &tree, const VssRay & vssRay); 106 106 107 void TestBeamCasting(VssTree *tree); 107 void TestBeamCasting(VssTree *tre, ViewCellsManager *vm); 108 109 bool mTestBeamSampling; 108 110 }; 109 111 -
trunk/VUT/GtpVisibilityPreprocessor/src/dual_depth.cg
r530 r532 12 12 }; 13 13 14 pixel dual_depth(fragment IN, 15 const uniform sampler2D depthMap) 14 pixel main(fragment IN, const uniform sampler2D depthMap) 16 15 { 17 16 pixel OUT; -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r496 r532 94 94 if (p->mUseGlRenderer) { 95 95 96 rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager);96 rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 97 97 // renderer->resize(640, 480); 98 98 rendererWidget->resize(640, 480);
Note: See TracChangeset
for help on using the changeset viewer.