- Timestamp:
- 11/06/05 01:24:55 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r381 r383 126 126 #splitPlaneStrategy 130 127 127 128 splitPlaneStrategy 1 28128 splitPlaneStrategy 1024 129 129 130 maxPolyCandidates 5 131 maxRayCandidates 50130 maxPolyCandidates 50 131 maxRayCandidates 0 132 132 133 133 Termination { … … 135 135 maxRays 1000 136 136 maxPolygons 1 137 maxDepth 10137 maxDepth 80 138 138 139 139 # axis aligned splits -
trunk/VUT/GtpVisibilityPreprocessor/src/Exporter.h
r379 r383 71 71 ExportBspSplitPlanes(const BspTree &tree) = 0; 72 72 virtual void 73 ExportBspSplits(const BspTree &tree ) = 0;73 ExportBspSplits(const BspTree &tree, const bool exportDepth = false) = 0; 74 74 virtual void 75 75 ExportLeavesGeometry(const BspTree &tree, const vector<BspLeaf *> &leaves) = 0; -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r380 r383 600 600 } 601 601 602 //-- visualization of the bspsplits602 //-- visualization of the BSP splits 603 603 bool exportSplits = false; 604 604 environment->GetBoolValue("BspTree.exportSplits", exportSplits); … … 703 703 704 704 mSampleRays.push_back(new Ray(ray)); 705 Debug << "abba " << mSampleRays.size() << endl;706 705 } 707 706 else … … 727 726 else if ((int)mSampleRays.size() < mPostProcessSamples) 728 727 { 729 Debug << "police " << mSampleRays.size() << endl;730 728 mSampleRays.push_back(new Ray(ray)); 731 729 } … … 779 777 exporter->SetForcedMaterial(m); 780 778 exporter->SetWireframe(); 781 exporter->ExportBspSplits(*mBspTree );779 exporter->ExportBspSplits(*mBspTree, true); 782 780 783 781 // take forced material, else big scenes cannot be viewed -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r380 r383 1084 1084 if (sSplitPlaneStrategy & RANDOM_POLYGON) 1085 1085 { 1086 Vector3 pt[3]; 1087 for (int j = 0; j < 3; j ++) 1088 { 1089 int idx = Random((int)rays.size()); 1090 pt[j] = rays[idx]->mRay->Extrap(rays[idx]->mMaxT); 1091 } 1092 1093 return Plane3(pt[0], pt[1], pt[2]); 1094 1095 //return polys[Random((int)polys.size())]->GetSupportingPlane(); 1086 return polys[Random((int)polys.size())]->GetSupportingPlane(); 1096 1087 } 1097 1088 1098 1089 // use heuristics to find appropriate plane 1099 return SelectPlaneHeuristics(polys, rays, sMaxPolyCandidates, sMaxRayCandidates); 1100 } 1101 1102 Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, 1090 return SelectPlaneHeuristics(leaf, 1091 polys, 1092 rays, 1093 sMaxPolyCandidates, 1094 sMaxRayCandidates); 1095 } 1096 1097 Plane3 BspTree::SelectPlaneHeuristics(BspLeaf *leaf, 1098 PolygonContainer &polys, 1103 1099 const BoundedRayContainer &rays, 1104 1100 const int maxPolyCandidates, … … 1108 1104 int bestPlaneIdx = 0; 1109 1105 1110 int limit = maxPolyCandidates > 0 ? Min((int)polys.size(), maxPolyCandidates) : (int)polys.size(); 1106 int limit = maxPolyCandidates > 0 ? 1107 Min((int)polys.size(), maxPolyCandidates) : (int)polys.size(); 1111 1108 1112 1109 int candidateIdx = limit; 1113 1110 1114 //Debug << endl; 1115 /*for (int i = 0; i < limit; ++ i) 1111 for (int i = 0; i < limit; ++ i) 1116 1112 { 1117 1113 candidateIdx = GetNextCandidateIdx(candidateIdx, polys); 1118 1119 Plane3 candidatePlane = polys[candidateIdx]->GetSupportingPlane(); 1114 1115 // evaluate current candidate 1116 const float candidateCost = 1117 SplitPlaneCost(leaf, 1118 polys[candidateIdx]->GetSupportingPlane(), 1119 polys, rays); 1120 1120 1121 //Debug << polys[candidateIdx] << endl; 1121 // evaluate current candidate1122 float candidateCost = SplitPlaneCost(candidatePlane, polys, rays);1123 1124 1122 if (candidateCost < lowestCost) 1125 1123 { … … 1127 1125 lowestCost = candidateCost; 1128 1126 } 1129 } */1127 } 1130 1128 1131 1129 //limit = maxRaysCandidates > 0 ? Min((int)rays.size(), maxRayCandidates) : (int)rays.size(); … … 1140 1138 for (int j = 0; j < 3; j ++) 1141 1139 { 1142 idx[j] = Random((int)rays.size()); 1143 pt[j] = rays[idx[j]]->mRay->Extrap(rays[idx[j]]->mMaxT); 1144 } 1145 1146 float candidateCost = SplitPlaneCost(Plane3(pt[0], pt[1], pt[2]), polys, rays); 1140 idx[j] = Random((int)rays.size() * 2); 1141 1142 if (idx[j] < (int)rays.size()) 1143 pt[j] = rays[idx[j]]->mRay->Extrap(rays[idx[j]]->mMinT); 1144 else 1145 { 1146 idx[j] -= (int)rays.size(); 1147 pt[j] = rays[idx[j]]->mRay->Extrap(rays[idx[j]]->mMaxT); 1148 } 1149 1150 } 1151 1152 const float candidateCost = 1153 SplitPlaneCost(leaf, Plane3(pt[0], pt[1], pt[2]), 1154 polys, rays); 1147 1155 1148 1156 if (candidateCost < lowestCost) … … 1157 1165 if (chooseFromRays) 1158 1166 { 1167 Debug << "choose ray plane: " << lowestCost << endl; 1159 1168 return Plane3(rays[bestIdx[0]]->mRay->Extrap(rays[bestIdx[0]]->mMaxT), 1160 1169 rays[bestIdx[1]]->mRay->Extrap(rays[bestIdx[1]]->mMaxT), … … 1177 1186 } 1178 1187 1179 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1188 float BspTree::SplitPlaneCost(BspLeaf *leaf, 1189 const Plane3 &candidatePlane, 1180 1190 const PolygonContainer &polys) const 1181 1191 { … … 1316 1326 } 1317 1327 1318 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1328 float BspTree::SplitPlaneCost(BspLeaf *leaf, 1329 const Plane3 &candidatePlane, 1319 1330 const BoundedRayContainer &rays) const 1320 1331 { … … 1333 1344 Intersectable::NewMail(); const int frontAndBackId = ViewCell::sMailId; 1334 1345 1335 /*PolygonContainer cell;1346 PolygonContainer cell; 1336 1347 PolygonContainer front; 1337 1348 PolygonContainer back; 1338 1349 1339 ConstructGeometry(currentNode, cell); 1340 ConstructChildrenGeometry(front, cell, planes, sides); 1341 ConstructChildrenGeometry(back, cell, planes, sides);*/ 1342 1343 1350 vector<Plane3 *> planes; 1351 vector<bool> sides; 1352 1353 ExtractSplitPlanes(leaf, planes, sides); 1354 1355 ConstructGeometry(leaf, cell); 1356 ConstructChildGeometry(front, cell, planes, sides, candidatePlane, true); 1357 ConstructChildGeometry(back, cell, planes, sides, candidatePlane, false); 1358 1359 CLEAR_CONTAINER(cell); 1360 CLEAR_CONTAINER(front); 1361 CLEAR_CONTAINER(back); 1362 1344 1363 int frontRays = 0; 1345 1364 int backRays = 0; … … 1475 1494 } 1476 1495 1477 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1496 float BspTree::SplitPlaneCost(BspLeaf *leaf, 1497 const Plane3 &candidatePlane, 1478 1498 const PolygonContainer &polys, 1479 1499 const BoundedRayContainer &rays) const … … 1497 1517 (sSplitPlaneStrategy & BLOCKED_RAYS)) 1498 1518 { 1499 val += SplitPlaneCost( candidatePlane, polys);1519 val += SplitPlaneCost(leaf, candidatePlane, polys); 1500 1520 } 1501 1521 … … 1505 1525 (sSplitPlaneStrategy & PVS)) 1506 1526 { 1507 val += SplitPlaneCost( candidatePlane, rays);1527 val += SplitPlaneCost(leaf, candidatePlane, rays); 1508 1528 } 1509 1529 … … 2019 2039 } 2020 2040 2021 bool BspTree::Co mputeChildrenGeometry(PolygonContainer &newCell,2022 2023 const vector<Plane3> &planes,2024 2025 2026 2041 bool BspTree::ConstructChildGeometry(PolygonContainer &newCell, 2042 const PolygonContainer &cell, 2043 const vector<Plane3 *> &planes, 2044 const vector<bool> &sides, 2045 const Plane3 &splitPlane, 2046 const bool side) const 2027 2047 { 2028 2048 // get cross section of new polygon … … 2034 2054 for (int i = 0; (i < planes.size()) && inside; ++ i) 2035 2055 { 2036 const int cf = planePoly->ClassifyPlane( planes[i]);2056 const int cf = planePoly->ClassifyPlane(*planes[i]); 2037 2057 2038 2058 // split new polygon with all previous planes … … 2046 2066 Polygon3 *backPoly = new Polygon3(); 2047 2067 2048 planePoly->Split( planes[i], *frontPoly, *backPoly, splitPts);2068 planePoly->Split(*planes[i], *frontPoly, *backPoly, splitPts); 2049 2069 DEL_PTR(planePoly); 2050 2070 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r379 r383 459 459 @returns true if plane contributes to the cell. 460 460 */ 461 bool Co mputeChildrenGeometry(PolygonContainer &newCell,462 const PolygonContainer &cell,463 const vector<Plane3> &planes,464 const vector<bool> &sides,465 const Plane3 &splitPlane,466 const bool side) const;461 bool ConstructChildGeometry(PolygonContainer &newCell, 462 const PolygonContainer &cell, 463 const vector<Plane3 *> &planes, 464 const vector<bool> &sides, 465 const Plane3 &splitPlane, 466 const bool side) const; 467 467 468 468 … … 540 540 @returns the cost of the candidate split plane 541 541 */ 542 float SplitPlaneCost(const Plane3 &candidatePlane, 542 float SplitPlaneCost(BspLeaf *leaf, 543 const Plane3 &candidatePlane, 543 544 const PolygonContainer &polys, 544 545 const BoundedRayContainer &rays) const; … … 548 549 @returns the cost of the candidate split plane 549 550 */ 550 float SplitPlaneCost(const Plane3 &candidatePlane, 551 float SplitPlaneCost(BspLeaf *leaf, 552 const Plane3 &candidatePlane, 551 553 const PolygonContainer &polys) const; 552 554 … … 555 557 @returns the cost of the candidate split plane 556 558 */ 557 float SplitPlaneCost(const Plane3 &candidatePlane, 559 float SplitPlaneCost(BspLeaf *leaf, 560 const Plane3 &candidatePlane, 558 561 const BoundedRayContainer &polys) const; 559 562 … … 608 611 @param maxRayCandidates the maximal number of ray candidates 609 612 */ 610 Plane3 SelectPlaneHeuristics(PolygonContainer &polys, 613 Plane3 SelectPlaneHeuristics(BspLeaf *leaf, 614 PolygonContainer &polys, 611 615 const BoundedRayContainer &rays, 612 616 const int maxPolyCandidates, -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r382 r383 131 131 long startTime = GetTime(); 132 132 133 int i;134 133 int totalSamples = 0; 135 134 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r380 r383 696 696 vector<bool> mSides; 697 697 bool mIsFront; 698 int mDepth; 698 699 699 700 BspSplitData(BspNode *node): 700 mNode(node), mIsFront(false) 701 mNode(node), mIsFront(false), mDepth(0) 701 702 {}; 703 702 704 BspSplitData(BspNode *node, 703 705 vector<Plane3 *> planes, 704 706 vector<bool> sides, 705 bool isFront): 706 mNode(node), mPlanes(planes), 707 mSides(sides), mIsFront(isFront) 707 const bool isFront, 708 const int depth): 709 mNode(node), mPlanes(planes), mSides(sides), 710 mIsFront(isFront), mDepth(depth) 708 711 {}; 709 712 }; 710 713 711 void X3dExporter::ExportLeavesGeometry(const BspTree &tree, const vector<BspLeaf *> &leaves) 714 void X3dExporter::ExportLeavesGeometry(const BspTree &tree, 715 const vector<BspLeaf *> &leaves) 712 716 { 713 717 vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); … … 724 728 } 725 729 726 void X3dExporter::ExportBspSplits(const BspTree &tree) 730 void X3dExporter::ExportBspSplits(const BspTree &tree, 731 const bool exportDepth) 727 732 { 728 733 std::stack<BspSplitData> tStack; … … 732 737 733 738 PolygonContainer polys; 739 vector <int> depths; 740 741 int maxDepth = 0; 734 742 735 743 while (!tStack.empty()) … … 739 747 tStack.pop(); 740 748 741 if (!tData.mNode->IsLeaf()) 749 if (tData.mNode->IsLeaf()) 750 { 751 if (tData.mDepth > maxDepth) 752 maxDepth = tData.mDepth; 753 } 754 else 742 755 { 743 756 BspInterior *interior = dynamic_cast<BspInterior *>(tData.mNode); 744 757 758 // add current side of split plane 745 759 if (tData.mNode != tree.GetRoot()) 746 tData.mSides.push_back(tData.mIsFront); // add current side of split plane760 tData.mSides.push_back(tData.mIsFront); 747 761 748 762 // bounded plane is added to the polygons 749 Polygon3 *planePoly = tree.GetBoundingBox().CrossSection(*interior->GetPlane()); 763 Polygon3 *planePoly = 764 tree.GetBoundingBox().CrossSection(*interior->GetPlane()); 750 765 751 766 // do all the splits with the previous planes … … 778 793 779 794 if (planePoly->Valid()) 795 { 780 796 polys.push_back(planePoly); 797 depths.push_back(tData.mDepth); 798 } 781 799 else 782 800 DEL_PTR(planePoly); 783 801 784 802 // push the children on the stack 785 tStack.push(BspSplitData(interior->GetFront(), tData.mPlanes, tData.mSides, true)); 786 tStack.push(BspSplitData(interior->GetBack(), tData.mPlanes, tData.mSides, false)); 787 } 788 } 789 ExportPolygons(polys); 803 tStack.push(BspSplitData(interior->GetFront(), tData.mPlanes, 804 tData.mSides, true, tData.mDepth + 1)); 805 tStack.push(BspSplitData(interior->GetBack(), tData.mPlanes, 806 tData.mSides, false, tData.mDepth + 1)); 807 } 808 } 809 810 if (maxDepth > 0) 811 { 812 mUseForcedMaterial = true; 813 814 for (int i = 0; i < (int)polys.size(); ++ i) 815 { 816 mForcedMaterial.mDiffuseColor.b = 1.0f; 817 float importance = (float)depths[i]/ (float)maxDepth; 818 819 mForcedMaterial.mDiffuseColor.r = importance; 820 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 821 822 ExportPolygon(polys[i]); 823 } 824 } 825 else 826 { 827 ExportPolygons(polys); 828 } 829 790 830 CLEAR_CONTAINER(polys); 791 831 } -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.h
r379 r383 75 75 76 76 virtual void 77 ExportBspSplits(const BspTree &tree );77 ExportBspSplits(const BspTree &tree, const bool exportDepth); 78 78 79 79 virtual void
Note: See TracChangeset
for help on using the changeset viewer.