- Timestamp:
- 12/10/07 18:43:33 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r2455 r2562 1033 1033 QueuedRenderableCollection::OM_SORT_DESCENDING, true); 1034 1034 } 1035 1036 1037 }// for each priority 1035 } // for each priority 1038 1036 } 1039 1037 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2560 r2562 309 309 SetupMaterial(mesh->mMaterial); 310 310 311 for (i =0; i < mesh->mFaces.size(); i++)311 for (i = 0; i < mesh->mFaces.size(); i++) 312 312 { 313 313 if (mWireFrame) … … 337 337 glFrontFace(GL_CCW); 338 338 glCullFace(GL_BACK); 339 glEnable(GL_CULL_FACE); 339 340 340 glShadeModel(GL_FLAT); 341 glDepthFunc( 341 glDepthFunc(GL_LESS ); 342 342 glEnable(GL_DEPTH_TEST); 343 343 glEnable(GL_CULL_FACE); … … 345 345 InitExtensions(); 346 346 347 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE 348 349 glEnable( GL_NORMALIZE);347 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 348 349 glEnable(GL_NORMALIZE); 350 350 351 351 glClearColor(0.0f, 0.0f, 1.0f, 1.0f); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2560 r2562 50 50 } 51 51 52 53 inline static bool nearerThan(ViewCell *vc1, ViewCell *vc2) 54 { 55 return vc1->GetDistance() > vc2->GetDistance(); 56 } 57 58 52 59 #if USE_CG 53 60 static void handleCgError() … … 322 329 glMatrixMode(GL_PROJECTION); 323 330 glLoadIdentity(); 324 gluPerspective(angle, ww/(float)hh, 0.1, 2.0 *Magnitude(mSceneGraph->GetBox().Diagonal()));331 gluPerspective(angle, ww/(float)hh, 0.1, 2.0 * Magnitude(mSceneGraph->GetBox().Diagonal())); 325 332 glMatrixMode(GL_MODELVIEW); 326 333 } else { … … 330 337 glMatrixMode(GL_PROJECTION); 331 338 glLoadIdentity(); 332 gluPerspective(50.0, ww /(float)hh, 0.1, 20.0*Magnitude(mSceneGraph->GetBox().Diagonal()));339 gluPerspective(50.0, ww / (float)hh, 0.1, 20.0 * Magnitude(mSceneGraph->GetBox().Diagonal())); 333 340 glMatrixMode(GL_MODELVIEW); 334 341 } … … 830 837 mRenderFilter = true; 831 838 mRenderVisibilityEstimates = false; 839 840 mHideByCost = false; 841 832 842 mTransferFunction = 0.2f; 833 843 mIndexBufferSize = 0; … … 835 845 //mCurrentFrame = 0; 836 846 837 const int delay = 500; // half a second847 const int delay = 250; // in milliseconds 838 848 timerId = startTimer(delay); 839 849 … … 873 883 connect(mControlWidget, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetVisibilityFilterSize(int))); 874 884 connect(mControlWidget, SIGNAL(SetSpatialFilterSize(int)), this, SLOT(SetSpatialFilterSize(int))); 885 connect(mControlWidget, SIGNAL(SetHidingCost(int)), this, SLOT(SetHidingCost(int))); 875 886 876 887 connect(mControlWidget, SIGNAL(SetShowViewCells(bool)), this, SLOT(SetShowViewCells(bool))); … … 879 890 connect(mControlWidget, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool))); 880 891 connect(mControlWidget, SIGNAL(SetCutViewCells(bool)), this, SLOT(SetCutViewCells(bool))); 892 connect(mControlWidget, SIGNAL(SetHideByCost(bool)), this, SLOT(SetHideByCost(bool))); 881 893 connect(mControlWidget, SIGNAL(SetCutScene(bool)), this, SLOT(SetCutScene(bool))); 882 894 connect(mControlWidget, SIGNAL(SetRenderErrors(bool)), this, SLOT(SetRenderErrors(bool))); … … 1119 1131 // shift it along y according to number, which is percentage of the bounding 1120 1132 // box position 1121 if (mViewCellsManager) { 1133 if (mViewCellsManager) 1134 { 1122 1135 AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); 1123 1136 Vector3 p = box.Min() + (number/1000.0f)*box.Max(); 1124 1137 mSceneCutPlane.mNormal = Vector3(0,-1,0); 1125 1138 mSceneCutPlane.mD = -DotProd(mSceneCutPlane.mNormal, p); 1139 1126 1140 updateGL(); 1127 1141 } 1128 1142 } 1143 1144 void 1145 QtGlRendererWidget::SetHidingCost(int number) 1146 { 1147 mHidingCost = (float)number / 1000.0f; 1148 cout << "hiding cost " << mHidingCost << endl; 1149 } 1150 1129 1151 1130 1152 void … … 1144 1166 glEnable(GL_CULL_FACE); 1145 1167 glCullFace(GL_FRONT); 1146 1147 glDisable(GL_CULL_FACE); 1168 //glDisable(GL_CULL_FACE); 1169 1148 1170 double eq[4]; 1149 1171 eq[0] = mSceneCutPlane.mNormal.x; … … 1159 1181 1160 1182 int i; 1183 1161 1184 ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 1162 1185 int maxPvs = -1; 1163 int maxPiercingRays = 0;1186 int maxPiercingRays = 1; // for savety 1164 1187 1165 1188 for (i = 0; i < viewcells.size(); ++ i) … … 1171 1194 if (p > maxPvs) 1172 1195 maxPvs = p; 1196 1173 1197 const int piercingRays = vc->GetNumPiercingRays(); 1198 1174 1199 if (piercingRays > maxPiercingRays) 1175 1200 maxPiercingRays = piercingRays; 1176 1201 } 1177 1202 1178 1179 for (i = 0; i < viewcells.size(); ++ i) 1203 cout << "here22 " << mHideByCost << " " << mHidingCost << endl; 1204 1205 if (!mShowPvsSizes && !mShowPiercingRays) 1180 1206 { 1181 ViewCell *vc = viewcells[i]; 1182 // Mesh *m = vc->GetMesh(); 1207 for (i = 0; i < viewcells.size(); ++ i) 1208 { 1209 ViewCell *vc = viewcells[i]; 1210 RgbColor c; 1211 1212 if (!mShowPvsSizes && !mShowPiercingRays) 1213 { 1214 mWireFrame = true; 1215 c = vc->GetColor(); 1216 } 1217 1218 glColor3f(c.r, c.g, c.b); 1219 1220 if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays)) 1221 { 1222 RenderViewCell(vc); 1223 } 1224 } 1225 } 1226 else 1227 { 1228 //glDisable(GL_CULL_FACE); 1229 //glEnable(GL_CULL_FACE); 1230 //glFrontFace(GL_CCW); 1231 //glCullFace(GL_BACK); 1232 glEnable(GL_DEPTH_TEST); 1233 glDisable(GL_BLEND); 1234 1235 //glDisable(GL_DEPTH_TEST); 1236 //glEnable(GL_BLEND); 1237 1238 //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1239 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 1240 1241 for (i = 0; i < viewcells.size(); ++ i) 1242 { 1243 ViewCell *vc = viewcells[i]; 1244 const float dist = SqrDistance(mViewPoint, vc->GetBox().Center()); 1245 1246 vc->SetDistance(dist); 1247 } 1248 1249 sort(viewcells.begin(), viewcells.end(), nearerThan); 1183 1250 1184 1251 RgbColor c; 1185 1252 1186 if (!mShowPvsSizes && !mShowPiercingRays) 1253 for (i = 0; i < viewcells.size(); ++ i) 1187 1254 { 1188 mWireFrame = true; 1189 c = vc->GetColor(); 1190 } 1191 else if (mShowPiercingRays) 1192 { 1193 // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 1194 const float importance = 5.0f * mTransferFunction * 1195 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 1196 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1197 c = RainbowColorMapping(importance); 1255 ViewCell *vc = viewcells[i]; 1256 1257 //cout << "dist: " << vc->GetDistance() << " "; 1258 1259 if (mShowPiercingRays) 1260 { 1261 // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 1262 const float importance = 5.0f * mTransferFunction * 1263 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 1264 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1265 c = RainbowColorMapping(importance); 1266 } 1267 else 1268 { 1269 // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 1270 const float importance = 5.0f * mTransferFunction * 1271 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 1272 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1273 c = RainbowColorMapping(importance); 1274 } 1275 1276 const float alpha = 0.2f; 1277 glColor4f(c.r, c.g, c.b, alpha); 1278 1279 if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays)) 1280 { 1281 RenderViewCell(vc); 1282 } 1198 1283 } 1199 else 1200 { 1201 // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 1202 const float importance = 5.0f * mTransferFunction * 1203 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 1204 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1205 c = RainbowColorMapping(importance); 1206 } 1207 1208 glColor3f(c.r, c.g, c.b); 1209 1210 RenderViewCell(vc); 1284 1285 glEnable(GL_DEPTH_TEST); 1211 1286 } 1212 1287 … … 1474 1549 connect(button, SIGNAL(clicked(void)), SLOT(FocusNextPvsErrorFrame(void))); 1475 1550 } 1551 1552 // the render cost visualization 1553 slider = new QSlider(Qt::Horizontal, vbox); 1554 vbox->layout()->addWidget(slider); 1555 slider->show(); 1556 slider->setRange(0, 1000); 1557 slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 1558 slider->setValue(100); 1559 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetHidingCost(int))); 1560 1561 cb = new QCheckBox("Hide view cells by render cost ", vbox); 1562 vbox->layout()->addWidget(cb); 1563 cb->setChecked(false); 1564 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetHideByCost(bool))); 1476 1565 1477 1566 setWindowTitle("Preprocessor Control Widget"); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2560 r2562 99 99 void SetSceneCut(int); 100 100 void SetTopDistance(int); 101 void SetHidingCost(int); 101 102 void SetVisibilityFilterSize(int); 102 103 void SetSpatialFilterSize(int); … … 116 117 void SetCutViewCells(bool); 117 118 void SetCutScene(bool); 119 120 void SetHideByCost(bool); 118 121 }; 119 122 … … 131 134 bool mCutViewCells; 132 135 bool mCutScene; 136 bool mHideByCost; 133 137 bool mRenderErrors; 134 138 bool mRenderFilter; … … 144 148 145 149 Plane3 mSceneCutPlane; 150 float mHidingCost; 151 146 152 float mTopDistance; 147 153 … … 277 283 SetTopDistance(int dist); 278 284 285 void 286 SetHidingCost(int dist); 287 279 288 void SetShowViewCells(bool b) { 280 289 mRenderViewCells = b; … … 308 317 309 318 void SetCutViewCells(bool b) { 319 std::cout << "here64" << std::endl; 320 310 321 mCutViewCells = b; 311 322 updateGL(); … … 313 324 void SetCutScene(bool b) { 314 325 mCutScene = b; 326 updateGL(); 327 } 328 329 void SetHideByCost(bool b) { 330 std::cout << "here45" << std::endl; 331 mHideByCost = b; 315 332 updateGL(); 316 333 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2560 r2562 29 29 mWireframe = false; 30 30 trackball(manipulatorLastQuat, 0.0f, 0.0f, 0.0f, 0.0f); 31 connect(renderer, SIGNAL(PvsUpdated()), this, SLOT(updateGL())); 31 //connect(renderer, SIGNAL(PvsUpdated()), this, SLOT(updateGL())); 32 //connect(renderer, SIGNAL(cutupdated), this, SLOT(updateGL())); 33 34 const int delay = 250; // in milliseconds 35 timerId = startTimer(delay); 32 36 } 33 37 … … 47 51 QtGlViewer::RenderScene() 48 52 { 49 mRenderer->mFrame++;53 ++ mRenderer->mFrame; 50 54 51 // render into the right side of the window buffer 52 if (mRenderer->mRenderViewCells) 53 mRenderer->RenderViewCells(); 54 55 glDisable(GL_DEPTH_TEST); 56 55 57 glColor3f(0.8f, 0.8f, 0.8f); 56 58 mRenderer->RenderPvs(); … … 68 70 // } 69 71 // } 70 72 71 73 if (mRenderer->mShowRenderCost) 72 74 mRenderer->RenderRenderCost(); 75 76 // render into the right side of the window buffer 77 if (mRenderer->mRenderViewCells) 78 mRenderer->RenderViewCells(); 73 79 74 80 glColor3f(1.0f, 1.0f, 1.0f); … … 190 196 } 191 197 192 } 193 198 void QtGlViewer::timerEvent(QTimerEvent *event) 199 { 200 update(); 201 } 202 203 204 } 205 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h
r2017 r2562 5 5 6 6 7 namespace GtpVisibilityPreprocessor { 7 namespace GtpVisibilityPreprocessor 8 { 8 9 9 10 class QtGlRendererWidget; 10 11 12 11 13 class QtGlViewer : public QGLWidget 12 14 { 13 14 //Q_OBJECT 15 //Q_OBJECT 15 16 16 17 friend class QtGlRendererWidget; … … 19 20 public: 20 21 QtGlRendererWidget *mRenderer; 21 22 22 23 QtGlViewer(QWidget *parent, 23 QtGlRendererWidget *renderer); 24 25 virtual ~QtGlViewer(){}; 26 27 QSize minimumSizeHint() const; 28 QSize sizeHint() const; 29 30 // This method has to be rendefined by all renderer implementations 31 virtual void RenderScene(); 32 24 QtGlRendererWidget *renderer); 25 26 virtual ~QtGlViewer(){}; 27 28 QSize minimumSizeHint() const; 29 QSize sizeHint() const; 30 31 // This method has to be rendefined by all renderer implementations 32 virtual void RenderScene(); 33 34 void timerEvent(QTimerEvent *event); 35 33 36 protected: 34 35 36 37 38 37 void initializeGL(); 38 void paintGL(); 39 void resizeGL(int width, int height); 40 void mousePressEvent(QMouseEvent *event); 41 void mouseMoveEvent(QMouseEvent *event); 39 42 40 43 void keyPressEvent ( QKeyEvent * e ); 41 42 bool mWireframe; 44 45 bool mWireframe; 46 47 int timerId; 43 48 44 49 private: 45 50 46 51 float manipulatorLastQuat[4]; 47 48 52 float scale; 53 QPoint lastPos; 49 54 50 55 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r2560 r2562 298 298 } 299 299 300 int GetNumPiercingRays() 300 int GetNumPiercingRays() const 301 301 { 302 302 return mNumPiercingRays; 303 303 } 304 304 305 float GetDistance() const 306 { 307 return mDistance; 308 } 309 310 void SetDistance(float dist) 311 { 312 mDistance = dist; 313 } 305 314 306 315 protected: … … 333 342 /// number of rays piercing this view cell 334 343 int mNumPiercingRays; 344 345 /// distance from the current view point 346 float mDistance; 335 347 }; 336 348
Note: See TracChangeset
for help on using the changeset viewer.