- Timestamp:
- 01/03/06 02:06:09 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r489 r490 19 19 20 20 Preprocessor { 21 # stored sample rays 22 samplesFilename rays.out 21 23 # type sampling 22 24 type vss … … 26 28 VssPreprocessor { 27 29 samplesPerPass 100000 28 initialSamples 500000 30 initialSamples 5000000 29 31 vssSamples 200000 30 32 vssSamplesPerPass 100000 31 33 useImportanceSampling true 34 loadInitialSamples false 35 storeInitialSamples true 32 36 } 33 37 … … 68 72 vssSamplesPerPass 100000 69 73 useImportanceSampling true 74 loadInitialSamples true 75 storeInitialSamples false 70 76 } 71 77 … … 143 149 } 144 150 145 146 151 ViewCells { 147 152 loadFromFile false … … 155 160 height 5.0 156 161 maxViewCells 100 157 maxPvs 130162 maxPvs 90 158 163 159 164 … … 167 172 168 173 Visualization { 169 # how much samples are be usedfor visualization170 samples 1000174 # how much samples we use for visualization 175 samples 5000 171 176 #colorCode PVS 172 177 #colorCode MergedLeaves … … 233 238 samples 300000 234 239 epsilon 0.005 235 randomize true240 randomize false 236 241 } 237 242 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r489 r490 1176 1176 "true"); 1177 1177 1178 RegisterOption("VssPreprocessor.loadInitialSamples", 1179 optBool, 1180 "-vss_load_loadInitialSamples=", 1181 "false"); 1182 1183 RegisterOption("VssPreprocessor.storeInitialSamples", 1184 optBool, 1185 "-vss_store_storedInitialSamples=", 1186 "false"); 1187 1178 1188 1179 1189 /************************************************************************************/ … … 1411 1421 "sampling"); 1412 1422 1423 RegisterOption("Preprocessor.samplesFilename", 1424 optString, 1425 "-preprocessor_samples_filename=", 1426 "rays.out"); 1413 1427 1414 1428 /**************************************************************************************/ … … 1628 1642 RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 1629 1643 1644 RegisterOption("RssPreprocessor.loadInitialSamples", 1645 optBool, 1646 "-vss_load_loadInitialSamples=", 1647 "false"); 1648 1649 RegisterOption("RssPreprocessor.storeInitialSamples", 1650 optBool, 1651 "-vss_store_storeInitialSamples=", 1652 "false"); 1630 1653 1631 1654 /************************************************************************************/ -
trunk/VUT/GtpVisibilityPreprocessor/src/Exporter.h
r486 r490 134 134 135 135 virtual void ExportViewpoint(const Vector3 &point, const Vector3 &direction) = 0; 136 137 136 }; 138 137 -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r480 r490 238 238 mViewCellsManager->SetRenderer(mRenderSimulator); 239 239 240 //Debug << "Visualization samples: " << mViewCellsManager->GetVisualizationSamples() << endl;241 242 240 //-- parse view cells construction method 243 244 241 bool loadViewCells = false; 245 242 environment->GetBoolValue("ViewCells.loadFromFile", loadViewCells); … … 256 253 return true; 257 254 } 255 256 257 inline bool ilt(Intersectable *obj1, Intersectable *obj2) 258 { 259 return obj1->mId < obj2->mId; 260 } 261 262 263 bool Preprocessor::LoadSamples(VssRayContainer &samples, 264 ObjectContainer &objects) const 265 { 266 std::stable_sort(objects.begin(), objects.end(), ilt); 267 char fileName[100]; 268 environment->GetStringValue("Preprocessor.samplesFilename", fileName); 269 270 Vector3 origin, termination; 271 // HACK: needed only for lower_bound algorithm 272 MeshInstance object(NULL); 273 ifstream samplesIn(fileName); 274 275 if (!samplesIn.is_open()) 276 return false; 277 278 string buf; 279 280 while (!(getline(samplesIn, buf)).eof()) 281 { 282 sscanf(buf.c_str(), "%f %f %f %f %f %f %d", 283 &origin.x, &origin.y, &origin.z, 284 &termination.x, &termination.y, &termination.z, &(object.mId)); 285 286 if (1) 287 { 288 ObjectContainer::iterator oit = 289 lower_bound(objects.begin(), objects.end(), &object, ilt); 290 291 samples.push_back(new VssRay(origin, termination, NULL, *oit)); 292 } 293 else 294 { 295 samples.push_back(new VssRay(origin, termination, NULL, objects[object.mId])); 296 } 297 } 298 299 samplesIn.close(); 300 301 return true; 302 } 303 304 bool Preprocessor::WriteSamples(const VssRayContainer &samples) const 305 { 306 char buf[100]; 307 environment->GetStringValue("Preprocessor.samplesFilename", buf); 308 ofstream samplesOut(buf); 309 310 VssRayContainer::const_iterator it, it_end = samples.end(); 311 312 if (!samplesOut.is_open()) 313 return false; 314 315 for (it = samples.begin(); it != it_end; ++ it) 316 { 317 VssRay *ray = *it; 318 319 samplesOut << ray->GetOrigin().x << " " << ray->GetOrigin().y << " " << ray->GetOrigin().z << " " 320 << ray->GetTermination().x << " " << ray->GetTermination().y << " " << ray->GetTermination().z << " " 321 << ray->mTerminationObject->mId << "\n"; 322 } 323 samplesOut.close(); 324 325 return true; 326 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r468 r490 16 16 class VspBspTree; 17 17 class RenderSimulator; 18 struct VssRayContainer; 19 18 20 19 21 /** Namespace for the external visibility preprocessor … … 78 80 virtual void BspTreeStatistics(ostream &s); 79 81 82 /** Loads samples from file. 83 @param samples returns the stored sample rays 84 @param objects needed to associate the objects ids 85 @returns true if samples were loaded successfully 86 */ 87 bool LoadSamples(VssRayContainer &samples, 88 ObjectContainer &objects) const; 89 90 /** Exports samples to file. 91 @returns true if samples were written successfully 92 */ 93 bool WriteSamples(const VssRayContainer &samples) const; 80 94 /// scene graph loaded from file 81 95 SceneGraph *mSceneGraph; … … 104 118 */ 105 119 RenderSimulator *mRenderSimulator; 106 107 protected:108 109 /////////////////////////110 111 /// samples used for construction of the BSP view cells tree.112 int mBspConstructionSamples;113 /// samples used for construction of the VSP KD tree.114 int mVspKdConstructionSamples;115 120 }; 116 121 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r487 r490 27 27 environment->GetIntValue("RssPreprocessor.vssSamplesPerPass", mRssSamplesPerPass); 28 28 environment->GetBoolValue("RssPreprocessor.useImportanceSampling", mUseImportanceSampling); 29 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples);30 29 31 30 environment->GetBoolValue("RssPreprocessor.Export.pvs", mExportPvs); … … 34 33 environment->GetIntValue("RssPreprocessor.Export.numRays", mExportNumRays); 35 34 environment->GetBoolValue("RssPreprocessor.useViewcells", mUseViewcells); 36 37 environment->GetBoolValue("RssPreprocessor.updateSubdivision", mUpdateSubdivision); 35 environment->GetBoolValue("RssPreprocessor.useViewcells", mUseViewcells); 36 37 environment->GetBoolValue("RssPreprocessor.loadInitialSamples", mLoadInitialSamples); 38 environment->GetBoolValue("RssPreprocessor.storeInitialSamples", mStoreInitialSamples); 38 39 39 40 mStats.open("stats.log"); … … 443 444 RssTree *rssTree = NULL; 444 445 445 while (totalSamples < mInitialSamples) { 446 int passContributingSamples = 0; 447 int passSampleContributions = 0; 448 int passSamples = 0; 449 int index = 0; 450 451 int sampleContributions; 452 453 int s = Min(mSamplesPerPass, mInitialSamples); 454 for (int k=0; k < s; k++) { 446 if (mLoadInitialSamples) 447 { 448 cout << "Loading samples from file ... "; 449 LoadSamples(mVssRays, mObjects); 450 cout << "finished\n" << endl; 451 } 452 else 453 { 454 while (totalSamples < mInitialSamples) { 455 int passContributingSamples = 0; 456 int passSampleContributions = 0; 457 int passSamples = 0; 458 int index = 0; 455 459 456 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 457 Vector3 viewpoint; 458 mViewCellsManager->GetViewPoint(viewpoint); 459 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 460 int sampleContributions; 460 461 461 sampleContributions = CastRay(viewpoint, direction, mVssRays); 462 int s = Min(mSamplesPerPass, mInitialSamples); 463 for (int k=0; k < s; k++) { 464 465 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 466 Vector3 viewpoint; 467 mViewCellsManager->GetViewPoint(viewpoint); 468 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 469 470 sampleContributions = CastRay(viewpoint, direction, mVssRays); 471 472 473 //-- CORR matt: put block inside loop 474 if (sampleContributions) { 475 passContributingSamples ++; 476 passSampleContributions += sampleContributions; 477 } 478 passSamples++; 479 totalSamples++; 480 } 481 462 482 483 float avgRayContrib = (passContributingSamples > 0) ? 484 passSampleContributions/(float)passContributingSamples : 0; 463 485 464 //-- CORR matt: put block inside loop 465 if (sampleContributions) { 466 passContributingSamples ++; 467 passSampleContributions += sampleContributions; 468 } 469 passSamples++; 470 totalSamples++; 471 } 472 473 474 float avgRayContrib = (passContributingSamples > 0) ? 475 passSampleContributions/(float)passContributingSamples : 0; 476 477 cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 478 cout << "#TotalSamples=" << totalSamples/1000 479 << "k #SampleContributions=" << passSampleContributions << " (" 480 << 100*passContributingSamples/(float)passSamples<<"%)" 481 << "avgcontrib=" << avgRayContrib << endl; 482 483 mStats << 484 "#Pass\n" <<mPass<<endl<< 485 "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<< 486 "#TotalSamples\n" << totalSamples<< endl<< 487 "#SampleContributions\n" << passSampleContributions << endl << 488 "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 489 "#AvgRayContrib\n" << avgRayContrib << endl; 490 491 mPass++; 492 493 } 494 495 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 486 cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 487 cout << "#TotalSamples=" << totalSamples/1000 488 << "k #SampleContributions=" << passSampleContributions << " (" 489 << 100*passContributingSamples/(float)passSamples<<"%)" 490 << "avgcontrib=" << avgRayContrib << endl; 491 492 mStats << 493 "#Pass\n" <<mPass<<endl<< 494 "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<< 495 "#TotalSamples\n" << totalSamples<< endl<< 496 "#SampleContributions\n" << passSampleContributions << endl << 497 "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 498 "#AvgRayContrib\n" << avgRayContrib << endl; 499 500 mPass++; 501 502 } 503 504 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 505 } 506 496 507 cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 497 508 … … 503 514 } 504 515 516 if (mStoreInitialSamples) 517 { 518 cout << "Writing samples to file ... "; 519 WriteSamples(mVssRays); 520 cout << "finished\n" << endl; 521 } 522 505 523 if (mUseViewcells) { 506 524 // construct view cells -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h
r487 r490 39 39 VssRayContainer mVssRays; 40 40 41 /// if initial samples should be loaded from file 42 bool mLoadInitialSamples; 43 /// if initial samples should be stored in file 44 bool mStoreInitialSamples; 45 41 46 RssPreprocessor(); 42 47 ~RssPreprocessor(); -
trunk/VUT/GtpVisibilityPreprocessor/src/SceneGraph.cpp
r387 r490 29 29 SceneGraph::CollectObjects(ObjectContainer *instances) 30 30 { 31 instances->clear(); 31 32 int number = 0; 32 33 stack<SceneGraphNode *> nodeStack; … … 40 41 ObjectContainer::const_iterator mi = node->mGeometry.begin(); 41 42 for (; mi != node->mGeometry.end(); mi++) 42 43 43 instances->push_back(*mi); 44 44 45 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 45 46 for (; ni != node->mChildren.end(); ni++) { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r489 r490 413 413 app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 414 414 415 app << "#N_INPUT_POLYGONS (number of input polygons )\n" << polys << endl; 415 app << "#N_INPUTPOLYGONS (number of input polygons )\n" << polys << endl; 416 417 app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 416 418 417 419 //app << "#N_PVS: " << pvs << endl; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r487 r490 127 127 /// largest pvs 128 128 int maxPvs; 129 /// number of invalid leaves 130 int invalidLeaves; 129 131 130 132 // Constructor … … 162 164 163 165 maxPvs = 0; 166 invalidLeaves = 0; 164 167 } 165 168 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r489 r490 45 45 environment->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry); 46 46 47 //Debug << "export rays: " << mExportRays << endl;48 //Debug << "export geometry: " << mExportGeometry << endl;49 47 char buf[50]; 50 48 … … 92 90 } 93 91 92 93 bool ViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 94 { 95 return mSceneBox.IsInside(viewPoint); 96 } 94 97 95 98 void ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays) … … 1717 1720 1718 1721 mVspBspTree->Construct(constructionRays, &mSceneBox); 1719 1722 1720 1723 Debug << mVspBspTree->GetStatistics() << endl; 1724 // collapse invalid regions 1725 mVspBspTree->CollapseTree(mVspBspTree->GetRoot()); 1721 1726 ResetViewCells(); 1722 1727 1723 1728 Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 1724 1729 … … 1812 1817 ExportViewCells(exporter); 1813 1818 1819 if (mExportRays) 1820 { 1821 exporter->ExportRays(postProcessRays, RgbColor(1, 1, 0)); 1822 } 1823 1814 1824 if (mExportGeometry) 1815 1825 { … … 1900 1910 } 1901 1911 1912 1902 1913 int VspBspViewCellsManager::GetType() const 1903 1914 { 1904 1915 return VSP_BSP; 1916 } 1917 1918 1919 bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 1920 { 1921 if (!ViewCellsConstructed()) 1922 return ViewCellsManager::GetViewPoint(viewPoint); 1923 1924 // TODO: set reasonable limit 1925 const int limit = 20; 1926 1927 for (int i = 0; i < limit; ++ i) 1928 { 1929 viewPoint = mSceneBox.GetRandomPoint(); 1930 if (mVspBspTree->ViewPointValid(viewPoint)) 1931 { 1932 return true; 1933 } 1934 } 1935 Debug << "failed to find valid view point, taking " << viewPoint << endl; 1936 return false; 1937 } 1938 1939 1940 bool VspBspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 1941 { 1942 return mSceneBox.IsInside(viewPoint) && 1943 mVspBspTree->ViewPointValid(viewPoint); 1905 1944 } 1906 1945 … … 1913 1952 1914 1953 VssRayContainer visRays; 1915 1916 1954 GetRaySets(sampleRays, mVisualizationSamples, visRays); 1917 1955 … … 1927 1965 1928 1966 // export rays 1929 /*if (mExportRays)1967 if (mExportRays) 1930 1968 { 1931 exporter->SetWireframe(); 1932 exporter->ExportRays(visRays, RgbColor(1, 1, 0)); 1933 exporter->SetFilled(); 1934 }*/ 1969 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 1970 } 1971 1935 1972 ExportViewCells(exporter); 1936 1973 delete exporter; … … 1943 1980 bool exportSplits = false; 1944 1981 environment->GetBoolValue("VspBspTree.Visualization.exportSplits", exportSplits); 1945 Debug << "export splits: " << exportSplits << endl; 1946 1982 1947 1983 if (exportSplits) 1948 1984 { … … 1956 1992 } 1957 1993 1958 1959 bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const1960 {1961 if (!ViewCellsConstructed())1962 return ViewCellsManager::GetViewPoint(viewPoint);1963 1964 // TODO: set reasonable limit1965 const int limit = 10;1966 cout << "===" << endl;1967 for (int i = 0; i < limit; ++ i)1968 {1969 cout << i << " " << endl;1970 viewPoint = mSceneBox.GetRandomPoint();1971 if (mVspBspTree->ViewPointValid(viewPoint))1972 return true;1973 }1974 1975 return false;1976 }1977 1994 1978 1995 void VspBspViewCellsManager::ExportSplits(const ObjectContainer &objects, -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r489 r490 221 221 virtual bool GetViewPoint(Vector3 &viewPoint) const; 222 222 223 /** Returns true if this view point is in the valid view space. 224 */ 225 virtual bool ViewPointValid(const Vector3 &viewPoint) const; 226 223 227 /** Sets a view space boundary. 224 228 */ … … 517 521 bool GetViewPoint(Vector3 &viewPoint) const; 518 522 523 bool ViewPointValid(const Vector3 &viewPoint) const; 524 519 525 protected: 520 526 /** DEPRECATED -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r489 r490 420 420 // view cell for invalid view space 421 421 viewCell = GetOrCreateOutOfBoundsCell(); 422 ++ mStat.invalidLeaves; 422 423 } 423 424 else … … 1225 1226 nodeStack.pop(); 1226 1227 1227 // this subtree is not valid view space1228 if (!node->TreeValid())1229 continue;1230 1231 1228 if (node->IsLeaf()) 1232 1229 { 1233 BspLeaf *leaf = (BspLeaf *)node; 1234 leaves.push_back(leaf); 1230 // test if this leaf is in valid view space 1231 if (node->TreeValid()) 1232 { 1233 BspLeaf *leaf = (BspLeaf *)node; 1234 leaves.push_back(leaf); 1235 } 1235 1236 } 1236 1237 else … … 1428 1429 BspNode *node = nodeStack.top(); 1429 1430 nodeStack.pop(); 1430 // this subtree is not valid view space1431 if (!node->TreeValid())1432 continue;1433 1431 1434 1432 if (node->IsLeaf()) 1435 1433 { 1436 1434 ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 1437 1438 if (!viewCell->Mailed()) 1435 if (node->TreeValid() && !viewCell->Mailed()) 1439 1436 { 1440 1437 viewCell->Mail(); … … 1667 1664 nodeStack.pop(); 1668 1665 1669 // view space not valid1670 if (!node->TreeValid())1671 continue;1672 1673 1666 if (node->IsLeaf()) 1674 { 1675 if (node != n && (!onlyUnmailed || !node->Mailed())) 1667 { // test if this leaf is in valid view space 1668 if (node->TreeValid() && 1669 node != n && 1670 (!onlyUnmailed || !node->Mailed())) 1676 1671 { 1677 1672 // test all planes of current node if candidate really … … 2344 2339 startTime = GetTime(); 2345 2340 2346 int nViewCells = /*mergeStats.nodes*/ mStat.Leaves(); 2347 2348 2341 int nViewCells = /*mergeStats.nodes*/ mStat.Leaves() - mStat.invalidLeaves; 2342 2349 2343 //-- use priority queue to merge leaf pairs 2350 2344 while (!mMergeQueue.empty() && (nViewCells > mMergeMinViewCells) && … … 2569 2563 2570 2564 BspInterior *in = dynamic_cast<BspInterior *>(node); 2571 Plane3 splitPlane = in->GetPlane(); 2572 2573 if (splitPlane.Side(viewPoint) <= 0) 2565 2566 if (in->GetPlane().Side(viewPoint) <= 0) 2574 2567 { 2575 2568 node = in->GetBack(); … … 2594 2587 void VspBspTree::PropagateUpValidity(BspNode *node) 2595 2588 { 2596 while (!node->IsRoot() && node-> TreeValid())2589 while (!node->IsRoot() && node->GetParent()->TreeValid()) 2597 2590 { 2598 2591 node = node->GetParent(); -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r489 r490 26 26 environment->GetIntValue("VssPreprocessor.vssSamplesPerPass", mVssSamplesPerPass); 27 27 environment->GetBoolValue("VssPreprocessor.useImportanceSampling", mUseImportanceSampling); 28 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 28 29 environment->GetBoolValue("VssPreprocessor.loadInitialSamples", mLoadInitialSamples); 30 environment->GetBoolValue("VssPreprocessor.storeInitialSamples", mStoreInitialSamples); 29 31 30 32 mStats.open("stats.log"); … … 91 93 SetupRay(ray, viewPoint, -direction); 92 94 93 94 95 if (mKdTree->CastRay(ray)) { 95 96 … … 389 390 VssTree *vssTree = NULL; 390 391 391 while (totalSamples < mInitialSamples) { 392 int passContributingSamples = 0; 393 int passSampleContributions = 0; 394 int passSamples = 0; 395 int index = 0; 396 397 int sampleContributions; 398 399 int s = Min(mSamplesPerPass, mInitialSamples); 400 for (int k=0; k < s; k++) { 401 // changed by matt 402 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 403 Vector3 viewpoint; 404 mViewCellsManager->GetViewPoint(viewpoint); 405 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 406 407 sampleContributions = CastRay(viewpoint, direction, mVssRays); 408 409 410 //-- CORR matt: put block inside loop 411 if (sampleContributions) { 412 passContributingSamples ++; 413 passSampleContributions += sampleContributions; 392 mSceneGraph->CollectObjects(&mObjects); 393 394 long initialTime = GetTime(); 395 396 if (mLoadInitialSamples) 397 { 398 cout << "Loading samples from file ... "; 399 LoadSamples(mVssRays, mObjects); 400 cout << "finished\n" << endl; 401 totalSamples = (int)mVssRays.size(); 402 } 403 else 404 { 405 while (totalSamples < mInitialSamples) { 406 int passContributingSamples = 0; 407 int passSampleContributions = 0; 408 int passSamples = 0; 409 410 int index = 0; 411 412 int sampleContributions; 413 414 int s = Min(mSamplesPerPass, mInitialSamples); 415 for (int k=0; k < s; k++) { 416 // changed by matt 417 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 418 Vector3 viewpoint; 419 mViewCellsManager->GetViewPoint(viewpoint); 420 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 421 422 sampleContributions = CastRay(viewpoint, direction, mVssRays); 423 424 if (sampleContributions) { 425 passContributingSamples ++; 426 passSampleContributions += sampleContributions; 427 } 428 passSamples++; 429 totalSamples++; 430 } 431 432 mPass++; 433 int pvsSize = 0; 434 float avgRayContrib = (passContributingSamples > 0) ? 435 passSampleContributions/(float)passContributingSamples : 0; 436 437 cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 438 cout << "#TotalSamples=" << totalSamples/1000 439 << "k #SampleContributions=" << passSampleContributions << " (" 440 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 441 << pvsSize/(float)mObjects.size() << endl 442 << "avg ray contrib=" << avgRayContrib << endl; 443 444 mStats << 445 "#Pass\n" <<mPass<<endl<< 446 "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<< 447 "#TotalSamples\n" << totalSamples<< endl<< 448 "#SampleContributions\n" << passSampleContributions << endl << 449 "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 450 "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 451 "#AvgRayContrib\n" << avgRayContrib << endl; 414 452 } 415 passSamples++; 416 totalSamples++; 417 } 418 419 mPass++; 420 421 int pvsSize = 0; 422 float avgRayContrib = (passContributingSamples > 0) ? 423 passSampleContributions/(float)passContributingSamples : 0; 424 425 cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 426 cout << "#TotalSamples=" << totalSamples/1000 427 << "k #SampleContributions=" << passSampleContributions << " (" 428 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 429 << pvsSize/(float)mObjects.size() << endl 430 << "avg ray contrib=" << avgRayContrib << endl; 431 432 mStats << 433 "#Pass\n" <<mPass<<endl<< 434 "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<< 435 "#TotalSamples\n" << totalSamples<< endl<< 436 "#SampleContributions\n" << passSampleContributions << endl << 437 "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 438 "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 439 "#AvgRayContrib\n" << avgRayContrib << endl; 440 441 442 443 444 } 445 446 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 447 cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 453 454 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 455 } 456 457 cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl << flush; 458 Debug << (int)mVssRays.size() << " rays generated in " 459 << TimeDiff(initialTime, GetTime()) * 1e-3 << " seconds" << endl; 460 461 if (mStoreInitialSamples) 462 { 463 cout << "Writing " << (int)mVssRays.size() << " samples to file ... "; 464 WriteSamples(mVssRays); 465 cout << "finished\n" << endl; 466 } 467 468 //VssRayContainer dummyRays; 469 //LoadSamples(dummyRays, mObjects); 470 //Debug << "rays " << (int)mVssRays.size() << " " << dummyRays.size() << endl; 448 471 449 472 //int numExportRays = 10000; … … 455 478 ExportRays(filename, mVssRays, numExportRays); 456 479 } 457 458 mSceneGraph->CollectObjects(&mObjects);459 480 460 481 // construct view cells … … 563 584 mViewCellsManager->GetVisualizationSamples())); 564 585 565 586 //-- post process view cells 566 587 mViewCellsManager->PostProcess(mObjects, storedRays); 567 588 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h
r487 r490 27 27 28 28 ObjectContainer mObjects; 29 30 /// if initial samples should be loaded from file 31 bool mLoadInitialSamples; 32 /// if initial samples should be stored in file 33 bool mStoreInitialSamples; 29 34 30 35 // rays cast during the processing -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp
r469 r490 66 66 , mCharacterCount(0) 67 67 , mSpaceCount(0) 68 // , mCurrentObjectId(0) 68 69 { 69 70 mCurrentNode = root; … … 94 95 MeshInstance *mi = new MeshInstance(mCurrentMesh); 95 96 mCurrentNode->mGeometry.push_back(mi); 97 // set the object id to a unique value 98 //mi->SetId(mCurrentObjectId ++); 96 99 } else { 97 100 cout<<"X"; … … 386 389 // --------------------------------------------------------------------------- 387 390 X3dViewCellsParseHandlers::X3dViewCellsParseHandlers(ViewCellsManager *viewCellsManager, 388 float viewCellHeight) 389 mElementCount(0) 390 , mAttrCount(0) 391 , mCharacterCount(0) 392 , mSpaceCount(0) 393 , mViewCellsManager(viewCellsManager) 394 ,mViewCellHeight(viewCellHeight)391 float viewCellHeight): 392 mElementCount(0), 393 mAttrCount(0), 394 mCharacterCount(0), 395 mSpaceCount(0), 396 mViewCellsManager(viewCellsManager), 397 mViewCellHeight(viewCellHeight) 395 398 { 396 399 } … … 512 515 513 516 // create view cell from base triangle 514 mViewCellsManager->AddViewCell(mViewCellsManager->ExtrudeViewCell(baseTri, mViewCellHeight)); 517 mViewCellsManager->AddViewCell( 518 mViewCellsManager->ExtrudeViewCell(baseTri, 519 mViewCellHeight)); 515 520 } 516 521 } -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.h
r439 r490 14 14 bool ParseFile(const string filename, SceneGraphNode **root); 15 15 bool ParseFile(const string filename, ViewCellsManager &viewCells); 16 16 17 /// height of a loaded view cell 17 18 float mViewCellHeight; 18 19 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParserXerces.h
r439 r490 64 64 Mesh *mCurrentMesh; 65 65 Material *mCurrentMaterial; 66 66 //int mCurrentObjectId; 67 67 68 // Handlers for X3D 68 69 void
Note: See TracChangeset
for help on using the changeset viewer.