- Timestamp:
- 01/13/06 14:17:46 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r532 r534 15 15 16 16 bool use2dSampling = false; 17 bool useViewspacePlane = true;17 bool useViewspacePlane = false; 18 18 19 19 VssPreprocessor::VssPreprocessor(): … … 78 78 float bsize = Magnitude(box.Size()); 79 79 80 81 if (!mDetectEmptyViewSpace) 82 ray.mFlags &= ~Ray::CULL_BACKFACES; 80 83 81 84 if (mKdTree->CastRay(ray)) { … … 92 95 } 93 96 94 bool detectEmptyViewSpace = true;95 97 96 if ( detectEmptyViewSpace) {98 if (mDetectEmptyViewSpace) { 97 99 SetupRay(ray, pointA, -direction); 98 100 } else 99 101 SetupRay(ray, viewPoint, -direction); 100 101 102 103 if (!mDetectEmptyViewSpace) 104 ray.mFlags &= ~Ray::CULL_BACKFACES; 105 102 106 if (mKdTree->CastRay(ray)) { 103 107 objectB = ray.intersections[0].mObject; … … 111 115 return 0; 112 116 } 113 117 114 118 // if (objectA == NULL && objectB != NULL) { 115 if ( 1) {119 if (mDetectEmptyViewSpace) { 116 120 // cast again to ensure that there is no objectA 117 121 SetupRay(ray, pointB, direction); … … 121 125 } 122 126 } 123 127 124 128 125 129 VssRay *vssRay = NULL; 126 130 127 131 bool validSample = (objectA != objectB); 128 if (0 && detectEmptyViewSpace) { // consider all samples valid132 if (0 && mDetectEmptyViewSpace) { // consider all samples valid 129 133 // check if the viewpoint lies on the line segment AB 130 134 if (Distance(pointA, pointB) < … … 183 187 Vector3 point; 184 188 if (!use2dSampling) { 185 Vector3 normal; 186 int i = (int)RandomValue(0, (Real)((int)mObjects.size()-1)); 187 Intersectable *object = mObjects[i]; 188 object->GetRandomSurfacePoint(point, normal); 189 if (0) { 190 Vector3 normal; 191 int i = Random((int)mObjects.size()); 192 Intersectable *object = mObjects[i]; 193 object->GetRandomSurfacePoint(point, normal); 194 } else 195 point = mKdTree->GetBox().GetRandomPoint(); 196 // point = viewpoint + UniformRandomVector(); 197 189 198 } else { 190 199 AxisAlignedBox3 box; … … 226 235 num = vssTree->GenerateRays(p, rays); 227 236 } else { 228 int leaves = vssTree->stat.Leaves() /2;237 int leaves = vssTree->stat.Leaves(); 229 238 num = vssTree->GenerateRays(desiredSamples, leaves, rays); 230 239 } … … 243 252 { 244 253 cout<<"Exporting vss rays..."<<endl<<flush; 245 246 float prob = number/(float)vssRays.size();247 248 254 249 255 Exporter *exporter = NULL; … … 261 267 } 262 268 263 VssRayContainer rays; for (int i=0; i < vssRays.size(); i++) 264 if (RandomValue(0,1) < prob) 265 rays.push_back(vssRays[i]); 266 269 VssRayContainer rays; 270 vssRays.SelectRays(number, rays); 271 267 272 exporter->ExportRays(rays, RgbColor(1, 0, 0)); 268 273 … … 411 416 412 417 AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox()); 413 418 414 419 if (!useViewspacePlane) { 415 420 float size = 0.05f; … … 430 435 box->SetMax(1, box->Min(1)); 431 436 437 cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 432 438 if (mUseViewSpaceBox) 433 439 { … … 440 446 mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 441 447 } 442 448 443 449 //-- load view cells from file if requested 444 450 if (mLoadViewCells) … … 464 470 else 465 471 { 466 while (totalSamples < mInitialSamples) { 472 473 while (totalSamples < mInitialSamples) { 467 474 int passContributingSamples = 0; 468 475 int passSampleContributions = 0; … … 476 483 for (int k=0; k < s; k++) { 477 484 // changed by matt 478 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox);479 485 Vector3 viewpoint; 486 // viewpoint = GetViewpoint(mViewSpaceBox); 480 487 mViewCellsManager->GetViewPoint(viewpoint); 481 488 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 482 489 483 490 sampleContributions = CastRay(viewpoint, direction, mVssRays); 484 491 … … 514 521 515 522 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 523 524 525 516 526 } 517 527 … … 537 547 } 538 548 539 //int numExportRays = 10000; 540 int numExportRays = 0; 549 550 int numExportRays = 5000; 551 //int numExportRays = 0; 541 552 542 553 if (numExportRays) {
Note: See TracChangeset
for help on using the changeset viewer.