- Timestamp:
- 01/13/06 14:17:46 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r503 r534 279 279 float *tmax) const 280 280 { 281 const float dirEps = 1e-8f; 281 282 register float minx, maxx; 282 283 ray.ComputeInvertedDir(); 283 284 284 if (fabs(ray.dir.x) < 0.001) {285 if (fabs(ray.dir.x) < dirEps) { 285 286 if (mMin.x < ray.loc.x && mMax.x > ray.loc.x) { 286 287 minx = -MAXFLOAT; … … 308 309 *tmax = maxx; 309 310 310 if (fabs(ray.dir.y) < 0.001) {311 if (fabs(ray.dir.y) < dirEps) { 311 312 if (mMin.y < ray.loc.y && mMax.y > ray.loc.y) { 312 313 minx = -MAXFLOAT; … … 336 337 *tmax = maxx; 337 338 338 if (fabs(ray.dir.z) < 0.001) {339 if (fabs(ray.dir.z) < dirEps) { 339 340 if (mMin.z < ray.loc.z && mMax.z > ray.loc.z) { 340 341 minx = -MAXFLOAT; -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.h
r492 r534 185 185 Vector3 GetRandomPoint() const { 186 186 Vector3 size = Size(); 187 return mMin + Vector3(RandomValue(0 , size.x),188 RandomValue(0, size.y),189 RandomValue(0, size.z));187 return mMin + Vector3(RandomValue(0.0f, size.x), 188 RandomValue(0.0f, size.y), 189 RandomValue(0.0f, size.z)); 190 190 } 191 191 -
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp
r531 r534 15 15 // "back plane" 16 16 mPlanes.push_back(Plane3(-VssRay::GetDirection(dCenter.x, dCenter.y), center)); 17 17 18 18 Vector3 directions[4]; 19 19 directions[0] = VssRay::GetDirection(dBox.Min().x, dBox.Min().y); … … 23 23 24 24 // side planes 25 mPlanes.push_back(Plane3( CrossProd(directions[0], directions[1]), center));26 mPlanes.push_back(Plane3( CrossProd(directions[1], directions[2]), center));27 mPlanes.push_back(Plane3( CrossProd(directions[2], directions[3]), center));28 mPlanes.push_back(Plane3( CrossProd(directions[3], directions[0]), center));25 mPlanes.push_back(Plane3(-CrossProd(directions[0], directions[1]), center)); 26 mPlanes.push_back(Plane3(-CrossProd(directions[1], directions[2]), center)); 27 mPlanes.push_back(Plane3(-CrossProd(directions[2], directions[3]), center)); 28 mPlanes.push_back(Plane3(-CrossProd(directions[3], directions[0]), center)); 29 29 30 30 … … 122 122 123 123 } 124 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r532 r534 1434 1434 "false"); 1435 1435 1436 RegisterOption("Preprocessor.detectEmptyViewSpace", 1437 optBool, 1438 "detectEmptyViewSpace", 1439 "false"); 1440 1441 1436 1442 /**************************************************************************************/ 1437 1443 /* View space partition KD tree related options */ -
trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp
r492 r534 216 216 // Watch for near-zero denominator 217 217 // ONLY single sided polygons!!!!! 218 if (dot > -Limits::Small) 219 // if (fabs(dot) < Limits::Small) 220 return Ray::NO_INTERSECTION; 218 if (ray.mFlags & Ray::CULL_BACKFACES) { 219 if (dot > -Limits::Small) 220 // if (fabs(dot) < Limits::Small) 221 return Ray::NO_INTERSECTION; 222 } else { 223 if (fabs(dot) < Limits::Small) 224 return Ray::NO_INTERSECTION; 225 } 221 226 222 227 t = (-plane.mD - DotProd(plane.mNormal, ray.GetLoc())) / dot; -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r532 r534 247 247 mViewCellsManager->SetRenderer(mRenderSimulator); 248 248 249 249 250 //-- parse view cells construction method 250 251 environment->GetBoolValue("ViewCells.loadFromFile", mLoadViewCells); … … 257 258 if (mUseGlRenderer) 258 259 renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 259 260 261 262 environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 263 264 265 260 266 return true; 261 267 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r520 r534 129 129 130 130 string mViewCellsFilename; 131 131 132 bool mDetectEmptyViewSpace; 133 132 134 protected: 133 135 -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h
r475 r534 71 71 vector<Intersectable *> testedObjects; 72 72 73 74 enum {STORE_KDLEAVES=1, STORE_BSP_INTERSECTIONS=2, STORE_TESTED_OBJECTS=4};75 73 // various flags 74 enum {STORE_KDLEAVES=1, STORE_BSP_INTERSECTIONS=2, STORE_TESTED_OBJECTS=4, CULL_BACKFACES=8}; 75 int mFlags; 76 76 77 77 … … 79 79 Ray(const Vector3 &wherefrom, 80 80 const Vector3 &whichdir, 81 const int _type):mFlags( 0) {81 const int _type):mFlags(CULL_BACKFACES) { 82 82 loc = wherefrom; 83 83 if (_type == LINE_SEGMENT) … … 96 96 Ray(const VssRay &vssRay) { 97 97 Init(vssRay); 98 mFlags |= CULL_BACKFACES; 98 99 } 99 100 … … 301 302 struct SimpleRay 302 303 { 303 Vector3 mOrigin; 304 Vector3 mDirection; 305 SimpleRay() {} 306 SimpleRay(const Vector3 &o, const Vector3 &d):mOrigin(o), mDirection(d) {} 304 Vector3 mOrigin; 305 Vector3 mDirection; 306 float mProbability; 307 308 SimpleRay() {} 309 SimpleRay(const Vector3 &o, const Vector3 &d):mOrigin(o), mDirection(d) {} 307 310 }; 308 311 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r527 r534 607 607 if (mUseViewcells) { 608 608 // construct view cells 609 mViewCellsManager->Construct(mObjects, mVssRays); 609 if (!mLoadViewCells) 610 mViewCellsManager->Construct(mObjects, mVssRays); 610 611 // evaluate contributions of the intitial rays 611 612 mViewCellsManager->ComputeSampleContributions(mVssRays); -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp
r516 r534 2041 2041 2042 2042 int nrays = leaf->rays.size(); 2043 2044 2043 int startIndex = rays.size(); 2044 2045 2045 AxisAlignedBox3 box = GetBBox(leaf); 2046 2046 AxisAlignedBox3 dirBox = GetDirBBox(leaf); 2047 2047 2048 2048 2049 AxisAlignedBox3 sBox(box); 2050 AxisAlignedBox3 sDirBox(dirBox); 2051 const float smoothRange = 0.5f; 2052 sBox.Scale(1.0f + smoothRange); 2053 sDirBox.Scale(1.0f + smoothRange); 2054 int smoothRays = (int)numberOfRays*0.0f; 2055 2056 #if AVG_LEN 2057 float avgLength = 0.0f; 2058 2059 if (nrays) { 2060 const int numAvg = 5; 2061 2062 int step = (nrays-1)/10; 2063 if (step<1) 2064 step = 1; 2065 2066 int summed = 0; 2067 float sumLength = 0.0f; 2068 for (int i=0; i < nrays; i+=step) { 2069 sumLength += leaf->rays[i].mRay->GetSize(); 2070 summed++; 2071 } 2072 2073 avgLength = sumLength/summed; 2074 } 2075 #endif 2049 const float smoothRange = 0.0f; 2050 if (smoothRange != 0.0f) { 2051 box.Scale(1.0f + smoothRange); 2052 dirBox.Scale(1.0f + smoothRange); 2053 } 2054 2076 2055 2077 2056 Exporter *exporter = NULL; … … 2149 2128 leaf->halton.GetNumber(5), 2150 2129 0.0f); 2130 2151 2131 leaf->halton.GenerateNext(); 2152 2132 } else { … … 2160 2140 } 2161 2141 2162 if (i < smoothRays) { 2163 origin = sBox.GetPoint(pVector); 2164 dirVector = sDirBox.GetPoint(dVector); 2165 } else { 2166 origin = box.GetPoint(pVector); 2167 dirVector = dirBox.GetPoint(dVector); 2168 } 2142 origin = box.GetPoint(pVector); 2143 dirVector = dirBox.GetPoint(dVector); 2144 2169 2145 direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 2170 2146 } … … 2216 2192 } 2217 2193 2194 2218 2195 // cout<<"desired="<<numberOfRays<<" tries="<<i<<endl; 2219 2196 // assign probabilitites to the generated rays 2197 for (i=startIndex; i < rays.size(); i++) 2198 rays[i].mProbability = 1.0f; 2199 2220 2200 if (exporter) { 2221 2201 exporter->ExportRays(selectedRays, RgbColor(1, 0, 0)); … … 2223 2203 CLEAR_CONTAINER(selectedRays); 2224 2204 } 2205 2206 2225 2207 } 2226 2208 -
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) { -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r492 r534 63 63 // computed by the prperocessor 64 64 float mWeightedPvsContribution; 65 66 // probability of this ray 67 float mProbability; 65 68 66 69 ////////////////////////////// … … 81 84 mPass(pass), 82 85 mViewCells(0), 83 mWeightedPvsContribution(0) 84 // mT(1.0f)86 mWeightedPvsContribution(0), 87 mProbability(1.0f) 85 88 { 86 89 Precompute(); … … 93 96 mOriginObject(ray.sourceObject.mObject), 94 97 mPass(0), 95 mViewCells(0) 96 // mT(1.0f)98 mViewCells(0), 99 mProbability(1.0f) 97 100 { 98 101 if (ray.sourceObject.mObject) -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r529 r534 6 6 Scene { 7 7 8 # filenameglasgow1.x3d8 # filename ../data/glasgow/glasgow1.x3d 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d … … 15 15 filename ../data/atlanta/atlanta2.x3d 16 16 # filename ../data/soda/soda.dat 17 filename ../data/soda/soda5.dat17 # filename ../data/soda/soda5.dat 18 18 } 19 19 … … 23 23 useGlRenderer true 24 24 # type sampling 25 # type vss 26 type rss 25 type vss 26 # type rss 27 detectEmptyViewSpace false 27 28 } 28 29 … … 30 31 samplesPerPass 100000 31 32 initialSamples 500000 32 vssSamples 200000 33 vssSamplesPerPass 10000033 vssSamples 2000000 34 vssSamplesPerPass 200000 34 35 useImportanceSampling true 35 36 loadInitialSamples false … … 44 45 maxDepth 40 45 46 minPvs 30 46 minRays 100 047 minRays 100 47 48 minSize 0.001 48 maxCostRatio 0.949 maxRayContribution 0. 0549 maxCostRatio 1.5 50 maxRayContribution 0.5 50 51 51 52 maxTotalMemory 200 52 maxStaticMemory 2053 maxStaticMemory 100 53 54 54 55 splitType regular … … 57 58 splitUseOnlyDrivingAxis true 58 59 59 interleaveDirSplits false60 dirSplitDepth 4060 interleaveDirSplits true 61 dirSplitDepth 0 61 62 62 63 numberOfEndPointDomains 10000 … … 167 168 168 169 ViewCells { 169 loadFromFile true170 loadFromFile false 170 171 #type kdTree 171 172 #type vspKdTree 172 type bspTree173 #type vspBspTree173 # type bspTree 174 type vspBspTree 174 175 175 176 #type sceneDependent … … 199 200 } 200 201 201 filename ../data/soda 5/viewcells_soda5.xml202 filename ../data/soda/viewcells_soda5.xml 202 203 # filename ../data/atlanta/atlanta_viewcells_large.x3d 203 204 # filename ../data/vienna/viewcells-25-sel.x3d
Note: See TracChangeset
for help on using the changeset viewer.