Changeset 383 for trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
- Timestamp:
- 11/06/05 01:24:55 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.