- Timestamp:
- 12/10/07 18:43:33 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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");
Note: See TracChangeset
for help on using the changeset viewer.