Changeset 1883 for GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
- Timestamp:
- 12/12/06 17:25:53 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1877 r1883 70 70 bool ObjectBasedDistribution::GenerateSample(SimpleRay &ray) 71 71 { 72 Vector3 origin, direction; 73 74 float r[5]; 75 mHalton.GetNext(5, r); 76 77 mPreprocessor.mViewCellsManager->GetViewPoint(origin, Vector3(r[2],r[3],r[4])); 78 79 Vector3 point; 80 Vector3 normal; 81 82 r[0] *= mPreprocessor.mObjects.size()-1; 83 const int i = (int)r[0]; 84 85 Intersectable *object = mPreprocessor.mObjects[i]; 86 87 // take the remainder as a parameter over objects surface 88 r[0] -= (float)i; 89 90 object->GetRandomSurfacePoint(r[0], r[1], point, normal); 91 92 direction = point - origin; 93 94 const float c = Magnitude(direction); 95 96 if (c <= Limits::Small) 97 return false; 98 99 // $$ jb the pdf is yet not correct for all sampling methods! 100 const float pdf = 1.0f; 101 102 direction *= 1.0f / c; 103 ray = SimpleRay(origin, direction, pdf); 104 105 return true; 106 } 107 108 109 bool ObjectDirectionBasedDistribution::GenerateSample(SimpleRay &ray) 72 Vector3 origin, direction; 73 74 float r[5]; 75 mHalton.GetNext(5, r); 76 77 mPreprocessor.mViewCellsManager->GetViewPoint(origin, 78 Vector3(r[2],r[3],r[4])); 79 80 81 Vector3 point, normal; 82 83 r[0] *= mPreprocessor.mObjects.size()-1; 84 const int i = (int)r[0]; 85 86 Intersectable *object = mPreprocessor.mObjects[i]; 87 88 // take the remainder as a parameter over objects surface 89 r[0] -= (float)i; 90 91 object->GetRandomSurfacePoint(r[0], r[1], point, normal); 92 93 direction = point - origin; 94 95 const float c = Magnitude(direction); 96 97 if (c <= Limits::Small) 98 return false; 99 100 // $$ jb the pdf is yet not correct for all sampling methods! 101 const float pdf = 1.0f; 102 103 direction *= 1.0f / c; 104 ray = SimpleRay(origin, direction, OBJECT_BASED_DISTRIBUTION, pdf); 105 106 return true; 107 } 108 109 110 bool 111 ObjectDirectionBasedDistribution::GenerateSample(SimpleRay &ray) 110 112 { 111 Vector3 origin, direction; 112 const int i = (int)RandomValue(0, (Real)mPreprocessor.mObjects.size() - 0.5f); 113 Intersectable *object = mPreprocessor.mObjects[i]; 114 115 Vector3 normal; 116 //cout << "x"; 117 object->GetRandomSurfacePoint(origin, normal); 118 direction = UniformRandomVector(normal); 119 120 origin += 0.1f * direction; 121 122 const float c = Magnitude(direction); 123 124 if (c <= Limits::Small) 125 return false; 126 127 // $$ jb the pdf is yet not correct for all sampling methods! 128 const float pdf = 1.0f; 129 130 direction *= 1.0f / c; 131 ray = SimpleRay(origin, direction, pdf); 132 133 return true; 113 Vector3 origin, direction; 114 115 116 float r[4]; 117 mHalton.GetNext(4, r); 118 119 r[0] *= mPreprocessor.mObjects.size()-1; 120 const int i = (int)r[0]; 121 122 Intersectable *object = mPreprocessor.mObjects[i]; 123 124 // take the remainder as a parameter over objects surface 125 r[0] -= (float)i; 126 127 Vector3 normal; 128 129 object->GetRandomSurfacePoint(r[0], r[1], origin, normal); 130 131 direction = Normalize(CosineRandomVector(r[2], r[3], normal)); 132 133 origin += 1e-2*direction; 134 135 // $$ jb the pdf is yet not correct for all sampling methods! 136 const float pdf = 1.0f; 137 138 ray = SimpleRay(origin, direction, OBJECT_DIRECTION_BASED_DISTRIBUTION, pdf); 139 140 return true; 134 141 } 135 142 … … 149 156 150 157 direction *= 1.0f / c; 151 ray = SimpleRay(origin, direction, pdf);158 ray = SimpleRay(origin, direction, DIRECTION_BASED_DISTRIBUTION, pdf); 152 159 153 160 return true; … … 173 180 174 181 direction *= 1.0f / c; 175 ray = SimpleRay(origin, direction, pdf);182 ray = SimpleRay(origin, direction, DIRECTION_BOX_BASED_DISTRIBUTION, pdf); 176 183 177 184 return true; … … 200 207 201 208 direction *= 1.0f / c; 202 ray = SimpleRay(origin, direction, pdf);209 ray = SimpleRay(origin, direction, SPATIAL_BOX_BASED_DISTRIBUTION, pdf); 203 210 204 211 return true; … … 238 245 point += direction * 0.001f; 239 246 240 ray = SimpleRay(point, direction, pdf);247 ray = SimpleRay(point, direction, REVERSE_OBJECT_BASED_DISTRIBUTION, pdf); 241 248 242 249 return true; … … 279 286 //cout << "p: " << point << " "; 280 287 direction *= 1.0f / c; 281 ray = SimpleRay(origin, direction, pdf);288 ray = SimpleRay(origin, direction, VIEWCELL_BORDER_BASED_DISTRIBUTION, pdf); 282 289 283 290 //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl; … … 352 359 point += direction * 0.001f; 353 360 354 ray = SimpleRay(point, direction, pdf);361 ray = SimpleRay(point, direction, REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION, pdf); 355 362 356 363 return true; … … 388 395 origin += direction * 0.001f; 389 396 390 ray = SimpleRay(origin, direction, pdf);397 ray = SimpleRay(origin, direction, VIEWSPACE_BORDER_BASED_DISTRIBUTION, pdf); 391 398 392 399 return true; … … 415 422 mHalton.GetNext(4, r); 416 423 417 #if 0418 #if 0419 r[0] = RandomValue(0,1);420 r[1] = RandomValue(0,1);421 r[2] = RandomValue(0,1);422 r[3] = RandomValue(0,1);423 #else424 r[0] = mHalton.GetNumber(1);425 r[1] = mHalton.GetNumber(2);426 r[2] = mHalton.GetNumber(3);427 r[3] = mHalton.GetNumber(4);428 mHalton.GenerateNext();429 #endif430 #endif431 424 origin = center + (radius*UniformRandomVector(r[0], r[1])); 432 425 termination = center + (radius*UniformRandomVector(r[2], r[3])); 433 426 434 427 direction = termination - origin; 435 //direction = UniformRandomVector();436 428 437 429 … … 458 450 459 451 460 ray = SimpleRay(origin, direction, pdf);452 ray = SimpleRay(origin, direction, GLOBAL_LINES_DISTRIBUTION, pdf); 461 453 ray.mType = Ray::GLOBAL_RAY; 462 454 return true; … … 466 458 } 467 459 468 } 469 470 460 461 // has to called before first usage 462 void 463 MixtureDistribution::Init() 464 { 465 466 } 467 468 // Generate a new sample according to a mixture distribution 469 bool 470 MixtureDistribution::GenerateSample(SimpleRay &ray) 471 { 472 473 return false; 474 } 475 476 // add contributions of the sample to the strategies 477 void 478 MixtureDistribution::UpdateContributions(VssRayContainer &vssRays) 479 { 480 481 } 482 483 } 484 485
Note: See TracChangeset
for help on using the changeset viewer.