[2576] | 1 | #include "glInterface.h"
|
---|
| 2 | #include "QtGlRenderer.h"
|
---|
[1252] | 3 | #include "Mesh.h"
|
---|
| 4 | #include "OcclusionQuery.h"
|
---|
| 5 | #include "ViewCellsManager.h"
|
---|
| 6 | #include "SceneGraph.h"
|
---|
| 7 | #include "Pvs.h"
|
---|
| 8 | #include "Viewcell.h"
|
---|
| 9 | #include "Beam.h"
|
---|
| 10 | #include "KdTree.h"
|
---|
| 11 | #include "Environment.h"
|
---|
[1942] | 12 | #include "RssPreprocessor.h"
|
---|
| 13 | #include "RssTree.h"
|
---|
| 14 | #include "Trackball.h"
|
---|
| 15 | #include "QtPreprocessorThread.h"
|
---|
[2148] | 16 | #include "Material.h"
|
---|
[2538] | 17 | #include "IntersectableWrapper.h"
|
---|
[2580] | 18 | #include "LogWriter.h"
|
---|
[2636] | 19 | #include "RayCaster.h"
|
---|
[1942] | 20 |
|
---|
[2538] | 21 |
|
---|
[1942] | 22 | #define USE_CG 1
|
---|
| 23 |
|
---|
[2620] | 24 | #define TEST_PVS_RENDERING 0
|
---|
[1942] | 25 |
|
---|
| 26 | #if USE_CG
|
---|
[1252] | 27 | #include <Cg/cg.h>
|
---|
| 28 | #include <Cg/cgGL.h>
|
---|
[1942] | 29 | #endif
|
---|
[1252] | 30 |
|
---|
| 31 | #include <QVBoxLayout>
|
---|
| 32 |
|
---|
[2669] | 33 | namespace GtpVisibilityPreprocessor
|
---|
| 34 | {
|
---|
[1252] | 35 |
|
---|
[1942] | 36 |
|
---|
[1252] | 37 | class ViewCellsManager;
|
---|
| 38 |
|
---|
| 39 | static CGcontext sCgContext = NULL;
|
---|
| 40 | static CGprogram sCgFragmentProgram = NULL;
|
---|
| 41 | static CGprofile sCgFragmentProfile;
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | QtGlRendererWidget *rendererWidget = NULL;
|
---|
| 45 | QtGlDebuggerWidget *debuggerWidget = NULL;
|
---|
| 46 |
|
---|
[2580] | 47 | const static int SAMPLES_INCR = 2000000;
|
---|
[1252] | 48 |
|
---|
[2604] | 49 |
|
---|
| 50 |
|
---|
[1252] | 51 | static inline bool ilt(Intersectable *obj1, Intersectable *obj2)
|
---|
| 52 | {
|
---|
| 53 | return obj1->mId < obj2->mId;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[2562] | 56 |
|
---|
| 57 | inline static bool nearerThan(ViewCell *vc1, ViewCell *vc2)
|
---|
| 58 | {
|
---|
| 59 | return vc1->GetDistance() > vc2->GetDistance();
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 |
|
---|
[1942] | 63 | #if USE_CG
|
---|
[1252] | 64 | static void handleCgError()
|
---|
| 65 | {
|
---|
| 66 | Debug << "Cg error: " << cgGetErrorString(cgGetError()) << endl;
|
---|
| 67 | exit(1);
|
---|
| 68 | }
|
---|
[1942] | 69 | #endif
|
---|
[1252] | 70 |
|
---|
| 71 | void
|
---|
[1942] | 72 | QtGlRendererBuffer::MakeCurrent()
|
---|
[1252] | 73 | {
|
---|
[2664] | 74 | makeCurrent();
|
---|
[1252] | 75 | }
|
---|
| 76 |
|
---|
| 77 | void
|
---|
[1942] | 78 | QtGlRendererBuffer::DoneCurrent()
|
---|
[1252] | 79 | {
|
---|
[2664] | 80 | doneCurrent();
|
---|
[1252] | 81 | }
|
---|
| 82 |
|
---|
| 83 |
|
---|
[2664] | 84 | QtGlRendererBuffer::QtGlRendererBuffer(int w, int h,
|
---|
[1252] | 85 | SceneGraph *sceneGraph,
|
---|
| 86 | ViewCellsManager *viewcells,
|
---|
| 87 | KdTree *tree):
|
---|
[2669] | 88 | QGLPixelBuffer(QSize(w, h),
|
---|
| 89 | QGLFormat(QGL::StencilBuffer |
|
---|
| 90 | QGL::DepthBuffer |
|
---|
| 91 | QGL::DoubleBuffer |
|
---|
| 92 | QGL::Rgba
|
---|
| 93 | )),
|
---|
[2664] | 94 | GlRendererBuffer(sceneGraph, viewcells, tree)
|
---|
[1942] | 95 | {
|
---|
[2664] | 96 | mUseVbos = true;
|
---|
| 97 | //mUseVbos = false;
|
---|
| 98 |
|
---|
| 99 | MakeCurrent();
|
---|
| 100 | glViewport(0, 0, w, h);
|
---|
| 101 | glMatrixMode(GL_PROJECTION);
|
---|
| 102 | glLoadIdentity();
|
---|
| 103 | glOrtho(-1, 1, -1, 1, -99, 99);
|
---|
| 104 | //glTranslatef(-0.5f, -0.5f, 0.0f);
|
---|
| 105 | glMatrixMode(GL_MODELVIEW);
|
---|
| 106 | glLoadIdentity();
|
---|
| 107 |
|
---|
| 108 | InitGL();
|
---|
| 109 | DoneCurrent();
|
---|
[1252] | 110 | }
|
---|
| 111 |
|
---|
[2664] | 112 |
|
---|
| 113 | void QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs)
|
---|
[2620] | 114 | {
|
---|
[2671] | 115 | EnableDrawArrays();
|
---|
[2663] | 116 | PreparePvs(pvs);
|
---|
[1942] | 117 |
|
---|
[2671] | 118 | if (mUseVbos)
|
---|
| 119 | glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
|
---|
| 120 |
|
---|
[2663] | 121 | int offset = (int)mObjects.size() * 3;
|
---|
| 122 | char *arrayPtr = mUseVbos ? NULL : (char *)mData;
|
---|
[2620] | 123 |
|
---|
[2663] | 124 | glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr);
|
---|
| 125 | glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3));
|
---|
| 126 | glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices);
|
---|
[2620] | 127 | }
|
---|
| 128 |
|
---|
[2670] | 129 |
|
---|
[2002] | 130 | // reimplemented here so that we can snap the error windows
|
---|
[2664] | 131 | float QtGlRendererBuffer::GetPixelError(int &pvsSize)
|
---|
[1252] | 132 | {
|
---|
[2662] | 133 | MakeCurrent();
|
---|
[2671] | 134 |
|
---|
[2670] | 135 | if (0)
|
---|
| 136 | {
|
---|
| 137 | cout << "stencil: " << format().stencil() << endl;
|
---|
| 138 | cout << "depth: " << format().depth() << endl;
|
---|
| 139 | cout << "rgba: " << format().rgba() << endl;
|
---|
| 140 | cout << "double: " << format().doubleBuffer() << endl;
|
---|
| 141 | }
|
---|
[2669] | 142 |
|
---|
[2670] | 143 | ++ mCurrentFrame;
|
---|
| 144 |
|
---|
[2662] | 145 | float pErrorPixels = -1.0f;
|
---|
[2008] | 146 |
|
---|
[2543] | 147 | mUseFalseColors = false;
|
---|
[2663] | 148 | unsigned int pixelCount = 0;
|
---|
[2008] | 149 |
|
---|
[2669] | 150 |
|
---|
[2543] | 151 | ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint);
|
---|
[2648] | 152 |
|
---|
[2543] | 153 | if (viewcell == NULL)
|
---|
[2664] | 154 | return -1.0f;
|
---|
[2050] | 155 |
|
---|
[2627] | 156 | bool evaluateFilter;
|
---|
| 157 | Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluateFilter", evaluateFilter);
|
---|
| 158 |
|
---|
[2670] | 159 | ObjectPvs pvs;
|
---|
| 160 |
|
---|
[2627] | 161 | if (!evaluateFilter)
|
---|
[2662] | 162 | pvs = viewcell->GetPvs();
|
---|
[2663] | 163 | else
|
---|
| 164 | mViewCellsManager->ApplyFilter2(viewcell, false, mViewCellsManager->GetFilterWidth(), pvs);
|
---|
[2635] | 165 |
|
---|
[2669] | 166 | pvsSize = pvs.GetSize();
|
---|
| 167 |
|
---|
| 168 | if (pvsSize == 0)
|
---|
| 169 | return 0.0f;
|
---|
[2002] | 170 |
|
---|
[2613] | 171 | mUseForcedColors = true;
|
---|
| 172 |
|
---|
[2543] | 173 | SetupCamera();
|
---|
[2664] | 174 |
|
---|
[2669] | 175 | // use shading
|
---|
| 176 | if (mSnapErrorFrames)
|
---|
| 177 | {
|
---|
| 178 | GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0};
|
---|
| 179 | GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0};
|
---|
| 180 | GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0};
|
---|
| 181 |
|
---|
[2670] | 182 | //GLfloat light_position[] = {278.0f, 548.8f,279.0f, 1.0f};
|
---|
| 183 | GLfloat light_position[] = {0.f,0.f,0.f, 1.0f};
|
---|
[2669] | 184 |
|
---|
| 185 | glEnable(GL_LIGHT0);
|
---|
| 186 |
|
---|
| 187 | // a light
|
---|
| 188 | glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
---|
| 189 | glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
---|
| 190 | glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
---|
| 191 |
|
---|
| 192 | glEnable(GL_LIGHTING);
|
---|
| 193 | glLightfv (GL_LIGHT0, GL_POSITION, light_position);
|
---|
| 194 |
|
---|
| 195 | glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
---|
| 196 | glEnable(GL_COLOR_MATERIAL);
|
---|
| 197 |
|
---|
| 198 | glShadeModel(GL_SMOOTH);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | glDisable(GL_ALPHA_TEST);
|
---|
| 202 |
|
---|
| 203 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
---|
[2543] | 204 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
---|
[2669] | 205 |
|
---|
| 206 | //glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE);
|
---|
| 207 | glColor3f(0, 1, 0);
|
---|
| 208 |
|
---|
| 209 | glDepthFunc(GL_LESS);
|
---|
| 210 | glDepthMask(GL_TRUE);
|
---|
[2663] | 211 | glEnable(GL_DEPTH_TEST);
|
---|
[2050] | 212 |
|
---|
[2669] | 213 | glStencilFunc(GL_EQUAL, 0x0, 0x1);
|
---|
| 214 | glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
---|
[2543] | 215 |
|
---|
[2670] | 216 | KdNode::NewMail2();
|
---|
| 217 | Intersectable::NewMail();
|
---|
| 218 |
|
---|
[2669] | 219 | // render pvs once
|
---|
[2620] | 220 | RenderPvs(pvs);
|
---|
[2662] | 221 |
|
---|
[2671] | 222 | //cout << "rendered nodes: " << mRenderedNodes << endl;
|
---|
| 223 |
|
---|
[2564] | 224 | //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
|
---|
[2669] | 225 | //glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
---|
[1942] | 226 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
---|
[2667] | 227 |
|
---|
[2543] | 228 | glEnable(GL_STENCIL_TEST);
|
---|
[2671] | 229 | glColor3f(1, 0, 0);
|
---|
[2543] | 230 |
|
---|
[2662] | 231 |
|
---|
[2669] | 232 | // render scene, record differences
|
---|
| 233 | OcclusionQuery *query = mOcclusionQueries[0];
|
---|
[2543] | 234 |
|
---|
[2669] | 235 | KdNode::NewMail2();
|
---|
[2613] | 236 | Intersectable::NewMail();
|
---|
| 237 |
|
---|
[2543] | 238 | query->BeginQuery();
|
---|
| 239 |
|
---|
[2670] | 240 | ++ mCurrentFrame;
|
---|
| 241 |
|
---|
[2543] | 242 | RenderScene();
|
---|
[2662] | 243 |
|
---|
[2543] | 244 | query->EndQuery();
|
---|
| 245 | glDisable(GL_STENCIL_TEST);
|
---|
[2664] | 246 |
|
---|
[2543] | 247 | pixelCount = query->GetQueryResult();
|
---|
| 248 |
|
---|
[2670] | 249 | pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight());
|
---|
| 250 |
|
---|
[2664] | 251 | if (pixelCount > 0)
|
---|
[2662] | 252 | {
|
---|
[2671] | 253 | cout << "frame " << mFrame << " vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl;
|
---|
[2670] | 254 |
|
---|
| 255 | if (mSnapErrorFrames)
|
---|
| 256 | {
|
---|
| 257 | glReadBuffer(GL_BACK);
|
---|
| 258 | //glReadBuffer(GL_FRONT);
|
---|
[2543] | 259 |
|
---|
[2671] | 260 |
|
---|
[2670] | 261 | //////////////
|
---|
| 262 | //-- output error visualization
|
---|
[2613] | 263 |
|
---|
[2670] | 264 | char filename[256];
|
---|
| 265 | sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels);
|
---|
| 266 | QImage im = toImage();
|
---|
| 267 | string str = mSnapPrefix + filename;
|
---|
| 268 | QString qstr(str.c_str());
|
---|
[2662] | 269 |
|
---|
[2670] | 270 | im.save(qstr, "PNG");
|
---|
[2662] | 271 |
|
---|
| 272 |
|
---|
[2670] | 273 | ///////////
|
---|
| 274 | //-- output computed pvs
|
---|
[2662] | 275 |
|
---|
[2670] | 276 | mUseFalseColors = false;
|
---|
[2669] | 277 |
|
---|
[2670] | 278 | glPushAttrib(GL_CURRENT_BIT);
|
---|
| 279 | glColor3f(0, 1, 0);
|
---|
[2662] | 280 |
|
---|
[2670] | 281 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
---|
| 282 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
---|
[2669] | 283 |
|
---|
[2670] | 284 | KdNode::NewMail2();
|
---|
| 285 | Intersectable::NewMail();
|
---|
[2662] | 286 |
|
---|
[2670] | 287 | ++ mCurrentFrame;
|
---|
[2671] | 288 |
|
---|
[2670] | 289 | // render pvs once
|
---|
| 290 | RenderPvs(pvs);
|
---|
[2669] | 291 |
|
---|
[2670] | 292 | mUseForcedColors = false;
|
---|
[2669] | 293 |
|
---|
[2670] | 294 | im = toImage();
|
---|
[2671] | 295 | sprintf(filename, "error-frame-%04d-%04d-%0.5f-pvs.png", mFrame, viewcell->GetId(), pErrorPixels);
|
---|
[2670] | 296 | str = mSnapPrefix + filename;
|
---|
| 297 | qstr = str.c_str();
|
---|
| 298 | im.save(qstr, "PNG");
|
---|
| 299 |
|
---|
| 300 | glPopAttrib();
|
---|
| 301 | }
|
---|
[1252] | 302 | }
|
---|
[2662] | 303 |
|
---|
[2543] | 304 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
---|
[2613] | 305 |
|
---|
| 306 | DoneCurrent();
|
---|
| 307 |
|
---|
[2543] | 308 | return pErrorPixels;
|
---|
[1252] | 309 | }
|
---|
| 310 |
|
---|
[1942] | 311 | int
|
---|
| 312 | QtGlRendererBuffer::ComputePvs(ObjectContainer &objects,
|
---|
| 313 | ObjectContainer &pvs) const
|
---|
[1252] | 314 | {
|
---|
| 315 | int pvsSize = 0;
|
---|
| 316 | QImage image = toImage();
|
---|
| 317 | Intersectable::NewMail();
|
---|
| 318 |
|
---|
| 319 | std::stable_sort(objects.begin(), objects.end(), ilt);
|
---|
| 320 |
|
---|
| 321 | MeshInstance dummy(NULL);
|
---|
| 322 |
|
---|
| 323 | Intersectable *obj = NULL;
|
---|
[2543] | 324 |
|
---|
[1252] | 325 | for (int x = 0; x < image.width(); ++ x)
|
---|
| 326 | {
|
---|
| 327 | for (int y = 0; y < image.height(); ++ y)
|
---|
| 328 | {
|
---|
| 329 | QRgb pix = image.pixel(x, y);
|
---|
| 330 | const int id = GetId(qRed(pix), qGreen(pix), qBlue(pix));
|
---|
| 331 |
|
---|
| 332 | dummy.SetId(id);
|
---|
| 333 |
|
---|
| 334 | ObjectContainer::iterator oit =
|
---|
| 335 | lower_bound(objects.begin(), objects.end(), &dummy, ilt);
|
---|
[2543] | 336 |
|
---|
[1252] | 337 | if (//(oit != oit.end()) &&
|
---|
| 338 | ((*oit)->GetId() == id) &&
|
---|
| 339 | !obj->Mailed())
|
---|
| 340 | {
|
---|
| 341 | obj = *oit;
|
---|
| 342 | obj->Mail();
|
---|
| 343 | ++ pvsSize;
|
---|
| 344 | pvs.push_back(obj);
|
---|
| 345 | }
|
---|
| 346 | }
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | return pvsSize;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 |
|
---|
[2543] | 353 | void QtGlRendererWidget::InitGL()
|
---|
[1997] | 354 | {
|
---|
[2543] | 355 | GlRenderer::InitGL();
|
---|
[1942] | 356 |
|
---|
[2643] | 357 | //glEnable(GL_FOG);
|
---|
| 358 | //glFogi(GL_FOG_MODE, GL_EXP);
|
---|
| 359 | glFogi(GL_FOG_MODE, GL_LINEAR);
|
---|
| 360 |
|
---|
| 361 | // glFogf(GL_FOG_DENSITY, .2f);
|
---|
| 362 | glFogf(GL_FOG_START, 50.f);
|
---|
| 363 | glFogf(GL_FOG_END, 500.f);
|
---|
| 364 |
|
---|
[2633] | 365 | GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0};
|
---|
| 366 | GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0};
|
---|
| 367 | GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0};
|
---|
| 368 | GLfloat light_position[] = //{278.0f, 548.8f,279.0f, 1.0f };
|
---|
| 369 | { 0.f,0.f,0.f,1.0f };
|
---|
| 370 |
|
---|
| 371 | /*glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
---|
| 372 | glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
---|
| 373 | glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
---|
| 374 | glLightfv(GL_LIGHT0, GL_POSITION, light_position);
|
---|
| 375 | */
|
---|
| 376 | glEnable(GL_LIGHT0);
|
---|
| 377 |
|
---|
[2604] | 378 | GLfloat mat_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
|
---|
| 379 |
|
---|
| 380 | // mat_specular and mat_shininess are NOT default values
|
---|
| 381 | GLfloat mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
---|
| 382 | GLfloat mat_specular[] = {0.3f, 0.3f, 0.3f, 1.0f};
|
---|
| 383 | GLfloat mat_shininess[] = {1.0f};
|
---|
[1942] | 384 |
|
---|
[2633] | 385 | /* GLfloat light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
|
---|
[2604] | 386 | GLfloat light_diffuse[] = {0.4f, 0.4f, 0.4f, 1.0f};
|
---|
| 387 | GLfloat light_specular[] = {0.3f, 0.3f, 0.3f, 1.0f};
|
---|
[2543] | 388 |
|
---|
[2604] | 389 | GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};
|
---|
[2633] | 390 | */
|
---|
[2543] | 391 |
|
---|
| 392 | // default Material
|
---|
| 393 | glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
|
---|
| 394 | glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
|
---|
| 395 | glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
|
---|
| 396 | glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
|
---|
| 397 |
|
---|
| 398 | // a light
|
---|
| 399 | glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
---|
| 400 | glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
---|
| 401 | glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
---|
| 402 |
|
---|
[2633] | 403 | /*glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
|
---|
[2543] | 404 | glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
|
---|
| 405 | glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
|
---|
[2633] | 406 | */
|
---|
| 407 | //glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
|
---|
[2543] | 408 |
|
---|
| 409 | glEnable(GL_LIGHTING);
|
---|
| 410 | glEnable(GL_LIGHT0);
|
---|
[2633] | 411 | // glEnable(GL_LIGHT1);
|
---|
[2543] | 412 |
|
---|
| 413 | // set position of the light
|
---|
[2633] | 414 | /*GLfloat infinite_light[] = { 1.0, 0.8, 1.0, 0.0 };
|
---|
[2543] | 415 | glLightfv (GL_LIGHT0, GL_POSITION, infinite_light);
|
---|
| 416 |
|
---|
| 417 | // set position of the light2
|
---|
| 418 | GLfloat infinite_light2[] = { -0.3, 1.5, 1.0, 0.0 };
|
---|
| 419 | glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2);
|
---|
[2633] | 420 | */
|
---|
| 421 | glLightfv (GL_LIGHT0, GL_POSITION, light_position);
|
---|
[2543] | 422 |
|
---|
| 423 | glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
---|
[2571] | 424 | // glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR);
|
---|
[2543] | 425 | glEnable(GL_COLOR_MATERIAL);
|
---|
| 426 |
|
---|
[2633] | 427 | glShadeModel(GL_SMOOTH);
|
---|
[1997] | 428 | }
|
---|
[1942] | 429 |
|
---|
[1997] | 430 |
|
---|
[1252] | 431 | void
|
---|
[1942] | 432 | QtGlRendererWidget::SetupCameraProjection(const int w, const int h, const float angle)
|
---|
[1252] | 433 | {
|
---|
[2543] | 434 | if (!mTopView) {
|
---|
| 435 | int ww = w;
|
---|
| 436 | int hh = h;
|
---|
| 437 | glViewport(0, 0, ww, hh);
|
---|
| 438 | glMatrixMode(GL_PROJECTION);
|
---|
| 439 | glLoadIdentity();
|
---|
[2562] | 440 | gluPerspective(angle, ww/(float)hh, 0.1, 2.0 * Magnitude(mSceneGraph->GetBox().Diagonal()));
|
---|
[2543] | 441 | glMatrixMode(GL_MODELVIEW);
|
---|
| 442 | } else {
|
---|
| 443 | int ww = w;
|
---|
| 444 | int hh = h;
|
---|
| 445 | glViewport(0, 0, ww, hh);
|
---|
| 446 | glMatrixMode(GL_PROJECTION);
|
---|
| 447 | glLoadIdentity();
|
---|
[2562] | 448 | gluPerspective(50.0, ww / (float)hh, 0.1, 20.0 * Magnitude(mSceneGraph->GetBox().Diagonal()));
|
---|
[2543] | 449 | glMatrixMode(GL_MODELVIEW);
|
---|
| 450 | }
|
---|
[1252] | 451 | }
|
---|
| 452 |
|
---|
[1942] | 453 |
|
---|
[2538] | 454 | bool QtGlRendererWidget::PvsChanged(ViewCell *viewCell) const
|
---|
| 455 | {
|
---|
| 456 | if (viewCell != mPvsCache.mViewCell)
|
---|
| 457 | return true;
|
---|
[1942] | 458 |
|
---|
[2538] | 459 | if (viewCell->GetPvs().GetSize() != mPvsCache.mUnfilteredPvsSize)
|
---|
| 460 | return true;
|
---|
| 461 |
|
---|
| 462 | return false;
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 |
|
---|
| 466 | void QtGlRendererWidget::_RenderPvs()
|
---|
[1252] | 467 | {
|
---|
[2671] | 468 | EnableDrawArrays();
|
---|
| 469 | if (mUseVbos)
|
---|
| 470 | glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
|
---|
| 471 |
|
---|
[2633] | 472 | mUseFalseColors = false;
|
---|
[2538] | 473 |
|
---|
[2543] | 474 | int offset = (int)mObjects.size() * 3;
|
---|
[2538] | 475 | char *arrayPtr = mUseVbos ? NULL : (char *)mData;
|
---|
[2543] | 476 |
|
---|
[2538] | 477 | glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr);
|
---|
| 478 | glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3));
|
---|
| 479 | glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices);
|
---|
[2664] | 480 |
|
---|
[2615] | 481 | #if DYNAMIC_OBJECTS_HACK
|
---|
[2609] | 482 | // handle dynamic objects
|
---|
| 483 | DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end();
|
---|
| 484 |
|
---|
| 485 | for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit)
|
---|
| 486 | {
|
---|
[2615] | 487 | #if USE_TRANSFORMED_MESH_INSTANCE_HACK
|
---|
[2609] | 488 | RenderIntersectable(*dit);
|
---|
[2615] | 489 | #else
|
---|
[2621] | 490 | _RenderDynamicObject(*dit);
|
---|
[2615] | 491 | #endif
|
---|
[2609] | 492 | }
|
---|
[2615] | 493 | #endif
|
---|
[2538] | 494 | }
|
---|
[1942] | 495 |
|
---|
[1252] | 496 |
|
---|
[2670] | 497 | void QtGlRendererWidget::PreparePvs(const ObjectPvs &pvs)
|
---|
[2538] | 498 | {
|
---|
[2543] | 499 | int indexBufferSize = 0;
|
---|
| 500 |
|
---|
[2670] | 501 | // hack: mail not working with multiple threads
|
---|
[2643] | 502 | KdNode::NewMail2();
|
---|
[2538] | 503 |
|
---|
[2633] | 504 | mPvsSize = pvs.GetSize();
|
---|
| 505 |
|
---|
[2615] | 506 | #if DYNAMIC_OBJECTS_HACK
|
---|
[2609] | 507 | mDynamicObjects.clear();
|
---|
[2615] | 508 | #endif
|
---|
[2538] | 509 |
|
---|
[2633] | 510 | ObjectPvsIterator it = pvs.GetIterator();
|
---|
| 511 |
|
---|
[2543] | 512 | while (it.HasMoreEntries())
|
---|
[2538] | 513 | {
|
---|
| 514 | Intersectable *obj = it.Next();
|
---|
[2609] | 515 | switch (obj->Type())
|
---|
| 516 | {
|
---|
| 517 | case Intersectable::KD_INTERSECTABLE:
|
---|
| 518 | {
|
---|
| 519 | KdNode *node = static_cast<KdIntersectable *>(obj)->GetItem();
|
---|
| 520 | _UpdatePvsIndices(node, indexBufferSize);
|
---|
| 521 | }
|
---|
| 522 | break;
|
---|
[2615] | 523 | #if DYNAMIC_OBJECTS_HACK
|
---|
| 524 | #if USE_TRANSFORMED_MESH_INSTANCE_HACK
|
---|
| 525 |
|
---|
[2609] | 526 | case Intersectable::TRANSFORMED_MESH_INSTANCE:
|
---|
| 527 | mDynamicObjects.push_back(static_cast<TransformedMeshInstance *>(obj));
|
---|
| 528 | break;
|
---|
[2615] | 529 |
|
---|
| 530 | #else
|
---|
| 531 | case Intersectable::SCENEGRAPHLEAF_INTERSECTABLE:
|
---|
| 532 | mDynamicObjects.push_back(static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem());
|
---|
| 533 | break;
|
---|
| 534 | #endif
|
---|
| 535 | #endif
|
---|
[2609] | 536 | default:
|
---|
| 537 | cerr << "PreparePvs: type " << Intersectable::GetTypeName(obj) << " not handled yet" << endl;
|
---|
| 538 | }
|
---|
[2538] | 539 | }
|
---|
[2543] | 540 |
|
---|
| 541 | mIndexBufferSize = indexBufferSize;
|
---|
[2538] | 542 | }
|
---|
| 543 |
|
---|
| 544 |
|
---|
[2670] | 545 | void QtGlRendererWidget::VisualizePvs()
|
---|
[2538] | 546 | {
|
---|
| 547 | if (mUseVbos)
|
---|
| 548 | glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
|
---|
| 549 |
|
---|
[2543] | 550 | ++ mCurrentFrame;
|
---|
| 551 |
|
---|
[2538] | 552 | EnableDrawArrays();
|
---|
[2669] | 553 |
|
---|
[2538] | 554 | if (mDetectEmptyViewSpace)
|
---|
| 555 | glEnable(GL_CULL_FACE);
|
---|
| 556 | else
|
---|
| 557 | glDisable(GL_CULL_FACE);
|
---|
| 558 |
|
---|
[2543] | 559 | ViewCell *viewcell = NULL;
|
---|
[2538] | 560 | viewcell = mViewCellsManager->GetViewCell(mViewPoint, true);
|
---|
| 561 |
|
---|
| 562 | if (viewcell)
|
---|
| 563 | {
|
---|
[2643] | 564 | #if 0
|
---|
[2543] | 565 | // copy the pvs so that it can be filtered ...
|
---|
[2538] | 566 | if (PvsChanged(viewcell))
|
---|
| 567 | {
|
---|
| 568 | mPvsCache.Reset();
|
---|
| 569 | mPvsCache.mViewCell = viewcell;
|
---|
| 570 | mPvsCache.mUnfilteredPvsSize = viewcell->GetPvs().GetSize();
|
---|
| 571 |
|
---|
| 572 | if (mUseSpatialFilter)
|
---|
| 573 | {
|
---|
[2543] | 574 | //mMutex.lock();
|
---|
[2538] | 575 | // mSpatialFilter size is in range 0.001 - 0.1
|
---|
[2643] | 576 | mViewCellsManager->ApplyFilter2(viewcell,
|
---|
| 577 | mUseFilter,
|
---|
| 578 | 100.0f * mSpatialFilterSize,
|
---|
| 579 | mPvsCache.mPvs,
|
---|
| 580 | &mPvsCache.filteredBoxes);
|
---|
[2543] | 581 | //mPvsCache.mPvs = pvs;
|
---|
| 582 | //mMutex.unlock();
|
---|
[2633] | 583 | //cout << "pvs size: " << mPvsCache.mPvs.GetSize() << endl;
|
---|
[2542] | 584 | }
|
---|
[2538] | 585 | else
|
---|
| 586 | {
|
---|
| 587 | mPvsCache.mPvs = viewcell->GetPvs();
|
---|
| 588 | }
|
---|
[2633] | 589 |
|
---|
| 590 | // update the indices for rendering
|
---|
[2671] | 591 | PreparePvs(mPvsCache.mPvs);
|
---|
[2538] | 592 | emit PvsUpdated();
|
---|
[2643] | 593 | mCurrentPvsCost = mPvsCache.mPvs.EvalPvsCost();
|
---|
[2538] | 594 | }
|
---|
[2633] | 595 | #else
|
---|
[2643] | 596 |
|
---|
[2670] | 597 | PreparePvs(viewcell->GetPvs());
|
---|
[2633] | 598 | emit PvsUpdated();
|
---|
[2643] | 599 |
|
---|
[2633] | 600 | #endif
|
---|
[2530] | 601 |
|
---|
[2538] | 602 | // Render PVS
|
---|
| 603 | if (mUseSpatialFilter && mRenderBoxes)
|
---|
| 604 | {
|
---|
[2664] | 605 | for (size_t i=0; i < mPvsCache.filteredBoxes.size(); ++ i)
|
---|
[2542] | 606 | {
|
---|
[2538] | 607 | RenderBox(mPvsCache.filteredBoxes[i]);
|
---|
[2542] | 608 | }
|
---|
[2538] | 609 | }
|
---|
| 610 | else
|
---|
| 611 | {
|
---|
[2604] | 612 | if (!mRenderVisibilityEstimates && !mUseRandomColorPerPvsObject)
|
---|
[2538] | 613 | _RenderPvs();
|
---|
| 614 | else
|
---|
[2609] | 615 | _RenderColoredPvs();
|
---|
[1942] | 616 | }
|
---|
[2538] | 617 |
|
---|
| 618 | if (mRenderFilter)
|
---|
| 619 | {
|
---|
| 620 | mWireFrame = true;
|
---|
| 621 | RenderIntersectable(viewcell);
|
---|
[2564] | 622 |
|
---|
[2538] | 623 | mWireFrame = false;
|
---|
| 624 | }
|
---|
[2643] | 625 | mCurrentPvsCost = viewcell->GetPvs().EvalPvsCost();
|
---|
[2538] | 626 | }
|
---|
| 627 | else
|
---|
| 628 | {
|
---|
[2664] | 629 | //OcclusionQuery *query = mOcclusionQueries[0];
|
---|
| 630 | //query->BeginQuery();
|
---|
| 631 |
|
---|
[2538] | 632 | RenderScene();
|
---|
[2664] | 633 |
|
---|
| 634 | //query->EndQuery();
|
---|
| 635 | //int pixels = query->GetQueryResult();
|
---|
| 636 | //cout << " pixels: " << pixels;
|
---|
[1942] | 637 | }
|
---|
[2643] | 638 |
|
---|
| 639 | //cout << "vp: " << mViewPoint << " vd: " << mViewDirection << endl;
|
---|
[1252] | 640 | }
|
---|
| 641 |
|
---|
| 642 | float
|
---|
| 643 | QtGlRendererWidget::RenderErrors()
|
---|
| 644 | {
|
---|
[2543] | 645 | float pErrorPixels = -1.0f;
|
---|
[1252] | 646 |
|
---|
[2543] | 647 | SetupCamera();
|
---|
| 648 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
---|
[2049] | 649 |
|
---|
[2543] | 650 | glPushAttrib(GL_ENABLE_BIT);
|
---|
[2049] | 651 |
|
---|
[2543] | 652 | glStencilFunc(GL_EQUAL, 0x0, 0x1);
|
---|
| 653 | glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
---|
[2049] | 654 |
|
---|
[2638] | 655 | glColor3f(0.6f, 0.6f, 0.6f);
|
---|
| 656 |
|
---|
[2543] | 657 | // Render PVS
|
---|
[2670] | 658 | VisualizePvs();
|
---|
[1252] | 659 |
|
---|
[2543] | 660 | glEnable(GL_STENCIL_TEST);
|
---|
[1252] | 661 |
|
---|
[2543] | 662 | glDisable(GL_LIGHTING);
|
---|
[1252] | 663 |
|
---|
[2543] | 664 | SetupCamera();
|
---|
[1252] | 665 |
|
---|
[2638] | 666 | mUseForcedColors = true;
|
---|
| 667 |
|
---|
[2543] | 668 | glColor3f(1.0f, 0.0f, 0.0f);
|
---|
[2049] | 669 |
|
---|
[2662] | 670 | OcclusionQuery *query = mOcclusionQueries[0];
|
---|
| 671 | query->BeginQuery();
|
---|
| 672 |
|
---|
[2543] | 673 | RenderScene();
|
---|
| 674 |
|
---|
| 675 | mUseForcedColors = false;
|
---|
| 676 |
|
---|
| 677 | query->EndQuery();
|
---|
| 678 |
|
---|
| 679 | glDisable(GL_STENCIL_TEST);
|
---|
| 680 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
---|
| 681 |
|
---|
| 682 | glPopAttrib();
|
---|
| 683 |
|
---|
| 684 | // reenable other state
|
---|
| 685 | // int wait=0;
|
---|
| 686 | // while (!query.ResultAvailable()) {
|
---|
| 687 | // wait++;
|
---|
| 688 | // }
|
---|
| 689 |
|
---|
| 690 | int pixelCount = query->GetQueryResult();
|
---|
[2664] | 691 | pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight());
|
---|
[2670] | 692 |
|
---|
[2664] | 693 | if (0) cout << "error pixels=" << pixelCount << endl;
|
---|
[2543] | 694 |
|
---|
| 695 | mRenderError = pErrorPixels;
|
---|
| 696 |
|
---|
| 697 | return pErrorPixels;
|
---|
[1252] | 698 | }
|
---|
| 699 |
|
---|
| 700 |
|
---|
[2538] | 701 | void QtGlRendererWidget::timerEvent(QTimerEvent *event)
|
---|
[1252] | 702 | {
|
---|
[2538] | 703 | //std::cout << "Timer ID:" << event->timerId();
|
---|
| 704 | update();
|
---|
| 705 | }
|
---|
| 706 |
|
---|
| 707 |
|
---|
| 708 | void QtGlRendererWidget::mousePressEvent(QMouseEvent *e)
|
---|
| 709 | {
|
---|
[2543] | 710 | int x = e->pos().x();
|
---|
| 711 | int y = e->pos().y();
|
---|
[1252] | 712 |
|
---|
[2543] | 713 | mousePoint.x = x;
|
---|
| 714 | mousePoint.y = y;
|
---|
| 715 |
|
---|
[1252] | 716 | }
|
---|
| 717 |
|
---|
[2636] | 718 | void QtGlRendererWidget::mouseReleaseEvent(QMouseEvent *e)
|
---|
| 719 | {
|
---|
| 720 |
|
---|
| 721 | if (e->modifiers() & Qt::AltModifier)
|
---|
| 722 | if (mCurrentDynamicObjectIdx >= 0) {
|
---|
| 723 | // preprocessor->ScheduleUpdateDynamicObjects();
|
---|
| 724 | }
|
---|
| 725 | }
|
---|
| 726 |
|
---|
[1252] | 727 | void
|
---|
| 728 | QtGlRendererWidget::mouseMoveEvent(QMouseEvent *e)
|
---|
| 729 | {
|
---|
[2538] | 730 | float MOVE_SENSITIVITY = Magnitude(mSceneGraph->GetBox().Diagonal())*1e-3;
|
---|
[2609] | 731 | float TURN_SENSITIVITY = 0.1f;
|
---|
| 732 | float TILT_SENSITIVITY = 32.0 ;
|
---|
| 733 | float TURN_ANGLE= M_PI /36.0 ;
|
---|
[1252] | 734 |
|
---|
[2538] | 735 | int x = e->pos().x();
|
---|
| 736 | int y = e->pos().y();
|
---|
[1942] | 737 |
|
---|
[2538] | 738 | int diffx = -(mousePoint.x - x);
|
---|
| 739 | int diffy = -(mousePoint.y - y);
|
---|
| 740 |
|
---|
[2614] | 741 | const float t = 1.0f;
|
---|
| 742 |
|
---|
[2538] | 743 | if (e->modifiers() & Qt::ControlModifier)
|
---|
| 744 | {
|
---|
[2609] | 745 | mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY / 2.0;
|
---|
| 746 | mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0;
|
---|
[2538] | 747 | }
|
---|
[2615] | 748 | #if DYNAMIC_OBJECTS_HACK
|
---|
[2614] | 749 | else if (e->modifiers() & Qt::AltModifier)
|
---|
[2538] | 750 | {
|
---|
[2614] | 751 | if (mCurrentDynamicObjectIdx >= 0)
|
---|
| 752 | {
|
---|
| 753 | Matrix4x4 tm;
|
---|
| 754 |
|
---|
| 755 | switch (mTrafoType)
|
---|
| 756 | {
|
---|
| 757 | case 0:
|
---|
| 758 | {
|
---|
[2638] | 759 | if (e->modifiers() & Qt::ShiftModifier) {
|
---|
| 760 | const Vector3 transl(0, diffy, 0);
|
---|
| 761 | tm = TranslationMatrix(transl);
|
---|
| 762 |
|
---|
| 763 | } else {
|
---|
[2614] | 764 | const Vector3 transl(diffx, 0, diffy);
|
---|
| 765 | tm = TranslationMatrix(transl);
|
---|
[2638] | 766 | }
|
---|
[2614] | 767 | }
|
---|
| 768 | break;
|
---|
| 769 | case 1:
|
---|
| 770 | {
|
---|
| 771 | float scalef = 1.0f + 0.01f * (diffx + diffy);
|
---|
| 772 | if (scalef < 0.9) scalef = 0.9f;
|
---|
| 773 | else if (scalef > 1.1f) scalef = 1.1f;
|
---|
| 774 | tm = ScaleMatrix(scalef, scalef, scalef);
|
---|
| 775 | }
|
---|
| 776 | break;
|
---|
| 777 | case 2:
|
---|
| 778 | {
|
---|
[2638] | 779 | // tm = RotationXMatrix(diffx) * RotationYMatrix(diffy);
|
---|
| 780 | tm = RotationYMatrix(diffx);
|
---|
[2614] | 781 | }
|
---|
| 782 | break;
|
---|
| 783 | default:
|
---|
| 784 | cerr << "not implemented" << endl;
|
---|
| 785 | }
|
---|
| 786 |
|
---|
[2621] | 787 | #if USE_TRANSFORMED_MESH_INSTANCE_HACK
|
---|
| 788 | TransformedMeshInstance *tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx];
|
---|
[2614] | 789 | tmi->ApplyWorldTransform(tm);
|
---|
[2621] | 790 | #else
|
---|
[2636] | 791 | SceneGraphLeaf *l =
|
---|
| 792 | mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx];
|
---|
[2621] | 793 | l->ApplyTransform(tm);
|
---|
[2636] | 794 |
|
---|
[2615] | 795 | #endif
|
---|
[2614] | 796 | updateGL();
|
---|
| 797 | }
|
---|
| 798 | }
|
---|
[2615] | 799 | #endif
|
---|
[2614] | 800 | else
|
---|
| 801 | {
|
---|
[2538] | 802 | mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY);
|
---|
| 803 | float adiff = TURN_ANGLE*(x - mousePoint.x)*-TURN_SENSITIVITY;
|
---|
| 804 | float angle = atan2(mViewDirection.x, mViewDirection.z);
|
---|
| 805 | mViewDirection.x = sin(angle + adiff);
|
---|
| 806 | mViewDirection.z = cos(angle + adiff);
|
---|
| 807 | }
|
---|
| 808 |
|
---|
| 809 | mousePoint.x = x;
|
---|
| 810 | mousePoint.y = y;
|
---|
| 811 |
|
---|
| 812 | updateGL();
|
---|
[1252] | 813 | }
|
---|
| 814 |
|
---|
| 815 |
|
---|
| 816 | void
|
---|
| 817 | QtGlRendererWidget::resizeGL(int w, int h)
|
---|
| 818 | {
|
---|
[2543] | 819 | SetupCameraProjection(w, h);
|
---|
| 820 | updateGL();
|
---|
[1252] | 821 | }
|
---|
| 822 |
|
---|
[2670] | 823 |
|
---|
| 824 | void QtGlRendererWidget::paintGL()
|
---|
[1252] | 825 | {
|
---|
[2543] | 826 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
---|
[1252] | 827 |
|
---|
[2560] | 828 | if (1)
|
---|
| 829 | {
|
---|
[2543] | 830 | SetupCameraProjection(width(), height());
|
---|
| 831 | SetupCamera();
|
---|
| 832 |
|
---|
[2560] | 833 | if (mRenderErrors)
|
---|
| 834 | {
|
---|
[2543] | 835 | RenderErrors();
|
---|
[2560] | 836 | }
|
---|
| 837 | else
|
---|
| 838 | {
|
---|
[2543] | 839 | glColor3f(0.6f, 0.6f, 0.6f);
|
---|
[2670] | 840 | VisualizePvs();
|
---|
[2543] | 841 | }
|
---|
[2571] | 842 |
|
---|
[2643] | 843 | if (mShowRays)
|
---|
[2571] | 844 | {
|
---|
[2593] | 845 | RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1);
|
---|
[2571] | 846 | }
|
---|
[1942] | 847 | }
|
---|
[1252] | 848 |
|
---|
[2543] | 849 | RenderInfo();
|
---|
| 850 | mFrame ++;
|
---|
[2638] | 851 | // cout<<"vp="<<mViewPoint<<" vd="<<mViewDirection<<endl;
|
---|
[1252] | 852 | }
|
---|
| 853 |
|
---|
| 854 |
|
---|
| 855 | void
|
---|
| 856 | QtGlRendererWidget::SetupCamera()
|
---|
| 857 | {
|
---|
[2543] | 858 | if (!mTopView)
|
---|
| 859 | GlRenderer::SetupCamera();
|
---|
[2593] | 860 | else
|
---|
| 861 | {
|
---|
| 862 | if (0)
|
---|
| 863 | {
|
---|
[2543] | 864 | float dist = Magnitude(mSceneGraph->GetBox().Diagonal())*0.05;
|
---|
| 865 | Vector3 pos = mViewPoint - dist*Vector3(mViewDirection.x,
|
---|
| 866 | -1,
|
---|
| 867 | mViewDirection.y);
|
---|
| 868 |
|
---|
| 869 | Vector3 target = mViewPoint + dist*mViewDirection;
|
---|
| 870 | Vector3 up(0,1,0);
|
---|
| 871 |
|
---|
| 872 | glLoadIdentity();
|
---|
| 873 | gluLookAt(pos.x, pos.y, pos.z,
|
---|
[1252] | 874 | target.x, target.y, target.z,
|
---|
| 875 | up.x, up.y, up.z);
|
---|
[2563] | 876 | }
|
---|
| 877 | else
|
---|
| 878 | {
|
---|
| 879 | float dist = Magnitude(mSceneGraph->GetBox().Diagonal()) * mTopDistance;
|
---|
[2625] | 880 | Vector3 pos = mViewPoint + dist * Vector3(0, 1, 0);
|
---|
[2543] | 881 |
|
---|
| 882 | Vector3 target = mViewPoint;
|
---|
| 883 | Vector3 up(mViewDirection.x, 0, mViewDirection.z);
|
---|
| 884 |
|
---|
| 885 | glLoadIdentity();
|
---|
| 886 | gluLookAt(pos.x, pos.y, pos.z,
|
---|
[1252] | 887 | target.x, target.y, target.z,
|
---|
| 888 | up.x, up.y, up.z);
|
---|
[2543] | 889 |
|
---|
| 890 | }
|
---|
[1252] | 891 | }
|
---|
| 892 |
|
---|
| 893 | }
|
---|
| 894 |
|
---|
[1942] | 895 |
|
---|
[1252] | 896 | void
|
---|
| 897 | QtGlRendererWidget::keyPressEvent ( QKeyEvent * e )
|
---|
| 898 | {
|
---|
[2604] | 899 | switch (e->key())
|
---|
| 900 | {
|
---|
| 901 | case Qt::Key_E:
|
---|
| 902 | mRenderErrors = !mRenderErrors;
|
---|
| 903 | updateGL();
|
---|
| 904 | break;
|
---|
| 905 | case Qt::Key_R:
|
---|
| 906 | mUseRandomColorPerPvsObject = !mUseRandomColorPerPvsObject;;
|
---|
| 907 | updateGL();
|
---|
| 908 | break;
|
---|
[2543] | 909 | case Qt::Key_T:
|
---|
[1252] | 910 | mTopView = !mTopView;
|
---|
[1942] | 911 | SetupCameraProjection(width(), height());
|
---|
[1252] | 912 | updateGL();
|
---|
| 913 | break;
|
---|
[2543] | 914 | case Qt::Key_V:
|
---|
[1252] | 915 | mRenderViewCells = !mRenderViewCells;
|
---|
| 916 | updateGL();
|
---|
| 917 | break;
|
---|
[2543] | 918 | case Qt::Key_P:
|
---|
[1252] | 919 | // set random viewpoint
|
---|
| 920 | mViewCellsManager->GetViewPoint(mViewPoint);
|
---|
| 921 | updateGL();
|
---|
| 922 | break;
|
---|
[2543] | 923 | case Qt::Key_S: {
|
---|
[1966] | 924 | // set view poitn and direction
|
---|
| 925 | QString text;
|
---|
| 926 | bool ok;
|
---|
| 927 | text.sprintf("%f %f %f", mViewPoint.x, mViewPoint.y, mViewPoint.z);
|
---|
| 928 | text = QInputDialog::getText(this,
|
---|
[2543] | 929 | "Enter a view point",
|
---|
| 930 | "",
|
---|
| 931 | QLineEdit::Normal,
|
---|
| 932 | text,
|
---|
| 933 | &ok);
|
---|
[1966] | 934 | if (!ok)
|
---|
[2543] | 935 | break;
|
---|
| 936 |
|
---|
[1967] | 937 | if (sscanf(text.toAscii(), "%f %f %f", &mViewPoint.x, &mViewPoint.y, &mViewPoint.z) == 3) {
|
---|
[2543] | 938 | text.sprintf("%f %f %f", mViewDirection.x, mViewDirection.y, mViewDirection.z);
|
---|
| 939 | text = QInputDialog::getText(this,
|
---|
| 940 | "Enter a direction",
|
---|
| 941 | "",
|
---|
| 942 | QLineEdit::Normal,
|
---|
| 943 | text,
|
---|
| 944 | &ok);
|
---|
| 945 | if (!ok)
|
---|
| 946 | break;
|
---|
| 947 | if (sscanf(text.toAscii(), "%f %f %f", &mViewDirection.x,
|
---|
| 948 | &mViewDirection.y, &mViewDirection.z) == 3) {
|
---|
| 949 | updateGL();
|
---|
| 950 | }
|
---|
| 951 | break;
|
---|
[1967] | 952 | }
|
---|
[2543] | 953 | }
|
---|
| 954 | default:
|
---|
[2604] | 955 | cerr << "unknown key" << endl;
|
---|
[1252] | 956 | e->ignore();
|
---|
| 957 | break;
|
---|
[2543] | 958 | }
|
---|
[1252] | 959 | }
|
---|
| 960 |
|
---|
| 961 |
|
---|
[2543] | 962 |
|
---|
[1942] | 963 | QtGlRendererWidget::QtGlRendererWidget(
|
---|
| 964 | SceneGraph *sceneGraph,
|
---|
| 965 | ViewCellsManager *viewcells,
|
---|
| 966 | KdTree *tree,
|
---|
| 967 | QWidget * parent,
|
---|
| 968 | const QGLWidget * shareWidget,
|
---|
| 969 | Qt::WFlags f
|
---|
| 970 | )
|
---|
[2543] | 971 | :
|
---|
[2633] | 972 | GlRendererWidget(sceneGraph, viewcells, tree), QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget, f)
|
---|
[1252] | 973 | {
|
---|
[2543] | 974 | mPreprocessorThread = NULL;
|
---|
| 975 | mTopView = false;
|
---|
| 976 | mRenderViewCells = false;
|
---|
| 977 | mTopDistance = 1.0f;
|
---|
| 978 | mCutViewCells = false;
|
---|
| 979 | mCutScene = false;
|
---|
| 980 | mRenderErrors = false;
|
---|
| 981 | mRenderBoxes = false;
|
---|
| 982 | mRenderFilter = true;
|
---|
| 983 | mRenderVisibilityEstimates = false;
|
---|
[2633] | 984 | //mRenderVisibilityEstimates = true;
|
---|
[2562] | 985 |
|
---|
[2643] | 986 | mComputeGVS = false;
|
---|
[2604] | 987 | mUseRandomColorPerPvsObject = false;
|
---|
| 988 |
|
---|
[2562] | 989 | mHideByCost = false;
|
---|
[2564] | 990 | mUseTransparency = false;
|
---|
[2562] | 991 |
|
---|
[2569] | 992 | mTransferFunction = 1.0f;
|
---|
[2543] | 993 | mIndexBufferSize = 0;
|
---|
[1252] | 994 |
|
---|
[2562] | 995 | const int delay = 250; // in milliseconds
|
---|
[2543] | 996 | timerId = startTimer(delay);
|
---|
[1252] | 997 |
|
---|
[2543] | 998 | bool tmp;
|
---|
[1942] | 999 |
|
---|
[2543] | 1000 | Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", tmp );
|
---|
| 1001 | mUseFilter = tmp;
|
---|
[1252] | 1002 |
|
---|
[2580] | 1003 | Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", tmp );
|
---|
[2543] | 1004 | mUseSpatialFilter = tmp;
|
---|
[1252] | 1005 |
|
---|
[2580] | 1006 | //mLogWriter = new LogWriter("myfile.out");
|
---|
| 1007 |
|
---|
[2543] | 1008 | mShowRenderCost = false;
|
---|
| 1009 | mShowPvsSizes = false;
|
---|
[2580] | 1010 | mShowComparison = false;
|
---|
[2560] | 1011 | mShowPiercingRays = false;
|
---|
[2566] | 1012 | mShowWeightedRays = false;
|
---|
[2604] | 1013 | mUseStandardColors = false;
|
---|
| 1014 | mShowWeightedCost = true;
|
---|
[2566] | 1015 |
|
---|
[2569] | 1016 | mShowDistanceWeightedPvs = true;
|
---|
| 1017 | mShowDistanceWeightedTriangles = false;
|
---|
| 1018 | mShowWeightedTriangles = false;
|
---|
[2591] | 1019 | mShowDistribution = 15;
|
---|
[2614] | 1020 | mCurrentDynamicObjectIdx = -1;
|
---|
[2569] | 1021 |
|
---|
[2543] | 1022 | mSpatialFilterSize = 0.01;
|
---|
| 1023 | mPvsSize = 0;
|
---|
[2587] | 1024 | mRayVisualizationMethod = 0;
|
---|
[2614] | 1025 | mTrafoType = 0;
|
---|
| 1026 |
|
---|
[2543] | 1027 | mRenderError = 0.0f;
|
---|
| 1028 | mShowRays = false;
|
---|
[1252] | 1029 |
|
---|
[2643] | 1030 | SetSceneCut(1000);
|
---|
[2543] | 1031 | mControlWidget = new QtRendererControlWidget(NULL);
|
---|
[1942] | 1032 |
|
---|
[2543] | 1033 | connect(mControlWidget, SIGNAL(SetViewCellGranularity(int)), this, SLOT(SetViewCellGranularity(int)));
|
---|
[2584] | 1034 | connect(mControlWidget, SIGNAL(SetTransferFunction(int)), this, SLOT(SetTransferFunction(int)));
|
---|
| 1035 |
|
---|
[2543] | 1036 | connect(mControlWidget, SIGNAL(UpdateAllPvs()), this, SLOT(UpdateAllPvs()));
|
---|
| 1037 | connect(mControlWidget, SIGNAL(ComputeVisibility()), this, SLOT(ComputeVisibility()));
|
---|
| 1038 | connect(mControlWidget, SIGNAL(StopComputation()), this, SLOT(StopComputation()));
|
---|
[2584] | 1039 | connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this, SLOT(SetRandomViewPoint()));
|
---|
| 1040 | connect(mControlWidget, SIGNAL(StoreStatistics(void)), this, SLOT(StoreStatistics(void)));
|
---|
[2643] | 1041 | connect(mControlWidget, SIGNAL(ComputeGVS(void)), this, SLOT(ComputeGVS(void)));
|
---|
[2609] | 1042 | connect(mControlWidget, SIGNAL(LoadObject(void)), this, SLOT(LoadObject(void)));
|
---|
[2543] | 1043 |
|
---|
| 1044 | connect(mControlWidget, SIGNAL(SetSceneCut(int)), this, SLOT(SetSceneCut(int)));
|
---|
| 1045 | connect(mControlWidget, SIGNAL(SetTopDistance(int)), this, SLOT(SetTopDistance(int)));
|
---|
[2563] | 1046 | connect(mControlWidget, SIGNAL(SetTransparency(int)), this, SLOT(SetTransparency(int)));
|
---|
[2543] | 1047 |
|
---|
| 1048 | connect(mControlWidget, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetVisibilityFilterSize(int)));
|
---|
| 1049 | connect(mControlWidget, SIGNAL(SetSpatialFilterSize(int)), this, SLOT(SetSpatialFilterSize(int)));
|
---|
[2562] | 1050 | connect(mControlWidget, SIGNAL(SetHidingCost(int)), this, SLOT(SetHidingCost(int)));
|
---|
[2543] | 1051 |
|
---|
| 1052 | connect(mControlWidget, SIGNAL(SetShowViewCells(bool)), this, SLOT(SetShowViewCells(bool)));
|
---|
| 1053 | connect(mControlWidget, SIGNAL(SetShowRenderCost(bool)), this, SLOT(SetShowRenderCost(bool)));
|
---|
[2564] | 1054 | connect(mControlWidget, SIGNAL(SetUseTransparency(bool)), this, SLOT(SetUseTransparency(bool)));
|
---|
[2543] | 1055 | connect(mControlWidget, SIGNAL(SetShowPvsSizes(bool)), this, SLOT(SetShowPvsSizes(bool)));
|
---|
[2580] | 1056 | connect(mControlWidget, SIGNAL(SetShowComparison(bool)), this, SLOT(SetShowComparison(bool)));
|
---|
[2543] | 1057 | connect(mControlWidget, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool)));
|
---|
| 1058 | connect(mControlWidget, SIGNAL(SetCutViewCells(bool)), this, SLOT(SetCutViewCells(bool)));
|
---|
[2562] | 1059 | connect(mControlWidget, SIGNAL(SetHideByCost(bool)), this, SLOT(SetHideByCost(bool)));
|
---|
[2543] | 1060 | connect(mControlWidget, SIGNAL(SetCutScene(bool)), this, SLOT(SetCutScene(bool)));
|
---|
| 1061 | connect(mControlWidget, SIGNAL(SetRenderErrors(bool)), this, SLOT(SetRenderErrors(bool)));
|
---|
| 1062 | connect(mControlWidget, SIGNAL(SetRenderBoxes(bool)), this, SLOT(SetRenderBoxes(bool)));
|
---|
| 1063 | connect(mControlWidget, SIGNAL(SetRenderFilter(bool)), this, SLOT(SetRenderFilter(bool)));
|
---|
[2566] | 1064 | connect(mControlWidget, SIGNAL(SetRenderVisibilityEstimates(bool)), this, SLOT(SetRenderVisibilityEstimates(bool)));
|
---|
[2543] | 1065 | connect(mControlWidget, SIGNAL(SetUseFilter(bool)), this, SLOT(SetUseFilter(bool)));
|
---|
[2566] | 1066 | connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), this, SLOT(SetUseSpatialFilter(bool)));
|
---|
[2560] | 1067 | connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool)));
|
---|
[2604] | 1068 | connect(mControlWidget, SIGNAL(SetShowWireFrame(bool)), this, SLOT(SetShowWireFrame(bool)));
|
---|
[2566] | 1069 | connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool)));
|
---|
[2569] | 1070 | connect(mControlWidget, SIGNAL(SetShowWeightedCost(bool)), this, SLOT(SetShowWeightedCost(bool)));
|
---|
[2543] | 1071 |
|
---|
[2569] | 1072 | connect(mControlWidget, SIGNAL(SetShowDistanceWeightedTriangles(bool)), this, SLOT(SetShowDistanceWeightedTriangles(bool)));
|
---|
| 1073 | connect(mControlWidget, SIGNAL(SetShowDistanceWeightedPvs(bool)), this, SLOT(SetShowDistanceWeightedPvs(bool)));
|
---|
| 1074 | connect(mControlWidget, SIGNAL(SetShowWeightedTriangles(bool)), this, SLOT(SetShowWeightedTriangles(bool)));
|
---|
| 1075 |
|
---|
[2587] | 1076 | connect(mControlWidget, SIGNAL(UseConstColorForRayViz(bool)), this, SLOT(UseConstColorForRayViz(bool)));
|
---|
| 1077 | connect(mControlWidget, SIGNAL(UseRayLengthForRayViz(bool)), this, SLOT(UseRayLengthForRayViz(bool)));
|
---|
| 1078 | connect(mControlWidget, SIGNAL(SetShowContribution(bool)), this, SLOT(SetShowContribution(bool)));
|
---|
| 1079 | connect(mControlWidget, SIGNAL(SetShowDistribution(bool)), this, SLOT(SetShowDistribution(bool)));
|
---|
| 1080 |
|
---|
[2591] | 1081 | connect(mControlWidget, SIGNAL(SetShowDistribution1(bool)), this, SLOT(SetShowDistribution1(bool)));
|
---|
| 1082 | connect(mControlWidget, SIGNAL(SetShowDistribution2(bool)), this, SLOT(SetShowDistribution2(bool)));
|
---|
| 1083 | connect(mControlWidget, SIGNAL(SetShowDistribution3(bool)), this, SLOT(SetShowDistribution3(bool)));
|
---|
| 1084 | connect(mControlWidget, SIGNAL(SetShowDistribution4(bool)), this, SLOT(SetShowDistribution4(bool)));
|
---|
[2587] | 1085 |
|
---|
[2591] | 1086 | connect(mControlWidget, SIGNAL(SetShowRays(bool)), this, SLOT(SetShowRays(bool)));
|
---|
| 1087 |
|
---|
[2614] | 1088 | connect(mControlWidget, SIGNAL(SetTranslation(bool)), this, SLOT(SetTranslation(bool)));
|
---|
| 1089 | connect(mControlWidget, SIGNAL(SetRotation(bool)), this, SLOT(SetRotation(bool)));
|
---|
| 1090 | connect(mControlWidget, SIGNAL(SetScale(bool)), this, SLOT(SetScale(bool)));
|
---|
[2636] | 1091 |
|
---|
| 1092 | connect(mControlWidget, SIGNAL(UpdateDynamicObjects()), this, SLOT(UpdateDynamicObjects()));
|
---|
| 1093 |
|
---|
[2615] | 1094 | setWindowTitle("PVS Visualization");
|
---|
| 1095 |
|
---|
| 1096 | // setting the main window size here
|
---|
[2645] | 1097 | resize(800, 600);
|
---|
| 1098 | //resize(640, 400);
|
---|
[2615] | 1099 |
|
---|
[2543] | 1100 | mControlWidget->show();
|
---|
[1252] | 1101 | }
|
---|
| 1102 |
|
---|
[1942] | 1103 | void
|
---|
| 1104 | QtGlRendererWidget::UpdateAllPvs()
|
---|
| 1105 | {
|
---|
[2543] | 1106 | // $$ does not work so far:(
|
---|
| 1107 | mViewCellsManager->UpdatePvsForEvaluation();
|
---|
| 1108 | // mViewCellsManager->FinalizeViewCells(false);
|
---|
[1942] | 1109 | }
|
---|
[1252] | 1110 |
|
---|
| 1111 | void
|
---|
[1942] | 1112 | QtGlRendererWidget::ComputeVisibility()
|
---|
[1252] | 1113 | {
|
---|
[2543] | 1114 | cerr<<"Compute Visibility called!\n"<<endl;
|
---|
| 1115 | if (!mPreprocessorThread->isRunning())
|
---|
| 1116 | mPreprocessorThread->RunThread();
|
---|
[1942] | 1117 | }
|
---|
[1925] | 1118 |
|
---|
[1942] | 1119 | void
|
---|
| 1120 | QtGlRendererWidget::StopComputation()
|
---|
| 1121 | {
|
---|
[2543] | 1122 | cerr<<"stop computation called!\n"<<endl;
|
---|
| 1123 | mViewCellsManager->GetPreprocessor()->mStopComputation = true;
|
---|
[1942] | 1124 | }
|
---|
[1252] | 1125 |
|
---|
[1942] | 1126 | void
|
---|
| 1127 | QtGlRendererWidget::SetRandomViewPoint()
|
---|
| 1128 | {
|
---|
[2584] | 1129 | cerr<<"setting random view point!\n"<<endl;
|
---|
[2543] | 1130 | mViewCellsManager->GetViewPoint(mViewPoint);
|
---|
| 1131 | updateGL();
|
---|
[1942] | 1132 | }
|
---|
[1252] | 1133 |
|
---|
[2584] | 1134 |
|
---|
| 1135 | void QtGlRendererWidget::StoreStatistics()
|
---|
| 1136 | {
|
---|
| 1137 | cerr<<"storing statistics!\n"<<endl;
|
---|
| 1138 | const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples;
|
---|
| 1139 |
|
---|
| 1140 | cout<<"**********************************************" << endl;
|
---|
| 1141 | cout << "reached " << currentSamples << " samples " << " => writing file" << endl;
|
---|
| 1142 |
|
---|
| 1143 | LogWriter writer;
|
---|
| 1144 | writer.SetFilename("compare.log");
|
---|
| 1145 | writer.Write(currentSamples, mViewCellsManager->GetViewCells());
|
---|
| 1146 | cout << "finished writing file" << endl;
|
---|
| 1147 | mCompareInfo.clear();
|
---|
| 1148 | updateGL();
|
---|
| 1149 | }
|
---|
| 1150 |
|
---|
[2609] | 1151 |
|
---|
| 1152 | void QtGlRendererWidget::LoadObject()
|
---|
| 1153 | {
|
---|
[2645] | 1154 | string filename("../data/teapot.bn");
|
---|
| 1155 | //string filename("../data/cube.obj");
|
---|
[2609] | 1156 |
|
---|
| 1157 | cout << "Loading model << " << filename << endl;
|
---|
| 1158 |
|
---|
[2614] | 1159 | ++ mCurrentDynamicObjectIdx;
|
---|
| 1160 |
|
---|
[2636] | 1161 | if (mViewCellsManager->GetPreprocessor()->LoadDynamicGeometry(filename)) {
|
---|
| 1162 |
|
---|
| 1163 | cout << "Loading finished" << endl;
|
---|
| 1164 | } else
|
---|
| 1165 | cerr << "Loading failed" << endl;
|
---|
| 1166 |
|
---|
[2609] | 1167 | updateGL();
|
---|
| 1168 | }
|
---|
| 1169 |
|
---|
[1942] | 1170 | void
|
---|
| 1171 | QtGlRendererWidget::RenderRenderCost()
|
---|
| 1172 | {
|
---|
[1252] | 1173 | static vector<float> costFunction;
|
---|
| 1174 | static float maxCost = -1;
|
---|
| 1175 | if (costFunction.size()==0) {
|
---|
[2543] | 1176 | ViewCellsTree *tree = mViewCellsManager->GetViewCellsTree();
|
---|
| 1177 | if (tree) {
|
---|
| 1178 | tree->GetCostFunction(costFunction);
|
---|
| 1179 | maxCost = -1;
|
---|
| 1180 | for (int i=0; i < costFunction.size(); i++) {
|
---|
| 1181 | // cout<<i<<":"<<costFunction[i]<<" ";
|
---|
| 1182 | // update cost function to an absolute value based on the total geometry count
|
---|
[2601] | 1183 | costFunction[i] *= mSceneGraph->GetSize();
|
---|
[2543] | 1184 | if (costFunction[i] > maxCost)
|
---|
| 1185 | maxCost = costFunction[i];
|
---|
| 1186 | }
|
---|
[1252] | 1187 | }
|
---|
| 1188 | }
|
---|
| 1189 |
|
---|
[2543] | 1190 |
|
---|
[1252] | 1191 | int currentPos = (int)mViewCellsManager->GetViewCells().size();
|
---|
| 1192 | float currentCost= -1;
|
---|
| 1193 |
|
---|
| 1194 | if (currentPos < costFunction.size())
|
---|
[2543] | 1195 | currentCost = costFunction[currentPos];
|
---|
[1942] | 1196 | #if 1
|
---|
[2538] | 1197 | cout<<"costFunction.size()="<<(int)costFunction.size()<<endl;
|
---|
[1252] | 1198 | cout<<"CP="<<currentPos<<endl;
|
---|
| 1199 | cout<<"MC="<<maxCost<<endl;
|
---|
| 1200 | cout<<"CC="<<currentCost<<endl;
|
---|
| 1201 | #endif
|
---|
| 1202 | if (costFunction.size()) {
|
---|
[2543] | 1203 | float scaley = 1.0f/log10(maxCost);
|
---|
| 1204 | float scalex = 1.0f/(float)costFunction.size();
|
---|
[1942] | 1205 |
|
---|
[2543] | 1206 | glDisable(GL_DEPTH_TEST);
|
---|
| 1207 | // init ortographic projection
|
---|
| 1208 | glMatrixMode(GL_PROJECTION);
|
---|
[1252] | 1209 |
|
---|
[2543] | 1210 | glPushMatrix();
|
---|
| 1211 |
|
---|
| 1212 | glLoadIdentity();
|
---|
| 1213 | gluOrtho2D(0, 1.0f, 0, 1.0f);
|
---|
| 1214 |
|
---|
| 1215 | glTranslatef(0.1f, 0.1f, 0.0f);
|
---|
| 1216 | glScalef(0.8f, 0.8f, 1.0f);
|
---|
| 1217 | glMatrixMode(GL_MODELVIEW);
|
---|
| 1218 | glLoadIdentity();
|
---|
| 1219 |
|
---|
| 1220 | glColor3f(1.0f,0,0);
|
---|
| 1221 | glBegin(GL_LINE_STRIP);
|
---|
| 1222 | // glVertex3f(0,0,0);
|
---|
| 1223 |
|
---|
| 1224 | for (int i=0; i < costFunction.size(); i++) {
|
---|
| 1225 | float x = i*scalex;
|
---|
| 1226 | float y = log10(costFunction[i])*scaley;
|
---|
| 1227 | glVertex3f(x,y,0.0f);
|
---|
| 1228 | }
|
---|
| 1229 | glEnd();
|
---|
| 1230 |
|
---|
| 1231 | glColor3f(1.0f,0,0);
|
---|
| 1232 | glBegin(GL_LINES);
|
---|
| 1233 | float x = currentPos*scalex;
|
---|
[1252] | 1234 | glVertex3f(x,0.0,0.0f);
|
---|
| 1235 | glVertex3f(x,1.0f,0.0f);
|
---|
[2543] | 1236 | glEnd();
|
---|
[1252] | 1237 |
|
---|
[2543] | 1238 | glColor3f(0.0f,0,0);
|
---|
| 1239 | // show a grid
|
---|
| 1240 | glBegin(GL_LINE_LOOP);
|
---|
| 1241 | glVertex3f(0,0,0.0f);
|
---|
| 1242 | glVertex3f(1,0,0.0f);
|
---|
| 1243 | glVertex3f(1,1,0.0f);
|
---|
| 1244 | glVertex3f(0,1,0.0f);
|
---|
| 1245 | glEnd();
|
---|
[1252] | 1246 |
|
---|
[2543] | 1247 | glBegin(GL_LINES);
|
---|
| 1248 | for (int i=0; i < costFunction.size(); i += 1000) {
|
---|
| 1249 | float x = i*scalex;
|
---|
| 1250 | glVertex3f(x,0.0,0.0f);
|
---|
| 1251 | glVertex3f(x,1.0f,0.0f);
|
---|
| 1252 | }
|
---|
[1252] | 1253 |
|
---|
[2543] | 1254 | for (int i=0; pow(10.0f, i) < maxCost; i+=1) {
|
---|
| 1255 | float y = i*scaley;
|
---|
| 1256 | // QString s;
|
---|
| 1257 | // s.sprintf("%d", (int)pow(10,i));
|
---|
| 1258 | // renderText(width()/2+5, y*height(), s);
|
---|
| 1259 | glVertex3f(0.0f, y, 0.0f);
|
---|
| 1260 | glVertex3f(1.0f, y, 0.0f);
|
---|
| 1261 | }
|
---|
[1252] | 1262 |
|
---|
[2543] | 1263 | glEnd();
|
---|
| 1264 |
|
---|
| 1265 |
|
---|
| 1266 | // restore the projection matrix
|
---|
| 1267 | glMatrixMode(GL_PROJECTION);
|
---|
| 1268 | glPopMatrix();
|
---|
| 1269 | glMatrixMode(GL_MODELVIEW);
|
---|
| 1270 | glEnable(GL_DEPTH_TEST);
|
---|
| 1271 |
|
---|
[1252] | 1272 | }
|
---|
[1942] | 1273 |
|
---|
| 1274 |
|
---|
[2543] | 1275 |
|
---|
[1252] | 1276 | }
|
---|
| 1277 |
|
---|
[1942] | 1278 | void
|
---|
| 1279 | QtGlRendererWidget::RenderInfo()
|
---|
| 1280 | {
|
---|
[1983] | 1281 |
|
---|
[2543] | 1282 | QString s;
|
---|
[2604] | 1283 |
|
---|
[2543] | 1284 | int vc = 0;
|
---|
| 1285 | if (mViewCellsManager)
|
---|
| 1286 | vc = (int)mViewCellsManager->GetViewCells().size();
|
---|
[1252] | 1287 |
|
---|
[2543] | 1288 | int filter = 0;
|
---|
| 1289 | if (mViewCellsManager)
|
---|
| 1290 | filter = mViewCellsManager->GetMaxFilterSize();
|
---|
[1942] | 1291 |
|
---|
[2604] | 1292 | glColor3f(0.0f, 0.0f, 1.0f);
|
---|
[1942] | 1293 |
|
---|
[2604] | 1294 | #if REMOVE_TEMPORARY
|
---|
[2543] | 1295 | s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)",
|
---|
| 1296 | mFrame,
|
---|
| 1297 | mViewPoint.x,
|
---|
| 1298 | mViewPoint.y,
|
---|
| 1299 | mViewPoint.z,
|
---|
| 1300 | mViewDirection.x,
|
---|
| 1301 | mViewDirection.y,
|
---|
| 1302 | mViewDirection.z
|
---|
| 1303 | );
|
---|
[1942] | 1304 |
|
---|
[2604] | 1305 | renderText(20, 20, s);
|
---|
[1942] | 1306 |
|
---|
[2543] | 1307 | s.sprintf("viewcells:%04d filter:%04d pvs:%04d error:%5.5f %",
|
---|
| 1308 | vc,
|
---|
| 1309 | filter,
|
---|
| 1310 | mPvsSize,
|
---|
| 1311 | mRenderError*100.0f);
|
---|
[1942] | 1312 |
|
---|
[2604] | 1313 | renderText(20, 40, s);
|
---|
| 1314 | #endif
|
---|
[2644] | 1315 |
|
---|
[2604] | 1316 | QFont font40; font40.setPointSize(30);
|
---|
[2643] | 1317 | //s.sprintf("PVS: %04d", mPvsSize);
|
---|
| 1318 | //renderText(20, 40, s, font40);
|
---|
[2638] | 1319 |
|
---|
[2643] | 1320 | //s.sprintf("RAW TRI: %07d", mViewCellsManager->GetPreprocessor()->mGenericStats);
|
---|
| 1321 | //renderText(290, 40, s, font40);
|
---|
| 1322 | //s.sprintf("PVS TRI: %07d", mViewCellsManager->GetPreprocessor()->mGenericStats2);
|
---|
| 1323 | //renderText(290, 70, s, font40);
|
---|
| 1324 |
|
---|
| 1325 | s.sprintf("PVS TRI: %07d", (int)mCurrentPvsCost);
|
---|
| 1326 | renderText(290, 70, s, font40);
|
---|
| 1327 | //renderText(290, 70, s, font40);
|
---|
| 1328 |
|
---|
[1942] | 1329 | }
|
---|
| 1330 |
|
---|
| 1331 |
|
---|
[1252] | 1332 | void
|
---|
| 1333 | QtGlRendererWidget::SetViewCellGranularity(int number)
|
---|
| 1334 | {
|
---|
[2643] | 1335 | if (mViewCellsManager)
|
---|
| 1336 | {
|
---|
| 1337 | // mViewCellsManager->SetMaxFilterSize(number);
|
---|
[1252] | 1338 |
|
---|
[2543] | 1339 | // $$ tmp off
|
---|
| 1340 | mViewCellsManager->CollectViewCells(number);
|
---|
[1983] | 1341 |
|
---|
[2543] | 1342 | // $$ does not work so far:(
|
---|
| 1343 | // mViewCellsManager->UpdatePvsForEvaluation();
|
---|
| 1344 | // mViewCellsManager->FinalizeViewCells(false);
|
---|
| 1345 | }
|
---|
| 1346 | updateGL();
|
---|
[1252] | 1347 | }
|
---|
| 1348 |
|
---|
| 1349 | void
|
---|
| 1350 | QtGlRendererWidget::SetVisibilityFilterSize(int number)
|
---|
| 1351 | {
|
---|
[2543] | 1352 | if (mViewCellsManager)
|
---|
| 1353 | mViewCellsManager->SetMaxFilterSize(number);
|
---|
[2643] | 1354 |
|
---|
[2543] | 1355 | mPvsCache.Reset();
|
---|
| 1356 | updateGL();
|
---|
[1252] | 1357 | }
|
---|
| 1358 |
|
---|
| 1359 | void
|
---|
| 1360 | QtGlRendererWidget::SetSpatialFilterSize(int number)
|
---|
| 1361 | {
|
---|
[2543] | 1362 | mSpatialFilterSize = 1e-3*number;
|
---|
| 1363 | mPvsCache.Reset();
|
---|
| 1364 | updateGL();
|
---|
[1252] | 1365 | }
|
---|
| 1366 |
|
---|
| 1367 | void
|
---|
| 1368 | QtGlRendererWidget::SetSceneCut(int number)
|
---|
| 1369 | {
|
---|
[2543] | 1370 | // assume the cut plane can only be aligned with xz plane
|
---|
| 1371 | // shift it along y according to number, which is percentage of the bounding
|
---|
| 1372 | // box position
|
---|
[2562] | 1373 | if (mViewCellsManager)
|
---|
| 1374 | {
|
---|
[2571] | 1375 | const float f = number / 1000.0f;
|
---|
[2543] | 1376 | AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox();
|
---|
[2571] | 1377 | Vector3 p = (1.0f - f) * box.Min() + f * box.Max();
|
---|
[2643] | 1378 | mSceneCutPlane.mNormal = Vector3(0, -1, 0);
|
---|
[2543] | 1379 | mSceneCutPlane.mD = -DotProd(mSceneCutPlane.mNormal, p);
|
---|
[2562] | 1380 |
|
---|
[2543] | 1381 | updateGL();
|
---|
| 1382 | }
|
---|
[1252] | 1383 | }
|
---|
| 1384 |
|
---|
| 1385 | void
|
---|
[2562] | 1386 | QtGlRendererWidget::SetHidingCost(int number)
|
---|
| 1387 | {
|
---|
| 1388 | mHidingCost = (float)number / 1000.0f;
|
---|
| 1389 | }
|
---|
| 1390 |
|
---|
| 1391 |
|
---|
| 1392 | void
|
---|
[1252] | 1393 | QtGlRendererWidget::SetTopDistance(int number)
|
---|
| 1394 | {
|
---|
[2569] | 1395 | mTopDistance = number / 1000.0f;
|
---|
[2543] | 1396 | updateGL();
|
---|
[1252] | 1397 | }
|
---|
| 1398 |
|
---|
[2569] | 1399 | void QtGlRendererWidget::SetTransparency(int number)
|
---|
[2563] | 1400 | {
|
---|
[2569] | 1401 | mTransparency = number / 1000.0f;
|
---|
[2563] | 1402 | updateGL();
|
---|
| 1403 | }
|
---|
| 1404 |
|
---|
[2570] | 1405 | #if 0
|
---|
[2569] | 1406 | float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc)
|
---|
| 1407 | {
|
---|
| 1408 | ObjectPvs basePvs;
|
---|
| 1409 |
|
---|
| 1410 | basePvs = vc->CopyPvs();
|
---|
| 1411 | ObjectPvsIterator pit = basePvs.GetIterator();
|
---|
| 1412 |
|
---|
| 1413 | float renderCost = 0;
|
---|
| 1414 |
|
---|
| 1415 | //cout << "cost vis: " << mShowDistanceWeightedPvs << " " << " " << mShowDistanceWeightedTriangles << " " << mShowWeightedTriangles << endl;
|
---|
| 1416 |
|
---|
| 1417 | // first mark all objects from this pvs
|
---|
| 1418 | while (pit.HasMoreEntries())
|
---|
| 1419 | {
|
---|
[2615] | 1420 | KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next());
|
---|
| 1421 |
|
---|
[2569] | 1422 | if (mShowDistanceWeightedPvs)
|
---|
| 1423 | {
|
---|
| 1424 | const AxisAlignedBox3 box = kdObj->GetBox();
|
---|
| 1425 |
|
---|
| 1426 | const float dist = SqrDistance(vc->GetBox().Center(), box.Center());
|
---|
| 1427 | renderCost += 1.0f / dist;
|
---|
| 1428 | }
|
---|
| 1429 | else if (mShowDistanceWeightedTriangles)
|
---|
| 1430 | {
|
---|
| 1431 | const AxisAlignedBox3 box = kdObj->GetBox();
|
---|
| 1432 |
|
---|
| 1433 | const float dist = SqrDistance(vc->GetBox().Center(), box.Center());
|
---|
| 1434 | renderCost += kdObj->ComputeNumTriangles() / dist;
|
---|
| 1435 | }
|
---|
| 1436 | else //if (mShowWeightedTriangles)
|
---|
| 1437 | {
|
---|
| 1438 | renderCost += kdObj->ComputeNumTriangles();
|
---|
| 1439 | }
|
---|
| 1440 | //if (pit.Next()->Mail();
|
---|
| 1441 | }
|
---|
| 1442 |
|
---|
| 1443 | return renderCost;
|
---|
| 1444 | }
|
---|
[2570] | 1445 | #else
|
---|
[2569] | 1446 |
|
---|
[2570] | 1447 | float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc)
|
---|
| 1448 | {
|
---|
| 1449 | float renderCost = 0;
|
---|
[2569] | 1450 |
|
---|
[2633] | 1451 | #ifdef USE_VERBOSE_PVS
|
---|
[2570] | 1452 | if (mShowDistanceWeightedPvs)
|
---|
| 1453 | {
|
---|
| 1454 | return vc->GetPvs().mStats.mDistanceWeightedPvs;
|
---|
| 1455 | }
|
---|
| 1456 | else if (mShowDistanceWeightedTriangles)
|
---|
| 1457 | {
|
---|
| 1458 | return vc->GetPvs().mStats.mDistanceWeightedTriangles;
|
---|
| 1459 | }
|
---|
| 1460 | else //if (mShowWeightedTriangles)
|
---|
| 1461 | {
|
---|
| 1462 | return vc->GetPvs().mStats.mWeightedTriangles;
|
---|
| 1463 | }
|
---|
[2617] | 1464 | #else
|
---|
| 1465 | return 0.0f;
|
---|
| 1466 | #endif
|
---|
[2570] | 1467 | }
|
---|
| 1468 | #endif
|
---|
| 1469 |
|
---|
[1252] | 1470 |
|
---|
[2049] | 1471 |
|
---|
[2576] | 1472 | void QtGlRendererWidget::ComputeMaxValues(const ViewCellContainer &viewCells,
|
---|
| 1473 | int &maxPvs,
|
---|
| 1474 | int &maxPiercingRays,
|
---|
| 1475 | float &maxRelativeRays,
|
---|
| 1476 | float &maxRcCost)
|
---|
| 1477 | {
|
---|
| 1478 | maxPvs = -1;
|
---|
| 1479 | maxPiercingRays = 1; // not zero for savety
|
---|
| 1480 | maxRelativeRays = Limits::Small; // not zero for savety
|
---|
| 1481 | maxRcCost = Limits::Small;
|
---|
[1252] | 1482 |
|
---|
[2576] | 1483 | for (size_t i = 0; i < viewCells.size(); ++ i)
|
---|
[2560] | 1484 | {
|
---|
[2576] | 1485 | ViewCell *vc = viewCells[i];
|
---|
[1252] | 1486 |
|
---|
[2571] | 1487 | if (mShowPvsSizes) // pvs size
|
---|
[2569] | 1488 | {
|
---|
| 1489 | //const int p = vc->GetPvs().CountObjectsInPvs();
|
---|
| 1490 | const int p = vc->GetPvs().GetSize();
|
---|
| 1491 | if (p > maxPvs)
|
---|
| 1492 | maxPvs = p;
|
---|
| 1493 | }
|
---|
| 1494 | else if (mShowPiercingRays) // relative number of rays
|
---|
| 1495 | {
|
---|
| 1496 | const int piercingRays = vc->GetNumPiercingRays();
|
---|
[2562] | 1497 |
|
---|
[2569] | 1498 | if (piercingRays > maxPiercingRays)
|
---|
| 1499 | maxPiercingRays = piercingRays;
|
---|
| 1500 | }
|
---|
| 1501 | else if (mShowWeightedRays)
|
---|
| 1502 | {
|
---|
| 1503 | const int piercingRays = vc->GetNumPiercingRays();
|
---|
[2566] | 1504 |
|
---|
[2569] | 1505 | const float relativeArea =
|
---|
| 1506 | vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
|
---|
[2566] | 1507 |
|
---|
[2569] | 1508 | if ((float)piercingRays / relativeArea > maxRelativeRays)
|
---|
| 1509 | maxRelativeRays = (float)piercingRays / relativeArea;
|
---|
| 1510 | }
|
---|
| 1511 | else if (mShowWeightedCost)
|
---|
| 1512 | {
|
---|
| 1513 | const float rcCost = ComputeRenderCost(vc);
|
---|
| 1514 | mViewCellsManager->UpdateScalarPvsCost(vc, rcCost);
|
---|
| 1515 |
|
---|
| 1516 | if (rcCost > maxRcCost)
|
---|
| 1517 | maxRcCost = rcCost;
|
---|
| 1518 | }
|
---|
[2543] | 1519 | }
|
---|
[2576] | 1520 | }
|
---|
[1252] | 1521 |
|
---|
[2576] | 1522 |
|
---|
| 1523 | void QtGlRendererWidget::RenderViewCells()
|
---|
| 1524 | {
|
---|
| 1525 | mUseFalseColors = true;
|
---|
| 1526 | //glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT);
|
---|
| 1527 |
|
---|
| 1528 | glEnable(GL_CULL_FACE);
|
---|
| 1529 | glCullFace(GL_FRONT);
|
---|
| 1530 | //glDisable(GL_CULL_FACE);
|
---|
| 1531 |
|
---|
| 1532 | if (mCutViewCells)
|
---|
| 1533 | {
|
---|
[2601] | 1534 | double eq[4];
|
---|
| 1535 | eq[0] = mSceneCutPlane.mNormal.x;
|
---|
| 1536 | eq[1] = mSceneCutPlane.mNormal.y;
|
---|
| 1537 | eq[2] = mSceneCutPlane.mNormal.z;
|
---|
| 1538 | eq[3] = mSceneCutPlane.mD;
|
---|
| 1539 |
|
---|
[2576] | 1540 | glClipPlane(GL_CLIP_PLANE0, eq);
|
---|
| 1541 | glEnable(GL_CLIP_PLANE0);
|
---|
| 1542 | }
|
---|
| 1543 |
|
---|
| 1544 | ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
|
---|
[2584] | 1545 |
|
---|
[2576] | 1546 | int maxPvs, maxPiercingRays;
|
---|
| 1547 | float maxRelativeRays, maxRcCost;
|
---|
| 1548 |
|
---|
| 1549 | ComputeMaxValues(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
|
---|
[2633] | 1550 |
|
---|
[2615] | 1551 | // matt: temp hack
|
---|
[2633] | 1552 | //maxRcCost = 5000.0f;
|
---|
[2615] | 1553 | //cout << "maxRcCost: " << maxRcCost << endl;
|
---|
[2633] | 1554 |
|
---|
[2581] | 1555 | int i;
|
---|
[2576] | 1556 |
|
---|
[2604] | 1557 | // transparency
|
---|
| 1558 | if (!mUseTransparency)
|
---|
| 1559 | {
|
---|
| 1560 | glEnable(GL_DEPTH_TEST);
|
---|
| 1561 | glDisable(GL_BLEND);
|
---|
| 1562 | }
|
---|
| 1563 | else
|
---|
| 1564 | {
|
---|
| 1565 | glDisable(GL_DEPTH_TEST);
|
---|
| 1566 | glEnable(GL_BLEND);
|
---|
| 1567 |
|
---|
| 1568 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
---|
| 1569 | //glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
---|
| 1570 |
|
---|
| 1571 | for (i = 0; i < viewcells.size(); ++ i)
|
---|
| 1572 | {
|
---|
| 1573 | ViewCell *vc = viewcells[i];
|
---|
| 1574 |
|
---|
| 1575 | const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center());
|
---|
| 1576 | vc->SetDistance(dist);
|
---|
| 1577 | }
|
---|
| 1578 |
|
---|
| 1579 | sort(viewcells.begin(), viewcells.end(), nearerThan);
|
---|
| 1580 | }
|
---|
| 1581 |
|
---|
| 1582 | //mWireFrame = true;
|
---|
| 1583 |
|
---|
[2601] | 1584 | // normal rendering
|
---|
[2604] | 1585 | //if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost && !mShowComparison)
|
---|
| 1586 | if (mUseStandardColors)
|
---|
[2560] | 1587 | {
|
---|
[2562] | 1588 | for (i = 0; i < viewcells.size(); ++ i)
|
---|
| 1589 | {
|
---|
| 1590 | ViewCell *vc = viewcells[i];
|
---|
| 1591 | RgbColor c;
|
---|
[2543] | 1592 |
|
---|
[2604] | 1593 | //if (!mShowPvsSizes && !mShowPiercingRays)
|
---|
| 1594 | c = vc->GetColor();
|
---|
| 1595 |
|
---|
[2562] | 1596 | glColor3f(c.r, c.g, c.b);
|
---|
| 1597 |
|
---|
[2569] | 1598 | if (!mHideByCost || (mHidingCost < (vc->GetNumPiercingRays() / (float)maxPiercingRays)))
|
---|
[2562] | 1599 | {
|
---|
| 1600 | RenderViewCell(vc);
|
---|
| 1601 | }
|
---|
| 1602 | }
|
---|
| 1603 | }
|
---|
[2601] | 1604 | else // using specialised colors
|
---|
[2562] | 1605 | {
|
---|
[2584] | 1606 | if (!mShowComparison)
|
---|
[2576] | 1607 | AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
|
---|
| 1608 | else
|
---|
[2577] | 1609 | {
|
---|
[2584] | 1610 | if (mCompareInfo.empty())
|
---|
| 1611 | {
|
---|
| 1612 | LogReader reader;
|
---|
| 1613 | reader.SetFilename("compare.log");
|
---|
| 1614 | int samples;
|
---|
| 1615 | reader.Read(samples, mCompareInfo);
|
---|
| 1616 | }
|
---|
[2580] | 1617 |
|
---|
[2584] | 1618 | AssignColorByComparison(viewcells, mCompareInfo);
|
---|
[2577] | 1619 | }
|
---|
[2566] | 1620 |
|
---|
[2562] | 1621 | glEnable(GL_DEPTH_TEST);
|
---|
[1252] | 1622 | }
|
---|
[2571] | 1623 |
|
---|
| 1624 | glEnable(GL_CULL_FACE);
|
---|
| 1625 | glDisable(GL_CULL_FACE);
|
---|
[1252] | 1626 |
|
---|
[2571] | 1627 | glDisable(GL_CLIP_PLANE0);
|
---|
| 1628 |
|
---|
[2543] | 1629 | mUseFalseColors = false;
|
---|
| 1630 | mWireFrame = false;
|
---|
[1942] | 1631 |
|
---|
[2543] | 1632 | glPopAttrib();
|
---|
[1252] | 1633 | }
|
---|
| 1634 |
|
---|
| 1635 |
|
---|
[2576] | 1636 | void QtGlRendererWidget::AssignImportanceByRelativeValue(const ViewCellContainer &viewCells,
|
---|
| 1637 | int &maxPvs,
|
---|
| 1638 | int &maxPiercingRays,
|
---|
| 1639 | float &maxRelativeRays,
|
---|
| 1640 | float &maxRcCost)
|
---|
| 1641 | {
|
---|
| 1642 | for (size_t i = 0; i < viewCells.size(); ++ i)
|
---|
| 1643 | {
|
---|
| 1644 | RgbColor c;
|
---|
| 1645 | ViewCell *vc = viewCells[i];
|
---|
[1252] | 1646 |
|
---|
[2576] | 1647 | float importance;
|
---|
[1252] | 1648 |
|
---|
[2576] | 1649 | if (mShowPiercingRays)
|
---|
| 1650 | {
|
---|
| 1651 | importance = mTransferFunction *
|
---|
| 1652 | ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays);
|
---|
| 1653 | }
|
---|
| 1654 | else if (mShowWeightedRays) // relative number of rays
|
---|
| 1655 | {
|
---|
| 1656 | float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
|
---|
[1252] | 1657 |
|
---|
[2576] | 1658 | if (relativeArea < Limits::Small)
|
---|
| 1659 | relativeArea = Limits::Small;
|
---|
| 1660 |
|
---|
| 1661 | importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays;
|
---|
| 1662 | }
|
---|
| 1663 | else if (mShowPvsSizes) // pvs size
|
---|
| 1664 | {
|
---|
| 1665 | importance = mTransferFunction *
|
---|
| 1666 | ((float)vc->GetPvs().GetSize() / (float)maxPvs);
|
---|
| 1667 | } // weighted render cost
|
---|
| 1668 | else if (mShowWeightedCost)
|
---|
| 1669 | {
|
---|
| 1670 | const float rcCost = mTransferFunction * ComputeRenderCost(vc);
|
---|
| 1671 | importance = rcCost / maxRcCost;
|
---|
| 1672 | }
|
---|
[2615] | 1673 | if (importance > 1.0f) importance = 1.0f;
|
---|
[2576] | 1674 | // c = RgbColor(importance, 1.0f - importance, 0.0f);
|
---|
| 1675 | c = RainbowColorMapping(importance);
|
---|
| 1676 |
|
---|
| 1677 | glColor4f(c.r, c.g, c.b, 1.0f - mTransparency);
|
---|
| 1678 |
|
---|
| 1679 | if (!mHideByCost || (mHidingCost < importance))
|
---|
| 1680 | {
|
---|
| 1681 | RenderViewCell(vc);
|
---|
| 1682 | }
|
---|
| 1683 | }
|
---|
[1252] | 1684 | }
|
---|
| 1685 |
|
---|
| 1686 |
|
---|
[2576] | 1687 | void QtGlRendererWidget::AssignColorByComparison(const ViewCellContainer &viewcells,
|
---|
[2580] | 1688 | //const ViewCellInfoContainer &infos1,
|
---|
| 1689 | const ViewCellInfoContainer &compareInfo)
|
---|
[1252] | 1690 | {
|
---|
[2584] | 1691 | if (viewcells.size() > compareInfo.size())
|
---|
| 1692 | {
|
---|
[2663] | 1693 | cerr << "loaded size (" << (int)compareInfo.size()
|
---|
| 1694 | << ") does not fit to view cells size (" << (int)viewcells.size() << ")" << endl;
|
---|
[2584] | 1695 | return;
|
---|
| 1696 | }
|
---|
[2576] | 1697 |
|
---|
[2584] | 1698 | //const float maxRatio = 1.0f;
|
---|
| 1699 | const float maxRatio = 2.0f;
|
---|
| 1700 | const float minRatio = 0.0f;
|
---|
| 1701 |
|
---|
[2576] | 1702 | const float scale = 1.0f / (maxRatio - minRatio);
|
---|
| 1703 |
|
---|
| 1704 | for (size_t i = 0; i < viewcells.size(); ++ i)
|
---|
| 1705 | {
|
---|
| 1706 | RgbColor c;
|
---|
| 1707 | ViewCell *vc = viewcells[i];
|
---|
| 1708 |
|
---|
[2580] | 1709 | //ViewCellInfo vc1Info = infos1[i];
|
---|
| 1710 | ViewCellInfo vc2Info = compareInfo[i];
|
---|
[2576] | 1711 |
|
---|
[2584] | 1712 | //const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small;
|
---|
| 1713 | float vcRatio = 1.0f;//maxRatio;
|
---|
| 1714 |
|
---|
| 1715 | if (vc2Info.mPvsSize > Limits::Small)
|
---|
| 1716 | vcRatio = (float)vc->GetPvs().GetSize() / vc2Info.mPvsSize;
|
---|
[2576] | 1717 |
|
---|
[2584] | 1718 | // truncate here
|
---|
| 1719 | if (vcRatio > maxRatio) vcRatio = 1.0f;
|
---|
| 1720 |
|
---|
[2576] | 1721 | const float importance = (vcRatio - minRatio) * scale;
|
---|
[2584] | 1722 |
|
---|
[2593] | 1723 | if (0 && (i < 20))
|
---|
[2584] | 1724 | {
|
---|
| 1725 | cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " << compareInfo[i].mPvsSize << " importance: " << importance << endl;
|
---|
| 1726 | }
|
---|
[2576] | 1727 |
|
---|
| 1728 | // c = RgbColor(importance, 1.0f - importance, 0.0f);
|
---|
| 1729 | c = RainbowColorMapping(importance);
|
---|
| 1730 |
|
---|
| 1731 | glColor4f(c.r, c.g, c.b, 1.0f);
|
---|
| 1732 |
|
---|
| 1733 | if (1)//!mHideByCost || (mHidingCost < importance))
|
---|
| 1734 | {
|
---|
| 1735 | RenderViewCell(vc);
|
---|
| 1736 | }
|
---|
| 1737 | }
|
---|
[1252] | 1738 | }
|
---|
| 1739 |
|
---|
| 1740 |
|
---|
[2576] | 1741 |
|
---|
| 1742 | /**********************************************************************/
|
---|
| 1743 | /* QtRendererControlWidget implementation */
|
---|
| 1744 | /**********************************************************************/
|
---|
| 1745 |
|
---|
[2580] | 1746 |
|
---|
[2569] | 1747 | QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent)
|
---|
| 1748 | {
|
---|
| 1749 | QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5;
|
---|
| 1750 |
|
---|
[2604] | 1751 | rb1 = new QRadioButton("random colors", parent);
|
---|
[2614] | 1752 | rb1->setText("random");
|
---|
[2587] | 1753 | connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool)));
|
---|
| 1754 |
|
---|
[2569] | 1755 | // Create a check box to be in the group box
|
---|
[2587] | 1756 | rb2 = new QRadioButton("piercing rays", parent);
|
---|
| 1757 | rb2->setText("piercing rays");
|
---|
[2569] | 1758 | //vl->addWidget(rb1);
|
---|
[2587] | 1759 | connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool)));
|
---|
[2569] | 1760 |
|
---|
[2587] | 1761 | rb3 = new QRadioButton("pvs size", parent);
|
---|
| 1762 | rb3->setText("pvs size");
|
---|
| 1763 | connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool)));
|
---|
[2569] | 1764 |
|
---|
| 1765 | rb4 = new QRadioButton("weighted rays", parent);
|
---|
| 1766 | rb4->setText("weighted rays");
|
---|
| 1767 | connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool)));
|
---|
| 1768 |
|
---|
| 1769 | rb5 = new QRadioButton("pvs cost", parent);
|
---|
| 1770 | rb5->setText("pvs cost");
|
---|
| 1771 | connect(rb5, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedCost(bool)));
|
---|
| 1772 |
|
---|
[2615] | 1773 | QGroupBox *groupBox = new QGroupBox("PVS Visualization");
|
---|
[2569] | 1774 |
|
---|
| 1775 | QVBoxLayout *vbox2 = new QVBoxLayout;
|
---|
| 1776 |
|
---|
| 1777 | vbox2->addWidget(rb1);
|
---|
| 1778 | vbox2->addWidget(rb2);
|
---|
[2587] | 1779 | vbox2->addWidget(rb3);
|
---|
[2569] | 1780 | vbox2->addWidget(rb4);
|
---|
| 1781 | vbox2->addWidget(rb5);
|
---|
| 1782 |
|
---|
[2604] | 1783 | rb5->setChecked(true);
|
---|
[2569] | 1784 |
|
---|
| 1785 | vbox2->addStretch(1);
|
---|
| 1786 | groupBox->setLayout(vbox2);
|
---|
| 1787 |
|
---|
| 1788 | return groupBox;
|
---|
| 1789 | }
|
---|
| 1790 |
|
---|
| 1791 |
|
---|
[2614] | 1792 | QGroupBox *QtRendererControlWidget::CreateTrafoPanel(QWidget *parent)
|
---|
| 1793 | {
|
---|
| 1794 | QRadioButton *rb1, *rb2, *rb3;
|
---|
| 1795 |
|
---|
| 1796 | rb1 = new QRadioButton("translation", parent);
|
---|
| 1797 | rb1->setText("translation");
|
---|
| 1798 | connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetTranslation(bool)));
|
---|
[2569] | 1799 |
|
---|
[2614] | 1800 | // Create a check box to be in the group box
|
---|
| 1801 | rb2 = new QRadioButton("scale", parent);
|
---|
| 1802 | rb2->setText("scale");
|
---|
| 1803 | //vl->addWidget(rb1);
|
---|
| 1804 | connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetScale(bool)));
|
---|
| 1805 |
|
---|
| 1806 | rb3 = new QRadioButton("rotation", parent);
|
---|
| 1807 | rb3->setText("rotation");
|
---|
| 1808 | connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetRotation(bool)));
|
---|
| 1809 |
|
---|
| 1810 | QVBoxLayout *vbox2 = new QVBoxLayout;
|
---|
| 1811 | QGroupBox *groupBox = new QGroupBox("Trafo types");
|
---|
| 1812 |
|
---|
| 1813 | vbox2->addWidget(rb1);
|
---|
| 1814 | vbox2->addWidget(rb2);
|
---|
| 1815 | vbox2->addWidget(rb3);
|
---|
| 1816 |
|
---|
| 1817 | rb1->setChecked(true);
|
---|
| 1818 |
|
---|
| 1819 | vbox2->addStretch(1);
|
---|
[2636] | 1820 |
|
---|
| 1821 |
|
---|
| 1822 | QPushButton *button = new QPushButton("Update", groupBox);
|
---|
| 1823 | vbox2->addWidget(button);
|
---|
| 1824 | connect(button, SIGNAL(clicked()), SIGNAL(UpdateDynamicObjects()));
|
---|
| 1825 |
|
---|
| 1826 |
|
---|
[2614] | 1827 | groupBox->setLayout(vbox2);
|
---|
[2636] | 1828 |
|
---|
[2614] | 1829 | return groupBox;
|
---|
| 1830 | }
|
---|
| 1831 |
|
---|
| 1832 |
|
---|
[2569] | 1833 | QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent)
|
---|
| 1834 | {
|
---|
| 1835 | QRadioButton *rb1, *rb2, *rb3;
|
---|
| 1836 |
|
---|
| 1837 | // Create a check box to be in the group box
|
---|
| 1838 | rb1 = new QRadioButton("triangles", parent);
|
---|
| 1839 | rb1->setText("triangles");
|
---|
| 1840 | connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedTriangles(bool)));
|
---|
| 1841 |
|
---|
| 1842 | rb2 = new QRadioButton("distance weighted pvs", parent);
|
---|
| 1843 | rb2->setText("distance weighted");
|
---|
| 1844 | connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedPvs(bool)));
|
---|
| 1845 |
|
---|
| 1846 | rb3 = new QRadioButton("distance weighted triangles", parent);
|
---|
| 1847 | rb3->setText("distance weighted triangles");
|
---|
| 1848 | connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedTriangles(bool)));
|
---|
| 1849 |
|
---|
| 1850 | QGroupBox *groupBox = new QGroupBox("Render cost options");
|
---|
| 1851 | QVBoxLayout *vbox2 = new QVBoxLayout;
|
---|
| 1852 |
|
---|
| 1853 | vbox2->addWidget(rb1);
|
---|
| 1854 | vbox2->addWidget(rb2);
|
---|
| 1855 | vbox2->addWidget(rb3);
|
---|
| 1856 |
|
---|
[2587] | 1857 | rb1->setChecked(true);
|
---|
[2569] | 1858 |
|
---|
| 1859 | vbox2->addStretch(1);
|
---|
| 1860 | groupBox->setLayout(vbox2);
|
---|
| 1861 |
|
---|
| 1862 | return groupBox;
|
---|
| 1863 | }
|
---|
| 1864 |
|
---|
[2576] | 1865 |
|
---|
[2587] | 1866 | QGroupBox *QtRendererControlWidget::CreateRayVisualizationPanel(QWidget *parent)
|
---|
| 1867 | {
|
---|
| 1868 | QRadioButton *rb1, *rb2, *rb3, *rb4;
|
---|
| 1869 |
|
---|
| 1870 | // Create a check box to be in the group box
|
---|
| 1871 | rb1 = new QRadioButton("const color", parent);
|
---|
| 1872 | rb1->setText("const color");
|
---|
| 1873 | //vl->addWidget(rb1);
|
---|
| 1874 | connect(rb1, SIGNAL(toggled(bool)), SIGNAL(UseConstColorForRayViz(bool)));
|
---|
| 1875 |
|
---|
| 1876 | rb2 = new QRadioButton("ray length", parent);
|
---|
| 1877 | rb2->setText("ray length");
|
---|
| 1878 | connect(rb2, SIGNAL(toggled(bool)), SIGNAL(UseRayLengthForRayViz(bool)));
|
---|
| 1879 |
|
---|
| 1880 | rb3 = new QRadioButton("contribution", parent);
|
---|
| 1881 | rb3->setText("contribution");
|
---|
| 1882 | connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowContribution(bool)));
|
---|
| 1883 |
|
---|
| 1884 | rb4 = new QRadioButton("distribution", parent);
|
---|
| 1885 | rb4->setText("distribution");
|
---|
| 1886 | connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowDistribution(bool)));
|
---|
| 1887 |
|
---|
[2591] | 1888 |
|
---|
| 1889 | ///////////////////////////
|
---|
| 1890 |
|
---|
| 1891 |
|
---|
[2615] | 1892 | QGroupBox *groupBox = new QGroupBox("Ray visualization");
|
---|
[2587] | 1893 | QVBoxLayout *vbox2 = new QVBoxLayout;
|
---|
| 1894 |
|
---|
| 1895 | vbox2->addWidget(rb1);
|
---|
| 1896 | vbox2->addWidget(rb2);
|
---|
| 1897 | vbox2->addWidget(rb3);
|
---|
| 1898 | vbox2->addWidget(rb4);
|
---|
| 1899 |
|
---|
| 1900 | rb1->setChecked(true);
|
---|
| 1901 |
|
---|
[2591] | 1902 |
|
---|
| 1903 | QCheckBox *cb = new QCheckBox("Distribution 1", parent);
|
---|
| 1904 | vbox2->addWidget(cb);
|
---|
| 1905 | cb->setChecked(true);
|
---|
| 1906 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowDistribution1(bool)));
|
---|
| 1907 |
|
---|
| 1908 | cb = new QCheckBox("Distribution 2", parent);
|
---|
| 1909 | vbox2->addWidget(cb);
|
---|
| 1910 | cb->setChecked(true);
|
---|
| 1911 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowDistribution2(bool)));
|
---|
| 1912 |
|
---|
| 1913 | cb = new QCheckBox("Distribution 3", parent);
|
---|
| 1914 | vbox2->addWidget(cb);
|
---|
| 1915 | cb->setChecked(true);
|
---|
| 1916 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowDistribution3(bool)));
|
---|
| 1917 |
|
---|
| 1918 | cb = new QCheckBox("Distribution 4", parent);
|
---|
| 1919 | vbox2->addWidget(cb);
|
---|
| 1920 | cb->setChecked(true);
|
---|
| 1921 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowDistribution4(bool)));
|
---|
| 1922 |
|
---|
| 1923 |
|
---|
[2587] | 1924 | vbox2->addStretch(1);
|
---|
| 1925 | groupBox->setLayout(vbox2);
|
---|
| 1926 |
|
---|
| 1927 | return groupBox;
|
---|
| 1928 | }
|
---|
| 1929 |
|
---|
| 1930 |
|
---|
[1252] | 1931 | QtRendererControlWidget::QtRendererControlWidget(QWidget * parent, Qt::WFlags f):
|
---|
[2543] | 1932 | QWidget(parent, f)
|
---|
[1252] | 1933 | {
|
---|
| 1934 |
|
---|
[2543] | 1935 | QVBoxLayout *vl = new QVBoxLayout;
|
---|
| 1936 | setLayout(vl);
|
---|
[2615] | 1937 |
|
---|
| 1938 | //QWidget *vbox;
|
---|
[1252] | 1939 |
|
---|
[2615] | 1940 | //vbox = new QGroupBox("Render Controls", this);
|
---|
| 1941 | //layout()->addWidget(vbox);
|
---|
| 1942 | //vl = new QVBoxLayout;
|
---|
| 1943 | //vbox->setLayout(vl);
|
---|
[1252] | 1944 |
|
---|
[2604] | 1945 | QLabel *label;
|
---|
| 1946 | QSlider *slider;
|
---|
| 1947 | QPushButton *button;
|
---|
| 1948 |
|
---|
[2645] | 1949 | #if 0//REMOVE_TEMPORARY
|
---|
[2604] | 1950 |
|
---|
| 1951 | label = new QLabel("Granularity");
|
---|
[2615] | 1952 | //vbox->layout()->addWidget(label);
|
---|
| 1953 | vl->addWidget(label);
|
---|
[1942] | 1954 |
|
---|
[2644] | 1955 | slider = new QSlider(Qt::Horizontal);
|
---|
[2543] | 1956 | vl->addWidget(slider);
|
---|
| 1957 | slider->show();
|
---|
| 1958 | slider->setRange(1, 10000);
|
---|
| 1959 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 1960 | slider->setValue(200);
|
---|
[1942] | 1961 |
|
---|
[2543] | 1962 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetViewCellGranularity(int)));
|
---|
[1252] | 1963 |
|
---|
[2563] | 1964 | ///////////////////////////
|
---|
| 1965 |
|
---|
[2543] | 1966 | label = new QLabel("Transfer function");
|
---|
[2615] | 1967 | vl->addWidget(label);
|
---|
[1252] | 1968 |
|
---|
[2644] | 1969 | slider = new QSlider(Qt::Horizontal);
|
---|
[2543] | 1970 | vl->addWidget(slider);
|
---|
| 1971 | slider->show();
|
---|
| 1972 | slider->setRange(1, 10000);
|
---|
| 1973 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 1974 | slider->setValue(100);
|
---|
[1252] | 1975 |
|
---|
| 1976 |
|
---|
[2543] | 1977 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetTransferFunction(int)));
|
---|
[1252] | 1978 |
|
---|
[2563] | 1979 | ////////////////////////////////////////7
|
---|
[1252] | 1980 |
|
---|
[2644] | 1981 | button = new QPushButton("Update all PVSs");
|
---|
[2615] | 1982 | vl->addWidget(button);
|
---|
[2563] | 1983 | connect(button, SIGNAL(clicked()), SLOT(UpdateAllPvs()));
|
---|
| 1984 |
|
---|
| 1985 | ////////////////////////////////////////77777
|
---|
| 1986 |
|
---|
[2543] | 1987 | label = new QLabel("Filter size");
|
---|
[2615] | 1988 | vl->addWidget(label);
|
---|
[1942] | 1989 |
|
---|
[2644] | 1990 | slider = new QSlider(Qt::Horizontal);
|
---|
[2615] | 1991 | vl->addWidget(slider);
|
---|
[2543] | 1992 | slider->show();
|
---|
| 1993 | slider->setRange(1, 100);
|
---|
| 1994 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 1995 | slider->setValue(3);
|
---|
[1252] | 1996 |
|
---|
[2543] | 1997 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetVisibilityFilterSize(int)));
|
---|
[1252] | 1998 |
|
---|
[2604] | 1999 | #endif
|
---|
[1252] | 2000 |
|
---|
[2604] | 2001 |
|
---|
[2615] | 2002 |
|
---|
[2563] | 2003 | ///////////////////////////////////
|
---|
[1252] | 2004 |
|
---|
[2563] | 2005 |
|
---|
[2644] | 2006 | QWidget *hbox = new QWidget();
|
---|
[2543] | 2007 | vl->addWidget(hbox);
|
---|
| 2008 | QHBoxLayout *hlayout = new QHBoxLayout;
|
---|
| 2009 | hbox->setLayout(hlayout);
|
---|
[1942] | 2010 |
|
---|
[2543] | 2011 | QCheckBox *cb = new QCheckBox("Show viewcells", hbox);
|
---|
| 2012 | hlayout->addWidget(cb);
|
---|
| 2013 | cb->setChecked(false);
|
---|
| 2014 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowViewCells(bool)));
|
---|
[2615] | 2015 |
|
---|
| 2016 | cb = new QCheckBox("Render errors", hbox);
|
---|
| 2017 | hlayout->layout()->addWidget(cb);
|
---|
| 2018 | cb->setChecked(false);
|
---|
| 2019 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool)));
|
---|
[1942] | 2020 |
|
---|
[2615] | 2021 | #if REMOVE_TEMPORARY
|
---|
[2543] | 2022 | cb = new QCheckBox("Render cost curve", hbox);
|
---|
| 2023 | hlayout->addWidget(cb);
|
---|
| 2024 | cb->setChecked(false);
|
---|
| 2025 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRenderCost(bool)));
|
---|
[2615] | 2026 | #endif
|
---|
[2543] | 2027 | cb = new QCheckBox("Show rays", hbox);
|
---|
| 2028 | hlayout->addWidget(cb);
|
---|
| 2029 | cb->setChecked(false);
|
---|
| 2030 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRays(bool)));
|
---|
[2615] | 2031 | #if REMOVE_TEMPORARY
|
---|
[2580] | 2032 | cb = new QCheckBox("Show Comparison", hbox);
|
---|
| 2033 | hlayout->addWidget(cb);
|
---|
| 2034 | cb->setChecked(false);
|
---|
| 2035 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowComparison(bool)));
|
---|
[2615] | 2036 | #endif
|
---|
[1252] | 2037 |
|
---|
[2569] | 2038 | //////////////////
|
---|
[2563] | 2039 |
|
---|
[2569] | 2040 | QHBoxLayout *vh = new QHBoxLayout;
|
---|
[2564] | 2041 |
|
---|
[2569] | 2042 | QGroupBox *myBox = new QGroupBox("Visualization");
|
---|
[2563] | 2043 |
|
---|
[2569] | 2044 | myBox->setLayout(vh);
|
---|
| 2045 | vl->addWidget(myBox, 0, 0);
|
---|
[2566] | 2046 |
|
---|
[2569] | 2047 | QGroupBox *groupBox = CreateVisualizationPanel(hbox);
|
---|
| 2048 | vh->addWidget(groupBox, 0, 0);
|
---|
[2643] | 2049 |
|
---|
[2615] | 2050 | #if REMOVE_TEMPORARY
|
---|
[2569] | 2051 | QGroupBox *groupBox2 = CreateRenderCostPanel(hbox);
|
---|
| 2052 | vh->addWidget(groupBox2, 0, 0);
|
---|
[2643] | 2053 |
|
---|
[2587] | 2054 | QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox);
|
---|
| 2055 | vh->addWidget(groupBox3, 0, 0);
|
---|
| 2056 |
|
---|
[2614] | 2057 | QGroupBox *groupBox4 = CreateTrafoPanel(hbox);
|
---|
| 2058 | vh->addWidget(groupBox4, 0, 0);
|
---|
[2643] | 2059 | #endif
|
---|
[2614] | 2060 |
|
---|
[2563] | 2061 | //////////////////////////////////
|
---|
| 2062 |
|
---|
[2644] | 2063 | bool tmp = false;
|
---|
| 2064 | const int range = 1000;
|
---|
[2563] | 2065 |
|
---|
[2615] | 2066 | //vbox->resize(800,150);
|
---|
| 2067 | QWidget *vbox;
|
---|
[1252] | 2068 |
|
---|
[2543] | 2069 | vbox = new QGroupBox("Rendering", this);
|
---|
| 2070 | layout()->addWidget(vbox);
|
---|
[1252] | 2071 |
|
---|
[2543] | 2072 | vl = new QVBoxLayout;
|
---|
| 2073 | vbox->setLayout(vl);
|
---|
[1252] | 2074 |
|
---|
| 2075 |
|
---|
[2543] | 2076 | cb = new QCheckBox("Cut view cells", vbox);
|
---|
| 2077 | vbox->layout()->addWidget(cb);
|
---|
| 2078 | cb->setChecked(false);
|
---|
| 2079 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetCutViewCells(bool)));
|
---|
[1252] | 2080 |
|
---|
[1942] | 2081 |
|
---|
[2543] | 2082 | slider = new QSlider(Qt::Horizontal, vbox);
|
---|
| 2083 | vbox->layout()->addWidget(slider);
|
---|
| 2084 | slider->show();
|
---|
| 2085 | slider->setRange(0, 1000);
|
---|
| 2086 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 2087 | slider->setValue(1000);
|
---|
[1942] | 2088 |
|
---|
[2543] | 2089 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetSceneCut(int)));
|
---|
[1252] | 2090 |
|
---|
[2644] | 2091 |
|
---|
| 2092 | cb = new QCheckBox("Use spatial filter", vbox);
|
---|
| 2093 | vbox->layout()->addWidget(cb);
|
---|
| 2094 | Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", tmp);
|
---|
| 2095 | cb->setChecked(tmp);
|
---|
| 2096 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseSpatialFilter(bool)));
|
---|
| 2097 |
|
---|
| 2098 |
|
---|
| 2099 | label = new QLabel("Spatial Filter size");
|
---|
| 2100 | vbox->layout()->addWidget(label);
|
---|
[2563] | 2101 |
|
---|
[2644] | 2102 | slider = new QSlider(Qt::Horizontal, vbox);
|
---|
| 2103 | vbox->layout()->addWidget(slider);
|
---|
| 2104 | slider->show();
|
---|
| 2105 | slider->setRange(1, 100);
|
---|
| 2106 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 2107 | slider->setValue(10);
|
---|
| 2108 |
|
---|
| 2109 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetSpatialFilterSize(int)));
|
---|
| 2110 |
|
---|
| 2111 | ////////////////////////////
|
---|
| 2112 |
|
---|
| 2113 |
|
---|
[2563] | 2114 | cb = new QCheckBox("Hide view cells by render cost ", vbox);
|
---|
| 2115 | vbox->layout()->addWidget(cb);
|
---|
| 2116 | cb->setChecked(false);
|
---|
| 2117 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetHideByCost(bool)));
|
---|
[1252] | 2118 |
|
---|
[2563] | 2119 | label = new QLabel("Hide by cost");
|
---|
| 2120 | vbox->layout()->addWidget(label);
|
---|
| 2121 |
|
---|
| 2122 | // the render cost visualization
|
---|
| 2123 | slider = new QSlider(Qt::Horizontal, vbox);
|
---|
| 2124 | vbox->layout()->addWidget(slider);
|
---|
| 2125 | slider->show();
|
---|
| 2126 | slider->setRange(0, range);
|
---|
| 2127 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 2128 | slider->setValue(0);
|
---|
| 2129 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetHidingCost(int)));
|
---|
| 2130 |
|
---|
| 2131 | ///////////////////////////////////////////
|
---|
| 2132 |
|
---|
| 2133 | cb = new QCheckBox("Top View", vbox);
|
---|
| 2134 | vbox->layout()->addWidget(cb);
|
---|
| 2135 | cb->setChecked(false);
|
---|
| 2136 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetTopView(bool)));
|
---|
| 2137 |
|
---|
| 2138 |
|
---|
| 2139 | label = new QLabel("Top distance");
|
---|
| 2140 | vbox->layout()->addWidget(label);
|
---|
| 2141 |
|
---|
| 2142 | slider = new QSlider(Qt::Horizontal, vbox);
|
---|
| 2143 | vbox->layout()->addWidget(slider);
|
---|
| 2144 | slider->show();
|
---|
| 2145 | slider->setRange(1, 1000);
|
---|
| 2146 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 2147 | slider->setValue(500);
|
---|
| 2148 |
|
---|
| 2149 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetTopDistance(int)));
|
---|
| 2150 |
|
---|
| 2151 |
|
---|
| 2152 | ///////////////////////////////////////////
|
---|
[2615] | 2153 | #if REMOVE_TEMPORARY
|
---|
[2563] | 2154 | cb = new QCheckBox("Transparency", vbox);
|
---|
| 2155 | vbox->layout()->addWidget(cb);
|
---|
| 2156 | cb->setChecked(false);
|
---|
[2564] | 2157 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseTransparency(bool)));
|
---|
[2563] | 2158 |
|
---|
| 2159 | label = new QLabel("Use transparency");
|
---|
| 2160 | vbox->layout()->addWidget(label);
|
---|
| 2161 |
|
---|
| 2162 | // the render cost visualization
|
---|
| 2163 | slider = new QSlider(Qt::Horizontal, vbox);
|
---|
| 2164 | vbox->layout()->addWidget(slider);
|
---|
| 2165 | slider->show();
|
---|
| 2166 | slider->setRange(0, range);
|
---|
| 2167 | slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
---|
| 2168 | slider->setValue(0);
|
---|
[2644] | 2169 | connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetTransparency(int)));
|
---|
[2615] | 2170 | #endif
|
---|
[2644] | 2171 |
|
---|
[2563] | 2172 |
|
---|
| 2173 | //////////////////////////////
|
---|
| 2174 |
|
---|
[2604] | 2175 | #if REMOVE_TEMPORARY
|
---|
[2644] | 2176 |
|
---|
[2543] | 2177 | cb = new QCheckBox("Cut scene", vbox);
|
---|
| 2178 | vbox->layout()->addWidget(cb);
|
---|
| 2179 | cb->setChecked(false);
|
---|
| 2180 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetCutScene(bool)));
|
---|
[2615] | 2181 |
|
---|
[2543] | 2182 | cb = new QCheckBox("Render boxes", vbox);
|
---|
| 2183 | vbox->layout()->addWidget(cb);
|
---|
| 2184 | cb->setChecked(false);
|
---|
| 2185 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderBoxes(bool)));
|
---|
[1942] | 2186 |
|
---|
[2543] | 2187 | cb = new QCheckBox("Render visibility estimates", vbox);
|
---|
| 2188 | vbox->layout()->addWidget(cb);
|
---|
| 2189 | cb->setChecked(false);
|
---|
| 2190 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderVisibilityEstimates(bool)));
|
---|
[2615] | 2191 | #endif
|
---|
[1942] | 2192 |
|
---|
[2604] | 2193 | #if REMOVE_TEMPORARY
|
---|
[2543] | 2194 |
|
---|
| 2195 | cb = new QCheckBox("Use filter", vbox);
|
---|
| 2196 | vbox->layout()->addWidget(cb);
|
---|
[2644] | 2197 | Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", tmp);
|
---|
[2543] | 2198 | cb->setChecked(tmp);
|
---|
| 2199 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseFilter(bool)));
|
---|
[2604] | 2200 | #endif
|
---|
[2543] | 2201 |
|
---|
[2644] | 2202 |
|
---|
| 2203 |
|
---|
| 2204 |
|
---|
[2615] | 2205 | #if REMOVE_TEMPORARY
|
---|
[2644] | 2206 |
|
---|
[2543] | 2207 | cb = new QCheckBox("Render filter", vbox);
|
---|
| 2208 | vbox->layout()->addWidget(cb);
|
---|
| 2209 | cb->setChecked(true);
|
---|
| 2210 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderFilter(bool)));
|
---|
| 2211 |
|
---|
| 2212 |
|
---|
[2584] | 2213 | /*vbox = new QGroupBox("PVS Errors", this);
|
---|
[1942] | 2214 | layout()->addWidget(vbox);
|
---|
[2543] | 2215 |
|
---|
[1942] | 2216 | vl = new QVBoxLayout;
|
---|
| 2217 | vbox->setLayout(vl);
|
---|
[2543] | 2218 |
|
---|
[2563] | 2219 | button = new QPushButton("Compute Visibility", vbox);
|
---|
[2543] | 2220 | vbox->layout()->addWidget(button);
|
---|
| 2221 | connect(button, SIGNAL(clicked()), SLOT(ComputeVisibility()));
|
---|
| 2222 |
|
---|
| 2223 | button = new QPushButton("Stop Computation", vbox);
|
---|
| 2224 | vbox->layout()->addWidget(button);
|
---|
| 2225 | connect(button, SIGNAL(clicked()), SLOT(StopComputation()));
|
---|
| 2226 |
|
---|
| 2227 | button = new QPushButton("Set Random View Point", vbox);
|
---|
| 2228 | vbox->layout()->addWidget(button);
|
---|
[2584] | 2229 | connect(button, SIGNAL(clicked()), SLOT(SetRandomViewPoint()));*/
|
---|
[2543] | 2230 |
|
---|
[2584] | 2231 | button = new QPushButton("Store statistics", vbox);
|
---|
| 2232 | vbox->layout()->addWidget(button);
|
---|
| 2233 | connect(button, SIGNAL(clicked()), SIGNAL(StoreStatistics()));
|
---|
[2644] | 2234 |
|
---|
[2621] | 2235 | #endif
|
---|
[2543] | 2236 |
|
---|
[2643] | 2237 | button = new QPushButton("Compute GVS", vbox);
|
---|
| 2238 | vbox->layout()->addWidget(button);
|
---|
| 2239 | connect(button, SIGNAL(clicked()), SIGNAL(ComputeGVS()));
|
---|
| 2240 |
|
---|
[2621] | 2241 | #if DYNAMIC_OBJECTS_HACK
|
---|
| 2242 |
|
---|
[2609] | 2243 | button = new QPushButton("Load object", vbox);
|
---|
| 2244 | vbox->layout()->addWidget(button);
|
---|
| 2245 | connect(button, SIGNAL(clicked()), SIGNAL(LoadObject()));
|
---|
[2615] | 2246 | #endif
|
---|
[2621] | 2247 |
|
---|
[2584] | 2248 | /*cb = new QCheckBox("Stats", vbox);
|
---|
| 2249 | vbox->layout()->addWidget(cb);
|
---|
| 2250 | cb->setChecked(false);
|
---|
[2609] | 2251 | connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics()));*/
|
---|
[2614] | 2252 |
|
---|
[2569] | 2253 | if (0)
|
---|
| 2254 | {
|
---|
[2543] | 2255 | vbox = new QGroupBox("PVS Errors", this);
|
---|
| 2256 | layout()->addWidget(vbox);
|
---|
| 2257 |
|
---|
| 2258 | vl = new QVBoxLayout;
|
---|
| 2259 | vbox->setLayout(vl);
|
---|
| 2260 |
|
---|
| 2261 | mPvsErrorWidget = new QListWidget(vbox);
|
---|
| 2262 | vbox->layout()->addWidget(mPvsErrorWidget);
|
---|
| 2263 |
|
---|
| 2264 | connect(mPvsErrorWidget,
|
---|
[1942] | 2265 | SIGNAL(doubleClicked(const QModelIndex &)),
|
---|
| 2266 | this,
|
---|
| 2267 | SLOT(PvsErrorClicked(const QModelIndex &)));
|
---|
[2543] | 2268 |
|
---|
[2563] | 2269 | button = new QPushButton("Next Error Frame", vbox);
|
---|
[2543] | 2270 | vbox->layout()->addWidget(button);
|
---|
| 2271 | connect(button, SIGNAL(clicked(void)), SLOT(FocusNextPvsErrorFrame(void)));
|
---|
| 2272 | }
|
---|
[2562] | 2273 |
|
---|
[2584] | 2274 | //connect(button, SIGNAL(clicked(void)), SLOT(StoreStatistics(void)));
|
---|
[2643] | 2275 |
|
---|
| 2276 | //////////////////////////////////////////
|
---|
[2562] | 2277 |
|
---|
[2615] | 2278 |
|
---|
[2543] | 2279 | setWindowTitle("Preprocessor Control Widget");
|
---|
| 2280 | adjustSize();
|
---|
[1252] | 2281 | }
|
---|
| 2282 |
|
---|
| 2283 |
|
---|
[1942] | 2284 |
|
---|
| 2285 |
|
---|
[1252] | 2286 | void
|
---|
| 2287 | QtRendererControlWidget::FocusNextPvsErrorFrame(void)
|
---|
[2576] | 2288 | {}
|
---|
[2543] | 2289 |
|
---|
[1252] | 2290 | void
|
---|
| 2291 | QtRendererControlWidget::UpdatePvsErrorItem(int row,
|
---|
[2543] | 2292 | GlRendererBuffer::PvsErrorEntry &pvsErrorEntry)
|
---|
[1252] | 2293 | {
|
---|
| 2294 |
|
---|
[2543] | 2295 | QListWidgetItem *i = mPvsErrorWidget->item(row);
|
---|
| 2296 | QString s;
|
---|
| 2297 | s.sprintf("%5.5f", pvsErrorEntry.mError);
|
---|
| 2298 | if (i) {
|
---|
| 2299 | i->setText(s);
|
---|
| 2300 | } else {
|
---|
| 2301 | new QListWidgetItem(s, mPvsErrorWidget);
|
---|
| 2302 | }
|
---|
| 2303 | mPvsErrorWidget->update();
|
---|
[1252] | 2304 | }
|
---|
| 2305 |
|
---|
| 2306 |
|
---|
[2576] | 2307 |
|
---|
| 2308 |
|
---|
| 2309 | /*********************************************************************/
|
---|
| 2310 | /* QtGlDebuggerWidget implementation */
|
---|
| 2311 | /*********************************************************************/
|
---|
| 2312 |
|
---|
| 2313 |
|
---|
| 2314 | QtGlDebuggerWidget::QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent)
|
---|
| 2315 | : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf)
|
---|
| 2316 | {
|
---|
| 2317 | // create the pbuffer
|
---|
| 2318 | //pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this);
|
---|
| 2319 | timerId = startTimer(20);
|
---|
| 2320 | setWindowTitle(("OpenGL pbuffers"));
|
---|
| 2321 | }
|
---|
| 2322 |
|
---|
| 2323 |
|
---|
| 2324 | QtGlDebuggerWidget::~QtGlDebuggerWidget()
|
---|
| 2325 | {
|
---|
| 2326 | mRenderBuffer->releaseFromDynamicTexture();
|
---|
| 2327 | glDeleteTextures(1, &dynamicTexture);
|
---|
| 2328 |
|
---|
| 2329 | DEL_PTR(mRenderBuffer);
|
---|
| 2330 | }
|
---|
| 2331 |
|
---|
| 2332 |
|
---|
[1252] | 2333 | void QtGlDebuggerWidget::initializeGL()
|
---|
| 2334 | {
|
---|
| 2335 | glMatrixMode(GL_PROJECTION);
|
---|
| 2336 | glLoadIdentity();
|
---|
| 2337 |
|
---|
| 2338 | glFrustum(-1, 1, -1, 1, 10, 100);
|
---|
| 2339 | glTranslatef(-0.5f, -0.5f, -0.5f);
|
---|
| 2340 | glTranslatef(0.0f, 0.0f, -15.0f);
|
---|
| 2341 | glMatrixMode(GL_MODELVIEW);
|
---|
| 2342 |
|
---|
| 2343 | glEnable(GL_CULL_FACE);
|
---|
| 2344 | initCommon();
|
---|
| 2345 | initPbuffer();
|
---|
| 2346 |
|
---|
| 2347 | }
|
---|
| 2348 |
|
---|
| 2349 |
|
---|
| 2350 | void QtGlDebuggerWidget::resizeGL(int w, int h)
|
---|
| 2351 | {
|
---|
| 2352 | glViewport(0, 0, w, h);
|
---|
| 2353 | }
|
---|
| 2354 |
|
---|
| 2355 |
|
---|
| 2356 | void QtGlDebuggerWidget::paintGL()
|
---|
| 2357 | {
|
---|
| 2358 | // draw a spinning cube into the pbuffer..
|
---|
| 2359 | mRenderBuffer->makeCurrent();
|
---|
[2543] | 2360 |
|
---|
[1252] | 2361 | BeamSampleStatistics stats;
|
---|
| 2362 | mRenderBuffer->SampleBeamContributions(mSourceObject, mBeam, mSamples, stats);
|
---|
| 2363 |
|
---|
| 2364 | glFlush();
|
---|
| 2365 |
|
---|
| 2366 | // rendering directly to a texture is not supported on X11, unfortunately
|
---|
[2543] | 2367 | mRenderBuffer->updateDynamicTexture(dynamicTexture);
|
---|
[1252] | 2368 |
|
---|
[2543] | 2369 | // and use the pbuffer contents as a texture when rendering the
|
---|
| 2370 | // background and the bouncing cubes
|
---|
| 2371 | makeCurrent();
|
---|
| 2372 | glBindTexture(GL_TEXTURE_2D, dynamicTexture);
|
---|
| 2373 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
---|
[1252] | 2374 |
|
---|
[2543] | 2375 | // draw the background
|
---|
[1252] | 2376 | glMatrixMode(GL_MODELVIEW);
|
---|
[2543] | 2377 | glPushMatrix();
|
---|
| 2378 | glLoadIdentity();
|
---|
| 2379 | glMatrixMode(GL_PROJECTION);
|
---|
| 2380 | glPushMatrix();
|
---|
| 2381 | glLoadIdentity();
|
---|
| 2382 |
|
---|
[1252] | 2383 | glPopMatrix();
|
---|
[2543] | 2384 | glMatrixMode(GL_MODELVIEW);
|
---|
| 2385 | glPopMatrix();
|
---|
[1252] | 2386 | }
|
---|
| 2387 |
|
---|
| 2388 |
|
---|
| 2389 | void QtGlDebuggerWidget::initPbuffer()
|
---|
| 2390 | {
|
---|
| 2391 | // set up the pbuffer context
|
---|
[2543] | 2392 | mRenderBuffer->makeCurrent();
|
---|
[2664] | 2393 |
|
---|
[1252] | 2394 | // generate a texture that has the same size/format as the pbuffer
|
---|
[2543] | 2395 | dynamicTexture = mRenderBuffer->generateDynamicTexture();
|
---|
[1252] | 2396 |
|
---|
| 2397 | // bind the dynamic texture to the pbuffer - this is a no-op under X11
|
---|
| 2398 | mRenderBuffer->bindToDynamicTexture(dynamicTexture);
|
---|
| 2399 | makeCurrent();
|
---|
| 2400 | }
|
---|
| 2401 |
|
---|
[2576] | 2402 |
|
---|
[1252] | 2403 | void QtGlDebuggerWidget::initCommon()
|
---|
| 2404 | {
|
---|
| 2405 | glEnable(GL_TEXTURE_2D);
|
---|
| 2406 | glEnable(GL_DEPTH_TEST);
|
---|
| 2407 |
|
---|
| 2408 | glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
---|
| 2409 | }
|
---|
| 2410 |
|
---|
| 2411 |
|
---|
[2609] | 2412 | void QtGlRendererWidget::_RenderColoredPvs()
|
---|
| 2413 | {
|
---|
| 2414 | // note: could be done more efficiently using color buffers
|
---|
| 2415 | mPvsSize = mPvsCache.mPvs.GetSize();
|
---|
| 2416 |
|
---|
| 2417 | ObjectPvsIterator it = mPvsCache.mPvs.GetIterator();
|
---|
| 2418 |
|
---|
| 2419 | PvsData pvsData;
|
---|
| 2420 |
|
---|
| 2421 | while (it.HasMoreEntries())
|
---|
| 2422 | {
|
---|
| 2423 | Intersectable *object = it.Next(pvsData);
|
---|
| 2424 |
|
---|
| 2425 | RgbColor color;
|
---|
| 2426 |
|
---|
| 2427 | //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f
|
---|
| 2428 | // glColor3f(visibility, 0.0f, 0.0f);
|
---|
| 2429 | //cerr << "sumpdf: " << pvsData.mSumPdf << endl;
|
---|
| 2430 | if (mUseRandomColorPerPvsObject)
|
---|
| 2431 | {
|
---|
| 2432 | KdIntersectable *kdint = static_cast<KdIntersectable *>(object);
|
---|
| 2433 |
|
---|
| 2434 | if (kdint->mGenericIdx == -1)
|
---|
| 2435 | {
|
---|
| 2436 | kdint->mGenericIdx = (int)mColors.size();
|
---|
| 2437 | mColors.push_back(RandomColor());
|
---|
| 2438 | }
|
---|
| 2439 | color = mColors[kdint->mGenericIdx];
|
---|
| 2440 | }
|
---|
| 2441 | else
|
---|
| 2442 | {
|
---|
| 2443 | color = RainbowColorMapping(mTransferFunction * log10(pvsData.mSumPdf + 1));
|
---|
| 2444 | }
|
---|
| 2445 |
|
---|
| 2446 | glColor3f(color.r, color.g, color.b);
|
---|
| 2447 |
|
---|
| 2448 | mUseForcedColors = true;
|
---|
| 2449 | RenderIntersectable(object);
|
---|
| 2450 | mUseForcedColors = false;
|
---|
| 2451 | }
|
---|
| 2452 | }
|
---|
| 2453 |
|
---|
[2636] | 2454 | void
|
---|
| 2455 | QtGlRendererWidget::UpdateDynamicObjects()
|
---|
| 2456 | {
|
---|
| 2457 | preprocessor->ScheduleUpdateDynamicObjects();
|
---|
| 2458 |
|
---|
[2611] | 2459 | }
|
---|
[2636] | 2460 |
|
---|
| 2461 | }
|
---|