- Timestamp:
- 01/11/06 15:50:37 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r511 r516 1649 1649 RegisterOption("RssTree.maxRays", optInt, "rss_max_rays=", "2000000"); 1650 1650 1651 RegisterOption("RssTree.perObjectTree", optBool, "rss_per_object_tree", "false"); 1652 1651 1653 RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false"); 1652 1654 RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false"); -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r513 r516 406 406 { 407 407 static int glList = -1; 408 if (glList != -1) { 409 glCallList(glList); 410 } else { 408 if (glList == -1) { 411 409 glList = glGenLists(1); 412 glNewList(glList, GL_COMPILE _AND_EXECUTE);410 glNewList(glList, GL_COMPILE); 413 411 ObjectContainer::const_iterator oi = mObjects.begin(); 414 412 for (; oi != mObjects.end(); oi++) … … 416 414 glEndList(); 417 415 } 416 glCallList(glList); 418 417 return true; 419 418 } … … 571 570 Beam &beam, 572 571 const int desiredSamples, 573 BeamSampleStatistics &stat)572 GlRendererBuffer::BeamSampleStatistics &stat) 574 573 { 575 574 // TODO: should not be done every time here … … 607 606 608 607 SampleViewpointContributions(sourceObject, 608 viewPoint, 609 609 beam, 610 610 directionalSamples, … … 624 624 625 625 void GlRendererBuffer::SampleViewpointContributions(Intersectable *sourceObject, 626 const Vector3 viewPoint, 626 627 Beam &beam, 627 628 const int desiredSamples, -
trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
r507 r516 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.0) on: s o 7. I 10:49:27 20063 # Generated by qmake (2.00a) (Qt 4.1.0) on: st 11. I 15:48:57 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r508 r516 15 15 static bool useViewSpaceBox = true; 16 16 static bool use2dSampling = false; 17 18 19 // not supported anymore! 17 20 static bool fromBoxVisibility = false; 18 21 … … 644 647 if (mUseImportanceSampling) { 645 648 646 if (fromBoxVisibility)647 rssTree->Construct(mVssRays, mViewSpaceBox);648 else649 rssTree->Construct(mVssRays, NULL);649 // if (fromBoxVisibility) 650 // rssTree->Construct(mObjects, mVssRays, mViewSpaceBox); 651 // else 652 rssTree->Construct(mObjects, mVssRays); 650 653 651 654 rssTree->stat.Print(mStats); -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp
r507 r516 163 163 environment->GetIntValue("RssTree.maxRays", mMaxRays); 164 164 165 root = NULL; 165 environment->GetBoolValue("RssTree.perObjectTree", mPerObjectTree); 166 167 // mRoots; 166 168 167 169 splitCandidates = new vector<SortableEntry>; … … 171 173 RssTree::~RssTree() 172 174 { 173 if (root) 174 delete root; 175 for (int i=0; i < mRoots.size(); i++) 176 if (mRoots[i]) 177 delete mRoots[i]; 175 178 } 176 179 … … 301 304 void 302 305 RssTree::Construct( 303 VssRayContainer &rays, 306 ObjectContainer &objects, 307 VssRayContainer &rays 304 308 // forced bounding box is only used when computing from-box 305 309 // visibility 306 AxisAlignedBox3 *forcedBoundingBox310 // AxisAlignedBox3 *forcedBoundingBox 307 311 ) 308 312 { 313 cout<<"Constructing rss tree"<<endl<<flush; 309 314 stat.Start(); 310 315 311 316 maxMemory = maxStaticMemory; 312 317 313 if (root) 314 delete root; 315 316 317 root = new RssTreeLeaf(NULL, rays.size()); 318 // first construct a leaf that will get subdivide 319 RssTreeLeaf *leaf = (RssTreeLeaf *) root; 320 321 stat.nodes = 1; 322 323 bbox.Initialize(); 324 dirBBox.Initialize(); 325 326 327 mForcedBoundingBox = forcedBoundingBox; 318 // if (root) 319 // delete root; 320 321 if (mPerObjectTree) { 322 // get max id from the rays 323 int i; 324 mRoots.resize(objects.size()); 325 for (i = 0; i < objects.size(); i++) { 326 RssTreeLeaf *leaf = new RssTreeLeaf(NULL, 0); 327 // leaf->bbox.Initialize(); 328 leaf->dirBBox.Initialize(); 329 leaf->dirBBox.SetMin(2, 0.0f); 330 leaf->dirBBox.SetMax(2, 1.0f); 331 332 mRoots[i] = leaf; 333 } 334 // init spatial bounding boxes 335 for (i = 0; i < objects.size(); i++) { 336 GetRoot(objects[i])->bbox = objects[i]->GetBox(); 337 } 338 339 stat.nodes = i; 340 } else { 341 mRoots.resize(1); 342 RssTreeLeaf *leaf = new RssTreeLeaf(NULL, rays.size()); 343 leaf->bbox.Initialize(); 344 leaf->dirBBox.Initialize(); 345 leaf->dirBBox.SetMin(2, 0.0f); 346 leaf->dirBBox.SetMax(2, 1.0f); 347 mRoots[0] = leaf; 348 stat.nodes = 1; 349 } 350 328 351 for(VssRayContainer::const_iterator ri = rays.begin(); 329 ri != rays.end(); 330 ri++) { 331 332 RssTreeNode::RayInfo info(*ri); 333 if (forcedBoundingBox) 334 if (!ClipRay(info, *forcedBoundingBox)) 335 continue; 336 337 leaf->AddRay(info); 338 339 bbox.Include((*ri)->GetOrigin()); 340 bbox.Include((*ri)->GetTermination()); 341 342 343 dirBBox.Include(Vector3( 344 (*ri)->GetDirParametrization(0), 345 (*ri)->GetDirParametrization(1), 346 0 347 ) 348 ); 349 } 350 352 ri != rays.end(); 353 ri++) { 354 355 RssTreeNode::RayInfo info(*ri); 356 357 // first construct a leaf that will get subdivide 358 RssTreeLeaf *leaf = (RssTreeLeaf *) GetRoot(info.GetObject()); 359 360 leaf->AddRay(info); 361 362 // leaf bbox contains bbox of origins only 363 leaf->bbox.Include((*ri)->GetOrigin()); 364 365 // include both origin and terminatin in the global bbox 366 bbox.Include((*ri)->GetOrigin()); 367 bbox.Include((*ri)->GetTermination()); 368 369 Vector3 dVec = Vector3( 370 (*ri)->GetDirParametrization(0), 371 (*ri)->GetDirParametrization(1), 372 0 373 ); 374 375 leaf->dirBBox.Include(dVec); 376 dirBBox.Include(dVec); 377 } 378 351 379 // make the z axis (unused) a unit size 352 380 // important for volume computation 353 dirBBox.SetMin(2, 0.0f); 354 dirBBox.SetMax(2, 1.0f); 355 356 if ( forcedBoundingBox ) 357 bbox = *forcedBoundingBox; 358 381 382 383 // if ( forcedBoundingBox ) 384 // bbox = *forcedBoundingBox; 385 359 386 cout<<"Bbox = "<<bbox<<endl; 360 387 cout<<"Dirr Bbox = "<<dirBBox<<endl; 361 362 stat.rays = leaf->rays.size(); 363 UpdatePvsSize(leaf); 364 365 stat.initialPvsSize = leaf->GetPvsSize(); 366 // Subdivide(); 367 root = Subdivide(TraversalData(leaf, bbox, 0)); 368 388 389 stat.rays = rays.size(); 390 stat.initialPvsSize = 0; 391 for (int i=0; i < mRoots.size(); i++) { 392 RssTreeLeaf *leaf = (RssTreeLeaf *)mRoots[i]; 393 stat.initialPvsSize += leaf->GetPvsSize(); 394 UpdatePvsSize(leaf); 395 mRoots[i] = Subdivide(TraversalData(leaf, GetBBox(leaf), 0)); 396 } 397 369 398 if (splitCandidates) { 370 399 // force realease of this vector … … 386 415 // stack<TraversalData> tStack; 387 416 388 tStack.push(TraversalData(root, bbox, 0)); 389 417 // tStack.push(TraversalData(root, bbox, 0)); 418 PushRoots(tStack); 419 390 420 AxisAlignedBox3 backBox; 391 421 AxisAlignedBox3 frontBox; … … 1071 1101 node->axis = axis; 1072 1102 node->position = info.position; 1073 node->bbox = box; 1074 node->dirBBox = GetDirBBox(leaf); 1075 1076 backBBox = box; 1077 frontBBox = box; 1103 // node->bbox = box; 1104 // node->dirBBox = GetDirBBox(leaf); 1105 1078 1106 1079 1107 RssTreeLeaf *back = new RssTreeLeaf(node, info.raysBack); 1080 1108 RssTreeLeaf *front = new RssTreeLeaf(node, info.raysFront); 1081 1109 1110 1082 1111 // update halton generator 1083 1112 back->halton.index = leaf->halton.index; … … 1089 1118 // and setup child links 1090 1119 node->SetupChildLinks(back, front); 1091 1120 1121 back->bbox = leaf->bbox; 1122 front->bbox = leaf->bbox; 1123 back->dirBBox = leaf->dirBBox; 1124 front->dirBBox = leaf->dirBBox; 1125 1092 1126 if (axis <= RssTreeNode::SPLIT_Z) { 1093 backBBox.SetMax(axis, info.position); 1094 frontBBox.SetMin(axis, info.position); 1095 } 1096 1127 back->bbox.SetMax(axis, info.position); 1128 front->bbox.SetMin(axis, info.position); 1129 } else { 1130 back->dirBBox.SetMax(axis-3, info.position); 1131 front->dirBBox.SetMin(axis-3, info.position); 1132 } 1133 1097 1134 for(RssTreeNode::RayInfoContainer::iterator ri = leaf->rays.begin(); 1098 1135 ri != leaf->rays.end(); … … 1117 1154 // distribute the total number of rays according to the distribution 1118 1155 // of rays which remained 1119 1120 1121 1156 // front->mTotalRays = front->rays.size()*leaf->mTotalRays/leaf->rays.size(); 1122 1157 // back->mTotalRays = back->rays.size()*leaf->mTotalRays/leaf->rays.size(); … … 1157 1192 int released; 1158 1193 1159 tstack.push(root);1194 PushRoots(tstack); 1160 1195 1161 1196 while (!tstack.empty()) { … … 1267 1302 ri++) { 1268 1303 RssTreeNode::RayInfo info(*ri); 1269 if (mForcedBoundingBox==NULL || ClipRay(info, bbox))1270 1304 // if (mForcedBoundingBox==NULL || ClipRay(info, bbox)) 1305 AddRay(info); 1271 1306 } 1272 1307 … … 1294 1329 stack<RayTraversalData> tstack; 1295 1330 1296 tstack.push(RayTraversalData(root, RssTreeNode::RayInfo(ray)));1331 PushRoots(tstack, RssTreeLeaf::RayInfo(ray)); 1297 1332 1298 1333 RayTraversalData data; … … 1374 1409 1375 1410 stack<RayTraversalData> tstack; 1376 1411 1412 RssTreeNode *root = GetRoot(info.GetObject()); 1377 1413 tstack.push(RayTraversalData(root, info)); 1378 1414 … … 1534 1570 { 1535 1571 stack<RssTreeNode *> tstack; 1536 tstack.push(root);1572 PushRoots(tstack); 1537 1573 1538 1574 Intersectable::NewMail(); … … 1581 1617 { 1582 1618 stack<RssTreeNode *> tstack; 1583 tstack.push(root);1619 PushRoots(tstack); 1584 1620 1585 1621 Intersectable::NewMail(); … … 1625 1661 { 1626 1662 stack<RssTreeNode *> tstack; 1627 tstack.push(root);1663 PushRoots(tstack); 1628 1664 1629 1665 float sumPvsSize = 0.0f; … … 1695 1731 { 1696 1732 stack<RssTreeNode *> tstack; 1697 tstack.push(root);1733 PushRoots(tstack); 1698 1734 1699 1735 while (!tstack.empty()) { … … 1730 1766 { 1731 1767 stack<RssTreeNode *> tstack; 1732 tstack.push(root);1768 PushRoots(tstack); 1733 1769 1734 1770 while (!tstack.empty()) { … … 2310 2346 float contributionThreshold = allRays[desired]->mWeightedPvsContribution; 2311 2347 2312 tstack.push(root);2348 PushRoots(tstack); 2313 2349 2314 2350 while (!tstack.empty()) { … … 2328 2364 } else { 2329 2365 // prune random rays from each leaf so that the ratio's remain the same 2330 tstack.push(root);2366 PushRoots(tstack); 2331 2367 float ratio = desired/(float)stat.rayRefs; 2332 2368 … … 2413 2449 { 2414 2450 stack<RssTreeNode *> tstack; 2415 tstack.push(root);2451 PushRoots(tstack); 2416 2452 2417 2453 int sumPvs = 0; … … 2705 2741 2706 2742 stack<RssTreeNode *> tstack; 2707 tstack.push(root);2743 PushRoots(tstack); 2708 2744 2709 2745 while (!tstack.empty()) { … … 2731 2767 } 2732 2768 2769 2770 RssTreeNode * 2771 RssTree::GetRoot(Intersectable *object) const 2772 { 2773 if (mPerObjectTree && object) { 2774 int id = object->GetId(); 2775 if (id >= mRoots.size()) 2776 id = mRoots.size()-1; // $$ last tree is used by all unsigned objects 2777 return mRoots[id]; 2778 } else 2779 return mRoots[0]; 2780 } 2781 2782 void 2783 RssTree::PushRoots(priority_queue<TraversalData> &st) const 2784 { 2785 for (int i=0; i < mRoots.size(); i++) 2786 st.push(TraversalData(mRoots[i], GetBBox(mRoots[i]), 0)); 2787 } 2788 2789 void 2790 RssTree::PushRoots(stack<RssTreeNode *> &st) const 2791 { 2792 for (int i=0; i < mRoots.size(); i++) 2793 st.push(mRoots[i]); 2794 } 2795 2796 void 2797 RssTree::PushRoots(stack<RayTraversalData> &st, RssTreeNode::RayInfo &info) const 2798 { 2799 for (int i=0; i < mRoots.size(); i++) 2800 st.push(RayTraversalData(mRoots[i], info)); 2801 } -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h
r512 r516 300 300 // 301 301 ///////////////////////////////// 302 303 304 // the bbox of the node 305 AxisAlignedBox3 bbox; 306 307 // the bbox of the node 308 AxisAlignedBox3 dirBBox; 309 302 310 303 311 inline RssTreeNode(RssTreeInterior *p); … … 333 341 RssTreeNode *back, *front; 334 342 335 // the bbox of the node336 AxisAlignedBox3 bbox;337 338 // the bbox of the node339 AxisAlignedBox3 dirBBox;340 343 341 344 // data for caching … … 611 614 ///////////////////////////// 612 615 // The core pointer 613 RssTreeNode *root; 616 vector<RssTreeNode *> mRoots; 617 618 614 619 615 620 ///////////////////////////// … … 618 623 // total number of nodes of the tree 619 624 int nodes; 625 620 626 // axis aligned bounding box of the scene 621 627 AxisAlignedBox3 bbox; … … 625 631 626 632 // forced bounding box for from viewcell visibility 627 AxisAlignedBox3 *mForcedBoundingBox;633 // AxisAlignedBox3 *mForcedBoundingBox; 628 634 629 635 ///////////////////////////// … … 652 658 float termMaxRayContribution; 653 659 654 655 660 // randomized construction 656 661 bool randomize; 662 663 // use a root per object in the tree 664 bool mPerObjectTree; 657 665 658 666 // type of the splitting to use fo rthe tree construction … … 711 719 virtual void 712 720 Construct( 713 VssRayContainer &rays, 714 AxisAlignedBox3 *forcedBoundingBox = NULL 721 ObjectContainer &objects, 722 VssRayContainer &rays 723 // AxisAlignedBox3 *forcedBoundingBox = NULL 715 724 ); 716 725 … … 849 858 850 859 AxisAlignedBox3 GetBBox(const RssTreeNode *node) const { 851 if (node->parent == NULL) 852 return bbox; 853 854 if (!node->IsLeaf()) 855 return ((RssTreeInterior *)node)->bbox; 856 857 if (node->parent->axis >= 3) 858 return node->parent->bbox; 860 return node->bbox; 861 862 // if (node->parent == NULL) 863 // return bbox; 864 865 // if (!node->IsLeaf()) 866 // return ((RssTreeInterior *)node)->bbox; 867 868 // if (node->parent->axis >= 3) 869 // return node->parent->bbox; 859 870 860 AxisAlignedBox3 box(node->parent->bbox);861 if (node->parent->front == node)862 box.SetMin(node->parent->axis, node->parent->position);863 else864 box.SetMax(node->parent->axis, node->parent->position);865 return box;871 // AxisAlignedBox3 box(node->parent->bbox); 872 // if (node->parent->front == node) 873 // box.SetMin(node->parent->axis, node->parent->position); 874 // else 875 // box.SetMax(node->parent->axis, node->parent->position); 876 // return box; 866 877 } 867 878 … … 869 880 870 881 AxisAlignedBox3 GetDirBBox(const RssTreeNode *node) const { 871 872 if (node->parent == NULL)873 return dirBBox;882 return node->dirBBox; 883 // if (node->parent == NULL) 884 // return dirBBox; 874 885 875 if (!node->IsLeaf() )876 return ((RssTreeInterior *)node)->dirBBox;877 878 if (node->parent->axis < 3)879 return node->parent->dirBBox;886 // if (!node->IsLeaf() ) 887 // return ((RssTreeInterior *)node)->dirBBox; 888 889 // if (node->parent->axis < 3) 890 // return node->parent->dirBBox; 880 891 881 AxisAlignedBox3 dBBox(node->parent->dirBBox);882 883 if (node->parent->front == node)884 dBBox.SetMin(node->parent->axis - 3, node->parent->position);885 else886 dBBox.SetMax(node->parent->axis - 3, node->parent->position);887 return dBBox;892 // AxisAlignedBox3 dBBox(node->parent->dirBBox); 893 894 // if (node->parent->front == node) 895 // dBBox.SetMin(node->parent->axis - 3, node->parent->position); 896 // else 897 // dBBox.SetMax(node->parent->axis - 3, node->parent->position); 898 // return dBBox; 888 899 } 889 900 … … 978 989 ); 979 990 980 RssTreeNode *GetRoot( ) const { return root; }991 RssTreeNode *GetRoot(Intersectable *object = NULL) const; 981 992 982 993 bool … … 1053 1064 vector<RssTreeLeaf::SilhouetteRays> &rays 1054 1065 ); 1055 1066 1067 void 1068 PushRoots(priority_queue<TraversalData> &stack) const; 1069 1070 void 1071 PushRoots(stack<RssTreeNode *> &st) const; 1072 1073 void 1074 PushRoots(stack<RayTraversalData> &st, RssTreeNode::RayInfo &info) const; 1075 1076 1056 1077 }; 1057 1078 -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r507 r516 69 69 RssPreprocessor { 70 70 samplesPerPass 100000 71 initialSamples 100000071 initialSamples 500000 72 72 vssSamples 10000000 73 73 vssSamplesPerPass 500000 … … 94 94 95 95 epsilon 1e-6 96 perObjectTree true 96 97 97 98 maxDepth 40 … … 105 106 maxStaticMemory 100 106 107 107 #splitType regular108 splitType regular 108 109 # splitType heuristic 109 splitType hybrid110 # splitType hybrid 110 111 splitUseOnlyDrivingAxis true 111 112 importanceBasedCost false … … 169 170 #type kdTree 170 171 #type vspKdTree 171 #type bspTree172 type vspBspTree172 type bspTree 173 #type vspBspTree 173 174 174 175 #type sceneDependent -
trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro
r505 r516 4 4 5 5 #win32:INCLUDEPATH += c:/STLport-4.6.2/stlport 6 win32:INCLUDEPATH += "d:/Programs/NVIDIA Corporation/Cg/include" 6 7 7 8 unix:INCLUDEPATH += ../support/src/xerces-c-src_2_7_0/include … … 10 11 11 12 12 win32:LIBPATH += ../support/xerces/lib ../support/devil/lib 13 win32:LIBPATH += ../support/xerces/lib ../support/devil/lib "d:/Programs/NVIDIA Corporation/Cg/lib" 13 14 unix:LIBPATH += ../support/src/xerces-c-src_2_7_0/lib ../support/devil/lib /usr/lib/qt3/lib64 14 15 … … 25 26 QT += opengl 26 27 27 win32:LIBS += xerces-c_2.lib devil.lib ilu.lib ilut.lib 28 win32:LIBS += xerces-c_2.lib devil.lib ilu.lib ilut.lib cg.lib cgGL.lib 28 29 unix:LIBS += -lxerces-c -lIL -lILU -lILUT 29 30 … … 43 44 RenderSimulator.cpp VspKdTree.cpp RayInfo.cpp RssTree.cpp RssPreprocessor.cpp \ 44 45 ViewCellsManager.cpp VspBspTree.cpp GlRenderer.cpp \ 45 PreprocessorThread.cpp Renderer.cpp Beam.cpp 46 PreprocessorThread.cpp Renderer.cpp Beam.cpp ViewCellsParser.cpp 46 47
Note: See TracChangeset
for help on using the changeset viewer.