Changeset 444
- Timestamp:
- 12/02/05 19:46:07 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r441 r444 112 112 minPvs 10 113 113 maxPvs 150 114 samples 10 0000114 samples 10 115 115 } 116 116 … … 167 167 maxRayCandidates 50 168 168 169 maxTests 500169 maxTests 10000 170 170 171 171 # factors for evaluating split plane costs … … 184 184 Termination { 185 185 # parameters used for autopartition 186 minRays 300186 minRays 200 187 187 minPolygons -1 188 maxDepth 40189 minPvs 200188 maxDepth 50 189 minPvs 100 190 190 minArea 0.01 191 191 maxRayContribution 0.005 … … 214 214 exportSplits true 215 215 # how much samples should be used in visualization 216 samples 20000216 samples 90000 217 217 } 218 218 } … … 255 255 256 256 Termination { 257 maxDepth 30257 maxDepth 40 258 258 minPvs 50 259 259 minRays 1 -
trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp
r382 r444 85 85 int 86 86 Mesh::CastRay( 87 88 89 87 Ray &ray, 88 MeshInstance *instance 89 ) 90 90 { 91 91 if (mKdTree) { … … 325 325 int 326 326 MeshInstance::CastRay( 327 328 327 Ray &ray 328 ) 329 329 { 330 330 int res = mMesh->CastRay(ray, this); … … 334 334 int 335 335 MeshInstance::CastRay( 336 337 338 336 Ray &ray, 337 const vector<int> &faces 338 ) 339 339 { 340 340 return mMesh->CastRayToSelectedFaces(ray, faces, this); -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r441 r444 210 210 mViewCellsManager->SetVisualizationSamples(visSamples); 211 211 212 //Debug << "Visualization samples: " << mViewCellsManager->GetVisualizationSamples() << endl; 212 213 213 214 //-- parse view cells construction method -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp
r441 r444 222 222 Ray::Ray(const VssRay &vssRay): 223 223 loc(vssRay.mOrigin), 224 sourceObject(0, vssRay.mOriginObject, 0) 224 sourceObject(0, vssRay.mOriginObject, 0), 225 mType(LOCAL_RAY) 225 226 { 226 227 const float dist = Distance(vssRay.mTermination, vssRay.mOrigin); -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r441 r444 32 32 const Ray::Intersection &origin) 33 33 { 34 35 36 37 34 ray.intersections.clear(); 35 ray.kdLeaves.clear(); 36 ray.testedObjects.clear(); 37 ray.bspIntersections.clear(); 38 38 39 39 ray.mFlags |= Ray::STORE_KDLEAVES | Ray::STORE_BSP_INTERSECTIONS; 40 // cout<<point<<" "<<direction<<endl; 41 ray.Init(point, direction, type); 40 // cout<<point<<" "<<direction<<endl; 41 42 ray.Init(point, direction, type); 42 43 ray.sourceObject = origin; 43 44 } … … 319 320 Ray *ray = new Ray(); 320 321 321 // the source object322 Ray::Intersection source =323 Ray::Intersection(0, reverseSample ? NULL : object, faceIndex);324 325 322 // construct a ray 326 SetupRay(*ray, point, direction, Ray::LOCAL_RAY, source); 323 SetupRay(*ray, point, direction, Ray::LOCAL_RAY, 324 Ray::Intersection(0, reverseSample ? NULL : object, faceIndex)); 325 327 326 passRays.push_back(ray); 328 327 … … 428 427 { 429 428 for (it = newRays.begin(); it != it_end; ++ it) 429 { 430 430 mVssSampleRays.push_back(new VssRay(*(*it))); 431 } 431 432 } 432 433 else 433 434 { 435 // construct view cells using the collected samples 436 cout << "building view cells from " << (int)mVssSampleRays.size() << " samples " << endl; 437 434 438 mViewCellsManager->Construct(objects, mVssSampleRays); 435 436 // construct view cells using the collected samples 437 cout << "building view cells from " << (int)mSampleRays.size() << " samples " << endl; 438 439 // add contributions of saved samples to PVS 440 //contributingSamples += mBspTree->GetStat().contributingSamples; 441 //sampleContributions += mBspTree->GetStat().sampleContributions; 442 439 443 440 // throw away samples 444 441 CLEAR_CONTAINER(mVssSampleRays); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r442 r444 226 226 void BspLeaf::AddToPvs(const BoundedRayContainer &rays, 227 227 int &sampleContributions, 228 int &contributingSamples, 229 bool storeLeavesWithRays) 228 int &contributingSamples) 230 229 { 231 230 sampleContributions = 0; … … 246 245 contribution += mViewCell->GetPvs().AddSample(ray->sourceObject.mObject); 247 246 248 if (contribution > 0)247 if (contribution) 249 248 { 250 249 sampleContributions += contribution; 251 250 ++ contributingSamples; 252 251 } 253 254 if (storeLeavesWithRays) 255 // warning: intersections not ordered 252 253 //if (ray->mFlags & Ray::STORE_BSP_INTERSECTIONS) 256 254 ray->bspIntersections.push_back(Ray::BspIntersection((*it)->mMinT, this)); 257 255 } … … 632 630 633 631 // generate view cells 634 mGenerateViewCells = false;632 mGenerateViewCells = true; 635 633 636 634 long startTime = GetTime(); … … 1452 1450 1453 1451 // bound ray or line segment 1454 if ( (ray.GetType() == Ray::LOCAL_RAY) &&1452 if (//(ray.GetType() == Ray::LOCAL_RAY) && 1455 1453 !ray.intersections.empty() && 1456 1454 (ray.intersections[0].mT <= maxT)) … … 2072 2070 const float newT = t * bRay->mMaxT; 2073 2071 2074 backRays.push_back(new BoundedRay(ray, bRay->mMinT, newT)); 2075 frontRays.push_back(new BoundedRay(ray, newT, bRay->mMaxT)); 2072 backRays.push_back(new BoundedRay(ray, minT, newT)); 2073 frontRays.push_back(new BoundedRay(ray, newT, maxT)); 2074 2076 2075 DEL_PTR(bRay); 2077 2076 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r443 r444 335 335 void AddToPvs(const BoundedRayContainer &rays, 336 336 int &sampleContributions, 337 int &contributingSamples, 338 bool storeLeavesWithRays = false); 337 int &contributingSamples); 339 338 340 339 protected: -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r443 r444 80 80 for (it = rays.begin(); it != it_end; ++ it) 81 81 { 82 sampleContributions += ComputeSampleContributions(*(*it), castRays);82 sampleContributions += ComputeSampleContributions(*(*it), castRays); 83 83 contributingSamples += sampleContributions > 0; 84 84 } … … 182 182 void ViewCellsManager::SetVisualizationSamples(const int visSamples) 183 183 { 184 intmVisualizationSamples = visSamples;184 mVisualizationSamples = visSamples; 185 185 } 186 186 … … 257 257 258 258 Debug << mBspTree->GetStatistics() << endl; 259 CLEAR_CONTAINER(sampleRays); 260 259 261 260 return sampleContributions; 262 261 } … … 287 286 BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 288 287 289 // if ray not in unboundedspace288 // if ray not outside of view space 290 289 if (leaf->GetViewCell() != mBspTree->GetRootCell()) 291 290 { … … 518 517 //-- some rays for output 519 518 const int raysOut = min((int)sampleRays.size(), mVisualizationSamples); 520 cout << "visualization using " << mVisualizationSamples<< " samples" << endl;521 vector<Ray *> vcRays[leafOut];522 523 if ( 0)519 Debug << "visualization using " << raysOut << " samples" << endl; 520 521 522 if (1) 524 523 { 525 524 //-- some random view cells and rays for output … … 531 530 for (int i = 0; i < bspLeaves.size(); ++ i) 532 531 { 532 BspLeaf *leaf = bspLeaves[i]; 533 534 RayContainer vcRays; 535 533 536 cout << "creating output for view cell " << i << " ... "; 537 534 538 // check whether we can add the current ray to the output rays 535 539 for (int k = 0; k < raysOut; ++ k) … … 539 543 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 540 544 { 541 BspLeaf *leaf = ray->bspIntersections[j].mLeaf;542 543 if ( bspLeaves[i]->GetViewCell() == leaf->GetViewCell())545 BspLeaf *leaf2 = ray->bspIntersections[j].mLeaf; 546 547 if (leaf->GetViewCell() == leaf2->GetViewCell()) 544 548 { 545 vcRays [i].push_back(ray);549 vcRays.push_back(ray); 546 550 } 547 551 } 548 552 } 549 553 550 551 552 BspViewCell *vc = dynamic_cast<BspViewCell *>( bspLeaves[i]->GetViewCell());554 Intersectable::NewMail(); 555 556 BspViewCell *vc = dynamic_cast<BspViewCell *>(leaf->GetViewCell()); 553 557 554 558 //bspLeaves[j]->Mail(); … … 558 562 exporter->SetFilled(); 559 563 560 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin();561 562 564 exporter->SetWireframe(); 563 565 //exporter->SetFilled(); 564 566 565 567 Material m;//= RandomMaterial(); 566 m.mDiffuseColor = RgbColor( 0, 1, 0);568 m.mDiffuseColor = RgbColor(1, 1, 0); 567 569 exporter->SetForcedMaterial(m); 568 570 … … 571 573 else 572 574 { 573 PolygonContainer cell;575 PolygonContainer vcGeom; 574 576 // export view cell geometry 575 mBspTree->ConstructGeometry(vc, cell);576 exporter->ExportPolygons( cell);577 CLEAR_CONTAINER( cell);577 mBspTree->ConstructGeometry(vc, vcGeom); 578 exporter->ExportPolygons(vcGeom); 579 CLEAR_CONTAINER(vcGeom); 578 580 } 579 581 580 582 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 581 << ", piercing rays=" << (int)vcRays[i].size() << endl;583 << ", piercing rays=" << (int)vcRays.size() << endl; 582 584 583 585 // export rays piercing this view cell 584 exporter->ExportRays(vcRays [i], 1000, RgbColor(0, 1, 0));585 586 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 587 586 588 m.mDiffuseColor = RgbColor(1, 0, 0); 587 589 exporter->SetForcedMaterial(m); … … 590 592 exporter->SetFilled(); 591 593 594 ViewCellPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end(); 592 595 // output PVS of view cell 593 for ( ; it != vc->GetPvs().mEntries.end(); ++ it)596 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 594 597 { 595 598 Intersectable *intersect = (*it).first; … … 600 603 } 601 604 } 602 603 // output rest of the objects 604 if (0) 605 { 606 Material m;//= RandomMaterial(); 607 m.mDiffuseColor = RgbColor(0, 0, 1); 608 exporter->SetForcedMaterial(m); 609 610 for (int j = 0; j < objects.size(); ++ j) 611 if (!objects[j]->Mailed()) 612 { 613 exporter->SetForcedMaterial(m); 614 exporter->ExportIntersectable(objects[j]); 615 objects[j]->Mail(); 616 } 617 } 605 618 606 DEL_PTR(exporter); 619 607 cout << "finished" << endl; … … 623 611 { 624 612 ViewCellContainer viewCells; 613 RayContainer vcRays; 625 614 626 615 mBspTree->CollectViewCells(viewCells); … … 648 637 if (vc == leaf->GetViewCell()) 649 638 { 650 vcRays [i].push_back(ray);639 vcRays.push_back(ray); 651 640 } 652 641 } … … 677 666 678 667 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 679 << ", piercing rays=" << (int)vcRays[i].size() << endl;668 << ", piercing rays=" << (int)vcRays.size() << endl; 680 669 681 670 682 671 // export rays piercing this view cell 683 exporter->ExportRays(vcRays [i], 1000, RgbColor(0, 1, 0));672 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 684 673 685 674 m.mDiffuseColor = RgbColor(1, 0, 0); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r442 r444 153 153 */ 154 154 virtual bool ViewCellsConstructed() const = 0; 155 156 155 157 156 158 157 protected: -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r443 r444 517 517 (data.mPvs <= mTermMinPvs) || 518 518 (data.mArea <= mTermMinArea) || 519 (data. mDepth >= mTermMaxDepth) ||520 (data. GetAvgRayContribution() < mTermMaxRayContribution));519 (data.GetAvgRayContribution() >= mTermMaxRayContribution) || 520 (data.mDepth >= mTermMaxDepth)); 521 521 } 522 522 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r441 r444 68 68 mOriginObject(ray.sourceObject.mObject), 69 69 mT(1.0f) 70 {71 if (ray.sourceObject.mObject)72 mOrigin = ray.Extrap(ray.sourceObject.mT);73 else74 mOrigin = ray.GetLoc();75 76 //Debug << "origin: " << mOrigin << endl;77 78 if (!ray.intersections.empty())79 70 { 80 mTermination = ray.Extrap(ray.intersections[0].mT); 81 mTerminationObject = ray.intersections[0].mObject; 82 } 83 else 84 { 85 mTermination = ray.Extrap(1e6);//TODO: should be Limits::Infinity 86 mTerminationObject = NULL; 87 } 88 89 Precompute(); 71 if (ray.sourceObject.mObject) 72 mOrigin = ray.Extrap(ray.sourceObject.mT); 73 else 74 mOrigin = ray.GetLoc(); 75 76 //Debug << "origin: " << mOrigin << endl; 77 if (!ray.intersections.empty()) 78 { 79 mTermination = ray.Extrap(ray.intersections[0].mT); 80 mTerminationObject = ray.intersections[0].mObject; 81 } 82 else 83 { 84 mTermination = ray.Extrap(1e6);//TODO: should be Limits::Infinity 85 mTerminationObject = NULL; 86 } 87 88 Precompute(); 90 89 } 91 90 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.h
r438 r444 432 432 433 433 virtual void Print(ostream &s) const { 434 s<<endl<<"L: r="<< rays.size()<<endl;434 s<<endl<<"L: r="<<(int)rays.size()<<endl; 435 435 }; 436 436 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r440 r444 80 80 bool 81 81 X3dExporter::ExportRays(const RayContainer &rays, 82 83 82 const float length, 83 const RgbColor &color) 84 84 { 85 85 RayContainer::const_iterator ri = rays.begin(); … … 130 130 bool 131 131 X3dExporter::ExportRays(const VssRayContainer &rays, 132 132 const RgbColor &color) 133 133 { 134 134 VssRayContainer::const_iterator ri = rays.begin(); … … 154 154 ri = rays.begin(); 155 155 for (; ri != rays.end(); ri++) { 156 Vector3 a = (*ri)->GetOrigin();157 Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize(b - a);156 const Vector3 a = (*ri)->GetOrigin(); 157 const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 158 158 159 159 stream<<a.x<<" "<<a.y<<" "<<a.z<<" ,"; 160 160 stream<<b.x<<" "<<b.y<<" "<<b.z<<" ,\n"; 161 161 } 162 162
Note: See TracChangeset
for help on using the changeset viewer.