- Timestamp:
- 01/01/06 06:25:55 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r469 r487 410 410 </File> 411 411 </Filter> 412 <File413 RelativePath=".\VTune\Preprocessor.vpj">414 </File>415 412 </Files> 416 413 <Globals> -
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r486 r487 143 143 } 144 144 145 145 146 ViewCells { 146 147 loadFromFile false … … 154 155 height 5.0 155 156 maxViewCells 100 157 maxPvs 70 158 156 159 157 160 PostProcess { … … 170 173 #colorCode MergedTreeDiff 171 174 colorCode Random 172 exportRays false175 exportRays true 173 176 exportGeometry true 174 177 } … … 216 219 # maximal cost for merging a view cell 217 220 PostProcess { 221 <<<<<<< .mine 218 222 maxCostRatio 0.005 219 minViewCells 100 223 minViewCells 200 224 220 225 maxPvsSize 50000 221 226 } … … 283 288 PostProcess { 284 289 maxCostRatio 0.1 285 minViewCells 100 290 minViewCells 200 291 286 292 maxPvsSize 500 287 293 useRaysForMerge false -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.h
r486 r487 175 175 176 176 177 Vector3 GetRandomPoint() {177 Vector3 GetRandomPoint() const { 178 178 Vector3 size = Size(); 179 179 return mMin + Vector3(RandomValue(0, size.x), -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r486 r487 1207 1207 "0"); 1208 1208 1209 1210 RegisterOption("ViewCells.maxPvs", 1211 optInt, 1212 "-view_cells_max_pvs", 1213 "300"); 1214 1209 1215 RegisterOption("ViewCells.PostProcess.minPvsDif", 1210 1216 optInt, -
trunk/VUT/GtpVisibilityPreprocessor/src/Plane3.h
r485 r487 81 81 const float dv = DotProd(v, mNormal); 82 82 83 // does not intersect 83 // does not intersect or coincident 84 84 if (signum(dv) == 0) 85 return -1;85 return 0; 86 86 87 87 return - Distance(a) / dv; // TODO: could be done more efficiently -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp
r485 r487 86 86 return; // has been already precomputed 87 87 88 const float eps = 1e-6 ;89 const float invEps = 1e6 ;88 const float eps = 1e-6f; 89 const float invEps = 1e6f; 90 90 91 91 // it does change the ray direction very slightly, -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r477 r487 430 430 431 431 if (useViewSpaceBox) 432 { 432 433 mViewSpaceBox = box; 434 mViewCellsManager->SetViewSpaceBox(*box); 435 } 433 436 else 437 { 434 438 mViewSpaceBox = NULL; 439 mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 440 } 435 441 436 442 … … 448 454 for (int k=0; k < s; k++) { 449 455 450 Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 456 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 457 Vector3 viewpoint; 458 mViewCellsManager->GetViewPoint(viewpoint); 451 459 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 452 460 … … 497 505 if (mUseViewcells) { 498 506 // construct view cells 499 mViewCellsManager->Construct(mObjects, mVssRays , mViewSpaceBox);507 mViewCellsManager->Construct(mObjects, mVssRays); 500 508 501 509 VssRayContainer selectedRays; … … 555 563 if (!mUseImportanceSampling) { 556 564 for (int j=0; j < num; j++) { 557 Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 565 //changed by matt 566 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 567 Vector3 viewpoint; 568 mViewCellsManager->GetViewPoint(viewpoint); 558 569 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 559 570 rays.push_back(SimpleRay(viewpoint, direction)); -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h
r464 r487 9 9 class RssTree; 10 10 class RssTreeLeaf; 11 11 12 12 13 /** Sampling based visibility preprocessing. The implementation is based on heuristical … … 32 33 33 34 ofstream mStats; 34 35 35 36 ObjectContainer mObjects; 36 37 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r477 r487 250 250 mSceneGraph->CollectObjects(&objects); 251 251 252 mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 253 252 254 Vector3 point, normal, direction; 253 255 //Ray ray; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r486 r487 76 76 } 77 77 78 78 79 int BspNode::GetDepth() const 79 80 { … … 89 90 return depth; 90 91 } 92 93 94 bool BspNode::TreeValid() const 95 { 96 return mTreeValid; 97 } 98 99 100 void BspNode::SetTreeValid(const bool v) 101 { 102 mTreeValid = v; 103 } 104 91 105 92 106 /****************************************************************/ … … 186 200 return true; 187 201 } 188 189 202 190 203 /****************************************************************/ … … 1762 1775 } 1763 1776 1777 1764 1778 AxisAlignedBox3 BspTree::GetBoundingBox() const 1765 1779 { 1766 1780 return mBox; 1767 1781 } 1782 1768 1783 1769 1784 BspNode *BspTree::GetRoot() const -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r485 r487 211 211 */ 212 212 int GetDepth() const; 213 static int sMailId; 214 int mMailbox; 215 213 214 /** returns true if the whole subtree is valid 215 */ 216 bool TreeValid() const; 217 218 void SetTreeValid(const bool v); 219 220 //-- mailing options 221 216 222 void Mail() { mMailbox = sMailId; } 217 223 static void NewMail() { ++ sMailId; } 218 224 bool Mailed() const { return mMailbox == sMailId; } 219 225 226 static int sMailId; 227 int mMailbox; 228 220 229 protected: 221 230 231 /// if this sub tree is a completely valid view space region 232 bool mTreeValid; 222 233 /// parent of this node 223 234 BspInterior *mParent; … … 294 305 void SetViewCell(BspViewCell *viewCell); 295 306 307 /// Rays piercing this leaf. 296 308 VssRayContainer mVssRays; 297 309 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r486 r487 21 21 mTotalArea(0.0f) 22 22 { 23 mSceneBox.Initialize(); 23 24 ParseEnvironment(); 24 25 } … … 30 31 mVisualizationSamples(0) 31 32 { 33 mSceneBox.Initialize(); 32 34 ParseEnvironment(); 33 35 } … … 81 83 82 84 85 bool ViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 86 { 87 viewPoint = mSceneBox.GetRandomPoint(); 88 89 return true; 90 } 91 92 83 93 void ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays) 84 94 { … … 88 98 89 99 VssRayContainer::const_iterator it, it_end = rays.end(); 90 int i = 0; 100 91 101 for (it = rays.begin(); it != it_end; ++ it) 92 { Debug << "here " << i ++ << endl;102 { 93 103 ComputeSampleContributions(*(*it)); 94 Debug << "**" << endl;95 104 } 96 105 } … … 104 113 105 114 for (it = mViewCells.begin(); it != it_end; ++ it) 115 { 106 116 (*it)->UpdateViewCellsStats(mViewCellsStats); 117 } 107 118 } 108 119 … … 295 306 296 307 308 void ViewCellsManager::SetViewSpaceBox(const AxisAlignedBox3 &box) 309 { 310 mSceneBox = box; 311 } 312 313 297 314 void ViewCellsManager::ResetViewCells() 298 315 { … … 432 449 433 450 int BspViewCellsManager::Construct(const ObjectContainer &objects, 434 const VssRayContainer &rays, 435 AxisAlignedBox3 *sceneBbox) 451 const VssRayContainer &rays) 436 452 { 437 453 // if view cells were already constructed … … 1024 1040 1025 1041 int KdViewCellsManager::Construct(const ObjectContainer &objects, 1026 const VssRayContainer &rays, 1027 AxisAlignedBox3 *sceneBbox) 1042 const VssRayContainer &rays) 1028 1043 { 1029 1044 // if view cells already constructed … … 1309 1324 1310 1325 int VspKdViewCellsManager::Construct(const ObjectContainer &objects, 1311 const VssRayContainer &rays, 1312 AxisAlignedBox3 *sceneBbox) 1326 const VssRayContainer &rays) 1313 1327 { 1314 1328 // if view cells already constructed … … 1327 1341 << (int)constructionRays.size() << " samples" << endl; 1328 1342 1329 mVspKdTree->Construct(constructionRays, sceneBbox);1343 mVspKdTree->Construct(constructionRays, &mSceneBox); 1330 1344 Debug << mVspKdTree->GetStatistics() << endl; 1331 1345 … … 1684 1698 1685 1699 int VspBspViewCellsManager::Construct(const ObjectContainer &objects, 1686 const VssRayContainer &rays, 1687 AxisAlignedBox3 *sceneBbox) 1700 const VssRayContainer &rays) 1688 1701 { 1689 1702 // if view cells were already constructed … … 1697 1710 1698 1711 GetRaySets(rays, mConstructionSamples, constructionRays, &savedRays); 1699 1712 1700 1713 Debug << "construction rays: " << (int)savedRays.size() << endl; 1701 1714 Debug << "saved rays: " << (int)constructionRays.size() << endl; 1702 1715 1703 mVspBspTree->Construct(constructionRays, sceneBbox); 1716 mVspBspTree->Construct(constructionRays, &mSceneBox); 1717 1704 1718 Debug << mVspBspTree->GetStatistics() << endl; 1705 1706 1719 ResetViewCells(); 1707 1720 … … 1932 1945 1933 1946 1947 bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 1948 { 1949 if (!ViewCellsConstructed()) 1950 return ViewCellsManager::GetViewPoint(viewPoint); 1951 1952 const int limit = 10; 1953 1954 for (int i = 0; i < limit; ++ i) 1955 { 1956 viewPoint = mSceneBox.GetRandomPoint(); 1957 if (mVspBspTree->ViewPointValid(viewPoint)) 1958 return true; 1959 } 1960 1961 return false; 1962 } 1963 1934 1964 void VspBspViewCellsManager::ExportSplits(const ObjectContainer &objects, 1935 1965 const VssRayContainer &rays) -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r485 r487 55 55 */ 56 56 virtual int Construct(const ObjectContainer &objects, 57 const VssRayContainer &rays, 58 AxisAlignedBox3 *sceneBbox = NULL) = 0; 57 const VssRayContainer &rays) = 0; 59 58 60 59 /** Computes sample contributions of the rays to the view cells PVS. … … 217 216 void SetRenderer(Renderer *renderer); 218 217 219 218 /** Computes a (random) view point in the valid view space. 219 @returns true if valid view point was found 220 */ 221 virtual bool GetViewPoint(Vector3 &viewPoint) const; 222 223 /** Sets a view space boundary. 224 */ 225 void SetViewSpaceBox(const AxisAlignedBox3 &box); 226 227 220 228 protected: 221 229 … … 251 259 252 260 /// the view cell corresponding to unbounded space 253 ViewCell *mUnbounded;261 //ViewCell *mUnbounded; 254 262 255 263 /// Renders the view cells. … … 280 288 281 289 ViewCellsStatistics mViewCellsStats; 290 /// the scene bounding box 291 AxisAlignedBox3 mSceneBox; 292 293 //-- visualization options 294 295 /// color code for view cells 296 int mColorCode; 297 bool mExportGeometry; 298 bool mExportRays; 282 299 }; 283 300 … … 299 316 300 317 int Construct(const ObjectContainer &objects, 301 const VssRayContainer &rays, 302 AxisAlignedBox3 *sceneBbox); 318 const VssRayContainer &rays); 303 319 304 320 … … 372 388 373 389 int Construct(const ObjectContainer &objects, 374 const VssRayContainer &rays, 375 AxisAlignedBox3 *sceneBbox); 390 const VssRayContainer &rays); 376 391 377 392 int CastLineSegment(const Vector3 &origin, … … 426 441 427 442 int Construct(const ObjectContainer &objects, 428 const VssRayContainer &rays, 429 AxisAlignedBox3 *sceneBbox); 443 const VssRayContainer &rays); 430 444 431 445 … … 483 497 484 498 int Construct(const ObjectContainer &objects, 485 const VssRayContainer &rays, 486 AxisAlignedBox3 *sceneBbox); 487 499 const VssRayContainer &rays); 488 500 489 501 int PostProcess(const ObjectContainer &objects, … … 510 522 AxisAlignedBox3 GetSceneBbox() const; 511 523 524 bool GetViewPoint(Vector3 &viewPoint) const; 525 512 526 protected: 513 527 /** DEPRECATED -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r486 r487 85 85 environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 86 86 environment->GetBoolValue("VspBspTree.PostProcess.useRaysForMerge", mUseRaysForMerge); 87 environment->GetIntValue("ViewCells.maxPvs", mMaxPvs); 88 87 89 88 90 //-- debug output … … 400 402 BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 401 403 404 if (!CheckValid(tData)) 405 { 406 leaf->SetTreeValid(false); 407 PropagateUpValidity(leaf); 408 } 409 402 410 // create new view cell for this leaf 403 411 BspViewCell *viewCell = new BspViewCell(); 404 412 leaf->SetViewCell(viewCell); 405 413 414 //-- update pvs 415 int conSamp = 0, sampCon = 0; 416 AddToPvs(leaf, *tData.mRays, conSamp, sampCon); 417 418 mStat.contributingSamples += conSamp; 419 mStat.sampleContributions += sampCon; 420 421 //-- store additional info 406 422 if (mStoreRays) 407 423 { … … 415 431 leaf->mArea = tData.mArea; 416 432 417 //-- update pvs 418 int conSamp = 0, sampCon = 0; 419 AddToPvs(leaf, *tData.mRays, conSamp, sampCon); 420 421 mStat.contributingSamples += conSamp; 422 mStat.sampleContributions += sampCon; 423 424 EvaluateLeafStats(tData); 425 } 426 433 EvaluateLeafStats(tData); 434 } 427 435 428 436 //-- cleanup … … 431 439 return newNode; 432 440 } 441 433 442 434 443 BspNode *VspBspTree::SubdivideNode(VspBspTraversalData &tData, … … 519 528 520 529 // replace a link from node's parent 521 if ( !leaf->IsRoot())530 if (parent) 522 531 { 523 532 parent->ReplaceChildLink(leaf, interior); … … 1897 1906 if (extSide < 0) 1898 1907 node = in->GetBack(); 1899 else if (extSide > 0)1908 else 1900 1909 node = in->GetFront(); 1901 1910 1902 1911 continue; // no far child 1903 1912 } … … 1908 1917 // find intersection of ray segment with plane 1909 1918 extp = splitPlane.FindIntersection(origin, extp, &t); 1910 //cout << "x";1911 1919 } 1912 1920 else 1913 1921 { 1914 //cout << "o";1915 1922 // reached leaf => intersection with view cell 1916 1923 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); … … 1937 1944 } 1938 1945 } 1939 //cout << "!!!!!!!!!!!" << endl; 1946 1940 1947 return hits; 1941 1948 } … … 2506 2513 } 2507 2514 2515 bool VspBspTree::ViewPointValid(const Vector3 &viewPoint) const 2516 { 2517 BspNode *node = mRoot; 2518 2519 while (1) 2520 { 2521 // early exit 2522 if (node->TreeValid()) 2523 return true; 2524 2525 if (node->IsLeaf()) 2526 return false; 2527 2528 BspInterior *in = dynamic_cast<BspInterior *>(node); 2529 Plane3 splitPlane = in->GetPlane(); 2530 2531 if (splitPlane.Side(viewPoint) <= 0) 2532 { 2533 node = in->GetBack(); 2534 } 2535 else 2536 { 2537 node = in->GetFront(); 2538 } 2539 } 2540 2541 // should never come here 2542 return false; 2543 } 2544 2545 2546 bool VspBspTree::CheckValid(const VspBspTraversalData &data) const 2547 { 2548 return data.mPvs <= mMaxPvs; 2549 } 2550 2551 2552 void VspBspTree::PropagateUpValidity(BspNode *node) 2553 { 2554 while (!node->IsRoot() && node->TreeValid()) 2555 { 2556 node = node->GetParent(); 2557 node->SetTreeValid(false); 2558 } 2559 } 2560 2508 2561 2509 2562 /************************************************************************/ -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r486 r487 268 268 void ConstructBspRays(vector<BspRay *> &bspRays, 269 269 const VssRayContainer &rays); 270 271 270 272 271 /** Merge view cells of leaves l1 and l2. 273 272 */ 274 273 bool MergeViewCells(BspLeaf *l1, BspLeaf *l2) const; 274 275 /** Returns true if this view point is in a valid view space, 276 false otherwise. 277 */ 278 bool ViewPointValid(const Vector3 &viewPoint) const; 279 275 280 276 281 protected: … … 535 540 BspViewCell *vc1, 536 541 BspViewCell *vc2) const; 542 543 /** 544 Checks if this traversal data corresponds to 545 a valid view space region. 546 */ 547 bool CheckValid(const VspBspTraversalData &data) const; 548 549 /** Propagates valid flag up the tree. 550 */ 551 void PropagateUpValidity(BspNode *node); 537 552 538 553 /// Pointer to the root of the tree … … 620 635 vector<SortableEntry> *mSplitCandidates; 621 636 637 622 638 typedef priority_queue<BspMergeCandidate> MergeQueue; 639 623 640 MergeQueue mMergeQueue; 624 641 /// if rays should be used to collect merge candidates 625 642 bool mUseRaysForMerge; 643 /// maximal allowed pvs so that view cell is valid 644 int mMaxPvs; 645 626 646 627 647 private: -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r485 r487 378 378 379 379 if (useViewSpaceBox) 380 { 380 381 mViewSpaceBox = box; 382 mViewCellsManager->SetViewSpaceBox(*box); 383 } 381 384 else 385 { 382 386 mViewSpaceBox = NULL; 383 384 387 mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 388 } 385 389 VssTree *vssTree = NULL; 386 390 … … 395 399 int s = Min(mSamplesPerPass, mInitialSamples); 396 400 for (int k=0; k < s; k++) { 397 398 Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 401 // changed by matt 402 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 403 Vector3 viewpoint; 404 mViewCellsManager->GetViewPoint(viewpoint); 399 405 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 400 406 … … 453 459 454 460 // construct view cells 455 mViewCellsManager->Construct(mObjects, mVssRays , mViewSpaceBox);461 mViewCellsManager->Construct(mObjects, mVssRays); 456 462 457 463 vssTree = new VssTree; … … 501 507 if (!mUseImportanceSampling) { 502 508 for (int j=0; j < num; j++) { 503 Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 509 // changed by matt 510 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 511 Vector3 viewpoint; 512 mViewCellsManager->GetViewPoint(viewpoint); 504 513 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 505 514 rays.push_back(SimpleRay(viewpoint, direction)); -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h
r469 r487 9 9 class VssTree; 10 10 class VssTreeLeaf; 11 11 12 12 13 /** Sampling based visibility preprocessing. The implementation is based on heuristical -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.cpp
r467 r487 211 211 212 212 s<<"##### VSS RAY STAT ##########\n"; 213 s<<"#RAYS\n"<< size()<<endl;213 s<<"#RAYS\n"<<(int)size()<<endl; 214 214 s<<"#AVG_RAY_PVS_CONTRIBUTION\n"<<sumContributions/(float)size()<<endl; 215 215 s<<"#AVG_RAY_RELATIVE_PVS_CONTRIBUTION\n"<<sumRelContributions/ -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r464 r487 57 57 p->KdTreeStatistics(cout); 58 58 59 60 59 // parse view cells related options 61 60 p->PrepareViewCells(); 62 63 61 64 62 // p->mSceneGraph->Export("soda.x3d");
Note: See TracChangeset
for help on using the changeset viewer.