90 "camera-top", "camera-front", "camera-left", |
90 "camera-top", "camera-front", "camera-left", |
91 "camera-bottom", "camera-back", "camera-right", |
91 "camera-bottom", "camera-back", "camera-right", |
92 "camera-free" |
92 "camera-free" |
93 }; |
93 }; |
94 |
94 |
95 CameraIcon* info = &m_cameraIcons[camera]; |
95 CameraIcon* info = &m_cameraIcons[static_cast<int>(camera)]; |
96 info->image = GetIcon (cameraIconNames[camera]); |
96 info->image = GetIcon (cameraIconNames[static_cast<int>(camera)]); |
97 info->camera = camera; |
97 info->camera = camera; |
98 } |
98 } |
99 |
99 |
100 calcCameraIcons(); |
100 calcCameraIcons(); |
101 } |
101 } |
119 int i = 0; |
119 int i = 0; |
120 |
120 |
121 for (CameraIcon& info : m_cameraIcons) |
121 for (CameraIcon& info : m_cameraIcons) |
122 { |
122 { |
123 // MATH |
123 // MATH |
124 int x1 = (width() - (info.camera != FreeCamera ? 48 : 16)) + ((i % 3) * 16) - 1; |
124 int x1 = (width() - (info.camera != Camera::Free ? 48 : 16)) + ((i % 3) * 16) - 1; |
125 int y1 = ((i / 3) * 16) + 1; |
125 int y1 = ((i / 3) * 16) + 1; |
126 |
126 |
127 info.sourceRect = QRect (0, 0, 16, 16); |
127 info.sourceRect = QRect (0, 0, 16, 16); |
128 info.targetRect = QRect (x1, y1, 16, 16); |
128 info.targetRect = QRect (x1, y1, 16, 16); |
129 info.hitRect = QRect ( |
129 info.hitRect = QRect ( |
376 if (m_config->lighting()) |
376 if (m_config->lighting()) |
377 glEnable(GL_LIGHTING); |
377 glEnable(GL_LIGHTING); |
378 else |
378 else |
379 glDisable(GL_LIGHTING); |
379 glDisable(GL_LIGHTING); |
380 |
380 |
381 if (camera() != FreeCamera) |
381 if (camera() != Camera::Free) |
382 { |
382 { |
383 glMatrixMode (GL_PROJECTION); |
383 glMatrixMode (GL_PROJECTION); |
384 glPushMatrix(); |
384 glPushMatrix(); |
385 |
385 |
386 glLoadIdentity(); |
386 glLoadIdentity(); |
387 glOrtho (-m_virtualWidth, m_virtualWidth, -m_virtualHeight, m_virtualHeight, -100.0f, 100.0f); |
387 glOrtho (-m_virtualWidth, m_virtualWidth, -m_virtualHeight, m_virtualHeight, -100.0f, 100.0f); |
388 glTranslatef(panning (X), panning (Y), 0.0f); |
388 glTranslatef(panning (X), panning (Y), 0.0f); |
389 |
389 |
390 if (camera() != FrontCamera and camera() != BackCamera) |
390 if (camera() != Camera::Front and camera() != Camera::Back) |
391 { |
391 { |
392 glRotatef(90.0f, g_cameraInfo[camera()].glrotate[0], |
392 glRotatef(90.0f, g_cameraInfo[static_cast<int>(camera())].glrotate[0], |
393 g_cameraInfo[camera()].glrotate[1], |
393 g_cameraInfo[static_cast<int>(camera())].glrotate[1], |
394 g_cameraInfo[camera()].glrotate[2]); |
394 g_cameraInfo[static_cast<int>(camera())].glrotate[2]); |
395 } |
395 } |
396 |
396 |
397 // Back camera needs to be handled differently |
397 // Back camera needs to be handled differently |
398 if (camera() == BackCamera) |
398 if (camera() == Camera::Back) |
399 { |
399 { |
400 glRotatef(180.0f, 1.0f, 0.0f, 0.0f); |
400 glRotatef(180.0f, 1.0f, 0.0f, 0.0f); |
401 glRotatef(180.0f, 0.0f, 0.0f, 1.0f); |
401 glRotatef(180.0f, 0.0f, 0.0f, 1.0f); |
402 } |
402 } |
403 } |
403 } |
415 glEnableClientState (GL_VERTEX_ARRAY); |
415 glEnableClientState (GL_VERTEX_ARRAY); |
416 glEnableClientState (GL_COLOR_ARRAY); |
416 glEnableClientState (GL_COLOR_ARRAY); |
417 |
417 |
418 if (m_isDrawingSelectionScene) |
418 if (m_isDrawingSelectionScene) |
419 { |
419 { |
420 drawVbos (TrianglesVbo, PickColorsVboComplement, GL_TRIANGLES); |
420 drawVbos (VboClass::Triangles, VboSubclass::PickColors, GL_TRIANGLES); |
421 drawVbos (QuadsVbo, PickColorsVboComplement, GL_QUADS); |
421 drawVbos (VboClass::Quads, VboSubclass::PickColors, GL_QUADS); |
422 drawVbos (LinesVbo, PickColorsVboComplement, GL_LINES); |
422 drawVbos (VboClass::Lines, VboSubclass::PickColors, GL_LINES); |
423 drawVbos (ConditionalLinesVbo, PickColorsVboComplement, GL_LINES); |
423 drawVbos (VboClass::ConditionalLines, VboSubclass::PickColors, GL_LINES); |
424 } |
424 } |
425 else |
425 else |
426 { |
426 { |
427 if (m_config->bfcRedGreenView()) |
427 if (m_config->bfcRedGreenView()) |
428 { |
428 { |
429 glEnable (GL_CULL_FACE); |
429 glEnable (GL_CULL_FACE); |
430 glCullFace (GL_BACK); |
430 glCullFace (GL_BACK); |
431 drawVbos (TrianglesVbo, BfcFrontColorsVboComplement, GL_TRIANGLES); |
431 drawVbos (VboClass::Triangles, VboSubclass::BfcFrontColors, GL_TRIANGLES); |
432 drawVbos (QuadsVbo, BfcFrontColorsVboComplement, GL_QUADS); |
432 drawVbos (VboClass::Quads, VboSubclass::BfcFrontColors, GL_QUADS); |
433 glCullFace (GL_FRONT); |
433 glCullFace (GL_FRONT); |
434 drawVbos (TrianglesVbo, BfcBackColorsVboComplement, GL_TRIANGLES); |
434 drawVbos (VboClass::Triangles, VboSubclass::BfcBackColors, GL_TRIANGLES); |
435 drawVbos (QuadsVbo, BfcBackColorsVboComplement, GL_QUADS); |
435 drawVbos (VboClass::Quads, VboSubclass::BfcBackColors, GL_QUADS); |
436 glDisable (GL_CULL_FACE); |
436 glDisable (GL_CULL_FACE); |
437 } |
437 } |
438 else |
438 else |
439 { |
439 { |
440 ComplementVboType colors; |
440 VboSubclass colors; |
441 |
441 |
442 if (m_config->randomColors()) |
442 if (m_config->randomColors()) |
443 colors = RandomColorsVboComplement; |
443 colors = VboSubclass::RandomColors; |
444 else |
444 else |
445 colors = NormalColorsVboComplement; |
445 colors = VboSubclass::NormalColors; |
446 |
446 |
447 drawVbos (TrianglesVbo, colors, GL_TRIANGLES); |
447 drawVbos (VboClass::Triangles, colors, GL_TRIANGLES); |
448 drawVbos (QuadsVbo, colors, GL_QUADS); |
448 drawVbos (VboClass::Quads, colors, GL_QUADS); |
449 } |
449 } |
450 |
450 |
451 drawVbos (LinesVbo, NormalColorsVboComplement, GL_LINES); |
451 drawVbos (VboClass::Lines, VboSubclass::NormalColors, GL_LINES); |
452 glEnable (GL_LINE_STIPPLE); |
452 glEnable (GL_LINE_STIPPLE); |
453 drawVbos (ConditionalLinesVbo, NormalColorsVboComplement, GL_LINES); |
453 drawVbos (VboClass::ConditionalLines, VboSubclass::NormalColors, GL_LINES); |
454 glDisable (GL_LINE_STIPPLE); |
454 glDisable (GL_LINE_STIPPLE); |
455 |
455 |
456 if (m_config->drawAxes()) |
456 if (m_config->drawAxes()) |
457 { |
457 { |
458 glDisableClientState (GL_NORMAL_ARRAY); |
458 glDisableClientState (GL_NORMAL_ARRAY); |
477 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
477 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
478 } |
478 } |
479 |
479 |
480 // ============================================================================= |
480 // ============================================================================= |
481 // |
481 // |
482 void GLRenderer::drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type) |
482 void GLRenderer::drawVbos (VboClass surface, VboSubclass colors, GLenum type) |
483 { |
483 { |
484 // Filter this through some configuration options |
484 // Filter this through some configuration options |
485 if ((isOneOf (surface, QuadsVbo, TrianglesVbo) and m_config->drawSurfaces() == false) |
485 if ((isOneOf (surface, VboClass::Quads, VboClass::Triangles) and m_config->drawSurfaces() == false) |
486 or (surface == LinesVbo and m_config->drawEdgeLines() == false) |
486 or (surface == VboClass::Lines and m_config->drawEdgeLines() == false) |
487 or (surface == ConditionalLinesVbo and m_config->drawConditionalLines() == false)) |
487 or (surface == VboClass::ConditionalLines and m_config->drawConditionalLines() == false)) |
488 { |
488 { |
489 return; |
489 return; |
490 } |
490 } |
491 |
491 |
492 int surfaceVboNumber = m_compiler->vboNumber(surface, SurfacesVboComplement); |
492 int surfaceVboNumber = m_compiler->vboNumber(surface, VboSubclass::Surfaces); |
493 int colorVboNumber = m_compiler->vboNumber(surface, colors); |
493 int colorVboNumber = m_compiler->vboNumber(surface, colors); |
494 int normalVboNumber = m_compiler->vboNumber(surface, NormalsVboComplement); |
494 int normalVboNumber = m_compiler->vboNumber(surface, VboSubclass::Normals); |
495 m_compiler->prepareVBO(surfaceVboNumber, m_model); |
495 m_compiler->prepareVBO(surfaceVboNumber, m_model); |
496 m_compiler->prepareVBO(colorVboNumber, m_model); |
496 m_compiler->prepareVBO(colorVboNumber, m_model); |
497 m_compiler->prepareVBO(normalVboNumber, m_model); |
497 m_compiler->prepareVBO(normalVboNumber, m_model); |
498 GLuint surfaceVbo = m_compiler->vbo(surfaceVboNumber); |
498 GLuint surfaceVbo = m_compiler->vbo(surfaceVboNumber); |
499 GLuint colorVbo = m_compiler->vbo(colorVboNumber); |
499 GLuint colorVbo = m_compiler->vbo(colorVboNumber); |
543 void GLRenderer::overpaint(QPainter &painter) |
543 void GLRenderer::overpaint(QPainter &painter) |
544 { |
544 { |
545 // Draw a background for the selected camera |
545 // Draw a background for the selected camera |
546 painter.setPen(thinBorderPen); |
546 painter.setPen(thinBorderPen); |
547 painter.setBrush(QBrush {QColor {0, 128, 160, 128}}); |
547 painter.setBrush(QBrush {QColor {0, 128, 160, 128}}); |
548 painter.drawRect(m_cameraIcons[camera()].hitRect); |
548 painter.drawRect(m_cameraIcons[static_cast<int>(camera())].hitRect); |
549 |
549 |
550 // Draw the camera icons |
550 // Draw the camera icons |
551 for (const CameraIcon& info : m_cameraIcons) |
551 for (const CameraIcon& info : m_cameraIcons) |
552 { |
552 { |
553 // Don't draw the free camera icon when we can't use the free camera |
553 // Don't draw the free camera icon when we can't use the free camera |
554 if (&info == &m_cameraIcons[FreeCamera] and not freeCameraAllowed()) |
554 if (info.camera == Camera::Free and not freeCameraAllowed()) |
555 continue; |
555 continue; |
556 |
556 |
557 painter.drawPixmap(info.targetRect, info.image, info.sourceRect); |
557 painter.drawPixmap(info.targetRect, info.image, info.sourceRect); |
558 } |
558 } |
559 |
559 |
560 // Tool tips |
560 // Tool tips |
561 if (m_drawToolTip) |
561 if (m_drawToolTip) |
562 { |
562 { |
563 if (not m_cameraIcons[m_toolTipCamera].targetRect.contains (m_mousePosition)) |
563 if (not m_cameraIcons[static_cast<int>(m_toolTipCamera)].targetRect.contains (m_mousePosition)) |
564 m_drawToolTip = false; |
564 m_drawToolTip = false; |
565 else |
565 else |
566 QToolTip::showText(m_globalpos, currentCameraName()); |
566 QToolTip::showText(m_globalpos, currentCameraName()); |
567 } |
567 } |
568 |
568 |
848 Axis GLRenderer::getCameraAxis (bool y, Camera camid) |
848 Axis GLRenderer::getCameraAxis (bool y, Camera camid) |
849 { |
849 { |
850 if (camid == (Camera) -1) |
850 if (camid == (Camera) -1) |
851 camid = camera(); |
851 camid = camera(); |
852 |
852 |
853 const CameraInfo* cam = &g_cameraInfo[camid]; |
853 const CameraInfo& cameraData = cameraInfo(camid); |
854 return (y) ? cam->localY : cam->localX; |
854 return (y) ? cameraData.localY : cameraData.localX; |
855 } |
855 } |
856 |
856 |
857 // ============================================================================= |
857 // ============================================================================= |
858 // |
858 // |
859 QString GLRenderer::cameraName (Camera camera) const |
859 QString GLRenderer::cameraName (Camera camera) const |
860 { |
860 { |
861 switch (camera) |
861 switch (camera) |
862 { |
862 { |
863 case TopCamera: return tr ("Top Camera"); |
863 case Camera::Top: return tr ("Top Camera"); |
864 case FrontCamera: return tr ("Front Camera"); |
864 case Camera::Front: return tr ("Front Camera"); |
865 case LeftCamera: return tr ("Left Camera"); |
865 case Camera::Left: return tr ("Left Camera"); |
866 case BottomCamera: return tr ("Bottom Camera"); |
866 case Camera::Bottom: return tr ("Bottom Camera"); |
867 case BackCamera: return tr ("Back Camera"); |
867 case Camera::Back: return tr ("Back Camera"); |
868 case RightCamera: return tr ("Right Camera"); |
868 case Camera::Right: return tr ("Right Camera"); |
869 case FreeCamera: return tr ("Free Camera"); |
869 case Camera::Free: return tr ("Free Camera"); |
870 default: break; |
870 default: break; |
871 } |
871 } |
872 |
872 |
873 return ""; |
873 return ""; |
874 } |
874 } |
1054 return m_camera; |
1054 return m_camera; |
1055 } |
1055 } |
1056 |
1056 |
1057 double& GLRenderer::panning (Axis ax) |
1057 double& GLRenderer::panning (Axis ax) |
1058 { |
1058 { |
1059 return (ax == X) ? m_panX[camera()] : |
1059 return (ax == X) ? m_panX[static_cast<int>(camera())] : m_panY[static_cast<int>(camera())]; |
1060 m_panY[camera()]; |
|
1061 } |
1060 } |
1062 |
1061 |
1063 double GLRenderer::panning (Axis ax) const |
1062 double GLRenderer::panning (Axis ax) const |
1064 { |
1063 { |
1065 return (ax == X) ? m_panX[camera()] : |
1064 return (ax == X) ? m_panX[static_cast<int>(camera())] : m_panY[static_cast<int>(camera())]; |
1066 m_panY[camera()]; |
|
1067 } |
1065 } |
1068 |
1066 |
1069 double& GLRenderer::zoom() |
1067 double& GLRenderer::zoom() |
1070 { |
1068 { |
1071 return m_zoom[camera()]; |
1069 return m_zoom[static_cast<int>(camera())]; |
1072 } |
1070 } |
1073 |
1071 |
1074 const QGenericMatrix<4, 4, GLfloat>& GLRenderer::rotationMatrix() const |
1072 const QGenericMatrix<4, 4, GLfloat>& GLRenderer::rotationMatrix() const |
1075 { |
1073 { |
1076 return m_rotationMatrix; |
1074 return m_rotationMatrix; |