- Timestamp:
- 11/22/05 17:43:29 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r425 r426 62 62 63 63 Sampling { 64 totalSamples 30000064 totalSamples 1000000 65 65 samplesPerPass 3 66 66 } … … 152 152 Termination { 153 153 # parameters used for autopartition 154 m axRays 200155 m axPolygons -1154 minRays 200 155 minPolygons -1 156 156 maxDepth 40 157 157 minPvs 35 … … 159 159 maxRayContribution 0.005 160 160 #maxAccRayLength 100 161 161 162 # used for pvs criterium 162 163 ct_div_ci 0.0 … … 164 165 # axis aligned splits 165 166 AxisAligned { 166 m axPolys 5000167 m axRays 500168 m axObjects 10167 minPolys 5000 168 minRays 500 169 minObjects 10 169 170 maxCostRatio 0.9 170 171 ct_div_ci 0.5 … … 218 219 219 220 Construction { 220 samples 200000221 } 222 223 Termination { 224 maxDepth 20225 minPvs 200226 minRays 10 0227 minSize 0. 001221 samples 1000000 222 } 223 224 Termination { 225 maxDepth 30 226 minPvs 50 227 minRays 10 228 minSize 0.1 228 229 maxCostRatio 0.95 229 maxRayContribution 0. 1230 maxRayContribution 0.2 230 231 } 231 232 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r424 r426 1240 1240 "0.002"); 1241 1241 1242 RegisterOption("BspTree.Termination.m axPolygons",1243 optInt, 1244 "-bsp_term_m ax_polygons=",1242 RegisterOption("BspTree.Termination.minPolygons", 1243 optInt, 1244 "-bsp_term_min_polygons=", 1245 1245 "5"); 1246 1246 … … 1260 1260 "0.005"); 1261 1261 1262 RegisterOption("BspTree.Termination.m axAccRayLenght",1263 optFloat, 1264 "-bsp_term_m ax_acc_ray_length=",1262 RegisterOption("BspTree.Termination.minAccRayLenght", 1263 optFloat, 1264 "-bsp_term_min_acc_ray_length=", 1265 1265 "50"); 1266 1266 1267 RegisterOption("BspTree.Termination.m axRays",1268 optInt, 1269 "-bsp_term_m ax_rays=",1267 RegisterOption("BspTree.Termination.minRays", 1268 optInt, 1269 "-bsp_term_min_rays=", 1270 1270 "-1"); 1271 1271 … … 1295 1295 "0.1"); 1296 1296 1297 RegisterOption("BspTree.Termination.AxisAligned.m axPolys",1297 RegisterOption("BspTree.Termination.AxisAligned.minPolys", 1298 1298 optInt, 1299 1299 "-bsp_term_axis_aligned_max_polygons=", 1300 1300 "50"); 1301 1301 1302 RegisterOption("BspTree.Termination.AxisAligned.m axObjects",1303 optInt, 1304 "-bsp_term_m ax_objects=",1302 RegisterOption("BspTree.Termination.AxisAligned.minObjects", 1303 optInt, 1304 "-bsp_term_min_objects=", 1305 1305 "3"); 1306 1306 1307 RegisterOption("BspTree.Termination.AxisAligned.m axRays",1308 optInt, 1309 "-bsp_term_axis_aligned_m ax_rays=",1307 RegisterOption("BspTree.Termination.AxisAligned.minRays", 1308 optInt, 1309 "-bsp_term_axis_aligned_min_rays=", 1310 1310 "-1"); 1311 1311 -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp
r406 r426 1 1 #include "Ray.h" 2 2 #include "Plane3.h" 3 #include "VssRay.h" 3 4 4 5 // ========================================================= … … 219 220 return s; 220 221 } 222 223 Ray::Ray(const VssRay &vssRay): 224 loc(vssRay.mOrigin), 225 sourceObject(0, vssRay.mOriginObject, 0), 226 dir(vssRay.GetDir()) 227 { 228 intersections.push_back(Intersection(vssRay.mT, vssRay.mTerminationObject, 0)); 229 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h
r406 r426 13 13 class ViewCell; 14 14 class BspLeaf; 15 class VssRay; 15 16 16 17 // ------------------------------------------------------------------- … … 101 102 // dummy constructor 102 103 Ray() {} 104 105 /** Construct ray from a vss ray. 106 */ 107 Ray(const VssRay &vssRay); 103 108 104 109 Intersectable *GetIntersectionObject(const int i) const { -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r425 r426 591 591 //exporter->ExportBspViewCellPartition(*mBspTree, 0); 592 592 593 if (1) // export scene geometry 594 { 595 Material m;//= RandomMaterial(); 596 m.mDiffuseColor = RgbColor(0, 1, 0); 597 exporter->SetForcedMaterial(m); 598 exporter->SetWireframe(); 599 600 for (int j = 0; j < objects.size(); ++ j) 601 exporter->ExportIntersectable(objects[j]); 602 } 593 if (1) 594 ExportSceneGeometry(exporter, objects); 603 595 604 596 delete exporter; … … 676 668 { 677 669 Exporter *exporter = Exporter::GetExporter("vspkdtree.x3d"); 678 exporter->SetWireframe(); 679 exporter->ExportVspKdTree(*mVspKdTree, 300); 670 //exporter->SetWireframe(); 671 exporter->ExportVspKdTree(*mVspKdTree, mVspKdTree->GetStatistics().maxPvsSize); 672 673 Debug << "average PVS size: " << mVspKdTree->GetAvgPvsSize() << endl; 674 675 if (1) ExportSceneGeometry(exporter, objects); 676 677 bool exportRays = false; 678 679 if (exportRays) 680 { 681 int raysSize = 500; 682 float prob = raysSize / (float)mVspSampleRays.size(); 683 684 exporter->SetWireframe(); 685 686 VssRayContainer rays; 687 for (int i = 0; i < mVspSampleRays.size(); ++ i) 688 { 689 if (RandomValue(0,1) < prob) 690 rays.push_back(mVspSampleRays[i]); 691 } 692 693 exporter->ExportRays(rays, RgbColor(1, 0, 0)); 694 } 695 680 696 delete exporter; 681 697 } … … 758 774 // also add origin to sample 759 775 sRay->mOriginObject = object; 776 sRay->mOrigin = ray.GetLoc(); 760 777 } 761 778 else … … 872 889 873 890 return merged; 891 } 892 893 // export scene geometry 894 void SamplingPreprocessor::ExportSceneGeometry(Exporter *exporter, const ObjectContainer &objects) 895 { 896 Material m;//= RandomMaterial(); 897 m.mDiffuseColor = RgbColor(0, 1, 0); 898 exporter->SetForcedMaterial(m); 899 exporter->SetWireframe(); 900 901 for (int j = 0; j < objects.size(); ++ j) 902 exporter->ExportIntersectable(objects[j]); 874 903 } 875 904 … … 911 940 } 912 941 913 // export scene geometry914 942 if (1) 915 { 916 Material m;//= RandomMaterial(); 917 m.mDiffuseColor = RgbColor(0, 1, 0); 918 exporter->SetForcedMaterial(m); 919 exporter->SetWireframe(); 920 921 for (int j = 0; j < objects.size(); ++ j) 922 exporter->ExportIntersectable(objects[j]); 923 } 943 ExportSceneGeometry(exporter, objects); 924 944 925 945 delete exporter; -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r411 r426 7 7 #include "Preprocessor.h" 8 8 #include "VssRay.h" 9 10 class Exporter; 9 11 10 12 /** Sampling based visibility preprocessing. The implementation is based on heuristical … … 85 87 void ExportBspPvs(const ObjectContainer &objects); 86 88 89 /** Export scene geometry. 90 */ 91 void ExportSceneGeometry(Exporter *exporter, const ObjectContainer &objects); 92 87 93 /** Post processes view cells (i.e., merges or subdivides view cells based 88 94 on the PVS and the ray sets. -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r424 r426 282 282 environment->GetIntValue("BspTree.Termination.maxDepth", mTermMaxDepth); 283 283 environment->GetIntValue("BspTree.Termination.minPvs", mTermMinPvs); 284 environment->GetIntValue("BspTree.Termination.m axPolygons", mTermMaxPolygons);285 environment->GetIntValue("BspTree.Termination.m axRays", mTermMaxRays);284 environment->GetIntValue("BspTree.Termination.minPolygons", mTermMinPolys); 285 environment->GetIntValue("BspTree.Termination.minRays", mTermMinRays); 286 286 environment->GetFloatValue("BspTree.Termination.minArea", mTermMinArea); 287 287 environment->GetFloatValue("BspTree.Termination.maxRayContribution", mTermMaxRayContribution); 288 environment->GetFloatValue("BspTree.Termination.m axAccRayLenght", mTermMaxAccRayLength);288 environment->GetFloatValue("BspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 289 289 290 290 //-- factors for bsp tree split plane heuristics … … 303 303 environment->GetFloatValue("BspTree.Termination.AxisAligned.ct_div_ci", mAaCtDivCi); 304 304 environment->GetFloatValue("BspTree.Termination.AxisAligned.maxCostRatio", mMaxCostRatio); 305 environment->GetIntValue("BspTree.Termination.AxisAligned.m axPolys",306 mTermM axPolysForAxisAligned);305 environment->GetIntValue("BspTree.Termination.AxisAligned.minPolys", 306 mTermMinPolysForAxisAligned); 307 307 environment->GetIntValue("BspTree.Termination.AxisAligned.maxRays", 308 mTermM axRaysForAxisAligned);308 mTermMinRaysForAxisAligned); 309 309 environment->GetIntValue("BspTree.Termination.AxisAligned.maxObjects", 310 mTermM axObjectsForAxisAligned);310 mTermMinObjectsForAxisAligned); 311 311 //-- partition criteria 312 312 environment->GetIntValue("BspTree.maxPolyCandidates", mMaxPolyCandidates); … … 326 326 Debug << "BSP min PVS: " << mTermMinPvs << endl; 327 327 Debug << "BSP min area: " << mTermMinArea << endl; 328 Debug << "BSP max polys: " << mTermM axPolygons << endl;329 Debug << "BSP max rays: " << mTermM axRays << endl;328 Debug << "BSP max polys: " << mTermMinPolys << endl; 329 Debug << "BSP max rays: " << mTermMinRays << endl; 330 330 Debug << "BSP max polygon candidates: " << mMaxPolyCandidates << endl; 331 331 Debug << "BSP max plane candidates: " << mMaxRayCandidates << endl; … … 403 403 app << "#N_SPLITS ( Number of splits )\n" << splits << "\n"; 404 404 405 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maxdepth )\n"<< 406 maxDepthNodes * 100 / (double)Leaves() << endl; 405 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n" 406 << maxDepthNodes * 100 / (double)Leaves() << endl; 407 408 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n" 409 << maxDepthNodes * 100 / (double)Leaves() << endl; 410 411 app << "#N_PMINPVSLEAVES ( Percentage of leaves with mininimal PVS )\n" 412 << minPvsNodes * 100 / (double)Leaves() << endl; 413 414 app << "#N_PMINRAYSLEAVES ( Percentage of leaves with minimal number of rays)\n" 415 << minRaysNodes * 100 / (double)Leaves() << endl; 416 417 app << "#N_PMINAREALEAVES ( Percentage of leaves with mininum area )\n" 418 << minAreaNodes * 100 / (double)Leaves() << endl; 419 420 app << "#N_PMAXRAYCONTRIBLEAVES ( Percentage of leaves with maximal ray contribution )\n" 421 << maxRayContribNodes * 100 / (double)Leaves() << endl; 407 422 408 423 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; … … 735 750 { 736 751 return 737 (((int)data.mPolygons->size() <= mTermM axPolygons) ||738 ((int)data.mRays->size() <= mTermM axRays) ||752 (((int)data.mPolygons->size() <= mTermMinPolys) || 753 ((int)data.mRays->size() <= mTermMinRays) || 739 754 (data.mPvs <= mTermMinPvs) || 740 755 (data.mArea <= mTermMinArea) || … … 1105 1120 1106 1121 if ((mSplitPlaneStrategy & AXIS_ALIGNED) && 1107 ((int)data.mPolygons->size() > mTermM axPolysForAxisAligned) &&1108 ((int)data.mRays->size() > mTermM axRaysForAxisAligned) &&1109 ((mTermM axObjectsForAxisAligned < 0) ||1110 (Polygon3::ParentObjectsSize(*data.mPolygons) > mTermM axObjectsForAxisAligned)))1122 ((int)data.mPolygons->size() > mTermMinPolysForAxisAligned) && 1123 ((int)data.mRays->size() > mTermMinRaysForAxisAligned) && 1124 ((mTermMinObjectsForAxisAligned < 0) || 1125 (Polygon3::ParentObjectsSize(*data.mPolygons) > mTermMinObjectsForAxisAligned))) 1111 1126 { 1112 1127 Plane3 plane; … … 1699 1714 BspLeaf *leaf = dynamic_cast<BspLeaf *>(data.mNode); 1700 1715 1701 if (data.mDepth >= mTermMaxDepth)1702 ++ mStat.maxDepthNodes;1703 1704 1716 // store maximal and minimal depth 1705 1717 if (data.mDepth > mStat.maxDepth) … … 1712 1724 mStat.accumDepth += data.mDepth; 1713 1725 1726 1727 if (data.mDepth >= mTermMaxDepth) 1728 ++ mStat.maxDepthNodes; 1729 1730 if (data.mPvs < mTermMinPvs) 1731 ++ mStat.minPvsNodes; 1732 1733 if ((int)data.mRays->size() < mTermMinRays) 1734 ++ mStat.minRaysNodes; 1735 1736 if (data.GetAvgRayContribution() > mTermMaxRayContribution) 1737 ++ mStat.maxRayContribNodes; 1738 1739 if (data.mGeometry->GetArea() <= mTermMinArea) 1740 ++ mStat.minAreaNodes; 1741 1714 1742 #ifdef _DEBUG 1715 1743 Debug << "BSP stats: " … … 1717 1745 << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 1718 1746 << "Area: " << data.mArea << " (min: " << mTermMinArea << "), " 1719 << "#polygons: " << (int)data.mPolygons->size() << " (max: " << mTermM axPolygons << "), "1720 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermM axRays << "), "1747 << "#polygons: " << (int)data.mPolygons->size() << " (max: " << mTermMinPolys << "), " 1748 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 1721 1749 << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "=, " 1722 1750 << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r424 r426 85 85 // minimal depth 86 86 int minDepth; 87 87 88 // max depth nodes 88 89 int maxDepthNodes; 90 // minimum depth nodes 91 int minDepthNodes; 92 // max depth nodes 93 int minPvsNodes; 94 // nodes with minimum PVS 95 int minRaysNodes; 96 // max ray contribution nodes 97 int maxRayContribNodes; 98 // minimum area nodes 99 int minAreaNodes; 100 89 101 // max number of rays per node 90 102 int maxObjectRefs; … … 117 129 nodes = 0; 118 130 splits = 0; 119 maxDepthNodes = 0;131 120 132 maxDepth = 0; 121 133 minDepth = 99999; … … 123 135 accumDepth = 0; 124 136 137 maxDepthNodes = 0; 138 minPvsNodes = 0; 139 minRaysNodes = 0; 140 maxRayContribNodes = 0; 141 minAreaNodes = 0; 142 125 143 contributingSamples = 0; 126 144 sampleContributions = 0; … … 783 801 784 802 /// maximal number of polygons before subdivision termination 785 int mTermM axPolygons;803 int mTermMinPolys; 786 804 /// maximal number of rays before subdivision termination 787 int mTermM axRays;805 int mTermMinRays; 788 806 /// maximal possible depth 789 807 int mTermMaxDepth; … … 792 810 /// mininum PVS 793 811 int mTermMinPvs; 812 813 /// minimal number of polygons for axis aligned split 814 int mTermMinPolysForAxisAligned; 815 /// minimal number of rays for axis aligned split 816 int mTermMinRaysForAxisAligned; 817 /// minimal number of objects for axis aligned split 818 int mTermMinObjectsForAxisAligned; 819 /// maximal contribution per ray 820 float mTermMaxRayContribution; 821 /// minimal accumulated ray length 822 float mTermMinAccRayLength; 823 824 794 825 /// strategy to get the best split plane 795 826 int mSplitPlaneStrategy; … … 799 830 int mMaxRayCandidates; 800 831 801 /// maximal number of polygons for axis aligned split802 int mTermMaxPolysForAxisAligned;803 /// maximal number of rays for axis aligned split804 int mTermMaxRaysForAxisAligned;805 /// maximal number of objects for axis aligned split806 int mTermMaxObjectsForAxisAligned;807 /// maximal contribution per ray808 float mTermMaxRayContribution;809 /// maximal accumulated ray length810 float mTermMaxAccRayLength;811 812 832 float mCtDivCi; 813 833 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r425 r426 241 241 } 242 242 243 RayInfoContainer &VspKdTreeLeaf::GetRays() 244 { 245 return mRays; 246 } 243 247 /*********************************************************/ 244 248 /* class VspKdTree implementation */ … … 313 317 void VspKdStatistics::Print(ostream &app) const 314 318 { 315 316 317 318 << rays <<endl;319 320 321 << initialPvsSize <<endl;322 323 324 325 326 327 328 for (int i=0; i<7; i++)329 app << splits[i] <<" "; 330 app <<endl;331 332 app << "#N_RAYREFS ( Number of rayRefs )\n" << 333 rayRefs << "\n"; 334 335 app << "#N_RAYRAYREFS ( Number of rayRefs / ray )\n" << 336 rayRefs/(double)rays << "\n"; 337 338 app << "#N_LEAFRAYREFS ( Number of rayRefs / leaf )\n" << 339 rayRefs/(double)Leaves() << "\n"; 340 341 app << "#N_MAXRAYREFS ( Max number of rayRefs / leaf )\n" << 342 maxRayRefs << "\n"; 343 319 app << "===== VspKdTree statistics ===============\n"; 320 321 app << "#N_RAYS ( Number of rays )\n" 322 << rays << endl; 323 324 app << "#N_INITPVS ( Initial PVS size )\n" 325 << initialPvsSize << endl; 326 327 app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 328 329 app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 330 331 app << "#N_SPLITS ( Number of splits in axes x y z dx dy dz \n"; 332 333 for (int i=0; i<7; i++) 334 app << splits[i] <<" "; 335 app << endl; 336 337 app << "#N_RAYREFS ( Number of rayRefs )\n" << 338 rayRefs << "\n"; 339 340 app << "#N_RAYRAYREFS ( Number of rayRefs / ray )\n" << 341 rayRefs / (double)rays << "\n"; 342 343 app << "#N_LEAFRAYREFS ( Number of rayRefs / leaf )\n" << 344 rayRefs / (double)Leaves() << "\n"; 345 346 app << "#N_MAXRAYREFS ( Max number of rayRefs / leaf )\n" << 347 maxRayRefs << "\n"; 344 348 345 349 // app << setprecision(4); 346 350 347 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maxdepth )\n"<<348 maxDepthNodes*100/(double)Leaves()<<endl;349 350 app << "#N_PMINPVSLEAVES ( Percentage of leaves with minCost )\n"<<351 minPvsNodes*100/(double)Leaves()<<endl;352 353 app << "#N_PMINRAYSLEAVES ( Percentage of leaves with minCost )\n"<<354 minRaysNodes*100/(double)Leaves()<<endl;355 351 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maxdepth )\n" << 352 maxDepthNodes * 100 / (double)Leaves() << endl; 353 354 app << "#N_PMINPVSLEAVES ( Percentage of leaves with mininimal PVS )\n" << 355 minPvsNodes * 100 / (double)Leaves() << endl; 356 357 app << "#N_PMINRAYSLEAVES ( Percentage of leaves with minimal number of rays)\n" << 358 minRaysNodes * 100 / (double)Leaves() << endl; 359 356 360 app << "#N_PMINSIZELEAVES ( Percentage of leaves with minSize )\n"<< 357 minSizeNodes*100/(double)Leaves()<<endl; 358 359 app << "#N_PMAXRAYCONTRIBLEAVES ( Percentage of leaves with maximal ray contribution )\n"<< 360 maxRayContribNodes*100/(double)Leaves()<<endl; 361 362 app << "#N_ADDED_RAYREFS (Number of dynamically added ray references )\n"<< 363 addedRayRefs<<endl; 364 365 app << "#N_REMOVED_RAYREFS (Number of dynamically removed ray references )\n"<< 366 removedRayRefs<<endl; 367 368 // app << setprecision(4); 369 370 app << "#N_CTIME ( Construction time [s] )\n" 371 << Time() << " \n"; 372 373 app << "===== END OF VspKdTree statistics ==========\n"; 374 361 minSizeNodes * 100 / (double)Leaves() << endl; 362 363 app << "#N_PMAXRAYCONTRIBLEAVES ( Percentage of leaves with maximal ray contribution )\n" << 364 maxRayContribNodes * 100 / (double)Leaves() << endl; 365 366 app << "#N_ADDED_RAYREFS ( Number of dynamically added ray references )\n"<< 367 addedRayRefs << endl; 368 369 app << "#N_REMOVED_RAYREFS ( Number of dynamically removed ray references )\n"<< 370 removedRayRefs << endl; 371 372 // app << setprecision(4); 373 374 app << "#N_MAXPVS ( Maximal PVS size / leaf)\n" 375 << maxPvsSize << endl; 376 377 app << "#N_CTIME ( Construction time [s] )\n" 378 << Time() << " \n"; 379 380 app << "===== END OF VspKdTree statistics ==========\n"; 375 381 } 376 382 … … 876 882 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(data.mNode); 877 883 884 if (leaf->GetPvsSize() > mStat.maxPvsSize) 885 mStat.maxPvsSize = leaf->GetPvsSize(); 886 887 if ((int)(leaf->mRays.size()) > mStat.maxRayRefs) 888 mStat.maxRayRefs = (int)leaf->mRays.size(); 889 890 878 891 if (data.mDepth >= mTermMaxDepth) 879 892 ++ mStat.maxDepthNodes; 880 893 881 // if ( (int)(leaf->mRays.size()) < termMinCost)882 // stat.minCostNodes++;883 894 if (leaf->GetPvsSize() < mTermMinPvs) 884 895 ++ mStat.minPvsNodes; 885 896 886 if ( leaf->GetPvsSize() < mTermMinRays)897 if ((int)leaf->GetRays().size() < mTermMinRays) 887 898 ++ mStat.minRaysNodes; 888 899 889 if ( 0 &&leaf->GetAvgRayContribution() > mTermMaxRayContribution)900 if (leaf->GetAvgRayContribution() > mTermMaxRayContribution) 890 901 ++ mStat.maxRayContribNodes; 891 902 892 903 if (SqrMagnitude(data.mBox.Size()) <= mTermMinSize) 893 904 ++ mStat.minSizeNodes; 894 895 // if ((int)(leaf->mRays.size()) > stat.maxRayRefs)896 // mStat.maxRayRefs = (int)leaf->mRays.size();897 905 } 898 906 … … 902 910 { 903 911 return ((leaf->GetPvsSize() < mTermMinPvs) || 904 //(leaf->mRays.size() < mTermMinRays) ||905 // (leaf->GetAvgRayContribution() > termMaxRayContribution ) ||912 (leaf->mRays.size() < mTermMinRays) || 913 (leaf->GetAvgRayContribution() > mTermMaxRayContribution ) || 906 914 (leaf->mDepth >= mTermMaxDepth) || 907 915 (SqrMagnitude(box.Size()) <= mTermMinSize)); … … 923 931 Debug << "Bbox: " << GetBBox(leaf) << endl; 924 932 } 925 926 Debug << "depth: " << (int)leaf->mDepth << " pvs: " << leaf->GetPvsSize() << " rays: " << leaf->mRays.size() << endl; 933 //Debug << "depth: " << (int)leaf->mDepth << " pvs: " << leaf->GetPvsSize() << " rays: " << leaf->mRays.size() << endl; 927 934 } 928 935 return leaf; … … 939 946 const int axis = SelectPlane(leaf, box, position, raysBack, raysFront, pvsBack, pvsFront); 940 947 941 Debug << "rays back=" << raysBack << " rays front=" << raysFront << " pvs back=" << pvsBack << " pvs front=" << pvsFront << endl;948 //Debug << "rays back=" << raysBack << " rays front=" << raysFront << " pvs back=" << pvsBack << " pvs front=" << pvsFront << endl; 942 949 943 950 if (axis == -1) … … 1695 1702 } 1696 1703 1697 int VspKdTree::ComputePvsSize(VspKdTreeNode *node, const RayInfoContainer &globalRays) const 1704 int VspKdTree::ComputePvsSize(VspKdTreeNode *node, 1705 const RayInfoContainer &globalRays) const 1698 1706 { 1699 1707 int pvsSize = 0; … … 1703 1711 RayInfoContainer::const_iterator it, it_end = globalRays.end(); 1704 1712 1713 // warning: implicit conversion from VssRay to Ray 1705 1714 for (it = globalRays.begin(); it != globalRays.end(); ++ it) 1706 ;//pvsSize += box.GetMinMaxT((*it).mRay, NULL, NULL);1707 1715 pvsSize += box.GetMinMaxT(*(*it).mRay, NULL, NULL); 1716 1708 1717 return pvsSize; 1709 1718 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r425 r426 57 57 // max depth nodes 58 58 int minPvsNodes; 59 // nodes with minimum PVS 59 60 int minRaysNodes; 60 61 // max ray contribution nodes … … 65 66 // max number of rays per node 66 67 int maxRayRefs; 68 // maximal PVS size / leaf 69 int maxPvsSize; 70 67 71 // number of dynamically added ray refs 68 72 int addedRayRefs; … … 86 90 rays = queryDomains = 0; 87 91 rayRefs = 0; 92 88 93 maxDepthNodes = 0; 89 94 minPvsNodes = 0; 90 minRaysNodes = 0; 95 minRaysNodes = 0; 96 maxRayContribNodes = 0; 97 minSizeNodes = 0; 98 91 99 maxRayRefs = 0; 92 100 addedRayRefs = removedRayRefs = 0; 101 93 102 initialPvsSize = 0; 94 maxRayContribNodes = 0; 95 minSizeNodes = 0; 103 maxPvsSize = 0; 96 104 } 97 105 … … 146 154 */ 147 155 VspKdTreeInterior *GetParent() const; 156 148 157 /** Sets parent node. 149 158 */ … … 251 260 */ 252 261 int GetPvsSize() const; 253 void SetPvsSize(const int s);254 262 255 263 /** If PVS is not valid, this function recomputes the leaf … … 258 266 void UpdatePvsSize(); 259 267 268 RayInfoContainer &GetRays(); 269 260 270 /** Returns average contribution of a ray to the PVS 261 271 */ … … 278 288 279 289 protected: 280 290 291 /** Manually sets PVS size. 292 @param s the PVS size 293 */ 294 void SetPvsSize(const int s); 295 281 296 int mMailbox; 282 297 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r422 r426 62 62 63 63 VssRay(const Ray &ray): 64 mOrigin(ray.GetLoc()),65 mOriginObject(ray.sourceObject.mObject),66 64 mRefCount(0), 67 65 mFlags(0), 68 mMailbox(-1) 66 mMailbox(-1), 67 mOriginObject(ray.sourceObject.mObject) 69 68 { 69 if (ray.sourceObject.mObject) 70 mOrigin = ray.Extrap(ray.sourceObject.mT); 71 else 72 mOrigin = ray.GetLoc(); 73 70 74 if (!ray.intersections.empty()) 71 75 { 72 mTermination = ray. intersections[0].mT;76 mTermination = ray.Extrap(ray.intersections[0].mT); 73 77 mTerminationObject = ray.intersections[0].mObject; 74 78 } 75 79 else 76 80 { 77 mTermination = Limits::Infinity;81 mTermination = 1e6; 78 82 mTerminationObject = NULL; 79 83 } 84 85 Precompute(); 80 86 } 81 87 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r425 r426 154 154 for (; ri != rays.end(); ri++) { 155 155 Vector3 a = (*ri)->GetOrigin(); 156 157 Vector3 b = (*ri)->GetTermination(); 156 Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize(b - a); 157 158 158 stream<<a.x<<" "<<a.y<<" "<<a.z<<" ,"; 159 159 stream<<b.x<<" "<<b.y<<" "<<b.z<<" ,\n"; 160 160 } 161 161 … … 585 585 bool X3dExporter::ExportVspKdTree(const VspKdTree &tree, const int maxPvs) 586 586 { 587 //if (mExportRayDensity) {588 //return ExportKdTreeRayDensity(tree); }589 590 587 stack<VspKdTreeNode *> tStack; 591 588 … … 602 599 603 600 tStack.pop(); 604 AxisAlignedBox3 box = tree.GetBBox(node); 605 606 Mesh *mesh = new Mesh; 607 608 // add 6 vertices of the box 609 int index = (int)mesh->mVertices.size(); 610 611 for (int i=0; i < 8; ++ i) 612 { 613 Vector3 v; 614 box.GetVertex(i, v); 615 mesh->mVertices.push_back(v); 616 } 617 618 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 619 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 620 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 621 622 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 623 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 624 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 625 626 if (maxPvs > 0) 627 { 628 mForcedMaterial.mDiffuseColor.b = 1.0f; 629 const float importance = maxPvs; 630 //float importance = (float)(*it)->GetPvs().GetSize() / (float)maxPvs; 631 632 mForcedMaterial.mDiffuseColor.r = importance; 633 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 634 } 635 636 ExportMesh(mesh); 637 DEL_PTR(mesh); 638 639 if (!node->IsLeaf()) 601 602 if (node->IsLeaf()) 603 { 604 AxisAlignedBox3 box = tree.GetBBox(node); 605 606 Mesh *mesh = new Mesh; 607 608 // add 6 vertices of the box 609 int index = (int)mesh->mVertices.size(); 610 611 for (int i=0; i < 8; ++ i) 612 { 613 Vector3 v; 614 box.GetVertex(i, v); 615 mesh->mVertices.push_back(v); 616 } 617 618 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 619 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 620 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 621 622 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 623 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 624 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 625 626 if (maxPvs > 0) 627 { 628 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(node); 629 630 mForcedMaterial.mDiffuseColor.b = 1.0f; 631 632 leaf->UpdatePvsSize(); 633 634 const float importance = (float)leaf->GetPvsSize() / (float)maxPvs; 635 mForcedMaterial.mDiffuseColor.r = importance; 636 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 637 } 638 639 ExportMesh(mesh); 640 DEL_PTR(mesh); 641 } 642 else 640 643 { 641 644 VspKdTreeInterior *interior = dynamic_cast<VspKdTreeInterior *>(node);
Note: See TracChangeset
for help on using the changeset viewer.