- Timestamp:
- 04/30/08 13:24:45 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 6 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2669 r2670 86 86 mUseVbos(false), 87 87 mComputeGVS(false), 88 mCurrentFrame( -1)88 mCurrentFrame(100) 89 89 { 90 90 mSceneGraph->CollectObjects(mObjects); -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2664 r2670 172 172 virtual void EvalPvsStat(); 173 173 174 void PreparePvs(const ObjectPvs &pvs); 174 /** Prepare the pvs for rendering. 175 */ 176 virtual void PreparePvs(const ObjectPvs &pvs); 177 /** Helper function that recursively prepares the indices for VBO renderin. 178 */ 175 179 void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 176 180 … … 207 211 208 212 Vector3 GetViewPoint() const { return mViewPoint; } 213 214 209 215 public: 210 216 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2669 r2670 1252 1252 void GvsPreprocessor::ComputeViewCell(ViewCell *vc) 1253 1253 { 1254 KdNode::NewMail(); 1255 1254 1256 mCurrentViewCell = vc; 1255 KdNode::NewMail();1256 1257 long startTime = GetTime(); 1257 1258 const long startTime = GetTime(); 1259 1258 1260 cout << "\n***********************\n" 1259 1261 << "computing view cell " << mProcessedViewCells -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.cpp
r2660 r2670 15 15 #endif 16 16 17 namespace GtpVisibilityPreprocessor { 17 namespace GtpVisibilityPreprocessor 18 { 18 19 19 20 … … 24 25 int Intersectable::sReservedMailboxes2 = 1; 25 26 27 26 28 // This is the result of computing intersection 27 29 // static data member 28 ALIGN16 IntersectionStr 29 SimpleRay::IntersectionRes[32]; 30 ALIGN16 IntersectionStr 31 SimpleRay::IntersectionRes[32]; 32 33 30 34 31 35 Intersectable::Intersectable(): -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2643 r2670 69 69 int Leaves() const { return (nodes / 2) + 1; } 70 70 71 void Reset() { 72 nodes = 0; 73 for (int i=0; i<7; i++) 74 splits[i] = 0; 75 rays = queryDomains = 0; 76 rayRefs = rayRefsNonZeroQuery = objectRefs = 0; 77 zeroQueryNodes = 0; 78 maxDepthNodes = 0; 79 minCostNodes = 0; 80 maxObjectRefs = 0; 81 addedRayRefs = removedRayRefs = 0; 71 void Reset() 72 { 73 nodes = 0; 74 for (int i=0; i<7; i++) 75 splits[i] = 0; 76 rays = queryDomains = 0; 77 rayRefs = rayRefsNonZeroQuery = objectRefs = 0; 78 zeroQueryNodes = 0; 79 maxDepthNodes = 0; 80 minCostNodes = 0; 81 maxObjectRefs = 0; 82 addedRayRefs = removedRayRefs = 0; 82 83 } 83 84 … … 94 95 95 96 class KdInterior; 96 /** Abstract class for kd-tree node */ 97 class KdNode { 97 98 /** Abstract class for kd-tree node 99 */ 100 class KdNode 101 { 98 102 99 103 public: … … 112 116 bool Mailed() const { return mMailbox == sMailId; } 113 117 114 static void NewMail(const int reserve = 1) { 115 sMailId += sReservedMailboxes; 116 sReservedMailboxes = reserve; 117 } 118 static void NewMail(const int reserve = 1) 119 { 120 sMailId += sReservedMailboxes; 121 sReservedMailboxes = reserve; 122 } 123 118 124 void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 119 125 bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 120 126 121 127 122 static void NewMail2(const int reserve = 1) { 123 sMailId2 += sReservedMailboxes; 124 sReservedMailboxes2 = reserve; 128 //////////// 129 //-- hack!!: second mail for a machine with 2 cores 130 131 static void NewMail2(const int reserve = 1) 132 { 133 sMailId2 += sReservedMailboxes; 134 sReservedMailboxes2 = reserve; 125 135 } 126 136 … … 130 140 void Mail2(const int mailbox) { mMailbox2 = sMailId2 + mailbox; } 131 141 bool Mailed2(const int mailbox) const { return mMailbox2 == sMailId2 + mailbox; } 142 143 ///////////////////////////////////// 132 144 133 145 … … 154 166 }; 155 167 156 /** Implementation of the kd-tree interior node */ 168 169 /** Implementation of the kd-tree interior node. 170 */ 157 171 class KdInterior : public KdNode { 158 172 -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp
r2643 r2670 13 13 #define USE_MULTIPLE_OBJECTS 0 14 14 using namespace std; 15 15 16 16 17 namespace GtpVisibilityPreprocessor { … … 155 156 156 157 157 158 158 float ObjectPvs::EvalPvsCost() const 159 159 { -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2669 r2670 123 123 } 124 124 125 125 126 // reimplemented here so that we can snap the error windows 126 127 float QtGlRendererBuffer::GetPixelError(int &pvsSize) … … 128 129 MakeCurrent(); 129 130 130 cout << "stencil: " << format().stencil() << endl; 131 cout << "depth: " << format().depth() << endl; 132 cout << "rgba: " << format().rgba() << endl; 133 cout << "double: " << format().doubleBuffer() << endl; 131 if (0) 132 { 133 cout << "stencil: " << format().stencil() << endl; 134 cout << "depth: " << format().depth() << endl; 135 cout << "rgba: " << format().rgba() << endl; 136 cout << "double: " << format().doubleBuffer() << endl; 137 } 138 139 ++ mCurrentFrame; 134 140 135 141 float pErrorPixels = -1.0f; … … 144 150 return -1.0f; 145 151 146 KdNode::NewMail2();147 Intersectable::NewMail();148 149 ObjectPvs pvs;150 151 152 bool evaluateFilter; 152 153 Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluateFilter", evaluateFilter); 154 155 ObjectPvs pvs; 153 156 154 157 if (!evaluateFilter) … … 169 172 if (mSnapErrorFrames) 170 173 { 171 172 174 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 173 175 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 174 176 GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 175 177 176 GLfloat light_position[] = //{278.0f, 548.8f,279.0f, 1.0f};177 {0.f,0.f,0.f, 1.0f};178 //GLfloat light_position[] = {278.0f, 548.8f,279.0f, 1.0f}; 179 GLfloat light_position[] = {0.f,0.f,0.f, 1.0f}; 178 180 179 181 glEnable(GL_LIGHT0); … … 208 210 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 209 211 210 212 KdNode::NewMail2(); 213 Intersectable::NewMail(); 214 215 KdNode::NewMail2(); 216 Intersectable::NewMail(); 217 KdNode::NewMail2(); 218 Intersectable::NewMail(); 219 211 220 // render pvs once 212 221 RenderPvs(pvs); … … 228 237 query->BeginQuery(); 229 238 239 ++ mCurrentFrame; 240 230 241 RenderScene(); 231 242 232 243 query->EndQuery(); 233 244 glDisable(GL_STENCIL_TEST); 234 235 236 // reenable other state237 int wait = 0;238 while (0 && !query->ResultAvailable())239 wait ++;240 245 241 246 pixelCount = query->GetQueryResult(); 242 247 248 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 249 243 250 if (pixelCount > 0) 244 251 { 245 252 cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; 246 } 247 248 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 249 250 251 if (mSnapErrorFrames && (pixelCount > 0)) 252 { 253 glReadBuffer(GL_BACK); 254 //glReadBuffer(GL_FRONT); 255 256 char filename[256]; 257 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 258 QImage im = toImage(); 259 string str = mSnapPrefix + filename; 260 QString qstr(str.c_str()); 261 262 im.save(qstr, "PNG"); 263 if (0) { //0 && mFrame == 1543) { 264 int x,y; 265 int lastIndex = -1; 266 for (y=0; y < im.height(); y++) 267 for (x=0; x < im.width(); x++) { 268 QRgb p = im.pixel(x,y); 269 int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 270 if (qGreen(p) != 255 && index!=0) { 271 if (index != lastIndex) { 272 // Debug<<"ei="<<index<<" "; 273 lastIndex = index; 274 } 275 } 276 } 277 } 278 279 280 #if 0 281 mUseFalseColors = false; 282 283 glPushAttrib(GL_CURRENT_BIT); 284 glColor3f(0, 1, 0); 285 286 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 287 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 288 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 289 290 KdNode::NewMail2(); 291 Intersectable::NewMail(); 292 293 RenderPvs(pvs); 294 295 glFinish(); 296 297 mUseForcedColors = false; 298 299 im = toImage(); 300 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 301 str = mSnapPrefix + filename; 302 qstr = str.c_str(); 303 im.save(qstr, "PNG"); 304 305 glPopAttrib(); 306 #endif 253 254 if (mSnapErrorFrames) 255 { 256 glReadBuffer(GL_BACK); 257 //glReadBuffer(GL_FRONT); 258 259 ////////////// 260 //-- output error visualization 261 262 char filename[256]; 263 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 264 QImage im = toImage(); 265 string str = mSnapPrefix + filename; 266 QString qstr(str.c_str()); 267 268 im.save(qstr, "PNG"); 269 270 271 /////////// 272 //-- output computed pvs 273 274 mUseFalseColors = false; 275 276 glPushAttrib(GL_CURRENT_BIT); 277 glColor3f(0, 1, 0); 278 279 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 280 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 281 282 KdNode::NewMail2(); 283 Intersectable::NewMail(); 284 285 ++ mCurrentFrame; 286 // render pvs once 287 RenderPvs(pvs); 288 289 mUseForcedColors = false; 290 291 im = toImage(); 292 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 293 str = mSnapPrefix + filename; 294 qstr = str.c_str(); 295 im.save(qstr, "PNG"); 296 297 glPopAttrib(); 298 } 307 299 } 308 300 … … 497 489 498 490 499 void QtGlRendererWidget::PreparePvs 2(const ObjectPvs &pvs)491 void QtGlRendererWidget::PreparePvs(const ObjectPvs &pvs) 500 492 { 501 493 int indexBufferSize = 0; 502 494 503 // super hack: mal not working with multiple threads495 // hack: mail not working with multiple threads 504 496 KdNode::NewMail2(); 505 //Intersectable::NewMail();506 497 507 498 mPvsSize = pvs.GetSize(); … … 546 537 547 538 548 549 550 void QtGlRendererWidget::RenderPvs() 539 void QtGlRendererWidget::VisualizePvs() 551 540 { 552 541 if (mUseVbos) … … 600 589 #else 601 590 602 PreparePvs 2(viewcell->GetPvs());591 PreparePvs(viewcell->GetPvs()); 603 592 emit PvsUpdated(); 604 593 605 594 #endif 606 607 595 608 596 // Render PVS … … 662 650 663 651 // Render PVS 664 RenderPvs();652 VisualizePvs(); 665 653 666 654 glEnable(GL_STENCIL_TEST); … … 696 684 int pixelCount = query->GetQueryResult(); 697 685 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 686 698 687 if (0) cout << "error pixels=" << pixelCount << endl; 699 688 … … 826 815 } 827 816 828 void 829 QtGlRendererWidget::paintGL()817 818 void QtGlRendererWidget::paintGL() 830 819 { 831 820 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 843 832 { 844 833 glColor3f(0.6f, 0.6f, 0.6f); 845 RenderPvs();834 VisualizePvs(); 846 835 } 847 836 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2664 r2670 269 269 void keyPressEvent(QKeyEvent * e); 270 270 271 void RenderPvs();271 void VisualizePvs(); 272 272 273 273 float RenderErrors(); … … 544 544 } 545 545 546 void PreparePvs2(const ObjectPvs &pvs); 547 546 547 /** Prepare pvs for rendering. 548 */ 549 virtual void PreparePvs(const ObjectPvs &pvs); 550 /** Internal method rendering the pvs if it has been properly prepared. 551 */ 548 552 void _RenderPvs(); 549 553 /** Render pvs using false colors. 550 554 */ 551 555 void _RenderColoredPvs(); 552 553 // void _UpdatePvsIndices(KdNode *node, int &indexBufferSize);554 556 555 557 float ComputeRenderCost(ViewCell *vc); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2664 r2670 124 124 glEnable(GL_LIGHT1); 125 125 126 mRenderer-> RenderPvs();126 mRenderer->VisualizePvs(); 127 127 128 128 glDisable(GL_LIGHTING);
Note: See TracChangeset
for help on using the changeset viewer.