- Timestamp:
- 10/10/05 04:19:59 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r312 r313 67 67 68 68 // add object to view cell 69 for (j=0; j < ray.viewCells.size(); j++)69 for (j=0; j < ray.viewCells.size(); ++ j) 70 70 { 71 71 ViewCell *vc = ray.viewCells[j]; 72 73 for (int i = 0; i < 5; ++ i) 74 if (vc == mViewCells[i]) 75 Debug << "adding sample to vc " << i << endl; 72 76 contributingSamples += vc->GetPvs().AddSample(obj); 73 77 } 74 78 75 79 if (mPass > 1) 76 for (j=1; j < ((int)ray.viewCells.size() - 1); j++)80 for (j=1; j < ((int)ray.viewCells.size() - 1); ++ j) 77 81 { 78 82 ray.viewCells[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); … … 112 116 sampleContributions += AddObjectSamples(object, ray); 113 117 114 if (ray.intersections.size() > 0) // view cellfound118 if (ray.intersections.size() > 0) // second intersection found 115 119 { 116 120 sampleContributions += … … 230 234 231 235 int pvsOut = Min((int)objects.size(), 10); 232 236 int vcPvsOut = Min((int)mViewCells.size(), 5); 237 233 238 vector<Ray> rays[10]; 234 239 vector<Ray> vcRays[5]; 240 235 241 while (totalSamples < mTotalSamples) { 236 242 int passContributingSamples = 0; … … 330 336 sampleContributions = CastRay(object, ray); 331 337 338 if (mViewCellsType == BSP_VIEW_CELLS) 339 { 340 // check whether we can add this to the rays 341 for (int k = 0; k < ray.viewCells.size(); ++ k) 342 for (int j = 0; j < vcPvsOut; ++ j) 343 if (mViewCells[j] == ray.viewCells[k]) 344 { 345 Debug << "Pushing back ray" << endl; 346 vcRays[j].push_back(ray); 347 } 348 } 332 349 } 333 350 } else { … … 350 367 } 351 368 } 352 369 353 370 passSamples++; 354 371 … … 369 386 int pvsSize = 0; 370 387 371 if (mViewCellsType == BSP_VIEW_CELLS) 372 { 388 if (mViewCellsType == BSP_VIEW_CELLS) { 373 389 for (i=0; i < mViewCells.size(); i++) { 374 390 ViewCell *vc = mViewCells[i]; 375 391 pvsSize += vc->GetPvs().GetSize(); 376 392 } 377 } else 378 { 393 } else { 379 394 for (i=0; i < objects.size(); i++) { 380 395 Intersectable *object = objects[i]; … … 435 450 if (mViewCellsType == BSP_VIEW_CELLS) 436 451 { 437 int limit = Min((int)mViewCells.size(), 1); 438 439 //char s[64]; sprintf(s, "bsp-pvs%04d.x3d", k); 440 Exporter *exporter = Exporter::GetExporter("bsp-pvs.x3d"); 441 exporter->SetFilled(); 442 443 Intersectable::NewMail(); 444 445 for (int j = 0; j < limit; ++ j) 446 { 447 // j random view cells 448 int k = Random((int)mViewCells.size()); 449 450 Debug << "next vc: " << k << endl; 451 ViewCellPvsMap::iterator it = mViewCells[k]->GetPvs().mEntries.begin(); 452 for (int j = 0; j < vcPvsOut; ++ j) 453 { 454 ViewCell *vc = mViewCells[j]; 455 456 Intersectable::NewMail(); 457 458 char s[64]; sprintf(s, "bsp-pvs%04d.x3d", j); 459 Exporter *exporter = Exporter::GetExporter(s); 460 exporter->SetFilled(); 461 462 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 452 463 453 464 Material m;//= RandomMaterial(); … … 455 466 exporter->SetForcedMaterial(m); 456 467 457 exporter->ExportViewCell(mViewCells[k]); 468 exporter->ExportViewCell(vc); 469 470 Debug << "pvs size: " << (int)vc->GetPvs().GetSize() << " of " << objects.size(); 471 Debug << " exporting rays: " << (int)vcRays[j].size() << endl; 472 473 exporter->SetWireframe(); 474 475 m.mDiffuseColor = RgbColor(1, 0, 1); 476 exporter->SetForcedMaterial(m); 477 478 exporter->ExportBspTree(*mBspTree); 479 exporter->ExportRays(vcRays[j], 1000, RgbColor(0, 1, 0)); 458 480 459 481 m.mDiffuseColor = RgbColor(1, 0, 0); 460 482 exporter->SetForcedMaterial(m); 461 483 462 Debug << "pvs size: " << mViewCells[k]->GetPvs().GetSize() << " of " << objects.size() << endl; 463 464 for (; it != mViewCells[k]->GetPvs().mEntries.end(); ++ it) 484 // output pvs of view cell 485 for (; it != vc->GetPvs().mEntries.end(); ++ it) 465 486 { 466 487 Intersectable *intersect = (*it).first; … … 469 490 exporter->ExportIntersectable(intersect); 470 491 intersect->Mail(); 471 } 472 492 } 473 493 } 494 495 // output rest of the objects 496 if (1) 497 { 498 Material m;//= RandomMaterial(); 499 m.mDiffuseColor = RgbColor(0, 0, 1); 500 exporter->SetForcedMaterial(m); 501 502 for (int j = 0; j < objects.size(); ++ j) 503 if (!objects[j]->Mailed()) 504 { 505 exporter->ExportIntersectable(objects[j]); 506 objects[j]->Mail(); 507 } 508 } 509 DEL_PTR(exporter); 474 510 } 475 476 // output rest of the objects477 Material m;//= RandomMaterial();478 m.mDiffuseColor = RgbColor(0, 0, 1);479 exporter->SetForcedMaterial(m);480 481 for (int j = 0; j < objects.size(); ++ j)482 if (!objects[j]->Mailed())483 {484 exporter->ExportIntersectable(objects[j]);485 objects[j]->Mail();486 }487 488 DEL_PTR(exporter);489 511 } 490 512 … … 529 551 return true; 530 552 } 531 532 533 534
Note: See TracChangeset
for help on using the changeset viewer.