Changeset 576 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 01/25/06 14:35:01 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r572 r576 44 44 mViewDirection = Vector3(0,0,1); 45 45 // timerId = startTimer(10); 46 // debug coords for atlanta 47 mViewPoint = Vector3(3473, 6.778, -1699); 48 mViewDirection = Vector3(-0.2432, 0, 0.97); 49 46 50 mFrame = 0; 47 51 mWireFrame = false; 48 52 environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 53 mSnapErrorFrames = false; 54 mSnapPrefix = ""; 49 55 50 56 } … … 177 183 glGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC) 178 184 wglGetProcAddress("glGetOcclusionQueryuivNV"); 179 } 180 185 186 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 187 188 } 189 190 void 191 GlRendererWidget::RenderInfo() 192 { 193 QString s; 194 s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 195 mFrame, 196 mViewPoint.x, 197 mViewPoint.y, 198 mViewPoint.z, 199 mViewDirection.x, 200 mViewDirection.y, 201 mViewDirection.z 202 203 ); 204 renderText(0,20,s); 205 } 181 206 182 207 … … 245 270 KdTree *tree): 246 271 QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 247 248 272 249 273 environment->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); … … 256 280 257 281 float 258 GlRenderer ::GetPixelError()282 GlRendererBuffer::GetPixelError() 259 283 { 260 284 float pErrorPixels = -1.0f; … … 262 286 glReadBuffer(GL_BACK); 263 287 264 mUseFalseColors = true; 265 288 // mUseFalseColors = true; 289 290 mUseFalseColors = false; 266 291 267 292 static int query = -1; … … 311 336 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 312 337 338 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); 339 313 340 // Render PVS 314 341 std::map<Intersectable *, … … 320 347 RenderIntersectable(object); 321 348 } 349 350 // glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 351 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 352 mUseFalseColors = true; 322 353 323 354 glBeginOcclusionQueryNV(query); … … 337 368 338 369 pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 370 if (mSnapErrorFrames && pErrorPixels > 0.01) { 371 372 char filename[256]; 373 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 374 QImage im = toImage(); 375 im.save(mSnapPrefix + filename, "PNG"); 376 if (1) { //0 && mFrame == 1543) { 377 int x,y; 378 int lastIndex = -1; 379 for (y=0; y < im.height(); y++) 380 for (x=0; x < im.width(); x++) { 381 QRgb p = im.pixel(x,y); 382 int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 383 if (qGreen(p) != 255 && index!=0) { 384 if (index != lastIndex) { 385 Debug<<"ei="<<index<<" "; 386 lastIndex = index; 387 } 388 } 389 } 390 } 391 392 393 mUseFalseColors = false; 394 glPushAttrib(GL_CURRENT_BIT); 395 glColor3f(0,1,0); 396 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 397 SetupCamera(); 398 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 399 400 // Render PVS 401 std::map<Intersectable *, 402 PvsData<Intersectable *>, 403 LtSample<Intersectable *> >::const_iterator it = viewcell->GetPvs().mEntries.begin(); 404 405 for (; it != viewcell->GetPvs().mEntries.end(); ++ it) { 406 Intersectable *object = (*it).first; 407 RenderIntersectable(object); 408 } 409 410 im = toImage(); 411 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 412 im.save(mSnapPrefix + filename, "PNG"); 413 glPopAttrib(); 414 } 415 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 339 416 } 340 417 … … 400 477 diff.setPixel(x, y, qRgba(255,128,128,255)); 401 478 errorPixels++; 479 402 480 } 403 481 pErrorPixels = ((float)errorPixels)/(im1.height()*im1.width()); … … 506 584 for (int i=0; i < mPvsStatFrames; i++) { 507 585 float err; 586 // set frame id for saving the error buffer 587 mFrame = i; 508 588 RandomViewPoint(); 589 590 // atlanta problematic frames: 325 525 691 1543 591 #if 0 592 if (mFrame != 325 && 593 mFrame != 525 && 594 mFrame != 691 && 595 mFrame != 1543) 596 mPvsErrorBuffer[i] = -1; 597 else { 598 Debug<<"frame ="<<mFrame<<" vp="<<mViewPoint<<" vd="<<mViewDirection<<endl; 599 } 600 #endif 509 601 if (mPvsErrorBuffer[i] > 0.0f) { 510 602 mPvsErrorBuffer[i] = GetPixelError(); … … 592 684 GlRendererWidget::paintGL() 593 685 { 594 595 596 686 RenderErrors(); 687 RenderInfo(); 688 mFrame++; 597 689 } 598 690 -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r572 r576 72 72 73 73 bool mDetectEmptyViewSpace; 74 bool mSnapErrorFrames; 75 QString mSnapPrefix; 74 76 75 77 KdTree *mKdTree; … … 96 98 RenderScene(); 97 99 100 98 101 void 99 102 SetupProjection(const int w, const int h); … … 101 104 102 105 103 float104 GetPixelError();105 106 106 107 void InitGL(); … … 159 160 int ComputePvs() const; 160 161 162 float 163 GetPixelError(); 161 164 162 165 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; … … 217 220 RenderErrors(); 218 221 222 void 223 RenderInfo(); 224 219 225 virtual int GetWidth() const { return width(); } 220 226 virtual int GetHeight() const { return height(); } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r575 r576 435 435 { 436 436 Vector3 origin, direction; 437 438 for (int i=0; rays.size() < number; i++) { 439 mViewCellsManager->GetViewPoint(origin); 440 437 int startSize = rays.size(); 438 for (int i=0; rays.size() - startSize < number; i++) { 441 439 // now get the direction 442 440 switch (sampleType) { 443 441 case OBJECT_BASED_DISTRIBUTION: { 442 mViewCellsManager->GetViewPoint(origin); 444 443 Vector3 point; 445 444 Vector3 normal; … … 450 449 } 451 450 break; 451 case OBJECT_DIRECTION_BASED_DISTRIBUTION: { 452 int i = RandomValue(0, mObjects.size() - 1); 453 Intersectable *object = mObjects[i]; 454 Vector3 normal; 455 object->GetRandomSurfacePoint(origin, normal); 456 direction = UniformRandomVector(normal); 457 origin += 0.1f*direction; 458 } 459 break; 452 460 case DIRECTION_BASED_DISTRIBUTION: 461 mViewCellsManager->GetViewPoint(origin); 453 462 direction = UniformRandomVector(); 454 463 break; 455 464 case DIRECTION_BOX_BASED_DISTRIBUTION: { 465 mViewCellsManager->GetViewPoint(origin); 456 466 float alpha = RandomValue(0.0f, 2*M_PI); 457 467 float beta = RandomValue(-M_PI/2, M_PI/2); … … 460 470 } 461 471 case SPATIAL_BOX_BASED_DISTRIBUTION: 472 mViewCellsManager->GetViewPoint(origin); 462 473 direction = mKdTree->GetBox().GetRandomPoint() - origin; 463 474 break; -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r575 r576 108 108 RSS_BASED_DISTRIBUTION, 109 109 RSS_SILHOUETTE_BASED_DISTRIBUTION, 110 VSS_BASED_DISTRIBUTION 110 VSS_BASED_DISTRIBUTION, 111 OBJECT_DIRECTION_BASED_DISTRIBUTION 111 112 }; 112 113 -
trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp
r556 r576 28 28 29 29 if (0) { 30 camera.LookAtBox(mPreprocessor->mKdTree->GetBox());30 // camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 31 31 // camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 32 // camera.SetPosition(camera.mPosition + Vector3(0,300,0)); 32 camera.SetPosition(Vector3(3473, 6.778, -1699)); 33 camera.SetDirection(Vector3(-0.2432, 0, 0.97)); 33 34 camera.SnapImage("camera.jpg", mPreprocessor->mKdTree, mPreprocessor->mSceneGraph); 34 35 } -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r574 r576 195 195 vssRays.push_back(vssRay); 196 196 hits ++; 197 197 198 } 198 199 … … 209 210 } 210 211 } 211 212 212 213 return hits; 213 214 } 214 215 215 216 217 void 218 RssPreprocessor::ExportObjectRays(VssRayContainer &rays, 219 const int objectId) 220 { 221 ObjectContainer::const_iterator oi; 222 223 Intersectable *object = NULL; 224 for (oi = mObjects.begin(); oi != mObjects.end(); ++oi) 225 if (objectId == (*oi)->GetId()) { 226 object = *oi; 227 break; 228 } 229 230 if (object == NULL) 231 return; 232 233 VssRayContainer selectedRays; 234 VssRayContainer::const_iterator it= rays.begin(), it_end = rays.end(); 235 236 237 for (; it != it_end; ++it) { 238 if ((*it)->mTerminationObject == object) 239 selectedRays.push_back(*it); 240 } 241 242 243 Exporter *exporter = Exporter::GetExporter("object-rays.x3d"); 244 // exporter->SetWireframe(); 245 // exporter->ExportKdTree(*mKdTree); 246 exporter->SetFilled(); 247 exporter->ExportIntersectable(object); 248 exporter->ExportRays(selectedRays, RgbColor(1, 0, 0)); 249 250 delete exporter; 251 252 } 216 253 217 254 … … 461 498 SimpleRayContainer rays; 462 499 463 GenerateRays(mInitialSamples, SPATIAL_BOX_BASED_DISTRIBUTION, rays); 500 GenerateRays(mInitialSamples/4, SPATIAL_BOX_BASED_DISTRIBUTION, rays); 501 GenerateRays(mInitialSamples/4, OBJECT_BASED_DISTRIBUTION, rays); 502 GenerateRays(mInitialSamples/4, DIRECTION_BASED_DISTRIBUTION, rays); 503 GenerateRays(mInitialSamples/4, OBJECT_DIRECTION_BASED_DISTRIBUTION, rays); 464 504 465 505 CastRays(rays, mVssRays); 506 507 ExportObjectRays(mVssRays, 1546); 466 508 } 467 509 … … 551 593 VssRayContainer tmpVssRays; 552 594 553 float ratios[] = { 1.0f,0,0};595 float ratios[] = {0.8f,0.1f,0.1f}; 554 596 555 597 … … 633 675 mViewCellsManager->PrintPvsStatistics(mStats); 634 676 } 635 677 678 if (0 && mPass > 0) { 679 if (mUseImportanceSampling) 680 renderer->mSnapPrefix.sprintf("snap/i-%02d-", mPass); 681 else 682 renderer->mSnapPrefix.sprintf("snap/r-%02d-", mPass); 683 renderer->mSnapErrorFrames = true; 684 } 685 636 686 ComputeRenderError(); 637 687 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h
r567 r576 87 87 ); 88 88 89 void 90 ExportObjectRays(VssRayContainer &rays, 91 const int objectId); 92 89 93 int 90 94 GenerateImportanceRays(RssTree *vssTree, -
trunk/VUT/GtpVisibilityPreprocessor/src/SceneGraph.cpp
r492 r576 65 65 nodeStack.pop(); 66 66 67 ObjectContainer::const_iterator mi = node->mGeometry.begin(); 68 for (; mi != node->mGeometry.end(); mi++) 69 (*mi)->SetId(id++); 67 ObjectContainer::iterator mi = node->mGeometry.begin(); 68 for (; mi != node->mGeometry.end(); mi++) { 69 // $$ JB remove object id=2601 (for debugging purposes in atlanta scene) 70 if (1) //id != 2601) 71 (*mi)->SetId(id++); 72 else { 73 node->mGeometry.erase(mi); 74 --mi; 75 id++; 76 } 77 } 70 78 71 79 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r574 r576 2303 2303 if (entSide < 0) 2304 2304 { 2305 2306 2307 2308 2309 2310 2305 node = in->GetBack(); 2306 // plane does not split ray => no far child 2307 if (extSide <= 0) 2308 continue; 2309 2310 farChild = in->GetFront(); // plane splits ray 2311 2311 } 2312 2312 else if (entSide > 0) 2313 2313 { 2314 2315 2316 2317 2314 node = in->GetFront(); 2315 2316 if (extSide >= 0) // plane does not split ray => no far child 2317 continue; 2318 2318 2319 2319 farChild = in->GetBack(); // plane splits ray … … 2364 2364 return hits; 2365 2365 } 2366 2367 2368 2366 2369 2367 2370 int VspBspTree::TreeDistance(BspNode *n1, BspNode *n2) const -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r569 r576 27 27 detectEmptyViewSpace false 28 28 pvsRenderErrorSamples 10000 29 30 29 } 31 30 … … 73 72 RssPreprocessor { 74 73 samplesPerPass 500000 75 initialSamples 100000076 vssSamples 1500000074 initialSamples 2000000 75 vssSamples 20000000 77 76 vssSamplesPerPass 1000000 78 77 useImportanceSampling true
Note: See TracChangeset
for help on using the changeset viewer.