- Timestamp:
- 01/23/06 21:37:50 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r569 r572 46 46 mFrame = 0; 47 47 mWireFrame = false; 48 environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 49 48 50 } 49 51 … … 69 71 { 70 72 71 SetupFalseColor(object->mId); 73 glPushAttrib(GL_CURRENT_BIT); 74 if (mUseFalseColors) 75 SetupFalseColor(object->mId); 76 72 77 73 78 switch (object->Type()) { … … 82 87 break; 83 88 } 89 90 glPopAttrib(); 84 91 } 85 92 … … 88 95 GlRenderer::RenderViewCell(ViewCell *vc) 89 96 { 90 if (vc->GetMesh()) 91 RenderMesh(vc->GetMesh()); 97 if (vc->GetMesh()) { 98 99 if (vc->GetValid()) 100 glColor3f(0,1,0); 101 else 102 glColor3f(0,0,1); 103 104 RenderMesh(vc->GetMesh()); 105 } 92 106 } 93 107 … … 117 131 if (m) 118 132 glColor3fv(&(m->mDiffuseColor.r)); 119 else120 glColor3f(1.0f, 1.0f, 1.0f);121 133 } 122 134 … … 194 206 GlRendererBuffer::RandomViewPoint() 195 207 { 196 Vector3 pVector = Vector3(halton.GetNumber(1), 197 halton.GetNumber(2), 198 halton.GetNumber(3)); 208 209 210 // do not use this function since it could return different viewpoints for 211 // different executions of the algorithm 212 213 //mViewCellsManager->GetViewPoint(mViewPoint); 214 215 while (1) { 216 Vector3 pVector = Vector3(halton.GetNumber(1), 217 halton.GetNumber(2), 218 halton.GetNumber(3)); 219 220 mViewPoint = mSceneGraph->GetBox().GetPoint(pVector); 221 ViewCell *v = mViewCellsManager->GetViewCell(mViewPoint); 222 if (v && v->GetValid()) 223 break; 224 // generate a new vector 225 halton.GenerateNext(); 226 } 227 199 228 200 229 Vector3 dVector = Vector3(2*M_PI*halton.GetNumber(4), 201 230 M_PI*halton.GetNumber(5), 202 231 0.0f); 203 204 mViewCellsManager->GetViewPoint(mViewPoint);205 206 // mViewPoint = mSceneGraph->GetBox().GetPoint(pVector);207 232 208 233 mViewDirection = Normalize(Vector3(sin(dVector.x), … … 210 235 0.0f, 211 236 cos(dVector.x))); 212 213 237 halton.GenerateNext(); 214 238 } … … 221 245 KdTree *tree): 222 246 QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 247 223 248 224 249 environment->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); … … 238 263 239 264 mUseFalseColors = true; 240 241 SetupCamera(); 242 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 243 glEnable( GL_CULL_FACE ); 244 245 RenderScene(); 246 247 // now check whether any backfacing polygon would pass the depth test 265 266 248 267 static int query = -1; 268 unsigned int pixelCount; 269 249 270 if (query == -1) 250 271 glGenOcclusionQueriesNV(1, (unsigned int *)&query); 251 252 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 253 glDepthMask(GL_FALSE); 254 glDisable( GL_CULL_FACE ); 255 256 glBeginOcclusionQueryNV(query); 257 258 RenderScene(); 259 260 glEndOcclusionQueryNV(); 261 262 // at this point, if possible, go and do some other computation 263 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 264 glDepthMask(GL_TRUE); 265 glEnable( GL_CULL_FACE ); 266 267 unsigned int pixelCount; 268 // reenable other state 269 glGetOcclusionQueryuivNV(query, 270 GL_PIXEL_COUNT_NV, 271 &pixelCount); 272 273 if (pixelCount > 0) 274 return -1.0f; // backfacing polygon found -> not a valid viewspace sample 272 273 if (mDetectEmptyViewSpace) { 274 // now check whether any backfacing polygon would pass the depth test 275 SetupCamera(); 276 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 277 glEnable( GL_CULL_FACE ); 278 279 RenderScene(); 280 281 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 282 glDepthMask(GL_FALSE); 283 glDisable( GL_CULL_FACE ); 284 285 glBeginOcclusionQueryNV(query); 286 287 RenderScene(); 288 289 glEndOcclusionQueryNV(); 290 291 // at this point, if possible, go and do some other computation 292 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 293 glDepthMask(GL_TRUE); 294 glEnable( GL_CULL_FACE ); 295 296 // reenable other state 297 glGetOcclusionQueryuivNV(query, 298 GL_PIXEL_COUNT_NV, 299 &pixelCount); 300 301 if (pixelCount > 0) 302 return -1.0f; // backfacing polygon found -> not a valid viewspace sample 303 } else 304 glDisable( GL_CULL_FACE ); 305 275 306 276 307 ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 277 308 278 309 if (viewcell) { 279 310 SetupCamera(); … … 323 354 SetupCamera(); 324 355 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 325 glEnable( GL_CULL_FACE ); 326 356 357 358 if (mDetectEmptyViewSpace) 359 glEnable( GL_CULL_FACE ); 360 else 361 glDisable( GL_CULL_FACE ); 362 327 363 ObjectContainer::const_iterator oi = mObjects.begin(); 328 364 for (; oi != mObjects.end(); oi++) … … 379 415 // now render im1 380 416 if (viewcell) { 381 if ( mTopView) {417 if (1 || mTopView) { 382 418 mWireFrame = true; 383 Render MeshInstance(viewcell);419 RenderIntersectable(viewcell); 384 420 mWireFrame = false; 385 421 } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r563 r572 70 70 int mFrame; 71 71 bool mWireFrame; 72 73 bool mDetectEmptyViewSpace; 72 74 73 75 KdTree *mKdTree; … … 164 166 int mPvsStatFrames; 165 167 vector<float> mPvsErrorBuffer; 166 167 168 private: 168 169 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r569 r572 437 437 // load now because otherwise bounding box not correct 438 438 mViewCellsManager->LoadViewCells(mViewCellsFilename, &mObjects); 439 // $$JB tmp make all viewcelss valid 440 mViewCellsManager->SetValidity(0, 9999999999); 441 439 442 } 440 443 … … 515 518 if (1) 516 519 mViewCellsManager->Visualize(mObjects, selectedRays); 520 521 // viewcells->UpdatePVS(newVssRays); 522 Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 523 // cull viewcells with PVS > median (0.5f) 524 mViewCellsManager->SetValidityPercentage(0, 0.5f); 525 Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 517 526 518 527 ComputeRenderError(); … … 547 556 } 548 557 549 // viewcells->UpdatePVS(newVssRays);550 Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl;551 // cull viewcells with PVS > median (0.5f)552 mViewCellsManager->SetValidityPercentage(0, 0.5f);553 Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl;554 558 555 559 while (1) { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r571 r572 1268 1268 if (!mBspTree) 1269 1269 return NULL; 1270 1271 if (!mViewSpaceBox.IsInside(point)) 1272 return NULL; 1273 1270 1274 return mBspTree->GetViewCell(point); 1271 1275 } … … 2614 2618 if (!mVspBspTree) 2615 2619 return NULL; 2620 2621 if (!mViewSpaceBox.IsInside(point)) 2622 return NULL; 2623 2616 2624 return mVspBspTree->GetViewCell(point); 2617 2625 }
Note: See TracChangeset
for help on using the changeset viewer.