- Timestamp:
- 10/11/05 19:25:27 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/VisibilityInfo.h
r316 r318 30 30 void SetProjectedPixels(int vis); 31 31 32 /** Computes ratio of visible to projected pixels. */ 32 /** Computes ratio of visible to projected pixels. 33 */ 33 34 float ComputeRelativeVisibility(); 34 35 … … 39 40 */ 40 41 void AddVisibility(const int visiblePixels, const int projectedPixels); 42 43 bool operator<(const VisibilityInfo<T> &b) const 44 { 45 return mSource < b.mSource; 46 } 47 48 bool operator==(const VisibilityInfo<T> &b) const 49 { 50 return mSource == b.mSource; 51 } 41 52 42 53 protected: -
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r313 r318 63 63 hierarchyType bspTree 64 64 height 7.0 65 maxViewCells 2065 maxViewCells 0 66 66 #hierarchyType kdTree 67 67 #hierarchyType sceneDependent 68 68 filename ../data/atlanta/atlanta_viewcells_large.x3d 69 69 # filename ../data/vienna/viewcells-25-sel.x3d 70 #filename ../data/vienna/viewcells-25.x3d70 filename ../data/vienna/viewcells-25.x3d 71 71 # filename ../data/vienna/viewcells-large-sel.x3d 72 72 } -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r313 r318 1647 1647 } 1648 1648 1649 struct VertexData 1650 { 1651 Vector3 mVertex; 1652 float mAngle; 1653 1654 VertexData(Vector3 vtx, float angle): mVertex(vtx), mAngle(angle) 1655 {} 1656 1657 bool operator<(const VertexData &b) const 1658 { 1659 return mAngle < b.mAngle; 1660 } 1661 }; 1662 1649 1663 // TODO: use a table to avoid normal and distance computations 1650 Polygon3 *AxisAlignedBox3::BoundPlane(const Plane3 &plane) 1651 { 1652 Vector3 ptA, ptB; 1653 int sideA = 0, sideB = 0; 1654 1655 VertexContainer vertices; 1656 1664 Polygon3 *AxisAlignedBox3::CrossSection(const Plane3 &plane) 1665 { 1666 Polygon3 *planePoly = new Polygon3(); 1667 1657 1668 int side[8]; 1658 1659 bool onFrontSide, onBackSide = false; 1660 1669 bool onFrontSide = false, onBackSide = false; 1670 1661 1671 Vector3 vtx; 1672 //-- compute classification of vertices 1662 1673 for (int i = 0; i < 8; ++i) 1663 1674 { … … 1669 1680 onBackSide = true; 1670 1681 else // vertex coincident => push_back 1671 vertices.push_back(vtx);1682 planePoly->mVertices.push_back(vtx); 1672 1683 } 1673 1684 1674 // does not intersect 1675 if (!onFrontSide && !onBackSide) 1676 return NULL; 1677 1678 for (int i = 0; i < 12; ++ i) 1685 //-- find intersections 1686 if (onFrontSide && onBackSide) 1679 1687 { 1680 int aIdx, bIdx; 1681 GetEdge(i, aIdx, bIdx); 1682 1683 ptA = GetVertex(aIdx); 1684 ptB = GetVertex(bIdx); 1685 1686 int sideA = side[aIdx]; 1687 int sideB = side[bIdx]; 1688 1689 if (((sideA > 0) && (sideB < 0)) || (sideA < 0) && (sideB > 0)) 1690 vertices.push_back(plane.FindIntersection(ptA, ptB)); 1691 } 1692 1693 // illformed polygon => swap 1694 // HACK: cannot work in abitrary cases 1695 if (vertices.size() > 3) 1696 { 1697 for (int j = 0; j < (int)vertices.size() - 1; ++j) 1688 Vector3 ptA, ptB; 1689 for (int i = 0; i < 12; ++ i) 1698 1690 { 1699 float minDist = 99999; 1700 int minIdx = j; 1701 1702 for (int i = j + 1; i < vertices.size(); ++i) 1703 { 1704 float dist = SqrDistance(vertices[j], vertices[i]); 1705 1706 if (dist < minDist) 1707 { 1708 minDist = dist; 1709 minIdx = i; 1710 } 1711 } 1712 1713 Vector3 vtx = vertices[minIdx]; 1714 vertices[minIdx] = vertices[j + 1]; 1715 vertices[j + 1] = vtx; 1691 int aIdx, bIdx; 1692 GetEdge(i, aIdx, bIdx); 1693 1694 ptA = GetVertex(aIdx); 1695 ptB = GetVertex(bIdx); 1696 1697 int sideA = side[aIdx]; 1698 int sideB = side[bIdx]; 1699 1700 if (((sideA > 0) && (sideB < 0)) || (sideA < 0) && (sideB > 0)) 1701 planePoly->mVertices.push_back(plane.FindIntersection(ptA, ptB)); 1716 1702 } 1717 1703 } 1718 1704 1719 Polygon3 *planePoly = new Polygon3(); 1720 1721 // wrong surface orientation? 1722 Vector3 norm = Normalize(CrossProd(vertices[0] - vertices[1], 1723 vertices[2] - vertices[1])); 1724 1725 1726 1727 if (DotProd(norm, plane.mNormal) > 0) 1728 for (int i = 0; i < (int)vertices.size(); ++ i) 1729 planePoly->mVertices.push_back(vertices[i]); 1730 else 1705 // order intersectioins 1706 if (planePoly->mVertices.size() > 3) 1731 1707 { 1732 for (int i = (int)vertices.size() - 1; i >= 0; -- i) 1733 planePoly->mVertices.push_back(vertices[i]); 1708 Vector3 centerOfMass(0); 1709 1710 // compute center of mass 1711 for (int i = 0; i < (int)planePoly->mVertices.size(); ++ i) 1712 centerOfMass += planePoly->mVertices[i]; 1713 1714 centerOfMass /= (float)planePoly->mVertices.size(); 1715 1716 vector<VertexData> vertexData; 1717 1718 Vector3 refVec = Normalize(centerOfMass - planePoly->mVertices[0]); 1719 1720 // compute angle to reference point 1721 for (int i = 1; i < (int)planePoly->mVertices.size(); ++ i) 1722 { 1723 float angle = 1724 Angle(refVec, centerOfMass - planePoly->mVertices[i], plane.mNormal); 1725 1726 vertexData.push_back(VertexData(planePoly->mVertices[i], angle)); 1727 } 1728 1729 std::stable_sort(vertexData.begin(), vertexData.end()); 1730 1731 // update vertices 1732 for (int i = 1; i < (int)planePoly->mVertices.size(); ++ i) 1733 planePoly->mVertices[i] = vertexData[i - 1].mVertex; 1734 1734 } 1735 1736 //Debug << *planePoly << "\narea: " << planePoly->GetArea() << endl; 1735 else if (planePoly->mVertices.size() == 3) 1736 { 1737 // fix orientation if needed 1738 if (DotProd(planePoly->GetNormal(), plane.mNormal) < 0) 1739 { 1740 Vector3 v = planePoly->mVertices[1]; 1741 planePoly->mVertices[1] = planePoly->mVertices[2]; 1742 planePoly->mVertices[2] = v; 1743 } 1744 } 1737 1745 1738 1746 return planePoly; 1739 1747 } 1740 /*1741 const int AxisAlignedBox3::complEdgeTbl[12][3] =1742 {1743 {3, 4, 5},1744 {3, 4, 5},1745 {3, 4, 5},1746 {0, 1, 2},1747 {0, 1, 2},1748 {0, 1, 2},1749 {9, 10, 11},1750 {8, 9, 10},1751 {7, 10, 11},1752 {6, 7, 11},1753 {6, 7, 8},1754 {6, 8, 9},1755 };1756 */1757 1758 /*1759 inline void addEdge(int idx, int ptAIdx, int ptBIdx)1760 {1761 edgeTable[idx].push_back(edge(ptAIdx, ptBIdx));1762 }1763 int AxisAlignedBox3::CreateEdgeTable()1764 {1765 //-- four vertices pattern 1 (3 + reflection)1766 int idx = getIdx(1) + getIdx(2) + getIdx(5) + getIdx(6);1767 addEdge(idx, 1, 0); addEdge(idx, 3, 2); addEdge(idx, 7, 6; addEdge(idx, 4, 5);1768 int idx = 255 - idx;1769 addEdge(idx, 4, 5); addEdge(idx, 7, 6); addEdge(idx, 3, 2); addEdge(idx, 1, 0);1770 1771 int idx = getIdx(0) + getIdx(1) + getIdx(2) + getIdx(3);1772 addEdge(idx, 0, 4); addEdge(idx, 3, 7); addEdge(idx, 2, 6); addEdge(idx, 1, 5);1773 int idx = 255 - idx;1774 addEdge(idx, 1, 5); addEdge(idx, 2, 6); addEdge(idx, 3, 7); addEdge(idx, 0, 4);1775 1776 int idx = getIdx(2) + getIdx(6) + getIdx(7) + getIdx(3);1777 addEdge(idx, 0, 3); addEdge(idx, 4, 7); addEdge(idx, 5, 6); addEdge(idx, 1, 2);1778 int idx = 255 - idx;1779 addEdge(idx, 1, 2); addEdge(idx, 5, 6); addEdge(idx, 4, 7); addEdge(idx, 0, 3);1780 1781 1782 //-- four vertices pattern 2 (12 + reflection1783 int idx = getIdx(0) + getIdx(4);1784 addEdge(idx, 0, 1); addEdge(idx, 0, 3); addEdge(idx, 4, 7; addEdge(idx, 4, 5);1785 }1786 */ -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.h
r312 r318 305 305 void GetEdge(const int edge, int &aIdx, int &bIdx) const; 306 306 307 /** Bounds plane with box. Returns polygon resulting from the bounded308 plane.307 /** Computes cross section of plane with box (i.e., bounds box). 308 @returns the cross section 309 309 */ 310 Polygon3 * BoundPlane(const Plane3 &plane);310 Polygon3 *CrossSection(const Plane3 &plane); 311 311 312 312 #define __EXTENT_HACK … … 360 360 static const int fsvertices[27][9]; 361 361 362 // table storing the complementary edges of each edge363 //static const int complEdgeTbl[12][3];364 365 362 // input and output operator with stream 366 363 friend ostream& operator<<(ostream &s, const AxisAlignedBox3 &A); -
trunk/VUT/GtpVisibilityPreprocessor/src/Containers.h
r263 r318 12 12 class Intersectable; 13 13 class Polygon3; 14 class Ray; 14 15 15 /** Container storing polygons used during BSP tree construction 16 /** Container storing polygons used during BSP tree construction. 16 17 */ 17 18 typedef vector<Polygon3 *> PolygonContainer; 19 20 /** Container storing a bundle of rays. 21 */ 22 typedef vector<Ray *> RayContainer; 18 23 19 24 /** Container for Mesh pointers primarily for the use within the kDTree and -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r317 r318 56 56 VertexContainer::const_iterator it; 57 57 58 bool foundSplit = false; 58 59 // find line - plane intersections 59 60 for (it = mVertices.begin(); it != mVertices.end(); ++ it) … … 71 72 72 73 // test if split point not too close to previous split point 73 if ( (splitPts.size() == 0)||74 if (!foundSplit || 74 75 (SqrDistance(splitPt, splitPts.back()) > SIDE_TOLERANCE_SQRD)) 75 76 { … … 79 80 80 81 splitPts.push_back(splitPt); 82 foundSplit = true; 81 83 } 82 84 } … … 91 93 // test if split point not too close to other split point 92 94 // test if split point not too close to previous split point 93 if ( (splitPts.size() == 0)||95 if (!foundSplit || 94 96 (SqrDistance(splitPt, splitPts.back()) > SIDE_TOLERANCE_SQRD)) 95 97 { … … 99 101 100 102 splitPts.push_back(splitPt); 103 foundSplit = true; 101 104 } 102 105 } -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r316 r318 400 400 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 401 401 << pvsSize/(float)objects.size() << endl 402 << "avg ray contrib=" << passSampleContributions/(float)passContributingSamples << endl; 402 << "avg ray contrib=" << 403 ((passContributingSamples > 0) ? passSampleContributions/(float)passContributingSamples : 0) 404 << endl; 403 405 404 406 … … 410 412 "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 411 413 "#AvgPVS\n"<< pvsSize/(float)objects.size() << endl << 412 "#AvgRayContrib\n" << passSampleContributions/(float)passContributingSamples << endl; 414 "#AvgRayContrib\n" << 415 ((passContributingSamples > 0) ? passSampleContributions/(float)passContributingSamples : 0) 416 << endl; 413 417 } 414 418 -
trunk/VUT/GtpVisibilityPreprocessor/src/Vector3.h
r176 r318 299 299 } 300 300 301 // angle between two vectors with respect to a surface normal in the 302 // range [0 .. 2 * pi] 303 inline float 304 Angle(const Vector3 &A, const Vector3 &B, const Vector3 &norm) 305 { 306 Vector3 cross = CrossProd(A, B); 307 308 float signedAngle; 309 310 if (DotProd(cross, norm) > 0) 311 signedAngle = atan2(-Magnitude(CrossProd(A, B)), DotProd(A, B)); 312 else 313 signedAngle = atan2(Magnitude(CrossProd(A, B)), DotProd(A, B)); 314 315 if (signedAngle < 0) 316 return 2 * PI + signedAngle; 317 318 return signedAngle; 319 } 320 301 321 inline Vector3 302 322 Vector3::operator+() const -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r313 r318 149 149 } 150 150 151 void BspInterior::SplitPolygons(PolygonContainer *polys,152 PolygonContainer *frontPolys,153 PolygonContainer *backPolys,154 PolygonContainer *coincident,151 void BspInterior::SplitPolygons(PolygonContainer &polys, 152 PolygonContainer &frontPolys, 153 PolygonContainer &backPolys, 154 PolygonContainer &coincident, 155 155 int &splits, 156 156 bool storePolys) … … 160 160 Debug << "splitting polygons of node " << this << " with plane " << mPlane << endl; 161 161 #endif 162 while (!polys ->empty())163 { 164 Polygon3 *poly = polys ->back();165 polys ->pop_back();162 while (!polys.empty()) 163 { 164 Polygon3 *poly = polys.back(); 165 polys.pop_back(); 166 166 167 167 //Debug << "New polygon with plane: " << poly->GetSupportingPlane() << "\n"; … … 179 179 case Polygon3::COINCIDENT: 180 180 //Debug << "coincident" << endl; 181 coincident ->push_back(poly);181 coincident.push_back(poly); 182 182 break; 183 183 case Polygon3::FRONT_SIDE: 184 184 //Debug << "front" << endl; 185 frontPolys ->push_back(poly);185 frontPolys.push_back(poly); 186 186 break; 187 187 case Polygon3::BACK_SIDE: 188 188 //Debug << "back" << endl; 189 backPolys ->push_back(poly);189 backPolys.push_back(poly); 190 190 break; 191 191 case Polygon3::SPLIT: … … 200 200 // check if polygons still valid 201 201 if (front_piece->Valid()) 202 frontPolys ->push_back(front_piece);202 frontPolys.push_back(front_piece); 203 203 else 204 204 DEL_PTR(front_piece); 205 205 206 206 if (back_piece->Valid()) 207 backPolys ->push_back(back_piece);207 backPolys.push_back(back_piece); 208 208 else 209 209 DEL_PTR(back_piece); … … 402 402 403 403 // split viewcell polygons with respect to split plane 404 interior->SplitPolygons( tData.mPolygons,405 frontPolys,406 backPolys,407 &coincident,404 interior->SplitPolygons(*tData.mPolygons, 405 *frontPolys, 406 *backPolys, 407 coincident, 408 408 splits, 409 409 mStoreSplitPolys); … … 475 475 } 476 476 477 int BspTree:: Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects)477 int BspTree::AddToPolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects) 478 478 { 479 479 int limit = (maxObjects > 0) ? Min((int)viewCells.size(), maxObjects) : (int)viewCells.size(); … … 491 491 } 492 492 493 int BspTree:: Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects)493 int BspTree::AddToPolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects) 494 494 { 495 495 int limit = (maxObjects > 0) ? Min((int)objects.size(), maxObjects) : (int)objects.size(); … … 531 531 // copy view cell meshes into one big polygon soup 532 532 PolygonContainer *polys = new PolygonContainer(); 533 mStat.polys = Copy2PolygonSoup(viewCells, *polys);533 mStat.polys = AddToPolygonSoup(viewCells, *polys); 534 534 535 535 // construct tree from viewcell polygons … … 546 546 547 547 // copy mesh instance polygons into one big polygon soup 548 mStat.polys = Copy2PolygonSoup(objects, *polys);548 mStat.polys = AddToPolygonSoup(objects, *polys); 549 549 550 550 // construct tree from polygon soup … … 607 607 leaf->SetViewCell(tData.mViewCell); 608 608 609 //-- clean up 610 609 611 // remaining polygons are discarded or added to node 610 612 leaf->ProcessPolygons(tData.mPolygons, mStoreSplitPolys); 611 613 DEL_PTR(tData.mPolygons); 614 615 CLEAR_CONTAINER(*tData.mRays); 616 DEL_PTR(tData.mRays); 612 617 613 618 return leaf; … … 621 626 // create new interior node and two leaf nodes 622 627 BspInterior *interior = SubdivideNode(dynamic_cast<BspLeaf *>(tData.mNode), 623 tData.mPolygons, 624 frontPolys, 625 backPolys, 626 &coincident); 628 *tData.mPolygons, 629 *frontPolys, 630 *backPolys, 631 coincident, 632 *tData.mRays); 627 633 628 634 ViewCell *frontViewCell = mRootCell; … … 648 654 interior->ProcessPolygons(&coincident, mStoreSplitPolys); 649 655 656 // split rays 657 RayContainer *frontRays = NULL; 658 RayContainer *backRays = NULL; 659 660 if (tData.mRays->size() > 0) 661 { 662 RayContainer *frontRays = new RayContainer(); 663 RayContainer *backRays = new RayContainer(); 664 665 Plane3 plane; 666 SplitRays(plane, *tData.mRays, *frontRays, *backRays); 667 } 668 650 669 // push the children on the stack 651 tStack.push(BspTraversalData(interior->GetBack(), backPolys, tData.mDepth + 1, backViewCell)); 652 tStack.push(BspTraversalData(interior->GetFront(), frontPolys, tData.mDepth + 1, frontViewCell)); 670 tStack.push(BspTraversalData(interior->GetBack(), 671 backPolys, 672 tData.mDepth + 1, 673 backViewCell, 674 backRays)); 675 676 tStack.push(BspTraversalData(interior->GetFront(), 677 frontPolys, 678 tData.mDepth + 1, 679 frontViewCell, 680 frontRays)); 653 681 654 682 // cleanup 655 683 DEL_PTR(tData.mNode); 656 684 DEL_PTR(tData.mPolygons); 685 DEL_PTR(tData.mRays); 657 686 658 687 return interior; … … 684 713 foundFront = true; 685 714 } 686 //if (foundFront) Debug << "front viewCell: " << *frontViewCell << endl;687 //if (foundBack) Debug << "back viewCell: " << *backViewCell << endl;688 715 } 689 716 } 690 717 691 718 BspInterior *BspTree::SubdivideNode(BspLeaf *leaf, 692 PolygonContainer *polys, 693 PolygonContainer *frontPolys, 694 PolygonContainer *backPolys, 695 PolygonContainer *coincident) 719 PolygonContainer &polys, 720 PolygonContainer &frontPolys, 721 PolygonContainer &backPolys, 722 PolygonContainer &coincident, 723 const RayContainer &rays) 696 724 { 697 725 mStat.nodes += 2; 698 726 699 727 // add the new nodes to the tree + select subdivision plane 700 BspInterior *interior = new BspInterior(SelectPlane(leaf, *polys));728 BspInterior *interior = new BspInterior(SelectPlane(leaf, polys, rays)); 701 729 702 730 #ifdef _DEBUG … … 707 735 int splits = 0; 708 736 709 interior->SplitPolygons(polys, frontPolys, backPolys, coincident, splits, mStoreSplitPolys); 737 interior->SplitPolygons(polys, 738 frontPolys, 739 backPolys, 740 coincident, 741 splits, 742 mStoreSplitPolys); 710 743 711 744 mStat.splits += splits; … … 829 862 } 830 863 831 Plane3 BspTree::SelectPlane(BspLeaf *leaf, PolygonContainer &polys) 864 Plane3 BspTree::SelectPlane(BspLeaf *leaf, 865 PolygonContainer &polys, 866 const RayContainer &rays) 832 867 { 833 868 if (polys.size() == 0) … … 882 917 883 918 // use heuristics to find appropriate plane 884 return SelectPlaneHeuristics(polys, sMaxCandidates); 885 } 886 887 Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, int maxTests) 919 return SelectPlaneHeuristics(polys, rays, sMaxCandidates); 920 } 921 922 Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, 923 const RayContainer &rays, 924 const int maxTests) 888 925 { 889 926 float lowestCost = MAX_FLOAT; … … 901 938 902 939 // evaluate current candidate 903 float candidateCost = EvalSplitPlane(polys, candidatePlane );940 float candidateCost = EvalSplitPlane(polys, candidatePlane, rays); 904 941 905 942 if (candidateCost < lowestCost) … … 928 965 } 929 966 930 float BspTree::EvalSplitPlane(PolygonContainer &polys, const Plane3 &candidatePlane) 967 float BspTree::EvalSplitPlane(PolygonContainer &polys, 968 const Plane3 &candidatePlane, 969 const RayContainer &rays) 931 970 { 932 971 float val = 0; … … 1318 1357 } 1319 1358 } 1359 1360 void BspTree::SplitRays(const Plane3 plane, 1361 RayContainer &rays, 1362 RayContainer &frontRays, 1363 RayContainer &backRays) 1364 { 1365 while (!rays.empty()) 1366 { 1367 //TODO 1368 } 1369 } 1320 1370 //} // GtpVisibilityPreprocessor -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r313 r318 8 8 class ViewCell; 9 9 class Plane3; 10 //class Mesh;11 10 class BspTree; 12 11 class BspInterior; … … 14 13 class AxisAlignedBox3; 15 14 class Ray; 16 17 //namespace GtpVisibilityPreprocessor {18 19 /** Container storing a soup of polygons used during BSP tree construction20 */21 typedef vector<Polygon3 *> PolygonContainer;22 typedef vector<Ray *> RayContainer;23 15 24 16 struct BspRayTraversalData … … 179 171 void SetupChildLinks(BspNode *b, BspNode *f); 180 172 181 /** Splits polygons. 182 @param polys the polygons to be split 173 /** Splits polygons with respect to the split plane. 174 @param polys the polygons to be split. the polygons are consumed and 175 distributed to the containers frontPolys, backPolys, coincident. 183 176 @param frontPolys returns the polygons in the front of the split plane 184 177 @param backPolys returns the polygons in the back of the split plane … … 187 180 @param storePolys if the polygons should be stored in the node 188 181 */ 189 void SplitPolygons(PolygonContainer *polys,190 PolygonContainer *frontPolys,191 PolygonContainer *backPolys,192 PolygonContainer *coincident,193 int &splits, 182 void SplitPolygons(PolygonContainer &polys, 183 PolygonContainer &frontPolys, 184 PolygonContainer &backPolys, 185 PolygonContainer &coincident, 186 int &splits, 194 187 bool storePolys = false); 195 188 … … 261 254 /// the view cell associated with this subdivsion 262 255 ViewCell *mViewCell; 263 /// if the node is an inside or outside node with respect to the parent plane 264 //bool mIsInside; 265 BspTraversalData() {} 256 /// rays piercing this node 257 RayContainer *mRays; 258 259 BspTraversalData(): 260 mNode(NULL), 261 mPolygons(NULL), 262 mDepth(0), 263 mViewCell(NULL), 264 mRays(NULL) 265 {} 266 266 267 BspTraversalData(BspNode *node, PolygonContainer *polys, const int depth, ViewCell *viewCell): 268 mNode(node), mPolygons(polys), mDepth(depth), mViewCell(viewCell) {} 267 BspTraversalData(BspNode *node, 268 PolygonContainer *polys, 269 const int depth, 270 ViewCell *viewCell, 271 RayContainer *rays = NULL): 272 mNode(node), 273 mPolygons(polys), 274 mDepth(depth), 275 mViewCell(viewCell), 276 mRays(rays) 277 {} 269 278 }; 270 279 … … 364 373 365 374 /** Evaluates the contribution of the candidate split plane. 375 @note the polygons can be reordered in the process. 366 376 @returns the cost of the candidate split plane 367 377 */ 368 float EvalSplitPlane(PolygonContainer &polys, const Plane3 &candidatePlane); 378 float EvalSplitPlane(PolygonContainer &polys, 379 const Plane3 &candidatePlane, 380 const RayContainer &rays); 369 381 370 382 /** Evaluates tree stats in the BSP tree leafs. … … 382 394 @param leaf the leaf to be split 383 395 @param polys the polygon list on which the split decition is based 384 */ 385 Plane3 SelectPlane(BspLeaf *leaf, PolygonContainer &polys); 396 @param rays ray container on which selection may be based 397 Returns the split plane 398 */ 399 Plane3 SelectPlane(BspLeaf *leaf, 400 PolygonContainer &polys, 401 const RayContainer &ray); 386 402 387 403 /** Filters next view cell down the tree and inserts it into the appropriate leaves … … 401 417 @param backPolys returns the polygons in the back of the split plane 402 418 @param coincident returns the polygons coincident to the split plane 419 @param rays ray container used to guide the split process 403 420 @returns the root of the subdivision 404 421 */ 405 422 BspInterior *SubdivideNode(BspLeaf *leaf, 406 PolygonContainer *polys, 407 PolygonContainer *frontPolys, 408 PolygonContainer *backPolys, 409 PolygonContainer *coincident); 423 PolygonContainer &polys, 424 PolygonContainer &frontPolys, 425 PolygonContainer &backPolys, 426 PolygonContainer &coincident, 427 const RayContainer &rays); 410 428 411 429 /** Filters polygons down the tree. … … 418 436 PolygonContainer *frontPolys, PolygonContainer *backPolys); 419 437 420 /** Selects the split plane in order to get a balanced tree. 438 /** Selects the split plane in order to construct a tree with 439 certain characteristics (e.g., balanced tree, least splits, 440 2.5d aligned) 421 441 @param polygons container of polygons 442 @param rays bundle of rays on which the split can be based 422 443 @param maxTests the maximal number of candidate tests 423 444 */ 424 Plane3 SelectPlaneHeuristics(PolygonContainer &polys, const int maxTests); 425 426 /** Extracts the meshes of the objects and copies them into the mesh. 445 Plane3 SelectPlaneHeuristics(PolygonContainer &polys, 446 const RayContainer &rays, 447 const int maxTests); 448 449 /** Extracts the meshes of the objects and adds them to polygons. 427 450 Adds object aabb to the aabb of the tree. 428 451 @param maxPolys the maximal number of objects to be stored as polygons 429 452 @returns the number of polygons 430 453 */ 431 int Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects = 0); 432 /** Extracts the meshes of the view cells and copies them into the mesh. 454 int AddToPolygonSoup(const ObjectContainer &objects, 455 PolygonContainer &polys, 456 int maxObjects = 0); 457 458 /** Extracts the meshes of the view cells and and adds them to polygons. 433 459 Adds view cell aabb to the aabb of the tree. 434 460 @param maxPolys the maximal number of objects to be stored as polygons 435 461 @returns the number of polygons 436 462 */ 437 int Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects = 0); 463 int AddToPolygonSoup(const ViewCellContainer &viewCells, 464 PolygonContainer &polys, 465 int maxObjects = 0); 438 466 439 467 /** Extract polygons of this mesh and add to polygon container. … … 491 519 vector<SortableEntry> &splitCandidates) const; 492 520 521 /** Splits the rays into front and back rays according to split plane 522 @param rays contains the rays to be split. The rays are 523 distributed to front and back rays. 524 @param frontRays returns rays on the front side of the plane 525 @param backRays returns rays on the back side of the plane 526 */ 527 void BspTree::SplitRays(const Plane3 plane, 528 RayContainer &rays, 529 RayContainer &frontRays, 530 RayContainer &backRays); 531 493 532 /// Pointer to the root of the tree 494 533 BspNode *mRoot; -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r316 r318 249 249 VertexContainer::const_iterator vi; 250 250 251 for (vi = poly->mVertices.begin(); vi != poly->mVertices.end(); ++vi) 252 { 253 stream << index ++ << " "; 254 } 251 for (int index = 0; index < (int)poly->mVertices.size(); ++ index) 252 stream << index << " "; 253 254 if (mWireframe) // final line to finish polygon 255 stream << "0 "; 256 255 257 stream << "-1" << endl; 256 257 258 stream << "\" >" << endl; 258 259 … … 278 279 void X3dExporter::ExportPolygons(const PolygonContainer &polys) 279 280 { 280 stream << "<Shape>" << endl;281 stream << "<Shape>" << endl; 281 282 stream << "<Appearance>" << endl; 282 283 … … 319 320 { 320 321 Polygon3 *poly = *pit; 322 int startIdx = index; 321 323 for (vi = poly->mVertices.begin(); vi != poly->mVertices.end(); ++vi) 322 324 { 323 325 stream << index ++ << " "; 324 326 } 327 328 stream << startIdx << " ";// finish line 325 329 stream << "-1" << endl; 326 330 } … … 329 333 330 334 stream << "<Coordinate point=\"" << endl; 331 for (pit = polys.begin(); pit != polys.end(); ++ pit)335 for (pit = polys.begin(); pit != polys.end(); ++ pit) 332 336 { 333 337 Polygon3 *poly = *pit; … … 657 661 658 662 // bounded plane is added to the polygons 659 Polygon3 *planePoly = tree.GetBoundingBox(). BoundPlane(*interior->GetPlane());663 Polygon3 *planePoly = tree.GetBoundingBox().CrossSection(*interior->GetPlane()); 660 664 661 665 // do all the splits with the previous planes … … 689 693 else 690 694 { 691 Debug << "polygon not valid: " << *planePoly << " size: " << (int)planePoly->mVertices.size() << endl;695 //Debug << "polygon not valid: " << *planePoly << " size: " << (int)planePoly->mVertices.size() << endl; 692 696 DEL_PTR(planePoly); 693 697 } … … 720 724 721 725 // bounded plane is added to the polygons 722 polys.push_back(tree.GetBoundingBox(). BoundPlane(*interior->GetPlane()));726 polys.push_back(tree.GetBoundingBox().CrossSection(*interior->GetPlane())); 723 727 724 728 // push the children on the stack -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp
r312 r318 484 484 ptr = endptr; 485 485 486 float y = strtod(ptr, &endptr);486 float y = (float)strtod(ptr, &endptr); 487 487 488 488 … … 491 491 ptr = endptr; 492 492 493 float z = strtod(ptr, &endptr);493 float z = (float)strtod(ptr, &endptr); 494 494 495 495 if (ptr == endptr) -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r315 r318 66 66 m.mDiffuseColor = RgbColor(1, 0, 0); 67 67 exporter->SetForcedMaterial(m); 68 exporter->SetWireframe(); 68 exporter->SetWireframe();//exporter->SetFilled(); 69 69 exporter->ExportBspSplits(*p->mBspTree); 70 70 71 m.mDiffuseColor = RgbColor(0, 1, 0);72 exporter->SetForcedMaterial(m);71 //m.mDiffuseColor = RgbColor(0, 1, 0); 72 //exporter->SetForcedMaterial(m); 73 73 exporter->SetFilled(); 74 74 75 exporter->ResetForcedMaterial(); 75 76 exporter->ExportViewCells(p->mViewCells); 76 77 -
trunk/VUT/Ogre/src/OgreOcclusionQueriesQueryManager.cpp
r316 r318 7 7 8 8 namespace Ogre { 9 10 //-----------------------------------------------------------------------11 bool nodeinfo_eq(const GtpVisibility::NodeInfo &a, const GtpVisibility::NodeInfo &b)12 {13 return a.GetSource() == b.GetSource();14 }15 bool nodeinfo_lt(const GtpVisibility::NodeInfo &a, const GtpVisibility::NodeInfo &b)16 {17 return a.GetSource() < b.GetSource();18 }19 bool meshinfo_eq(const GtpVisibility::MeshInfo &a, const GtpVisibility::MeshInfo &b)20 {21 return a.GetSource() == b.GetSource();22 }23 bool meshinfo_lt(const GtpVisibility::MeshInfo &a, const GtpVisibility::MeshInfo &b)24 {25 return a.GetSource() < b.GetSource();26 }27 bool patchinfo_eq(const GtpVisibility::PatchInfo &a, const GtpVisibility::PatchInfo &b)28 {29 return a.GetSource() == b.GetSource();30 }31 bool patchinfo_lt(const GtpVisibility::PatchInfo &a, const GtpVisibility::PatchInfo &b)32 {33 return a.GetSource() < b.GetSource();34 }35 9 36 10 //----------------------------------------------------------------------- … … 408 382 GtpVisibility::NodeInfoContainer *visibleNodes) 409 383 { 410 s ort(visibleNodes->begin(), visibleNodes->end(), nodeinfo_lt);384 stable_sort(visibleNodes->begin(), visibleNodes->end()/*, nodeinfo_lt*/); 411 385 412 386 GtpVisibility::NodeInfoContainer::iterator visibleNodesIt, … … 429 403 430 404 // physically delete duplicates 431 visibleNodes->erase(std::unique(visibleNodes->begin(), visibleNodes->end() , nodeinfo_eq),405 visibleNodes->erase(std::unique(visibleNodes->begin(), visibleNodes->end()), 432 406 visibleNodes->end()); 433 407 } … … 436 410 GtpVisibility::MeshInfoContainer *visibleGeometry) 437 411 { 438 s ort(visibleGeometry->begin(), visibleGeometry->end(), meshinfo_lt);412 stable_sort(visibleGeometry->begin(), visibleGeometry->end()); 439 413 440 414 GtpVisibility::MeshInfoContainer::iterator visibleGeomIt, … … 457 431 458 432 // physically delete duplicates 459 visibleGeometry->erase(std::unique(visibleGeometry->begin(), visibleGeometry->end() , meshinfo_eq),433 visibleGeometry->erase(std::unique(visibleGeometry->begin(), visibleGeometry->end()), 460 434 visibleGeometry->end()); 461 435 } … … 464 438 GtpVisibility::PatchInfoContainer *visiblePatches) 465 439 { 466 s ort(visiblePatches->begin(), visiblePatches->end(), patchinfo_lt);440 stable_sort(visiblePatches->begin(), visiblePatches->end()); 467 441 468 442 GtpVisibility::PatchInfoContainer::iterator visiblePatchIt, … … 485 459 486 460 // physically delete duplicates 487 visiblePatches->erase(std::unique(visiblePatches->begin(), visiblePatches->end() , patchinfo_eq),461 visiblePatches->erase(std::unique(visiblePatches->begin(), visiblePatches->end()), 488 462 visiblePatches->end()); 489 463 } -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
r316 r318 1034 1034 1035 1035 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 1036 mNumOct reeNodes = 1;1036 mNumOctants = 1; 1037 1037 #endif // GTP_VISIBILITY_MODIFIED_OGRE 1038 1038
Note: See TracChangeset
for help on using the changeset viewer.