- Timestamp:
- 11/03/05 16:43:51 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Camera.cpp
r370 r374 109 109 exporter->ExportBox(tree->GetBox(ray->kdLeaves[i])); 110 110 if (0) 111 for (i= 0; i < ray->meshes.size(); i++)112 exporter->ExportIntersectable(ray->meshes[i]);111 for (i= 0; i < ray->testedObjects.size(); i++) 112 exporter->ExportIntersectable(ray->testedObjects[i]); 113 113 114 114 } … … 131 131 ray.intersections.clear(); 132 132 ray.kdLeaves.clear(); 133 ray. meshes.clear();133 ray.testedObjects.clear(); 134 134 ray.bspIntersections.clear(); 135 135 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r372 r374 1241 1241 1242 1242 RegisterOption("BspTree.splitPlaneStrategy", 1243 optString,1244 "-bsp_split_method=",1245 "leastSplits");1243 optString, 1244 "-bsp_split_method=", 1245 "leastSplits"); 1246 1246 1247 1247 RegisterOption("BspTree.maxCandidates", … … 1259 1259 "-bsp_exportSplits", 1260 1260 "false"); 1261 1262 RegisterOption("Preprocessor.type", 1263 optString, 1264 "-preprocessor=", 1265 "sampling"); 1266 1261 1267 } 1262 1268 -
trunk/VUT/GtpVisibilityPreprocessor/src/ExactPreprocessor.h
r372 r374 9 9 public: 10 10 virtual bool ComputeVisibility(); 11 12 virtual bool BuildBspTree() { return false; } 13 11 14 }; 12 15 -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r372 r374 476 476 float sum; 477 477 if (mSahUseFaces) 478 sum = intersectionsLeft*lbox.SurfaceArea() + intersectionsRight*rbox.SurfaceArea();478 sum = intersectionsLeft*lbox.SurfaceArea() + intersectionsRight*rbox.SurfaceArea(); 479 479 else 480 sum = objectsLeft*lbox.SurfaceArea() + objectsRight*rbox.SurfaceArea();480 sum = objectsLeft*lbox.SurfaceArea() + objectsRight*rbox.SurfaceArea(); 481 481 482 482 // cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; … … 484 484 485 485 if (sum < minSum) { 486 minSum = sum;487 position = (*ci).value;488 489 objectsBack = objectsLeft;490 objectsFront = objectsRight;486 minSum = sum; 487 position = (*ci).value; 488 489 objectsBack = objectsLeft; 490 objectsFront = objectsRight; 491 491 } 492 492 } … … 507 507 int 508 508 KdTree::CastRay( 509 Ray &ray510 )509 Ray &ray 510 ) 511 511 { 512 512 int hits = 0; … … 570 570 maxt = tdist; 571 571 } else { 572 // compute intersection with all objects in this leaf 573 KdLeaf *leaf = (KdLeaf *) node; 574 ray.kdLeaves.push_back(leaf); 575 576 ObjectContainer::const_iterator mi; 577 for ( mi = leaf->mObjects.begin(); 578 mi != leaf->mObjects.end(); 579 mi++) { 580 Intersectable *object = *mi; 581 if (!object->Mailed() ) { 582 object->Mail(); 583 //ray.meshes.push_back(mesh); 584 hits += object->CastRay(ray); 572 // compute intersection with all objects in this leaf 573 KdLeaf *leaf = (KdLeaf *) node; 574 if (ray.mFlags & Ray::STORE_KDLEAVES) 575 ray.kdLeaves.push_back(leaf); 576 577 ObjectContainer::const_iterator mi; 578 for ( mi = leaf->mObjects.begin(); 579 mi != leaf->mObjects.end(); 580 mi++) { 581 Intersectable *object = *mi; 582 if (!object->Mailed() ) { 583 object->Mail(); 584 if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 585 ray.testedObjects.push_back(object); 586 hits += object->CastRay(ray); 587 } 588 } 589 590 if (hits && ray.GetType() == Ray::LOCAL_RAY) 591 if (ray.intersections[0].mT <= maxt) 592 break; 593 594 // get the next node from the stack 595 if (tStack.empty()) 596 break; 597 598 entp = extp; 599 mint = maxt; 600 if (ray.GetType() == Ray::LINE_SEGMENT && mint > 1.0f) 601 break; 602 603 RayTraversalData &s = tStack.top(); 604 node = s.mNode; 605 extp = s.mExitPoint; 606 maxt = s.mMaxT; 607 tStack.pop(); 585 608 } 586 }587 588 if (hits && ray.GetType() == Ray::LOCAL_RAY)589 if (ray.intersections[0].mT <= maxt)590 break;591 592 // get the next node from the stack593 if (tStack.empty())594 break;595 596 entp = extp;597 mint = maxt;598 if (ray.GetType() == Ray::LINE_SEGMENT && mint > 1.0f)599 break;600 601 RayTraversalData &s = tStack.top();602 node = s.mNode;603 extp = s.mExitPoint;604 maxt = s.mMaxT;605 tStack.pop();606 }607 609 } 608 610 … … 624 626 KdLeaf *leaf = (KdLeaf *)node; 625 627 for (int j=0; j < leaf->mObjects.size(); j++) { 626 Intersectable *object = leaf->mObjects[j];627 if (!object->Mailed()) {628 629 630 }628 Intersectable *object = leaf->mObjects[j]; 629 if (!object->Mailed()) { 630 object->Mail(); 631 objects.push_back(object); 632 } 631 633 } 632 634 } else { … … 699 701 KdInterior *interior = (KdInterior *)node; 700 702 if (interior->mPosition > box.Max(interior->mAxis)) 701 nodeStack.push(interior->mBack);703 nodeStack.push(interior->mBack); 702 704 else 703 if (interior->mPosition < box.Min(interior->mAxis))704 705 else {706 707 708 709 }705 if (interior->mPosition < box.Min(interior->mAxis)) 706 nodeStack.push(interior->mFront); 707 else { 708 // random decision 709 nodeStack.push(interior->mBack); 710 nodeStack.push(interior->mFront); 711 } 710 712 } 711 713 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h
r370 r374 29 29 /// front (back) to the back (front) 30 30 enum {FRONT, BACK, BACK_FRONT, FRONT_BACK, COINCIDENT}; 31 31 32 32 struct Intersection { 33 33 // the point of intersection … … 63 63 64 64 BspIntersection(const float t, BspLeaf *l): 65 mT(t), mLeaf(l) {}66 65 mT(t), mLeaf(l) {} 66 67 67 BspIntersection() {} 68 68 69 69 bool operator<(const BspIntersection &b) const { 70 70 return mT <b.mT; } … … 79 79 vector<BspIntersection> bspIntersections; 80 80 vector<KdLeaf *> kdLeaves; 81 vector<MeshInstance *> meshes; 82 81 vector<Intersectable *> testedObjects; 82 83 // various flags 84 enum {STORE_KDLEAVES=1, STORE_BSP_INTERSECTIONS=2, STORE_TESTED_OBJECTS=4}; 85 int mFlags; 86 87 83 88 // constructors 84 89 Ray(const Vector3 &wherefrom, 85 90 const Vector3 &whichdir, 86 const int _type) {91 const int _type):mFlags(0) { 87 92 loc = wherefrom; 88 93 if (_type == LINE_SEGMENT) … … 92 97 mType = _type; 93 98 depth = 0; 94 99 Init(); 95 100 } 96 101 // dummy constructor 97 102 Ray() {} 98 103 99 104 Intersectable *GetIntersectionObject(const int i) const { 100 105 return intersections[i].mObject; … … 236 241 // to the number of bounces of the ray, also called the depth of the 237 242 // ray (primary ray has its depth zero) 238 int depth; 239 240 243 int depth; 244 245 246 241 247 void Init(); 242 248 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r373 r374 33 33 ray.intersections.clear(); 34 34 ray.kdLeaves.clear(); 35 ray. meshes.clear();35 ray.testedObjects.clear(); 36 36 ray.bspIntersections.clear(); 37 37 ray.mFlags |= Ray::STORE_KDLEAVES | Ray::STORE_BSP_INTERSECTIONS; 38 38 // cout<<point<<" "<<direction<<endl; 39 39 ray.Init(point, direction, type); -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r372 r374 28 28 VssPreprocessor::SetupRay(Ray &ray, 29 29 const Vector3 &point, 30 const Vector3 &direction ,31 const int type)30 const Vector3 &direction 31 ) 32 32 { 33 33 ray.intersections.clear(); 34 ray.kdLeaves.clear(); 35 ray.meshes.clear(); 36 34 // do not store anything else then intersections at the ray 35 ray.kdLeaves.clear(); 36 ray.mFlags = Ray::STORE_KDLEAVES; 37 37 38 // cout<<point<<" "<<direction<<endl; 38 ray.Init(point, direction, type);39 ray.Init(point, direction, Ray::LOCAL_RAY); 39 40 } 40 41 … … 51 52 int 52 53 VssPreprocessor::AddNodeSamples(const Ray &ray, 53 54 55 54 Intersectable *sObject, 55 Intersectable *tObject 56 ) 56 57 { 57 58 int contributingSamples = 0; … … 62 63 if (tObject) 63 64 objects++; 64 65 65 66 if (objects) { 66 67 for (j=0; j < ray.kdLeaves.size(); j++) { … … 123 124 KdNode *nodeToSample = NULL; 124 125 125 bool samplePvsBoundary = false; 126 if (pvsSize && samplePvsBoundary) { 127 // this samples the nodes from the boundary of the current PVS 128 // mail all nodes from the pvs 129 Intersectable::NewMail(); 130 KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 131 132 for (; i != object->mKdPvs.mEntries.end(); i++) { 133 KdNode *node = (*i).first; 134 node->Mail(); 135 } 136 137 int maxTries = 2*pvsSize; 138 Debug << "Finding random neighbour" << endl; 139 for (int tries = 0; tries < 10; tries++) { 140 int index = RandomValue(0, pvsSize - 1); 141 KdPvsData data; 142 KdNode *node; 143 object->mKdPvs.GetData(index, node, data); 144 nodeToSample = mKdTree->FindRandomNeighbor(node, true); 145 if (nodeToSample) 146 break; 147 } 148 } else { 149 // just pickup a random node 150 // nodeToSample = mKdTree->GetRandomLeaf(Plane3(normal, point)); 151 nodeToSample = mKdTree->GetRandomLeaf(); 152 } 126 // just pickup a random node 127 nodeToSample = mKdTree->GetRandomLeaf(); 153 128 return nodeToSample; 154 129 } … … 229 204 230 205 // construct a ray 231 SetupRay(ray, point, direction , Ray::LOCAL_RAY);206 SetupRay(ray, point, direction); 232 207 233 208 sampleContributions = CastRay(reverseSample ? NULL : object, ray); … … 298 273 } 299 274 300 if (ViewCell::sHierarchy == ViewCell::KD) 301 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 302 303 304 // HoleSamplingPass(); 275 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 276 277 305 278 if (0) { 306 279 Exporter *exporter = Exporter::GetExporter("ray-density.x3d"); -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h
r372 r374 29 29 void 30 30 SetupRay(Ray &ray, 31 32 const Vector3 &direction,33 const int type);31 const Vector3 &point, 32 const Vector3 &direction 33 ); 34 34 35 35 KdNode * … … 49 49 GetNodeToSample(Intersectable *object); 50 50 51 virtual bool BuildBspTree() { return false; } 52 51 53 }; 52 54 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp
r364 r374 458 458 void 459 459 X3dViewCellsParseHandlers::StartCoordinate( 460 460 AttributeList& attributes) 461 461 { 462 462 int len = attributes.getLength(); … … 518 518 #ifdef _DEBUG 519 519 Debug << "Viewcell: " 520 521 520 << mesh->mVertices[0] << " " << mesh->mVertices[1] << " " << mesh->mVertices[2] << " " 521 << mesh->mVertices[3] << " " << mesh->mVertices[4] << " " << mesh->mVertices[5] << "\n"; 522 522 #endif 523 }523 } 524 524 } 525 525 … … 527 527 void 528 528 X3dViewCellsParseHandlers::startElement(const XMLCh* const name, 529 529 AttributeList& attributes) 530 530 { 531 531 StrX lname(name); -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r370 r374 12 12 # filename ../data/vienna/viewcells-25-sel.x3d 13 13 # filename ../data/atlanta/atlanta2.x3d 14 # filename ../data/soda/soda.dat 15 filename ../data/soda/soda5.dat 14 filename ../data/soda/soda.dat 15 # filename ../data/soda/soda5.dat 16 } 17 18 Preprocessor { 19 # type sampling 20 type vss 16 21 } 17 22 … … 61 66 62 67 ViewCells { 63 #hierarchy kdTree64 hierarchy bspTree68 hierarchy kdTree 69 #hierarchy bspTree 65 70 # hierarchy sceneDependent 66 71 -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r372 r374 1 1 #include "SamplingPreprocessor.h" 2 #include "VssPreprocessor.h" 2 3 #include "ExactPreprocessor.h" 3 4 #include "Parser.h" … … 24 25 BspTree::ParseEnvironment(); 25 26 26 Preprocessor *p = 27 new SamplingPreprocessor(); 27 char buff[128]; 28 28 29 char buff[128]; 29 environment->GetStringValue("Preprocessor.type", buff); 30 31 string preprocessorType(buff); 32 33 Preprocessor *p; 34 35 if (preprocessorType == "vss") 36 p = new VssPreprocessor(); 37 else 38 if (preprocessorType == "exact") 39 p = new ExactPreprocessor(); 40 else 41 if (preprocessorType == "sampling") 42 p = new SamplingPreprocessor(); 43 else { 44 cerr<<"Unknown preprocessor type"<<endl; 45 Debug<<"Unknown preprocessor type"<<endl; 46 exit(1); 47 } 48 49 30 50 environment->GetStringValue("Scene.filename", buff); 31 51 string filename(buff);
Note: See TracChangeset
for help on using the changeset viewer.