- Timestamp:
- 11/18/05 16:29:31 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r421 r422 68 68 ViewCells { 69 69 #hierarchy kdTree 70 #hierarchy vspTree71 hierarchy bspTree70 hierarchy vspTree 71 #hierarchy bspTree 72 72 # hierarchy sceneDependent 73 73 … … 91 91 BspTree { 92 92 Construction { 93 input from Rays93 input fromSamples 94 94 # input fromViewCells 95 95 # input fromSceneGeometry … … 219 219 220 220 splitType regular 221 222 numberOfEndPointDomains 10000 221 # splitType heuristics 223 222 ct_div_ci 0.0 224 223 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r419 r422 11 11 mKdTree(NULL), 12 12 mBspTree(NULL), 13 mVspKdTree(NULL), 13 14 mRenderSimulator(NULL) 14 15 { … … 18 19 Preprocessor::~Preprocessor() 19 20 { 20 DeleteViewCells();21 22 21 DEL_PTR(mBspTree); 23 22 DEL_PTR(mKdTree); 24 23 25 24 DEL_PTR(mRenderSimulator); 25 26 DeleteViewCells(); 26 27 } 27 28 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r421 r422 73 73 mBspTree->Construct(objects); 74 74 break; 75 case BspTree::FROM_ RAYS:75 case BspTree::FROM_SAMPLES: 76 76 DeleteViewCells(); // we generate new view cells 77 77 mBspTree->SetGenerateViewCells(true); … … 490 490 passSampleContributions); 491 491 492 //mVspKdTree->Construct(mSampleRays, mBoundingBox);493 492 } 494 493 else if (ViewCell::sHierarchy == ViewCell::VSP) … … 555 554 556 555 //-- render simulation 557 cout << "\nevaluating bsp view cells render time before merge ... "; 558 GetRenderSimulator()->SimulateRendering(); 559 560 cout << " finished" << endl; 561 562 cout << GetRenderSimulator()->mStat << endl; 563 Debug << GetRenderSimulator()->mStat << endl; 564 556 RenderSimulator *rs = GetRenderSimulator(); 557 558 if (rs) 559 { 560 cout << "\nevaluating bsp view cells render time before merge ... "; 561 562 rs->SimulateRendering(); 563 564 cout << " finished" << endl; 565 566 cout << GetRenderSimulator()->mStat << endl; 567 Debug << GetRenderSimulator()->mStat << endl; 568 } 565 569 566 570 if (mBspTree) … … 618 622 619 623 //-- render simulation 620 cout << "\nevaluating render time after merge ... "; 621 622 GetRenderSimulator()->SimulateRendering(); 623 cout << " finished" << endl; 624 625 cout << GetRenderSimulator()->mStat << endl; 626 Debug << GetRenderSimulator()->mStat << endl; 624 625 RenderSimulator *rs = GetRenderSimulator(); 626 627 if (rs) 628 { 629 cout << "\nevaluating render time after merge ... "; 630 631 rs->SimulateRendering(); 632 633 cout << " finished" << endl; 634 635 cout << GetRenderSimulator()->mStat << endl; 636 Debug << GetRenderSimulator()->mStat << endl; 637 } 627 638 628 639 if (1) // export view cells … … 659 670 exporter->SetExportRayDensity(true); 660 671 exporter->ExportKdTree(*mKdTree); 661 662 if (mBspTree && (ViewCell::sHierarchy == ViewCell::VSP)) 663 exporter->ExportVspKdTree(*mVspKdTree); 664 672 delete exporter; 673 } 674 675 if (mVspKdTree) 676 { 677 Exporter *exporter = Exporter::GetExporter("vspkdtree.x3d"); 678 exporter->SetWireframe(); 679 exporter->ExportVspKdTree(*mVspKdTree); 665 680 delete exporter; 666 681 } … … 732 747 int &sampleContributions) 733 748 { 734 // save rays for bsp tree construction735 749 if (!mVspKdTree) 736 750 { 751 // store samples for vsp kd tree construction 737 752 if ((int)mVspSampleRays.size() < mVspConstructionSamples) 738 753 { 739 MeshInstance *mi = dynamic_cast<MeshInstance *>(object);740 741 754 VssRay *sRay = new VssRay(ray); 742 mVspSampleRays.push_back(sRay); 755 756 mVspSampleRays.push_back(sRay); 743 757 744 758 // also add origin to sample … … 749 763 // construct VSP tree using the collected samples 750 764 cout << "building VSP tree from " << (int)mVspSampleRays.size() << " samples " << endl; 765 mVspKdTree = new VspKdTree(); 751 766 mVspKdTree->Construct(mVspSampleRays); 752 767 … … 779 794 if (!mBspTree) 780 795 { 781 if ((BspTree::sConstructionMethod == BspTree::FROM_ RAYS) &&796 if ((BspTree::sConstructionMethod == BspTree::FROM_SAMPLES) && 782 797 ((int)mSampleRays.size() < mBspConstructionSamples)) 783 798 { … … 889 904 outRays.push_back(mSampleRays[i]); 890 905 } 891 if (BspTree::sConstructionMethod == BspTree::FROM_ RAYS)906 if (BspTree::sConstructionMethod == BspTree::FROM_SAMPLES) 892 907 { 893 908 // export rays -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r421 r422 300 300 301 301 //-- termination criteria for axis aligned split 302 environment->GetFloatValue("BspTree.Termination.AxisAligned.ct_div_ci", mCt _div_ci);302 environment->GetFloatValue("BspTree.Termination.AxisAligned.ct_div_ci", mCtDivCi); 303 303 environment->GetFloatValue("BspTree.Termination.AxisAligned.maxCostRatio", mMaxCostRatio); 304 304 environment->GetIntValue("BspTree.Termination.AxisAligned.maxPolys", … … 370 370 else if (strcmp(constructionMethodStr, "fromSceneGeometry") == 0) 371 371 sConstructionMethod = FROM_SCENE_GEOMETRY; 372 else if (strcmp(constructionMethodStr, "from Rays") == 0)373 sConstructionMethod = FROM_ RAYS;372 else if (strcmp(constructionMethodStr, "fromSamples") == 0) 373 sConstructionMethod = FROM_SAMPLES; 374 374 else 375 375 { … … 826 826 tBackData, 827 827 coincident, 828 interior->mPlane); 829 828 interior->mPlane); 830 829 } 831 830 … … 1036 1035 1037 1036 float oldCost = (float)polys.size(); 1038 float newCost = mCt _div_ci + minSum / boxArea;1037 float newCost = mCtDivCi + minSum / boxArea; 1039 1038 float ratio = newCost / oldCost; 1040 1039 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r421 r422 447 447 448 448 /// bsp tree construction types 449 enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_ RAYS};449 enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_SAMPLES}; 450 450 451 451 /** Returns statistics. … … 501 501 /// BSP tree construction method 502 502 static int sConstructionMethod; 503 504 503 505 protected: 504 506 … … 803 805 804 806 /// axis aligned split criteria 805 float mCt _div_ci;807 float mCtDivCi; 806 808 float mSplitBorder; 807 809 float mMaxCostRatio; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r421 r422 243 243 244 244 // Constructor 245 VspKdTree::VspKdTree() 245 VspKdTree::VspKdTree(): 246 mOnlyDrivingAxis(true) 246 247 { 247 248 environment->GetIntValue("VspKdTree.Termination.maxDepth", mTermMaxDepth); … … 250 251 environment->GetFloatValue("VspKdTree.Termination.maxRayContribution", mTermMaxRayContribution); 251 252 environment->GetFloatValue("VspKdTree.Termination.maxCostRatio", mTermMaxCostRatio); 252 253 253 environment->GetFloatValue("VspKdTree.Termination.minSize", mTermMinSize); 254 254 255 mTermMinSize = sqr(mTermMinSize); 255 256 256 environment->GetFloatValue("VspKdTree.epsilon", epsilon); 257 environment->GetFloatValue("VspKdTree.ct_div_ci", ct_div_ci); 258 259 environment->GetFloatValue("VspKdTree.maxTotalMemory", maxTotalMemory); 260 environment->GetFloatValue("VspKdTree.maxStaticMemory", maxStaticMemory); 261 262 263 environment->GetIntValue("VspKdTree.accessTimeThreshold", accessTimeThreshold); 264 //= 1000; 265 environment->GetIntValue("VspKdTree.minCollapseDepth", minCollapseDepth); 266 257 environment->GetFloatValue("VspKdTree.epsilon", mEpsilon); 258 environment->GetFloatValue("VspKdTree.ct_div_ci", mCtDivCi); 259 260 environment->GetFloatValue("VspKdTree.maxTotalMemory", mMaxTotalMemory); 261 environment->GetFloatValue("VspKdTree.maxStaticMemory", mMaxStaticMemory); 262 263 environment->GetIntValue("VspKdTree.accessTimeThreshold", mAccessTimeThreshold); 264 environment->GetIntValue("VspKdTree.minCollapseDepth", mMinCollapseDepth); 267 265 268 266 // split type … … 284 282 } 285 283 284 Debug << "======= vsp kd tree options ========" << endl; 285 Debug << "max depth: "<< mTermMaxDepth << endl; 286 Debug << "min pvs: "<< mTermMinPvs << endl; 287 Debug << "min rays: "<< mTermMinRays << endl; 288 Debug << "max ray contribution: "<< mTermMaxRayContribution << endl; 289 Debug << "max cost ratio: "<< mTermMaxCostRatio << endl; 290 Debug << "min size: "<<mTermMinSize << endl; 291 286 292 mRoot = NULL; 287 293 288 splitCandidates = new vector<SortableEntry>;294 mSplitCandidates = new vector<SortableEntry>; 289 295 } 290 296 … … 403 409 mStat.Start(); 404 410 405 m axMemory = maxStaticMemory;411 mMaxMemory = mMaxStaticMemory; 406 412 407 413 DEL_PTR(mRoot); … … 411 417 // first construct a leaf that will get subdivide 412 418 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(mRoot); 413 414 419 415 420 mStat.nodes = 1; … … 428 433 mBox = *forcedBoundingBox; 429 434 430 cout << "Bbox = " << mBox << endl;435 Debug << "bbox = " << mBox << endl; 431 436 432 437 mStat.rays = (int)leaf->mRays.size(); … … 438 443 mRoot = Subdivide(TraversalData(leaf, mBox, 0)); 439 444 440 if ( splitCandidates)441 { 442 // force re alease of this vector443 delete splitCandidates;444 splitCandidates = new vector<SortableEntry>;445 if (mSplitCandidates) 446 { 447 // force release of this vector 448 delete mSplitCandidates; 449 mSplitCandidates = new vector<SortableEntry>; 445 450 } 446 451 … … 476 481 lastMem = (int)mem; 477 482 478 if ( mem > maxMemory)483 if (mem > mMaxMemory) 479 484 { 480 485 // count statistics on unprocessed leafs … … 528 533 float costRatio; 529 534 530 if (splitType == ESplitRegular) { 535 if (splitType == ESplitRegular) 536 { 531 537 costRatio = BestCostRatioRegular(leaf, 532 538 axis, … … 556 562 if (costRatio > mTermMaxCostRatio) 557 563 { 558 // cout<<"Too big cost ratio "<<costRatio<<endl;564 cout<<"Too big cost ratio " << costRatio << endl; 559 565 return -1; 560 566 } 561 567 562 #if 0563 cout <<564 "pvs=" <<leaf->mPvsSize<<565 " rays=" <<leaf->mRays.size()<<566 " rc=" <<leaf->GetAvgRayContribution()<<567 " axis=" <<axis<<endl;568 #if 1 569 cout << 570 "pvs=" << leaf->mPvsSize << 571 " rays=" << (int)leaf->mRays.size() << 572 " rc=" << leaf->GetAvgRayContribution() << 573 " axis=" << axis << endl; 568 574 #endif 569 575 … … 624 630 625 631 // float sum = raysBack*(position - minBox) + raysFront*(maxBox - position); 626 float sum = pvsBack*(position - minBox) + pvsFront *(maxBox - position);627 628 newCost = ct_div_ci + sum/sizeBox;632 float sum = pvsBack*(position - minBox) + pvsFront * (maxBox - position); 633 634 newCost = mCtDivCi + sum /sizeBox; 629 635 630 636 // cout<<axis<<" "<<pvsSize<<" "<<pvsBack<<" "<<pvsFront<<endl; … … 637 643 } 638 644 639 float 640 VspKdTree::BestCostRatioRegular(VspKdTreeLeaf *leaf,641 int &axis,642 float &position,643 int &raysBack,644 int &raysFront,645 int &pvsBack,646 int &pvsFront) 647 { 648 int n RaysBack[6], nRaysFront[6];649 int nPvsBack[6], nPvsFront[6]; 650 float nPosition[ 6];651 float nCostRatio[ 6];645 float VspKdTree::BestCostRatioRegular(VspKdTreeLeaf *leaf, 646 int &axis, 647 float &position, 648 int &raysBack, 649 int &raysFront, 650 int &pvsBack, 651 int &pvsFront) 652 { 653 int nRaysBack[3], nRaysFront[3]; 654 int nPvsBack[3], nPvsFront[3]; 655 656 float nPosition[3]; 657 float nCostRatio[3]; 652 658 int bestAxis = -1; 653 659 … … 656 662 // int sAxis = box.Size().DrivingAxis(); 657 663 int sAxis = sBox.Size().DrivingAxis(); 658 659 bool onlyDrivingAxis = true; 660 661 for (axis = 0; axis < 6; ++ axis) 662 { 663 if (!onlyDrivingAxis || axis == sAxis) 664 665 for (axis = 0; axis < 3; ++ axis) 666 { 667 if (!mOnlyDrivingAxis || axis == sAxis) 664 668 { 665 669 nPosition[axis] = (sBox.Min()[axis] + sBox.Max()[axis])*0.5f; … … 746 750 Intersectable::NewMail(); 747 751 748 for (vector<SortableEntry>::const_iterator ci = splitCandidates->begin();749 ci < splitCandidates->end(); ++ ci)752 for (vector<SortableEntry>::const_iterator ci = mSplitCandidates->begin(); 753 ci < mSplitCandidates->end(); ++ ci) 750 754 { 751 755 VssRay *ray; … … 805 809 806 810 float oldCost = (float)leaf->GetPvsSize(); 807 float newCost = ct_div_ci + minSum / sizeBox;811 float newCost = mCtDivCi + minSum / sizeBox; 808 812 float ratio = newCost / oldCost; 809 813 810 // cout<<"===================="<<endl; 811 // cout<<"costRatio="<<ratio<<" pos="<<position<<" t="<<(position - minBox)/(maxBox - minBox) 812 // <<"\t q=("<<queriesBack<<","<<queriesFront<<")\t r=("<<raysBack<<","<<raysFront<<")"<<endl; 814 //Debug << "costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 815 // <<"\t q=(" << queriesBack << "," << queriesFront << ")\t r=(" << raysBack << "," << raysFront << ")" << endl; 813 816 814 817 return ratio; … … 818 821 const int axis) 819 822 { 820 splitCandidates->clear();823 mSplitCandidates->clear(); 821 824 822 825 int requestedSize = 2 * (int)(node->mRays.size()); 823 826 // creates a sorted split candidates array 824 if ( splitCandidates->capacity() > 500000 &&825 requestedSize < (int)( splitCandidates->capacity()/10) )826 { 827 delete splitCandidates;828 splitCandidates = new vector<SortableEntry>;829 } 830 831 splitCandidates->reserve(requestedSize);827 if (mSplitCandidates->capacity() > 500000 && 828 requestedSize < (int)(mSplitCandidates->capacity()/10) ) 829 { 830 delete mSplitCandidates; 831 mSplitCandidates = new vector<SortableEntry>; 832 } 833 834 mSplitCandidates->reserve(requestedSize); 832 835 833 836 // insert all queries … … 836 839 { 837 840 bool positive = (*ri).mRay->HasPosDir(axis); 838 splitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,839 (*ri).ExtrapOrigin(axis), (void *)&*ri));841 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 842 (*ri).ExtrapOrigin(axis), (void *)&*ri)); 840 843 841 splitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,842 (*ri).ExtrapTermination(axis), (void *)&*ri));843 } 844 845 stable_sort( splitCandidates->begin(), splitCandidates->end());844 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin, 845 (*ri).ExtrapTermination(axis), (void *)&*ri)); 846 } 847 848 stable_sort(mSplitCandidates->begin(), mSplitCandidates->end()); 846 849 } 847 850 … … 891 894 { 892 895 893 #if 0 894 if (leaf->mDepth >= termMaxDepth) { 895 cout<<"Warning: max depth reached depth="<<(int)leaf->mDepth<<" rays="<<leaf->mRays.size()<<endl; 896 cout<<"Bbox: "<<GetBBox(leaf)<<" dirbbox:"<<GetDirBBox(leaf)<<endl; 896 #if 1 897 if (leaf->mDepth >= mTermMaxDepth) 898 { 899 Debug << "Warning: max depth reached depth="<<(int)leaf->mDepth<<" rays=" << (int)leaf->mRays.size() << endl; 900 Debug << "Bbox: " << GetBBox(leaf) << endl; 897 901 } 898 902 #endif … … 1031 1035 1032 1036 // find a node in the tree which subtree will be collapsed 1033 int maxAccessTime = time - accessTimeThreshold;1037 int maxAccessTime = time - mAccessTimeThreshold; 1034 1038 int released = 0; 1035 1039 … … 1045 1049 VspKdTreeInterior *in = dynamic_cast<VspKdTreeInterior *>(node); 1046 1050 // cout<<"depth="<<(int)in->depth<<" time="<<in->lastAccessTime<<endl; 1047 if (in->mDepth >= m inCollapseDepth && in->mLastAccessTime <= maxAccessTime)1051 if (in->mDepth >= mMinCollapseDepth && in->mLastAccessTime <= maxAccessTime) 1048 1052 { 1049 1053 released = CollapseSubtree(node, time); … … 1092 1096 { 1093 1097 // memory check and realese... 1094 if (GetMemUsage() > m axTotalMemory)1098 if (GetMemUsage() > mMaxTotalMemory) 1095 1099 ReleaseMemory(pass); 1096 1100 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r421 r422 258 258 void UpdatePvsSize(); 259 259 260 void Mail();261 262 bool Mailed() const;263 264 bool Mailed(const int mail);265 266 260 /** Returns average contribution of a ray to the PVS 267 261 */ … … 270 264 */ 271 265 inline float GetSqrRayContribution() const; 266 267 //-- mailing options 268 269 void Mail(); 270 271 bool Mailed() const; 272 273 bool Mailed(const int mail); 272 274 273 275 static void NewMail(); … … 520 522 521 523 // total number of nodes of the tree 522 int nodes;524 int mNumNodes; 523 525 524 526 // axis aligned bounding box of the scene … … 526 528 527 529 // epsilon used for the construction 528 float epsilon;530 float mEpsilon; 529 531 530 532 // ratio between traversal and intersection costs 531 float ct_div_ci;533 float mCtDivCi; 532 534 533 535 // type of the splitting to use for the tree construction … … 536 538 537 539 // maximum alovable memory in MB 538 float m axTotalMemory;540 float mMaxTotalMemory; 539 541 540 542 // maximum alovable memory for static kd tree in MB 541 float m axStaticMemory;543 float mMaxStaticMemory; 542 544 543 545 // this is used during the construction depending 544 546 // on the type of the tree and queries... 545 float m axMemory;547 float mMaxMemory; 546 548 547 549 // minimal acess time for collapse 548 int accessTimeThreshold;550 int mAccessTimeThreshold; 549 551 550 552 // minimal depth at which to perform collapse 551 int m inCollapseDepth;553 int mMinCollapseDepth; 552 554 553 555 // reusable array of split candidates 554 vector<SortableEntry> *splitCandidates; 555 556 vector<SortableEntry> *mSplitCandidates; 556 557 557 558 ///////////////////////////// … … 577 578 578 579 580 bool mOnlyDrivingAxis; 579 581 ///////////////////////////// 580 582 VspKdStatistics mStat; -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r411 r422 61 61 } 62 62 63 VssRay(const Ray &ray) 64 :mOrigin(ray.GetLoc()), 65 mTermination(ray.Extrap(ray.intersections[0].mT)), 63 VssRay(const Ray &ray): 64 mOrigin(ray.GetLoc()), 66 65 mOriginObject(ray.sourceObject.mObject), 67 mTerminationObject(ray.intersections[0].mObject),68 66 mRefCount(0), 69 67 mFlags(0), 70 68 mMailbox(-1) 71 {} 69 { 70 if (!ray.intersections.empty()) 71 { 72 mTermination = ray.intersections[0].mT; 73 mTerminationObject = ray.intersections[0].mObject; 74 } 75 else 76 { 77 mTermination = Limits::Infinity; 78 mTerminationObject = NULL; 79 } 80 } 72 81 73 82 void Precompute() { -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r419 r422 587 587 /*if (mExportRayDensity) { 588 588 return ExportKdTreeRayDensity(tree); }*/ 589 590 591 592 593 594 595 596 597 598 589 590 stack<VspKdTreeNode *> tStack; 591 592 tStack.push(tree.GetRoot()); 593 594 Mesh *mesh = new Mesh; 595 596 while (!tStack.empty()) 597 { 598 VspKdTreeNode *node = tStack.top(); 599 599 600 tStack.pop(); 601 AxisAlignedBox3 box = tree.GetBBox(node); 602 603 // add 6 vertices of the box 604 605 int index = (int)mesh->mVertices.size(); 600 tStack.pop(); 601 AxisAlignedBox3 box = tree.GetBBox(node); 602 603 // add 6 vertices of the box 604 int index = (int)mesh->mVertices.size(); 606 605 607 for (int i=0; i < 8; ++ i) 608 { 609 Vector3 v; 610 box.GetVertex(i, v); 611 mesh->mVertices.push_back(v); 612 } 613 614 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 615 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 616 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 617 618 619 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 620 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 621 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 622 623 if (!node->IsLeaf()) 624 { 625 VspKdTreeInterior *interior = dynamic_cast<VspKdTreeInterior *>(node); 626 tStack.push(interior->GetFront()); 627 tStack.push(interior->GetBack()); 628 } 629 } 630 631 ExportMesh(mesh); 632 DEL_PTR(mesh); 633 634 return true; 606 for (int i=0; i < 8; ++ i) 607 { 608 Vector3 v; 609 box.GetVertex(i, v); 610 mesh->mVertices.push_back(v); 611 } 612 613 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 614 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 615 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 616 617 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 618 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 619 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 620 621 if (!node->IsLeaf()) 622 { 623 VspKdTreeInterior *interior = dynamic_cast<VspKdTreeInterior *>(node); 624 tStack.push(interior->GetFront()); 625 tStack.push(interior->GetBack()); 626 } 627 } 628 629 ExportMesh(mesh); 630 DEL_PTR(mesh); 631 632 return true; 635 633 } 636 634 -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r421 r422 23 23 environment->Parse(argc, argv, USE_EXE_PATH); 24 24 MeshKdTree::ParseEnvironment(); 25 BspTree::ParseEnvironment(); 26 25 27 26 char buff[128]; 28 27 … … 58 57 p->ParseViewCellsOptions(); 59 58 60 // construct tree immediately for "from view cells" or "from scene geometry" 61 // construction method. For "from rays" construction, wait until there is 62 // a certain number of rays collected 63 if (ViewCell::sHierarchy == ViewCell::BSP && 64 !(BspTree::sConstructionMethod == BspTree::FROM_RAYS)) 59 if (ViewCell::sHierarchy == ViewCell::BSP) 65 60 { 66 if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) 67 { 68 // view cells input file name 69 environment->GetStringValue("ViewCells.filename", buff); 70 string vcFilename(buff); 71 p->LoadViewCells(vcFilename); 72 Debug << (int)p->mViewCells.size() << " view cells loaded" << endl; 61 BspTree::ParseEnvironment(); 62 63 // We construct BSP tree immediately for "from view cells" or "from scene geometry" 64 // construction method. 65 // For the "from samples" option, construction is delayed until enough samples were collected 66 if (BspTree::sConstructionMethod != BspTree::FROM_SAMPLES) 67 { 68 if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) 69 { 70 //-- load view cells from file 71 environment->GetStringValue("ViewCells.filename", buff); 72 string vcFilename(buff); 73 p->LoadViewCells(vcFilename); 74 Debug << (int)p->mViewCells.size() << " view cells loaded" << endl; 75 } 76 77 p->BuildBspTree(); 78 79 p->Export("vc_bsptree.x3d", false, false, true); 80 p->BspTreeStatistics(Debug); 73 81 } 74 75 p->BuildBspTree();76 77 p->Export("vc_bsptree.x3d", false, false, true);78 p->BspTreeStatistics(Debug);79 82 } 80 83
Note: See TracChangeset
for help on using the changeset viewer.