diff options
author | Mika Salmela <mika.salmela@qt.io> | 2017-03-08 16:29:06 +0200 |
---|---|---|
committer | Mika Salmela <mika.salmela@qt.io> | 2017-03-10 07:37:59 +0000 |
commit | a29f9af154aca4a88be3df46641762a289556693 (patch) | |
tree | d988059b438ee0d997b441fd7f4a7ab70f4566e2 /src/datavisualization/engine/selectionpointer.cpp | |
parent | 7d278e3bcfc27b4ad06f500a406c5b8ff18953de (diff) |
Enable transparency for walls
When alpha value for wall is below 1.0, enable blending for walls.
Rearrange code so that solid objects are drawn first and then possible
tranparent objects.
Task-number: QTBUG-59140
Change-Id: I5087a664a59ecdb4516b17e8fac1f8ff48ad1c16
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/datavisualization/engine/selectionpointer.cpp')
-rw-r--r-- | src/datavisualization/engine/selectionpointer.cpp | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp index da5d5e54..d646429a 100644 --- a/src/datavisualization/engine/selectionpointer.cpp +++ b/src/datavisualization/engine/selectionpointer.cpp @@ -78,7 +78,7 @@ void SelectionPointer::updateScene(Q3DScene *scene) m_cachedScene = scene; } -void SelectionPointer::render(GLuint defaultFboHandle, bool useOrtho) +void SelectionPointer::renderSelectionPointer(GLuint defaultFboHandle, bool useOrtho) { Q_UNUSED(defaultFboHandle) @@ -86,7 +86,6 @@ void SelectionPointer::render(GLuint defaultFboHandle, bool useOrtho) m_mainViewPort.width(), m_mainViewPort.height()); Q3DCamera *camera = m_cachedScene->activeCamera(); - QSize textureSize = m_labelItem.size(); QMatrix4x4 itModelMatrix; @@ -111,10 +110,6 @@ void SelectionPointer::render(GLuint defaultFboHandle, bool useOrtho) projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f); } - // Calculate scale factor to get uniform font size - GLfloat scaledFontSize = 0.05f + m_drawer->font().pointSizeF() / 500.0f; - GLfloat scaleFactor = scaledFontSize / (GLfloat)textureSize.height(); - QMatrix4x4 modelMatrix; QMatrix4x4 MVPMatrix; @@ -152,11 +147,44 @@ void SelectionPointer::render(GLuint defaultFboHandle, bool useOrtho) Utils::vectorFromColor(m_cachedTheme->lightColor())); m_drawer->drawObject(m_pointShader, m_pointObj); +} - // - // Draw the label - // +void SelectionPointer::renderSelectionLabel(GLuint defaultFboHandle, bool useOrtho) +{ + Q_UNUSED(defaultFboHandle) + + glViewport(m_mainViewPort.x(), m_mainViewPort.y(), + m_mainViewPort.width(), m_mainViewPort.height()); + + Q3DCamera *camera = m_cachedScene->activeCamera(); + + // Get view matrix + QMatrix4x4 viewMatrix; QMatrix4x4 modelMatrixLabel; + QMatrix4x4 projectionMatrix; + GLfloat viewPortRatio = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height(); + if (m_cachedIsSlicingActivated) { + GLfloat sliceUnitsScaled = sliceUnits / m_autoScaleAdjustment; + viewMatrix.lookAt(QVector3D(0.0f, 0.0f, 1.0f), zeroVector, upVector); + projectionMatrix.ortho(-sliceUnitsScaled * viewPortRatio, sliceUnitsScaled * viewPortRatio, + -sliceUnitsScaled, sliceUnitsScaled, + -1.0f, 4.0f); + } else if (useOrtho) { + viewMatrix = camera->d_ptr->viewMatrix(); + GLfloat orthoRatio = 2.0f; + projectionMatrix.ortho(-viewPortRatio * orthoRatio, viewPortRatio * orthoRatio, + -orthoRatio, orthoRatio, + 0.0f, 100.0f); + } else { + viewMatrix = camera->d_ptr->viewMatrix(); + projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f); + } + + QSize textureSize = m_labelItem.size(); + + // Calculate scale factor to get uniform font size + GLfloat scaledFontSize = 0.05f + m_drawer->font().pointSizeF() / 500.0f; + GLfloat scaleFactor = scaledFontSize / (GLfloat)textureSize.height(); // Position label QVector3D labelAlign(0.0f, 1.0f * scaledFontSize + 0.05f, 0.0f); @@ -184,6 +212,8 @@ void SelectionPointer::render(GLuint defaultFboHandle, bool useOrtho) m_labelShader->bind(); + QMatrix4x4 MVPMatrix; + // Set shader bindings MVPMatrix = projectionMatrix * viewMatrix * modelMatrixLabel; m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix); |