- Timestamp:
- 08/20/07 12:51:12 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 1 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBiHierarchySceneManager.cpp
r2455 r2542 72 72 } 73 73 74 74 75 BiHierarchySceneManager::~BiHierarchySceneManager(void) 75 76 { … … 77 78 delete mBiHierarchy; 78 79 } 80 79 81 80 82 void BiHierarchySceneManager::clearScene() -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
r2532 r2542 268 268 </File> 269 269 <File 270 RelativePath=".\FlexibleHeap.h">271 </File>272 <File273 270 RelativePath="..\src\FrustumCullingManager.cpp"> 274 271 </File> -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp
r2539 r2542 106 106 int nodesTested = 0; 107 107 108 #if 1 109 // test a certain ratio of random candidates 110 HierarchyNodeContainer mynodes; 111 mHierarchyInterface->CollectLeaves(node, mynodes); 112 113 const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 114 115 HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 116 117 for (nit = mynodes.begin(); nit != nit_end; ++ nit) 108 if(1) 118 109 { 119 HierarchyNode *leaf = *nit; 120 121 if (rand() > p) 122 continue; 110 // test a certain ratio of random candidates 111 HierarchyNodeContainer mynodes; 112 mHierarchyInterface->CollectLeaves(node, mynodes); 113 114 const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 115 116 HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 117 118 for (nit = mynodes.begin(); nit != nit_end; ++ nit) 119 { 120 HierarchyNode *leaf = *nit; 121 122 if (rand() > p) 123 continue; 124 125 bool intersects = false; 126 const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 127 128 // don't test in these cases ... 129 if (frustumCulled || intersects) 130 continue; 131 132 ++ nodesTested; 133 134 mHierarchyInterface->SetNodeVisible(leaf, false); 135 136 // update node's visited flag: this is important as we are not testing 137 // all nodes in the hierarchy in this mode 138 mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 139 // issue the query 140 mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 141 } 142 143 //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 144 //CullingLogManager::GetSingleton()->LogMessage(d.str()); 145 } 146 else 147 { 148 // always test one random candidate 149 HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node); 123 150 124 151 bool intersects = false; 125 152 const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 126 153 127 // don't test in these cases ... 128 if (frustumCulled || intersects) 154 if (frustumCulled || intersects) // don't test in these cases ... 129 155 continue; 130 156 131 157 ++ nodesTested; 132 158 133 159 mHierarchyInterface->SetNodeVisible(leaf, false); 134 160 … … 137 163 mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 138 164 // issue the query 139 mHierarchyInterface->IssueNodeOcclusionQuery( node, mTestGeometryForVisibleLeaves);165 mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves); 140 166 } 141 167 142 //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 143 //CullingLogManager::GetSingleton()->LogMessage(d.str()); 144 145 #else 146 // always test one random candidate 147 HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node); 148 149 bool intersects = false; 150 const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 151 152 if (frustumCulled || intersects) // don't test in these cases ... 153 continue; 154 155 ++ nodesTested; 156 157 mHierarchyInterface->SetNodeVisible(leaf, false); 158 159 // update node's visited flag: this is important as we are not testing 160 // all nodes in the hierarchy in this mode 161 mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 162 // issue the query 163 mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves); 164 165 #endif 166 168 // render the whole subtree 167 169 mHierarchyInterface->RenderNodeRecursive(node); 168 170 -
GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env
r2539 r2542 219 219 ################################################### 220 220 221 # minimal steps of same type: for interleaved, this is only valid for the first few splits221 # minimal steps of same domain (view /object): for interleaved mode 222 222 minStepsOfSameType 100 223 223 maxStepsOfSameType 900 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r2538 r2542 2393 2393 "vsp_term_max_view_cells=", 2394 2394 "10000"); 2395 2396 2395 2397 2396 RegisterOption("VspTree.Termination.missTolerance", -
GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h
r2360 r2542 34 34 35 35 36 /** This class implements a flexible heap for 37 use as a priority queue. 38 39 Unlike the stl priority_queue, the class allows access to all 40 elements. It implements efficient insertion routines and remove routines 41 of arbitrary elements. 36 /** This class implements a flexible heap for use as a priority queue. 37 Unlike the stl priority_queue, the class allows access to all 38 elements. It implements efficient insertion routines and remove routines 39 of arbitrary elements. 42 40 */ 43 41 template<typename T> … … 48 46 FlexibleHeap(const unsigned int n): mBuffer(n) { } 49 47 50 void Push(T t) { Push(t, t->GetPriority()); }48 void Push(T t); 51 49 void Push(T t, const float priority); 52 bool Update(T t) { return Update(t, t->GetPriority()); }50 bool Update(T t); 53 51 bool Update(T t, const float priority); 54 52 55 unsigned int Size() const { return (unsigned int)mBuffer.size(); }56 bool Empty() const {return mBuffer.empty(); }57 T Item(const unsigned int i) { return mBuffer[i]; }58 const T Item(const unsigned int i) const { return mBuffer[i]; }53 inline unsigned int Size() const; 54 inline bool Empty() const; 55 inline T Item(const unsigned int i); 56 inline const T Item(const unsigned int i) const; 59 57 T Pop(); 60 T Top() const { return (mBuffer.empty() ? (T)NULL : mBuffer.front()); }58 inline T Top() const; 61 59 /** Erases the element from the heap. 62 60 */ … … 79 77 80 78 81 /*****************************************************************************/ 82 /* MyHeap implementation * 83 /*****************************************************************************/ 79 80 81 /******************************************************************/ 82 /* FexibleHeap implementation */ 83 /******************************************************************/ 84 85 86 template <typename T> 87 void FlexibleHeap<T>::Push(T t) 88 { 89 Push(t, t->GetPriority()); 90 } 91 92 93 template <typename T> 94 bool FlexibleHeap<T>::Update(T t) 95 { 96 return Update(t, t->GetPriority()); 97 } 98 99 100 template <typename T> 101 inline unsigned int FlexibleHeap<T>::Size() const 102 { 103 return (unsigned int)mBuffer.size(); 104 } 105 106 107 template <typename T> 108 inline bool FlexibleHeap<T>::Empty() const 109 { 110 return mBuffer.empty(); 111 } 112 113 114 template <typename T> 115 inline T FlexibleHeap<T>::Item(const unsigned int i) 116 { 117 return mBuffer[i]; 118 } 119 120 121 template <typename T> 122 inline const T FlexibleHeap<T>::Item(const unsigned int i) const 123 { 124 return mBuffer[i]; 125 } 126 127 128 template <typename T> 129 inline T FlexibleHeap<T>::Top() const 130 { 131 return (mBuffer.empty() ? (T)NULL : mBuffer.front()); 132 } 133 84 134 85 135 template <typename T> … … 120 170 } 121 171 } 172 122 173 123 174 template <typename T> … … 200 251 mBuffer.pop_back(); 201 252 202 DownHeap(0); 253 if (!mBuffer.empty()) 254 DownHeap(0); 255 203 256 dead->NotInHeap(); 204 257 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r2539 r2542 549 549 550 550 PrepareViewSpaceSubdivision(viewSpaceQueue, sampleRays, objects); 551 551 /// q: why clear the dirty list here? 552 552 dirtyList.clear(); 553 553 // view space subdivision started -
GTP/trunk/Lib/Vis/Preprocessing/src/LogManager.h
r1112 r2542 16 16 there is always only one log manager. 17 17 */ 18 class LogManager {19 18 class LogManager 19 { 20 20 public: 21 21 … … 34 34 LogManager(); 35 35 36 37 36 ~LogManager() {} 37 38 38 void LogMessage(const std::string &str); 39 39 40 40 protected: 41 42 41 std::ofstream mOutStream; 43 42 44 43 private: 45 46 44 static LogManager *sLogManager; 47 48 45 }; 49 46 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r2176 r2542 1591 1591 } 1592 1592 1593 // andidates holdingthis view cells are thrown into dirty list1593 // candidates that contain this view cells are thrown into dirty list 1594 1594 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1595 1595 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r2538 r2542 255 255 { 256 256 mDirty = false; 257 // todo: avoid computing split plane258 257 sOspTree->EvalSubdivisionCandidate(*this); 259 258 } … … 272 271 } 273 272 274 void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 275 const bool onlyUnmailed) 273 void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, const bool onlyUnmailed) 276 274 { 277 275 sOspTree->CollectDirtyCandidates(this, dirtyList, onlyUnmailed); -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2539 r2542 509 509 if (result) 510 510 { 511 512 511 mSceneGraph->AssignObjectIds(); 513 512 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2538 r2542 462 462 if (mUseSpatialFilter) 463 463 { 464 // 9.11. 2006 -> experiment with new spatial filter465 #if 0466 mViewCellsManager->ApplySpatialFilter(mKdTree,467 mSpatialFilterSize*468 Magnitude(mViewCellsManager->GetViewSpaceBox().Size()),469 mPvsCache.mPvs);470 #else471 //cout<<"updating filter" << endl;472 464 // mSpatialFilter size is in range 0.001 - 0.1 473 465 mViewCellsManager->ApplyFilter2(viewcell, 474 mUseFilter, 475 100 * mSpatialFilterSize, 476 mPvsCache.mPvs, 477 &mPvsCache.filteredBoxes 478 ); 479 #endif 480 } 466 mUseFilter, 467 100 * mSpatialFilterSize, 468 mPvsCache.mPvs, 469 &mPvsCache.filteredBoxes); 470 } 481 471 else 482 472 { … … 496 486 if (mUseSpatialFilter && mRenderBoxes) 497 487 { 498 for (int i=0; i < mPvsCache.filteredBoxes.size(); i++) 488 for (int i=0; i < mPvsCache.filteredBoxes.size(); ++ i) 489 { 499 490 RenderBox(mPvsCache.filteredBoxes[i]); 491 } 500 492 } 501 493 else … … 507 499 else 508 500 { 501 mPvsSize = mPvsCache.mPvs.GetSize(); 502 509 503 ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 510 504 511 mPvsSize = mPvsCache.mPvs.GetSize(); 512 for (; it.HasMoreEntries(); ) 505 while (it.HasMoreEntries()) 513 506 { 514 507 Intersectable *object = it.Next(pvsData); -
GTP/trunk/Lib/Vis/Preprocessing/src/ResourceManager.h
r2176 r2542 8 8 #include "Mesh.h" 9 9 #include "Material.h" 10 11 10 12 11 13 namespace GtpVisibilityPreprocessor { … … 124 126 ResourceManager<T>() 125 127 {} 126 127 128 /** Release resources. 128 129 */ … … 137 138 } 138 139 } 139 140 140 /** Copy constructor. 141 141 */ … … 143 143 { 144 144 } 145 146 /** Helper function returning unique id for resource. 147 */ 145 /** Helper function returning unique id for resource. 146 */ 148 147 static unsigned int CreateUniqueId() 149 148 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp
r2176 r2542 37 37 Vector3 &normal) const 38 38 { 39 #if 040 VertexContainer vertices;41 vertices.push_back(mVertices[0]);42 vertices.push_back(mVertices[1]);43 vertices.push_back(mVertices[2]);44 45 Polygon3 poly(vertices);46 47 int dummy = poly.CastRay(ray, t, nearestT);48 normal = poly.GetNormal();49 50 // cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl;51 return dummy;52 #endif53 54 39 ////////////// 55 40 // specialised triangle ray casting version -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r2539 r2542 2589 2589 2590 2590 /////////////////// 2591 // Binary export2591 //-- Binary export 2592 2592 2593 2593 void ViewCellsTree::ExportBinInterior(OUT_STREAM &stream, ViewCellInterior *interior) 2594 2594 { 2595 #if TODO2596 2595 int interiorid = TYPE_INTERIOR; 2597 2596 stream.write(reinterpret_cast<char *>(&interiorid), sizeof(int)); 2598 2599 int axis = interior->GetAxis();2600 float pos = interior->GetPosition();2601 2602 stream.write(reinterpret_cast<char *>(&axis), sizeof(int));2603 stream.write(reinterpret_cast<char *>(&pos), sizeof(float));2604 #endif2605 2597 } 2606 2598 … … 2608 2600 void ViewCellsTree::ExportBinLeaf(OUT_STREAM &stream, ViewCell *leaf) 2609 2601 { 2610 #if TODO2611 2602 int type = TYPE_LEAF; 2612 2603 2613 int id = -1; 2614 if (viewCell != mOutOfBoundsCell) 2615 id = viewCell->GetId(); 2604 int id = leaf->GetId(); 2616 2605 2617 2606 stream.write(reinterpret_cast<char *>(&type), sizeof(int)); 2618 2607 stream.write(reinterpret_cast<char *>(&id), sizeof(int)); 2619 2608 2620 int pvsSize = viewCell->GetPvs().GetSize();2609 int pvsSize = leaf->GetPvs().GetSize(); 2621 2610 stream.write(reinterpret_cast<char *>(&pvsSize), sizeof(int)); 2622 2611 2623 ObjectPvsIterator pit = viewCell->GetPvs().GetIterator();2624 2625 // write PVS of view cell2612 ObjectPvsIterator pit = leaf->GetPvs().GetIterator(); 2613 2614 // write pvs 2626 2615 while (pit.HasMoreEntries()) 2627 2616 { … … 2630 2619 stream.write(reinterpret_cast<char *>(&id), sizeof(int)); 2631 2620 } 2632 #endif2633 2621 } 2634 2622 … … 2636 2624 bool ViewCellsTree::ExportBinary(OUT_STREAM &stream) 2637 2625 { 2638 #if TODO 2626 2639 2627 // export binary version of mesh 2640 2628 queue<ViewCell *> tStack; … … 2652 2640 else 2653 2641 { 2654 VspInterior *interior = static_cast<ViewCellInterior *>(node); 2655 2642 ViewCellInterior *interior = static_cast<ViewCellInterior *>(node); 2643 2644 // export current interior 2656 2645 ExportBinInterior(stream, interior); 2657 2646 2658 tStack.push(interior->GetFront()); 2659 tStack.push(interior->GetBack()); 2660 } 2661 } 2662 #endif 2647 // push children 2648 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 2649 2650 for (it = interior->mChildren.begin(); it != it_end; ++ it) 2651 { 2652 tStack.push(*it); 2653 } 2654 } 2655 } 2656 2663 2657 return true; 2664 2658 } … … 2666 2660 2667 2661 ////////////////// 2668 // import binary2662 //-- import binary 2669 2663 2670 2664 ViewCellInterior *ViewCellsTree::ImportBinInterior(IN_STREAM &stream, ViewCellInterior *parent) … … 2725 2719 2726 2720 2727 /** Data used for tree traversal2728 */2729 struct MyTraversalData2730 {2731 public:2732 2733 MyTraversalData(ViewCell *node, const int depth, const AxisAlignedBox3 &box):2734 mNode(node), mDepth(depth), mBox(box)2735 {}2736 2737 2738 //////////////////////2739 2740 /// the current node2741 ViewCell *mNode;2742 /// current depth2743 int mDepth;2744 /// the bounding box2745 AxisAlignedBox3 mBox;2746 };2747 2748 2749 2721 bool ViewCellsTree::ImportBinary(IN_STREAM &stream, const ObjectContainer &pvsObjects) 2750 2722 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2539 r2542 34 34 #define PVS_ADD_DIRTY 1 35 35 36 37 36 38 namespace GtpVisibilityPreprocessor { 37 39 … … 46 48 const static bool CLAMP_TO_BOX = true; 47 49 50 51 52 inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 53 { 54 return obj1->mId < obj2->mId; 55 } 48 56 49 57 … … 994 1002 EvaluateViewCellsStats(); 995 1003 996 if (1) CompressViewCells(); 1004 // compress the final solution 1005 if (0) CompressViewCells(); 997 1006 998 1007 // write view cells to disc … … 1021 1030 1022 1031 { 1032 if (!Debug.is_open()) Debug.open("debug.log"); 1033 1023 1034 // give just an empty container as parameter: 1024 1035 // this loading function is used in the engine, thus it 1025 1036 // does not need to load the entities the preprocessor works on 1026 1037 ObjectContainer preprocessorObjects; 1027 1028 if (!Debug.is_open()) Debug.open("debug.log");1029 1038 1030 1039 return LoadViewCells(filename, … … 1033 1042 finalizeViewCells, 1034 1043 bconverter); 1044 } 1045 1046 1047 void ViewCellsManager::LoadIndexedBoundingBoxes(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes) 1048 { 1049 Vector3 bmin; 1050 Vector3 bmax; 1051 int id; 1052 1053 stream.read(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 1054 stream.read(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 1055 stream.read(reinterpret_cast<char *>(&id), sizeof(int)); 1056 1057 AxisAlignedBox3 box(bmin, bmax); 1058 1059 iboxes.push_back(IndexedBoundingBox(id, box)); 1060 //Debug << "bbox: " << box << endl; 1061 } 1062 1063 1064 ViewCellsManager *ViewCellsManager::LoadViewCellsBin(const string &filename, 1065 ObjectContainer &pvsObjects, 1066 ObjectContainer &preprocessorObjects, 1067 bool finalizeViewCells, 1068 BoundingBoxConverter *bconverter) 1069 { 1070 IN_STREAM stream(filename.c_str()); 1071 1072 IndexedBoundingBoxContainer iboxes; 1073 LoadIndexedBoundingBoxes(stream, iboxes); 1074 1075 if (bconverter) 1076 { 1077 // all bounding boxes gathered in this step => 1078 // associate object ids with bounding boxes 1079 bconverter->IdentifyObjects(iboxes, pvsObjects); 1080 } 1081 1082 // sort objects by id 1083 sort(pvsObjects.begin(), pvsObjects.end(), ilt); 1084 1085 ViewCellsTree *vcTree = new ViewCellsTree(); 1086 VspTree *vspTree = new VspTree(); 1087 1088 HierarchyManager *hm = new HierarchyManager(0); 1089 1090 vspTree->ImportBinary(stream, pvsObjects); 1091 1092 VspOspViewCellsManager *vcm = new VspOspViewCellsManager(vcTree, hm); 1093 1094 return vcm; 1035 1095 } 1036 1096 … … 1061 1121 } 1062 1122 1063 if (0) //hack: should work with reset function, but something is wrong ..1123 if (0) //hack: reset function should work, but something is wrong .. 1064 1124 { 1065 1125 vm->ResetViewCells(); … … 1104 1164 const ObjectContainer &objects) 1105 1165 { 1166 // no view cells constructed yet 1106 1167 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 1107 {1108 1168 return false; 1109 }1110 1169 1111 1170 cout << "exporting view cells to xml ... "; … … 2424 2483 2425 2484 2426 2427 if (evaluateFilter){2485 if (evaluateFilter) 2486 { 2428 2487 ObjectPvs filteredPvs; 2429 2488 2430 PvsFilterStatistics fstat = ApplyFilter2(viewcell, 2431 false, 2432 mFilterWidth, 2433 filteredPvs); 2434 2435 float filteredCost = filteredPvs.EvalPvsCost(); 2489 PvsFilterStatistics fstat = ApplyFilter2(viewcell, false, mFilterWidth, filteredPvs); 2490 2491 const float filteredCost = filteredPvs.EvalPvsCost(); 2436 2492 2437 2493 stat.avgFilteredPvs += filteredCost; … … 3070 3126 MeshInstance *mi = static_cast<MeshInstance *>(*it); 3071 3127 const AxisAlignedBox3 box = mi->GetBox(); 3128 3072 3129 Vector3 bmin = box.Min(); 3073 3130 Vector3 bmax = box.Max(); 3131 3074 3132 int id = mi->GetId(); 3075 3133 … … 3444 3502 3445 3503 // Minimal number of samples so that filtering takes place 3446 #define MIN_SAMPLES 50 3504 const float MIN_SAMPLES = 50; 3447 3505 3448 3506 if (samples > MIN_SAMPLES) … … 3537 3595 } 3538 3596 3539 Debug << " nPvs size = " << pvs.GetSize() << endl;3597 //Debug << " nPvs size = " << pvs.GetSize() << endl; 3540 3598 3541 3599 if (!mUseKdPvs) … … 5887 5945 5888 5946 5889 Intersectable * 5890 VspOspViewCellsManager::GetIntersectable(const VssRay &ray,const bool isTermination) const5947 Intersectable *VspOspViewCellsManager::GetIntersectable(const VssRay &ray, 5948 const bool isTermination) const 5891 5949 { 5892 5950 if (mUseKdPvs) … … 6387 6445 const bool exportBounds = false; 6388 6446 6389 if (1)6390 6447 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, 6391 6448 objects, … … 6575 6632 const ObjectContainer &objects) 6576 6633 { 6634 // no view cells were computed 6577 6635 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 6578 6636 return false; 6637 6638 cout << "exporting binary" << endl; 6639 string fname("test.vc"); 6640 return ExportBinaryViewCells(fname, exportPvs, objects); 6579 6641 6580 6642 const long starttime = GetTime(); … … 6612 6674 6613 6675 stream << "<BoundingBox" << " id=\"" << id << "\"" 6614 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""6615 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;6676 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 6677 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 6616 6678 } 6679 6617 6680 stream << "</BoundingBoxes>" << endl; 6618 6681 } … … 6661 6724 const ObjectContainer &objects) 6662 6725 { 6726 // no view cells constructed yet 6663 6727 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 6664 6728 return false; … … 6678 6742 /////////////// 6679 6743 //-- export bounding boxes 6680 //-- we need the boxes to identify objects in the target engine 6681 6744 6745 // we use bounding box intersection to identify pvs objects in the target engine 6682 6746 vector<KdIntersectable *>::const_iterator kit, kit_end = mPreprocessor->mKdTree->mKdIntersectables.end(); 6683 6747 … … 6689 6753 const AxisAlignedBox3 &box = obj->GetBox(); 6690 6754 6691 // set kd node id6755 // setting the kd node id important to identify the kd node as pvs entry 6692 6756 obj->SetId(id); 6757 6693 6758 Vector3 bmin = box.Min(); 6694 6759 Vector3 bmax = box.Max(); … … 6703 6768 //-- export the view cells and the pvs 6704 6769 6705 6706 6770 int numViewCells = mCurrentViewCellsStats.viewCells; 6707 6771 stream.write(reinterpret_cast<char *>(&numViewCells), sizeof(int)); … … 6712 6776 stream.write(reinterpret_cast<char *>(&vmin), sizeof(Vector3)); 6713 6777 stream.write(reinterpret_cast<char *>(&vmax), sizeof(Vector3)); 6778 6779 // todo 6780 mViewCellsTree->ExportBinary(stream); 6714 6781 6715 6782 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2539 r2542 520 520 BoundingBoxConverter *bconverter = NULL); 521 521 522 /** Convenience function assuming that there are no preprocessor objects. 523 */ 522 524 static ViewCellsManager *LoadViewCells(const string &filename, 523 525 ObjectContainer &pvsObjects, … … 525 527 BoundingBoxConverter *bconverter = NULL); 526 528 529 ViewCellsManager *LoadViewCellsBin(const string &filename, 530 ObjectContainer &pvsObjects, 531 ObjectContainer &preprocessorObjects, 532 bool finalizeViewCells, 533 BoundingBoxConverter *bconverter); 534 535 527 536 /////////////////////// 528 // visiblity filter options537 //-- visiblity filter options 529 538 530 539 // TODO: write own visibiltiy filter class … … 636 645 const vector<int> &strategies, 637 646 VssRayContainer &vssRays) const; 638 647 /** cast samples for the purpose of evaluating the view cells solution 648 */ 639 649 int CastEvaluationSamples(const int samplesPerPass, 640 650 VssRayContainer &passSamples);// const; … … 660 670 */ 661 671 void EvaluateViewCellsStats(); 672 /** This helper function loads the bounding boxes for a binary solution. 673 */ 674 void LoadIndexedBoundingBoxes(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes); 662 675 663 676 … … 1135 1148 { 1136 1149 friend class ViewCellsParseHandlers; 1150 friend class ViewCellsManager; 1137 1151 1138 1152 public: 1139 1153 1154 /** This version takes a view cells tree and a hierarchy 1155 as input. 1156 */ 1140 1157 VspOspViewCellsManager(ViewCellsTree *vcTree, 1141 1158 const string &hierarchyType); … … 1196 1213 const string &prefix, 1197 1214 VssRayContainer *visRays = NULL); 1198 1199 ;1200 1215 /** See parent class. 1201 1216 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r2539 r2542 60 60 // can be set via the -v= command. 61 61 // --------------------------------------------------------------------------- 62 static bool doNamespaces= false;63 static bool doSchema= false;64 static bool 65 static SAXParser::ValSchemes valScheme= SAXParser::Val_Auto;62 static bool doNamespaces = false; 63 static bool doSchema = false; 64 static bool schemaFullChecking = false; 65 static SAXParser::ValSchemes valScheme = SAXParser::Val_Auto; 66 66 67 67 // hack for loading bvh nodes … … 313 313 else 314 314 { 315 // sort objects by id 315 316 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 316 317 } … … 318 319 Debug << "\nconverted bounding boxes to objects in " 319 320 << TimeDiff(startTime, GetTime()) * 1e-6 << " secs" << endl; 321 320 322 mBoxTimer.Exit(); 321 323 } … … 693 695 string attrName(StrX(attributes.getName(i)).LocalForm()); 694 696 StrX attrValue(attributes.getValue(i)); 697 695 698 const char *ptr = attrValue.LocalForm(); 696 699 … … 711 714 AxisAlignedBox3 box(bmin, bmax); 712 715 mIBoundingBoxes.push_back(IndexedBoundingBox(id, box)); 713 //Debug << "bbox: " << box << endl;714 716 } 715 717 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2539 r2542 792 792 793 793 mPlaneTimer.Exit(); 794 795 794 mEvalTimer.Entry(); 796 795 797 796 VspLeaf *leaf = static_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 797 798 798 799 799 ////////////// … … 832 832 833 833 #if COUNT_ORIGIN_OBJECTS 834 835 834 obj = (*ray).mOriginObject; 836 835 … … 838 837 { 839 838 leaf = mBvHierarchy->GetLeaf(obj); 840 841 839 UpdateContributionsToPvs(leaf, cf, sData); 842 840 } … … 3227 3225 3228 3226 void VspTree::AddCandidateToDirtyList(const VssRay &ray, 3229 const bool isTermination,3230 vector<SubdivisionCandidate *> &dirtyList,3231 const bool onlyUnmailed) const3227 const bool isTermination, 3228 vector<SubdivisionCandidate *> &dirtyList, 3229 const bool onlyUnmailed) const 3232 3230 3233 3231 { 3234 3232 #if HACK_PERFORMANCE 3235 3236 3233 Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject; 3237 3234 … … 3251 3248 } 3252 3249 #else 3253 3254 3250 SubdivisionCandidate *candidate = NULL; 3255 3251 … … 3379 3375 // simple render cost evaluation 3380 3376 if (-- leaf->mCounter == 0) 3381 //pvs += (int)leaf->mObjects.size();3382 3377 pvs += BvHierarchy::EvalAbsCost(leaf->mObjects); 3378 3383 3379 break; 3384 3380 } … … 3466 3462 return pvsSize; 3467 3463 #endif 3468 3469 3464 } 3470 3465 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r2332 r2542 254 254 { 255 255 //debuggerWidget = new GlDebuggerWidget(renderer); 256 // 256 //renderer->resize(640, 480); 257 257 //debuggerWidget->resize(640, 480); 258 258 … … 265 265 exporter->ExportGeometry(objects); 266 266 exporter->SetFilled(); 267 267 268 //Randomize(); 268 // §§matt 269 // debuggerWidget = new GlDebuggerWidget(renderer); 270 271 /*debuggerWidget->mBeam = beam; 269 //§§matt 270 //debuggerWidget = new GlDebuggerWidget(renderer); 271 272 /* 273 debuggerWidget->mBeam = beam; 272 274 debuggerWidget->mSourceObject = sourceObj; 273 275 debuggerWidget->mSamples = 10000; … … 276 278 debuggerWidget->show(); 277 279 278 renderer->makeCurrent();*/ 280 renderer->makeCurrent(); 281 */ 279 282 280 283 for (int i = 0; i < 10; ++ i) … … 299 302 300 303 BeamSampleStatistics stats; 301 // §§matt 302 /* renderer->SampleBeamContributions(sourceObj, 304 305 // §§matt 306 /* 307 renderer->SampleBeamContributions(sourceObj, 303 308 beam, 304 309 200000, … … 310 315 image.save(s, "PNG"); 311 316 Debug << "beam statistics: " << stats << endl << endl; 312 */ 317 */ 318 313 319 if (1) 314 320 { … … 321 327 } 322 328 323 bool exportViewCells = false; 329 const bool exportViewCells = false; 330 324 331 if (exportViewCells) 325 332 { … … 338 345 exporter->ExportViewCell(*it); 339 346 } 340 341 /*vector<KdNode *>::const_iterator it, it_end = beam.mKdNodes.end();342 343 for (it = beam.mKdNodes.begin(); it != beam.mKdNodes.end(); ++ it)344 {345 exporter->ExportBox(mKdTree->GetBox((*it)));346 }*/347 347 } 348 348 } 349 /*while (1) 350 { debuggerWidget->repaint(); 351 };*/ 349 352 350 delete exporter; 353 351 } … … 376 374 int totalSamples = 0; 377 375 378 //mSceneGraph->CollectObjects(&mObjects);379 380 376 if (!mLoadViewCells) 381 377 { 382 //-- generate new view cells from the scratch 383 //-- for construction the manager uses it's own set of samples 378 // generate new view cells from the scratch using coarse sampling 384 379 ConstructViewCells(); 385 380 } … … 387 382 else 388 383 { 389 //-- load view cells from file 390 //-- test successful view cells loading by exporting them again 391 VssRayContainer dummies; 392 mViewCellsManager->Visualize(mObjects, dummies); 384 // load view cells from file 385 // we test success by exporting view cells again 386 VssRayContainer dummyContainer; 387 mViewCellsManager->Visualize(mObjects, dummyContainer); 388 393 389 mViewCellsManager->ExportViewCells("test.xml.zip", mViewCellsManager->GetExportPvs(), mObjects); 394 390 } … … 401 397 { 402 398 cout << "Loading samples from file ... "; 399 403 400 LoadSamples(mVssRays, mObjects); 401 404 402 cout << "finished\n" << endl; 405 403 totalSamples = (int)mVssRays.size();
Note: See TracChangeset
for help on using the changeset viewer.