diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-29 13:07:58 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-29 13:17:45 +0300 |
commit | 715fce1f5b14eb2d837f8bb8efe21530c183e79a (patch) | |
tree | 6847ac543f09d18efc8388708298172b5a1af77b /src/datavis3d | |
parent | 8a76867344d2a67270197132dfbb0eb4be4febd1 (diff) |
Q3DBars: Fixed shadows for negative valued bars
Change-Id: Ibe735b3f3f95038d0d3c5b7530fcd1ad554335c1
Change-Id: Ibe735b3f3f95038d0d3c5b7530fcd1ad554335c1
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavis3d')
-rw-r--r-- | src/datavis3d/engine/q3dbars.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/datavis3d/engine/q3dbars.cpp b/src/datavis3d/engine/q3dbars.cpp index 69ff4eac..41a52aad 100644 --- a/src/datavis3d/engine/q3dbars.cpp +++ b/src/datavis3d/engine/q3dbars.cpp @@ -533,12 +533,9 @@ void Q3DBars::drawScene() glBindFramebuffer(GL_FRAMEBUFFER, d_ptr->m_depthFrameBuffer); glClear(GL_DEPTH_BUFFER_BIT); - // Set front face culling to reduce self-shadowing issues - glCullFace(GL_FRONT); - // Get the depth view matrix // It may be possible to hack lightPos here if we want to make some tweaks to shadow - depthViewMatrix.lookAt(lightPos, QVector3D(0.0f, 1.0f - d_ptr->m_yAdjustment, zComp), + depthViewMatrix.lookAt(lightPos, QVector3D(0.0f, -d_ptr->m_yAdjustment, zComp), QVector3D(0.0f, 1.0f, 0.0f)); // TODO: Why does depthViewMatrix.column(3).y() goes to zero when we're directly above? That causes the scene to be not drawn from above -> must be fixed //qDebug() << lightPos << depthViewMatrix << depthViewMatrix.column(3); @@ -561,15 +558,17 @@ void Q3DBars::drawScene() continue; GLfloat barHeight = item->d_ptr->value() / d_ptr->m_heightNormalizer; - // skip shadows for barHeight < 0 (for now) + // skip shadows for 0 -height bars - if (barHeight <= 0) + if (barHeight == 0) continue; - //if (barHeight < 0) - // glCullFace(GL_FRONT); - //else - // glCullFace(GL_BACK); + // Set front face culling for positive valued bars and back face culling for + // negative valued bars to reduce self-shadowing issues + if (barHeight < 0) + glCullFace(GL_BACK); + else + glCullFace(GL_FRONT); QMatrix4x4 modelMatrix; QMatrix4x4 MVPMatrix; @@ -2284,17 +2283,17 @@ void Q3DBarsPrivate::handleLimitChange() // Get the limits QPair<GLfloat, GLfloat> limits = m_dataSet->d_ptr->limitValues(); + // TODO: What if we have only negative values? + // Check if we have negative values if (limits.first < 0 && !m_negativeValues) { m_negativeValues = true; // Reload background loadBackgroundMesh(); - // TODO: What else is needed here? } else if (limits.first >= 0 && m_negativeValues) { m_negativeValues = false; // Reload background loadBackgroundMesh(); - // TODO: What else is needed here? } // Don't auto-adjust height if tick count is set |