- Timestamp:
- 10/06/05 02:53:00 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r310 r311 1150 1150 "10"); 1151 1151 1152 RegisterOption("ViewCells. type",1152 RegisterOption("ViewCells.hierarchyType", 1153 1153 optString, 1154 "-view_cells ",1155 " BSP");1154 "-view_cells_hierarchy_type", 1155 "bspTree"); 1156 1156 1157 1157 RegisterOption("ViewCells.filename", 1158 1158 optString, 1159 "-view cells_filename=",1159 "-view_cells_filename=", 1160 1160 "atlanta_viewcells_large.x3d"); 1161 1161 -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r245 r311 797 797 // $$ JB TEMPORARY solution -> should add object PVS or explictly computed 798 798 // kd tree PVS 799 if (leaf->mKdPvs.Add NodeSample(node))799 if (leaf->mKdPvs.AddSample(node)) 800 800 totalPvsSize++; 801 801 } -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h
r245 r311 162 162 163 163 void AddPassingRay(const Ray &ray, const int contributions) { 164 Debug << "here2" << endl; 164 165 mPassingRays.AddRay(ray, contributions); 166 Debug << "here4" << endl; 165 167 } 166 168 -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp
r310 r311 1 1 #include <iostream> 2 #include "Pvs.h" 3 2 4 using namespace std; 3 #include "Pvs.h"4 #include "Intersectable.h"5 6 7 /*8 int mypvs::AddSample(T *sample)9 {10 int result;11 12 PvsData<typename T> *data = Find(sample);13 if (data) {14 data->mVisibleSamples++;15 result = 0;16 } else {17 mEntries[node] = PvsData<typename T>(1);18 result = 1;19 }20 return result;21 }22 5 23 6 24 7 25 */ 26 KdPvsData * 27 KdPvs::Find(KdNode *node) 8 int 9 KdPvs::Compress() 28 10 { 29 KdPvsMap::iterator i = mEntries.find(node); 30 if (i != mEntries.end()) { 31 // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl; 32 return &(*i).second; 33 } else 34 return NULL; 11 return 0; // TODO 35 12 } 36 37 int38 KdPvs::AddNodeSample(KdNode *node)39 {40 int result;41 42 KdPvsData *data = Find(node);43 if (data) {44 data->mVisibleSamples++;45 result = 0;46 } else {47 mEntries[node] = KdPvsData(1);48 result = 1;49 }50 return result;51 }52 53 54 void55 KdPvs::GetData(const int index,56 KdNode *&node,57 KdPvsData &data58 )59 {60 KdPvsMap::iterator i = mEntries.begin();61 for (int k = 0; k!=index && i != mEntries.end(); i++, k++);62 node = (*i).first;63 data = (*i).second;64 }65 66 BspPvsData *BspPvs::Find(BspNode *node)67 {68 BspPvsMap::iterator i = mEntries.find(node);69 70 if (i != mEntries.end())71 {72 // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl;73 return &(*i).second;74 }75 else76 return NULL;77 }78 79 // TODO: Get common ancestor for bsp and kd tree (HierarchyNode)80 int BspPvs::AddNodeSample(BspNode *node)81 {82 int result;83 84 BspPvsData *data = Find(node);85 86 if (data)87 {88 data->mVisibleSamples ++;89 result = 0;90 }91 else92 {93 mEntries[node] = BspPvsData(1);94 result = 1;95 }96 97 return result;98 }99 100 101 void BspPvs::GetData(const int index, BspNode *&node, BspPvsData &data)102 {103 BspPvsMap::iterator i = mEntries.begin();104 105 for (int k = 0; k!=index && i != mEntries.end(); i++, k++);106 107 node = (*i).first;108 data = (*i).second;109 }110 111 ViewCellPvsData *ViewCellPvs::Find(Intersectable *obj)112 {113 ViewCellPvsMap::iterator i = mEntries.find(obj);114 115 if (i != mEntries.end())116 {117 // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl;118 return &(*i).second;119 }120 else121 return NULL;122 }123 124 int ViewCellPvs::AddObject(Intersectable *obj)125 {126 int result;127 128 ViewCellPvsData *data = Find(obj);129 130 if (data)131 {132 data->mVisibleSamples ++;133 result = 0;134 }135 else136 {137 mEntries[obj] = ViewCellPvsData(1);138 result = 1;139 }140 141 return result;142 }143 144 void ViewCellPvs::GetData(const int index, Intersectable *&obj, ViewCellPvsData &data)145 {146 ViewCellPvsMap::iterator i = mEntries.begin();147 148 for (int k = 0; k!=index && i != mEntries.end(); i++, k++);149 150 obj = (*i).first;151 data = (*i).second;152 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r310 r311 12 12 template<typename T> 13 13 struct LtSample { 14 bool operator()(const T *a, const T *b) const14 bool operator()(const T a, const T b) const 15 15 { 16 16 return a < b; … … 24 24 int mVisibleSamples; 25 25 PvsData<T>() {} 26 PvsData<T>(const int samples): mVisibleSamples(samples) {}26 PvsData<T>(const int samples): mVisibleSamples(samples) {} 27 27 }; 28 28 29 29 template<typename T> 30 class mypvs30 class Pvs 31 31 { 32 32 public: 33 mypvs(): mSamples(0), mEntries() {}33 Pvs(): mSamples(0), mEntries() {} 34 34 int mSamples; 35 35 36 //int Compress() {return 0;}36 int Compress() {return 0;} 37 37 int GetSize() {return (int)mEntries.size();} 38 38 … … 48 48 49 49 template <typename T> 50 PvsData<T> * mypvs<T>::Find(T sample)50 PvsData<T> *Pvs<T>::Find(T sample) 51 51 { 52 /*std::map<T *, PvsData<T>, LtSample<T> >::iterator i = mEntries.find(sample);52 std::map<T, PvsData<T>, LtSample<T> >::iterator i = mEntries.find(sample); 53 53 if (i != mEntries.end()) { 54 54 return &(*i).second; 55 } else */55 } else 56 56 return NULL; 57 57 } 58 58 59 59 template <typename T> 60 void mypvs<T>::GetData(const int index,60 void Pvs<T>::GetData(const int index, 61 61 T &entry, 62 62 PvsData<T> &data) 63 63 { 64 /*PvsMap<typename T>::iterator i = mEntries.begin();64 std::map<T, PvsData<T>, LtSample<T> >::iterator i = mEntries.begin(); 65 65 for (int k = 0; k != index && i != mEntries.end(); i++, k++); 66 66 67 67 entry = (*i).first; 68 data = (*i).second; */68 data = (*i).second; 69 69 } 70 70 71 struct LtKdNode 71 template <typename T> 72 int Pvs<T>::AddSample(T sample) 72 73 { 73 bool operator()(const KdNode *a, 74 const KdNode *b) const 75 { 76 return a < b; 77 } 78 74 int result; 75 PvsData<T> *data = Find(sample); 76 77 if (data) 78 { 79 data->mVisibleSamples ++; 80 result = 0; 81 82 } 83 else 84 { 85 mEntries[sample] = PvsData<T>(1); 86 result = 1; 87 } 88 89 return result; 90 } 91 92 /** Class instantiating the Pvs template for kd tree nodes. 93 */ 94 class KdPvs: public Pvs<KdNode *> 95 { 96 int Compress(); 79 97 }; 80 98 81 /** Superclass for all types of PVS data. 82 */ 83 class Pvs { 84 public: 85 Pvs(): mSamples(0) {} 86 int mSamples; 99 typedef std::map<KdNode *, PvsData<KdNode *>, LtSample<KdNode *> > KdPvsMap; 100 typedef PvsData<KdNode *> KdPvsData; 87 101 88 virtual int Compress() = 0; 89 virtual int GetSize() = 0; 90 }; 91 92 struct KdPvsData { 93 int mVisibleSamples; 94 KdPvsData() {} 95 KdPvsData(const int samples):mVisibleSamples(samples) {} 96 }; 97 98 typedef std::map<KdNode *, KdPvsData, LtKdNode> KdPvsMap; 99 100 101 class KdPvs: public Pvs { 102 public: 103 104 KdPvsMap mEntries; 105 106 KdPvs():mEntries() {} 107 108 KdPvsData *Find(KdNode *node); 109 int AddNodeSample(KdNode *node); 110 int Compress() {return 0;} 111 int GetSize() { return (int)mEntries.size(); } 112 void GetData(const int index, 113 KdNode *&node, 114 KdPvsData &data 115 ); 116 117 }; 118 119 struct LtBspNode 120 { 121 bool operator()(const BspNode *a, 122 const BspNode *b) const 123 { 124 return a < b; 125 } 126 }; 127 128 struct BspPvsData { 129 int mVisibleSamples; 130 BspPvsData() {} 131 BspPvsData(const int samples): mVisibleSamples(samples) {} 132 }; 133 134 typedef std::map<BspNode *, BspPvsData, LtBspNode> BspPvsMap; 135 136 class BspPvs: public Pvs 137 { 138 public: 139 BspPvs(): mEntries() {} 140 141 BspPvsMap mEntries; 142 143 BspPvsData *Find(BspNode *node); 144 int AddNodeSample(BspNode *node); 145 146 int Compress() {return 0;} 147 148 int GetSize() {return (int)mEntries.size();} 149 150 void GetData(const int index, 151 BspNode *&node, 152 BspPvsData &data); 153 }; 154 155 156 struct LtIntersectable 157 { 158 bool operator()(const Intersectable *a, 159 const Intersectable *b) const 160 { 161 return a < b; 162 } 163 }; 164 165 struct ViewCellPvsData { 166 int mVisibleSamples; 167 ViewCellPvsData() {} 168 ViewCellPvsData(const int samples): mVisibleSamples(samples) {} 169 }; 170 171 typedef std::map<Intersectable *, ViewCellPvsData, LtIntersectable> ViewCellPvsMap; 172 173 class ViewCellPvs 174 { 175 public: 176 ViewCellPvs(): mEntries() {} 177 178 ViewCellPvsMap mEntries; 179 180 int Compress() {return 0;} 181 int GetSize() {return (int)mEntries.size();} 182 183 ViewCellPvsData *Find(Intersectable *obj); 184 int AddObject(Intersectable *obj); 185 186 void GetData(const int index, 187 Intersectable *&obj, 188 ViewCellPvsData &data); 189 190 }; 102 //typedef Pvs<KdNode *> KdPvs; 103 typedef Pvs<Intersectable *> ViewCellPvs; 191 104 192 105 #endif -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r310 r311 49 49 for (j=0; j < ray.leaves.size(); j++) { 50 50 KdNode *node = GetNodeForPvs( ray.leaves[j] ); 51 contributingSamples += object->mKdPvs.Add NodeSample(node);52 } 53 51 contributingSamples += object->mKdPvs.AddSample(node); 52 } 53 54 54 if (mPass > 10) 55 for (j=1; j < ray.leaves.size() - 1; j++) {55 for (j=1; j < ((int)ray.leaves.size() - 1); j++) { 56 56 ray.leaves[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 57 57 } … … 65 65 int contributingSamples = 0; 66 66 int j; 67 68 if (mPass > 10) 69 for (j=1; j < ray.viewCells.size() - 1; j++) 70 { 71 ray.viewCells[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 72 } 73 67 74 68 // add object to view cell 75 69 for (j=0; j < ray.viewCells.size(); j++) 76 { 70 { 77 71 ViewCell *vc = ray.viewCells[j]; 78 contributingSamples += vc->GetPvs().Add Object(obj);72 contributingSamples += vc->GetPvs().AddSample(obj); 79 73 } 80 74 75 if (mPass > 1) 76 for (j=1; j < ((int)ray.viewCells.size() - 1); j++) 77 { 78 ray.viewCells[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 79 } 80 81 81 return contributingSamples; 82 82 } … … 109 109 // cast ray to BSP tree to get intersection with view cells 110 110 mBspTree->CastRay(ray); 111 112 sampleContributions += sampleContributions +=AddObjectSamples(object, ray);113 111 112 sampleContributions += AddObjectSamples(object, ray); 113 114 114 if (ray.intersections.size() > 0) // view cell found 115 115 { 116 if (ray.intersections.size())117 sampleContributions +=AddObjectSamples(ray.intersections[0].mObject, ray);116 sampleContributions += 117 AddObjectSamples(ray.intersections[0].mObject, ray); 118 118 } 119 119 } … … 325 325 326 326 SetupRay(ray, point, direction); 327 327 328 sampleContributions = CastRay(object, ray); 329 328 330 } 329 331 } else { … … 346 348 } 347 349 } 348 350 349 351 passSamples++; 350 352 … … 405 407 exporter->SetExportRayDensity(true); 406 408 exporter->ExportKdTree(*mKdTree); 407 exporter->ExportBspTree(*mBspTree); 409 if (mViewCellsType == BSP_VIEW_CELLS) 410 exporter->ExportBspTree(*mBspTree); 408 411 409 412 delete exporter; … … 432 435 Exporter *exporter = Exporter::GetExporter(s); 433 436 exporter->SetWireframe(); 434 KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 437 438 if (mViewCellsType == BSP_VIEW_CELLS) 439 { 440 441 } 442 else 443 { 444 KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 445 Intersectable::NewMail(); 435 446 436 Intersectable::NewMail(); 437 438 // avoid adding the object to the list 439 object->Mail(); 440 ObjectContainer visibleObjects; 441 for (; i != object->mKdPvs.mEntries.end(); i++){442 KdNode *node = (*i).first;443 exporter->ExportBox(mKdTree->GetBox(node));444 mKdTree->CollectObjects(node, visibleObjects);445 446 447 448 449 450 451 exporter->ExportIntersectable(visibleObjects[j]);447 // avoid adding the object to the list 448 object->Mail(); 449 ObjectContainer visibleObjects; 450 451 for (; i != object->mKdPvs.mEntries.end(); i++) 452 { 453 KdNode *node = (*i).first; 454 exporter->ExportBox(mKdTree->GetBox(node)); 455 mKdTree->CollectObjects(node, visibleObjects); 456 } 457 458 exporter->ExportRays(rays[k], 1000, RgbColor(0, 1, 0)); 459 exporter->SetFilled(); 460 461 for (int j = 0; j < visibleObjects.size(); j++) 462 exporter->ExportIntersectable(visibleObjects[j]); 452 463 453 Material m; 454 m.mDiffuseColor = RgbColor(1, 0, 0); 455 exporter->SetForcedMaterial(m); 456 exporter->ExportIntersectable(object); 457 464 465 Material m; 466 m.mDiffuseColor = RgbColor(1, 0, 0); 467 exporter->SetForcedMaterial(m); 468 exporter->ExportIntersectable(object); 469 } 470 458 471 delete exporter; 459 472 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r310 r311 47 47 static bool ParseEnvironment(); 48 48 49 /** Ray set description of the rays passing through this node */ 50 PassingRaySet mPassingRays; 49 51 50 52 protected: … … 52 54 /// the potentially visible objects 53 55 ViewCellPvs mPvs; 54 55 /** Ray set description of the rays passing through this node */56 PassingRaySet mPassingRays;57 56 }; 58 57 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r310 r311 263 263 mStoreSplitPolys(false) 264 264 { 265 mypvs<BspNode *> testpvs; testpvs.Find(mRoot);266 265 Randomize(); // initialise random generator for heuristics 267 266 } … … 1192 1191 float maxt = 1e6; 1193 1192 float mint = 0; 1194 1193 1195 1194 Intersectable::NewMail(); 1196 1195 1197 1196 // test with tree bounding box 1198 1197 if (!mBox.GetMinMaxT(ray, &mint, &maxt)) 1198 { 1199 1199 return 0; 1200 } 1200 1201 1201 1202 if (mint < 0) … … 1255 1256 // find intersection with plane between ray origin and exit point 1256 1257 extp = splitPlane->FindIntersection(ray.GetLoc(), extp, &maxt); 1257 1258 1258 } else // reached leaf => intersection with view cell 1259 1259 { … … 1261 1261 1262 1262 //ray.mBspLeaves.push_back(leaf); 1263 1263 //Debug << "adding view cell" << leaf->mViewCell; 1264 1264 if (!leaf->mViewCell->Mailed()) 1265 1265 { … … 1268 1268 ++ hits; 1269 1269 } 1270 1270 //Debug << "view cell added" << endl; 1271 1271 // get the next node from the stack 1272 1272 if (tStack.empty()) -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r308 r311 510 510 X3dExporter::ExportBspTreeRayDensity(const BspTree &tree) 511 511 { 512 // TODO 512 stack<BspNode *> tStack; 513 514 tStack.push(tree.GetRoot()); 515 516 bool fm = mUseForcedMaterial; 517 518 mUseForcedMaterial = true; 519 520 mForcedMaterial.mDiffuseColor.g = 1.0f; 521 mForcedMaterial.mDiffuseColor.b = 1.0f; 522 523 while (!tStack.empty()) 524 { 525 BspNode *node = tStack.top(); 526 tStack.pop(); 527 528 if (node->IsLeaf()) 529 { 530 ViewCell *vc = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 531 532 // set the mesh material according to the ray density 533 if (vc->mPassingRays.mRays) 534 { 535 float importance = vc->mPassingRays.mContributions/(float)vc->mPassingRays.mRays; 536 537 mForcedMaterial.mDiffuseColor.r = importance; 538 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 539 ExportViewCell(vc); 540 } 541 } else 542 { 543 BspInterior *interior = (BspInterior *)node; 544 tStack.push(interior->GetFront()); 545 tStack.push(interior->GetBack()); 546 } 547 } 548 549 // restore the state of forced material 550 mUseForcedMaterial = fm; 551 513 552 return true; 514 553 } -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r258 r311 6 6 Scene { 7 7 8 # filename ../data/glasgow/glasgow1.x3d 9 filename ../data/vienna/vienna-buildings.x3d 8 # filename glasgow1.x3d 9 # filename vienna.x3d 10 # filename ../data/vienna/vienna-simple.x3d 11 filename ../data/vienna/vienna-buildings.x3d 12 # filename ../data/vienna/viewcells-25-sel.x3d 10 13 # filename ../data/atlanta/atlanta2.x3d 11 14 # filename ../data/soda/soda.dat 12 15 # filename ../data/soda/soda5.dat 13 14 16 } 15 17 … … 54 56 55 57 Sampling { 56 totalSamples 5000000057 samplesPerPass 2058 totalSamples 1000000 59 samplesPerPass 5 58 60 } 61 62 ViewCells { 63 hierarchyType bspTree 64 #hierarchyType kdTree 65 #hierarchyType sceneDependent 66 # filename ../data/atlanta/atlanta_viewcells_large.x3d 67 # filename ../data/atlanta/atlanta_viewcells_large2.x3d 68 filename ../data/vienna/viewcells-25-sel.x3d 69 # filename ../data/vienna/viewcells-25.x3d 70 # filename ../data/vienna/viewcells-large-sel.x3d 71 } 72 73 BspTree { 74 # constructionMethod fromRays 75 constructionMethod fromViewCells 76 # constructionMethod fromSceneGeometry 77 78 # next polygon = 1 79 # axis aligned = 2 80 # least splits = 4 81 # balanced polygons = 8 82 # balanced view cells = 16 83 # largest polygon area = 32 84 # vertical axis = 64 85 86 splitPlaneStrategy 66 87 # least splits + balanced polygons 88 #splitPlaneStrategy 12 89 90 #axis aligned + vertical axis 91 #splitPlaneStrategy 66 92 93 # axis aligned + balanced view cells 94 # splitPlaneStrategy 18 95 96 # largest polygon area 97 #splitPlaneStrategy 32 98 99 # axus aligned + balanced polygons 100 #splitPlaneStrategy 72 101 102 maxCandidates 50 103 maxViewCells 999999 104 Termination { 105 maxPolysForAxisAligned 100 106 maxPolygons 0 107 maxDepth 200 108 } 109 }
Note: See TracChangeset
for help on using the changeset viewer.