- Timestamp:
- 11/25/05 17:16:26 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r433 r436 126 126 # input fromViewCells 127 127 # input fromSceneGeometry 128 samples 150000128 samples 50000 129 129 sideTolerance 0.005 130 130 } … … 164 164 #splitPlaneStrategy 130 165 165 166 splitPlaneStrategy 1 167 168 maxPolyCandidates 70169 maxRayCandidates 100166 splitPlaneStrategy 1024 167 168 maxPolyCandidates 50 169 maxRayCandidates 50 170 170 171 171 # factors for evaluating split plane costs … … 186 186 minRays 200 187 187 minPolygons -1 188 maxDepth 20189 minPvs 1 00188 maxDepth 30 189 minPvs 150 190 190 minArea 0.01 191 191 maxRayContribution 0.005 -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r404 r436 42 42 void Polygon3::Split(const Plane3 &partition, 43 43 Polygon3 &front, 44 Polygon3 &back, 45 VertexContainer &splitPts) 44 Polygon3 &back) 46 45 { 47 46 Vector3 ptA = mVertices.back(); … … 51 50 VertexContainer::const_iterator it; 52 51 52 Vector3 lastSplit; 53 53 54 bool foundSplit = false; 54 55 // find line - plane intersections … … 68 69 // test if split point not too close to previous split point 69 70 if (!foundSplit || 70 (SqrDistance(splitPt, splitPts.back()) > Vector3::sDistToleranceSqrt))71 (SqrDistance(splitPt, lastSplit) > Vector3::sDistToleranceSqrt)) 71 72 { 72 73 // add vertex to both polygons … … 74 75 back.mVertices.push_back(splitPt); 75 76 76 splitPts.push_back(splitPt);77 lastSplit = splitPt; 77 78 foundSplit = true; 78 79 } … … 89 90 // test if split point not too close to previous split point 90 91 if (!foundSplit || 91 (SqrDistance(splitPt, splitPts.back()) > Vector3::sDistToleranceSqrt))92 (SqrDistance(splitPt, lastSplit) > Vector3::sDistToleranceSqrt)) 92 93 { 93 94 // add vertex to both polygons … … 95 96 back.mVertices.push_back(splitPt); 96 97 97 splitPts.push_back(splitPt);98 lastSplit = splitPt; 98 99 foundSplit = true; 99 100 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r404 r436 50 50 @param front returns the front the front polygon 51 51 @param back returns the back polygon 52 @param splitPts returns the split points53 52 */ 54 53 void Split(const Plane3 &partition, 55 54 Polygon3 &front, 56 Polygon3 &back, 57 VertexContainer &splitPts); 55 Polygon3 &back); 58 56 59 57 /** Returns the area of this polygon. … … 65 63 */ 66 64 int ClassifyPlane(const Plane3 &plane) const; 67 68 65 69 66 -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp
r433 r436 229 229 dir = vssRay.GetDir() / dist; 230 230 231 if (!vssRay.mTerminationObject)232 Debug << "error!" << endl;233 234 231 intersections.push_back(Intersection(dist, vssRay.mTerminationObject, 0)); 235 232 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r433 r436 143 143 Polygon3 *front_piece = NULL; 144 144 Polygon3 *back_piece = NULL; 145 146 VertexContainer splitVertices;147 145 148 146 switch (cf) … … 164 162 poly->Split(mPlane, 165 163 *front_piece, 166 *back_piece, 167 splitVertices); 164 *back_piece); 168 165 169 166 ++ splits; // increase number of splits … … 698 695 facePolyMap.clear(); 699 696 700 // compu e bounding box697 // compute bounding box 701 698 Polygon3::IncludeInBox(*polys, mBox); 702 699 … … 721 718 } 722 719 720 void BspTree::Construct(const ObjectContainer &objects, const RayContainer &sampleRays) 721 { 722 mStat.nodes = 1; 723 mBox.Initialize(); // initialise BSP tree bounding box 724 725 BoundedRayContainer *rays = new BoundedRayContainer(); 726 PolygonContainer *polys = new PolygonContainer(); 727 728 // copy mesh instance polygons into one big polygon soup 729 mStat.polys = AddToPolygonSoup(objects, *polys); 730 731 RayContainer::const_iterator rit, rit_end = sampleRays.end(); 732 733 //-- store rays 734 for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 735 { 736 Ray *ray = *rit; 737 ray->SetId(-1); // reset id 738 739 float minT, maxT; 740 if (BoundRay(*ray, minT, maxT)) 741 rays->push_back(new BoundedRay(ray, minT, maxT)); 742 } 743 744 Debug << "tree has " << (int)polys->size() << " polys, " << (int)sampleRays.size() << " rays" << endl; 745 Construct(polys, rays); 746 } 747 723 748 void BspTree::Construct(PolygonContainer *polys, BoundedRayContainer *rays) 724 749 { … … 736 761 737 762 mStat.Start(); 738 cout << " **** Contructing bsp tree ****\n";739 763 cout << "Contructing bsp tree ... "; 764 long startTime = GetTime(); 740 765 while (!tStack.empty()) 741 766 { 742 767 tData = tStack.top(); 768 743 769 tStack.pop(); 744 770 745 771 // subdivide leaf node 746 BspNode *subRoot = Subdivide(tStack, tData); 747 } 772 BspNode *r = Subdivide(tStack, tData); 773 774 if (r == mRoot) 775 Debug << "BSP tree construction time spent at root: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 776 } 777 778 cout << "finished\n"; 748 779 749 780 mStat.Stop(); … … 1452 1483 float pFront = 0; 1453 1484 float pBack = 0; 1454 Debug << "here" << endl; 1485 1455 1486 if (mSplitPlaneStrategy & PVS) 1456 1487 { … … 1573 1604 1574 1605 // give penalty to unbalanced split 1575 if ( 0)1606 if (1) 1576 1607 if (((pFront * 0.2 + Limits::Small) > pBack) || (pFront < (pBack * 0.2 + Limits::Small))) 1577 1608 val += 0.5; … … 1583 1614 << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl; 1584 1615 #endif 1585 Debug << "here2" << endl;1586 1616 return val; 1587 1617 } … … 2195 2225 backPoly = new Polygon3(); 2196 2226 2197 candidatePolys[i]->Split(halfSpaces[j], *frontPoly, 2198 *backPoly, splitPts); 2227 candidatePolys[i]->Split(halfSpaces[j], 2228 *frontPoly, 2229 *backPoly); 2199 2230 2200 2231 DEL_PTR(candidatePolys[i]); … … 2450 2481 Polygon3 *backPoly = new Polygon3(); 2451 2482 2452 VertexContainer splitPts; 2453 2454 poly->Split(splitPlane, *frontPoly, *backPoly, splitPts); 2483 poly->Split(splitPlane, *frontPoly, *backPoly); 2455 2484 2456 2485 DEL_PTR(poly); … … 2507 2536 case Polygon3::SPLIT: 2508 2537 { 2509 VertexContainer splitPts;2510 2511 2538 Polygon3 *frontPoly = new Polygon3(); 2512 2539 Polygon3 *backPoly = new Polygon3(); 2513 2540 2514 planePoly->Split(plane, *frontPoly, *backPoly , splitPts);2541 planePoly->Split(plane, *frontPoly, *backPoly); 2515 2542 DEL_PTR(planePoly); 2516 2543 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r428 r436 434 434 void Construct(const ObjectContainer &objects); 435 435 436 void Construct(const ObjectContainer &objects, 437 const RayContainer &sampleRays); 438 436 439 /** Constructs the tree from a given set of rays. 437 440 @param sampleRays the set of sample rays the construction is based on -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r434 r436 440 440 cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush; 441 441 442 int numExportRays = 10000;443 //int numExportRays = 0;442 //int numExportRays = 10000; 443 int numExportRays = 0; 444 444 445 445 if (numExportRays) { … … 451 451 //-- construct BSP view cells 452 452 if (ViewCell::sHierarchy == ViewCell::BSP) 453 453 { 454 454 const int bspSamples = min((int)mVssRays.size(), mBspConstructionSamples); 455 455 456 Debug << "bpssamples: " << bspSamples << endl; 456 457 for (int i = 0; i < bspSamples; ++ i) 457 458 458 bspRays.push_back(new Ray(*mVssRays[i])); 459 459 460 //-- construct BSP tree using the samples 460 461 mBspTree = new BspTree(&mUnbounded); 461 462 463 ObjectContainer objects; 464 mSceneGraph->CollectObjects(&objects); 465 462 466 mBspTree->SetGenerateViewCells(true); 463 mBspTree->Construct(bspRays); 464 465 Exporter *exporter = Exporter::GetExporter("vccbsprays.x3d"); 466 467 // export rays piercing this view cell 468 exporter->ExportRays(bspRays, 1000, RgbColor(0, 1, 0)); 469 470 // cast remaining initial rays into BSP tree 471 for (int i = bspSamples; i < (int)mVssRays.size(); ++ i) 472 CastRay(*mBspTree, *mVssRays[i]); 467 mBspTree->Construct(objects, bspRays); 473 468 } 474 469 … … 587 582 //-- cast ray to BSP tree to get intersection with view cells 588 583 Ray ray(vssRay); 589 590 Debug << ray << endl;591 if (ray.intersections.empty())592 Debug << "empty ray" << endl;593 else594 Debug << "intersection: " << ray.intersections[0].mT << " " << ray.intersections[0].mObject << endl;595 596 584 mBspTree->CastRay(ray); 597 585 … … 601 589 602 590 if (!ray.intersections.empty()) // second intersection found 603 591 { 604 592 //sampleContributions += 605 593 AddObjectSamples(ray.intersections[0].mObject, ray); 606 594 } 607 595 } 608 596 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r435 r436 965 965 // do all the splits with the previous planes 966 966 for (int i = 0; i < (int)tData.mPlanes.size(); ++ i) 967 { 968 VertexContainer splitPts; 969 967 { 970 968 if (planePoly->ClassifyPlane(*tData.mPlanes[i]) == Polygon3::SPLIT) 971 969 { … … 973 971 Polygon3 *backPoly = new Polygon3(); 974 972 975 planePoly->Split(*tData.mPlanes[i], *frontPoly, *backPoly , splitPts);973 planePoly->Split(*tData.mPlanes[i], *frontPoly, *backPoly); 976 974 DEL_PTR(planePoly); 977 975
Note: See TracChangeset
for help on using the changeset viewer.