Changeset 2743 for GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Timestamp:
- 06/09/08 10:36:36 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2741 r2743 128 128 KdTree *tree): 129 129 QGLPixelBuffer(QSize(w, h), 130 QGLFormat(QGL::SampleBuffers) 131 /*,| 132 QGL::StencilBuffer | 130 QGLFormat(QGL::StencilBuffer | 133 131 QGL::DepthBuffer | 134 132 QGL::DoubleBuffer | 135 133 QGL::Rgba) 136 */),134 ), 137 135 GlRendererBuffer(sceneGraph, viewcells, tree) 138 136 { … … 172 170 173 171 174 void QtGlRendererBuffer::RenderTrianglePvs() 175 { 176 //Intersectable::NewMail; 177 178 ObjectContainer::const_iterator oit, oit_end = 179 mViewCellsManager->GetPreprocessor()->mTrianglePvs.end(); 180 181 //int sz = mViewCellsManager->GetPreprocessor()->mDummyBuffer.size(); 182 183 for (oit = mViewCellsManager->GetPreprocessor()->mTrianglePvs.begin(); 184 oit != oit_end; ++ oit) 172 void GlRenderer::RenderVisTriangles() 173 { 174 DisableDrawArrays(); 175 176 vector<VizStruct>::const_iterator oit, oit_end = GetPreprocessor()->visTriangles.end(); 177 int currentId = 0; 178 //glEnable(GL_POINT_SMOOTH); 179 for (oit = GetPreprocessor()->visTriangles.begin(); oit != oit_end; ++ oit) 180 { 181 VizStruct viz = *oit; 182 TriangleIntersectable *triObj = viz.originalTriangle; 183 184 glColor3f(RandomValue(0.3f, 1.0f), RandomValue(0.3f, 1.0f), RandomValue(0.3f, 1.0f)); 185 RenderIntersectable(triObj); 186 187 glColor3f(1, 0, 0); 188 glPointSize(1.0); 189 190 glBegin(GL_POINTS); 191 192 VertexContainer::const_iterator vit, vit_end = viz.enlargedTriangle.end(); 193 194 for (vit = viz.enlargedTriangle.begin(); vit != vit_end; ++ vit) 195 { 196 Vector3 v = *vit; 197 glVertex3f(v.x, v.y, v.z); 198 } 199 200 glEnd(); 201 } 202 } 203 204 205 #if 0 206 207 void GlRenderer::RenderTrianglePvs() 208 { 209 DisableDrawArrays(); 210 211 ObjectContainer::const_iterator oit, oit_end = GetPreprocessor()->mTrianglePvs.end(); 212 213 for (oit = GetPreprocessor()->mTrianglePvs.begin(); oit != oit_end; ++ oit) 185 214 { 186 215 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 187 188 //int dum = mViewCellsManager->GetPreprocessor()->mDummyBuffer[i]; 189 //glColor3f(0, (float)dum / 20.0f, 1); 216 glColor3f(RandomValue(0.3f, 1.0f), RandomValue(0.3f, 1.0f), RandomValue(0.3f, 1.0f)); 190 217 if (mUseFalseColors) SetupFalseColor(triObj->mId); 191 218 192 219 RenderIntersectable(triObj); 193 194 /*if (!triObj->Mailed()) 195 triObj->Mail(); 196 else 197 cerr << "böser fehler" << endl; 198 */ 199 } 200 } 201 202 220 } 221 } 222 223 #else 224 225 void GlRenderer::RenderTrianglePvs() 226 { 227 if (GetPreprocessor()->mTrianglePvs.empty()) 228 return; 229 230 EnableDrawArrays(); 231 232 if (mUseVbos) 233 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 234 235 unsigned int bufferSize = GetPreprocessor()->mTrianglePvs.size() * 3; 236 unsigned int *indices = new unsigned int[bufferSize]; 237 238 for (unsigned int i = 0; i < GetPreprocessor()->mTrianglePvs.size(); ++ i) 239 { 240 const int id = GetPreprocessor()->mTrianglePvs[i]->GetId() * 3; 241 242 indices[i * 3 + 0] = id + 0; 243 indices[i * 3 + 1] = id + 1; 244 indices[i * 3 + 2] = id + 2; 245 } 246 247 size_t offset = mObjects.size() * 3; 248 char *arrayPtr = mUseVbos ? NULL : (char *)mData; 249 250 glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr); 251 glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 252 253 glDrawElements(GL_TRIANGLES, bufferSize, GL_UNSIGNED_INT, indices); 254 255 DisableDrawArrays(); 256 delete [] indices; 257 } 258 259 #endif 203 260 204 261 // reimplemented here so that we can snap the error windows … … 247 304 return 0.0f; 248 305 306 //mTopView = false; 307 SetupProjection(GetWidth(), GetHeight()); 249 308 SetupCamera(); 250 309 … … 257 316 GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 258 317 GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 259 GLfloat mat_specular[] = {0. 5f, 0.5f, 0.5f, 1.0f};260 GLfloat mat_shininess[] = { 1.0f};318 GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f}; 319 GLfloat mat_shininess[] = {8.0f}; 261 320 262 321 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); … … 266 325 267 326 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 268 //GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0};269 327 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 270 GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0};328 GLfloat light_specular[] = {0.6, 0.6, 0.6, 1.0}; 271 329 272 330 glEnable(GL_LIGHTING); … … 293 351 glDisable(GL_ALPHA_TEST); 294 352 353 glClearDepth(1.0f); 354 295 355 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 296 356 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); … … 302 362 glDepthMask(GL_TRUE); 303 363 glEnable(GL_DEPTH_TEST); 304 364 365 if (mDetectEmptyViewSpace) 366 glEnable(GL_CULL_FACE); 367 else 368 glDisable(GL_CULL_FACE); 369 305 370 glFrontFace(GL_CCW); 306 371 glCullFace(GL_BACK); … … 308 373 glStencilFunc(GL_EQUAL, 0x0, 0x1); 309 374 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 375 glDisable(GL_STENCIL_TEST); 310 376 311 377 KdNode::NewMail2(); 312 //Intersectable::NewMail(); 313 378 379 DisableDrawArrays(); 380 314 381 //mUseFalseColors = true; 315 382 // hack for gvs … … 322 389 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 323 390 324 glEnable(GL_STENCIL_TEST);391 //glEnable(GL_STENCIL_TEST); 325 392 326 393 // errors in red … … 332 399 333 400 KdNode::NewMail2(); 334 //Intersectable::NewMail(); 335 401 336 402 query->BeginQuery(); 337 403 … … 340 406 341 407 RenderScene(); 342 343 408 glFlush(); 344 409 345 410 query->EndQuery(); 411 346 412 glDisable(GL_STENCIL_TEST); 347 413 … … 396 462 // render pvs once 397 463 //RenderPvs(pvs); 398 EnableDrawArrays();399 464 //EnableDrawArrays(); 465 //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 400 466 // prepare pvs for rendering 401 PreparePvs(pvs); 402 _RenderColoredPvs(pvs); 467 //PreparePvs(pvs); 468 //_RenderColoredPvs(pvs); 469 //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 403 470 // hack for gvs visualization 404 471 //RenderTrianglePvs(); 472 RenderVisTriangles(); 405 473 406 474 glFlush(); … … 591 659 #if 0 592 660 for (dit = mDynamicPvsObjects.begin(); dit != dit_end; ++ dit) 593 {594 661 _RenderDynamicObject(*dit); 595 }596 662 #endif 597 663 //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 598 664 599 665 // show placed dynamic objects as wireframe 600 Preprocessor *p = mViewCellsManager->GetPreprocessor();666 Preprocessor *p = GetPreprocessor(); 601 667 dit_end = p->mDynamicObjects.end(); 602 668 … … 722 788 if (mRenderFilter) 723 789 { 790 bool oldWireFrame = mWireFrame; 724 791 mWireFrame = true; 725 792 RenderIntersectable(viewcell); 726 793 727 mWireFrame = false;794 mWireFrame = oldWireFrame; 728 795 } 729 796 } … … 1013 1080 { 1014 1081 glColor3f(0.6f, 0.6f, 0.6f); 1082 1083 if (mWireFrame) 1084 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 1085 else 1086 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1087 1015 1088 VisualizePvs(); 1089 1090 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1016 1091 } 1017 1092 … … 1068 1143 1069 1144 void 1070 QtGlRendererWidget::keyPressEvent ( QKeyEvent * e)1145 QtGlRendererWidget::keyPressEvent(QKeyEvent *e) 1071 1146 { 1072 1147 switch (e->key()) … … 1077 1152 break; 1078 1153 case Qt::Key_R: 1079 mUseRandomColorPerPvsObject = !mUseRandomColorPerPvsObject;; 1154 mUseRandomColorPerPvsObject = !mUseRandomColorPerPvsObject; 1155 updateGL(); 1156 break; 1157 case Qt::Key_W: 1158 mWireFrame = !mWireFrame; 1080 1159 updateGL(); 1081 1160 break; … … 1094 1173 updateGL(); 1095 1174 break; 1096 case Qt::Key_S: { 1097 // set view poitn and direction 1098 QString text; 1099 bool ok; 1100 text.sprintf("%f %f %f", mViewPoint.x, mViewPoint.y, mViewPoint.z); 1101 text = QInputDialog::getText(this, 1102 "Enter a view point", 1103 "", 1104 QLineEdit::Normal, 1105 text, 1106 &ok); 1107 if (!ok) 1108 break; 1109 1110 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) { 1111 text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z); 1175 case Qt::Key_S: 1176 { 1177 // set view poitn and direction 1178 QString text; 1179 bool ok; 1180 text.sprintf("%f %f %f", mViewPoint.x, mViewPoint.y, mViewPoint.z); 1112 1181 text = QInputDialog::getText(this, 1113 "Enter a direction",1182 "Enter a view point", 1114 1183 "", 1115 1184 QLineEdit::Normal, 1116 1185 text, 1117 1186 &ok); 1187 1118 1188 if (!ok) 1119 1189 break; 1120 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewDirection.x, 1121 &mViewDirection.y, &mViewDirection.z) == 3) { 1122 updateGL(); 1190 1191 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) 1192 { 1193 text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z); 1194 text = QInputDialog::getText(this, 1195 "Enter a direction", 1196 "", 1197 QLineEdit::Normal, 1198 text, 1199 &ok); 1200 if (!ok) 1201 break; 1202 if (sscanf_s(text.toAscii(), "%f %f %f", &mViewDirection.x, 1203 &mViewDirection.y, &mViewDirection.z) == 3) { 1204 updateGL(); 1205 } 1206 break; 1123 1207 } 1124 break; 1125 } 1126 } 1208 1209 } 1127 1210 default: 1128 1211 cerr << "unknown key" << endl; … … 1156 1239 //mRenderVisibilityEstimates = true; 1157 1240 1241 mWireFrame = false; 1158 1242 mComputeGVS = false; 1159 1243 mUseRandomColorPerPvsObject = false; … … 1312 1396 { 1313 1397 cerr<<"stop computation called!\n"<<endl; 1314 mViewCellsManager->GetPreprocessor()->mStopComputation = true;1398 GetPreprocessor()->mStopComputation = true; 1315 1399 } 1316 1400 … … 1787 1871 } 1788 1872 1789 //mWireFrame = true;1790 1873 1791 // normalrendering1874 // default rendering 1792 1875 //if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison) 1793 1876 if (mUseStandardColors) … … 1835 1918 1836 1919 mUseFalseColors = false; 1837 mWireFrame = false;1920 //mWireFrame = false; 1838 1921 1839 1922 glPopAttrib(); … … 2711 2794 int QtGlRendererWidget::FindDynamicObject(float x, float y) 2712 2795 { 2713 2714 2796 if (GetPreprocessor()->mDynamicObjects.empty()) 2715 2797 return -1; -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2736 r2743 76 76 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 77 77 78 /** quick hack in order to be able to render gvs based triangle pvs.79 */80 void RenderTrianglePvs();81 78 82 79 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2709 r2743 28 28 { 29 29 scale = 1.0f; 30 mWire frame = false;30 mWireFrame = false; 31 31 mModelMatrix = IdentityMatrix(); 32 32 … … 235 235 236 236 case Qt::Key_W: 237 mWire frame = !mWireframe;237 mWireFrame = !mWireFrame; 238 238 updateGL(); 239 239 break; -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h
r2657 r2743 45 45 void keyPressEvent(QKeyEvent * e); 46 46 47 bool mWireframe; 47 48 /////////////// 49 50 bool mWireFrame; 48 51 49 52 int timerId;
Note: See TracChangeset
for help on using the changeset viewer.