Sat, 13 Jan 2018 00:04:54 +0200
moved matrix calculations, added inverted normals for BFC back sides
src/glShared.h | file | annotate | diff | comparison | revisions | |
src/glcamera.cpp | file | annotate | diff | comparison | revisions | |
src/glcamera.h | file | annotate | diff | comparison | revisions | |
src/glcompiler.cpp | file | annotate | diff | comparison | revisions | |
src/glrenderer.cpp | file | annotate | diff | comparison | revisions |
--- a/src/glShared.h Fri Jan 12 00:55:31 2018 +0200 +++ b/src/glShared.h Sat Jan 13 00:04:54 2018 +0200 @@ -67,6 +67,7 @@ BfcBackColors, RandomColors, Normals, + InvertedNormals, _End };
--- a/src/glcamera.cpp Fri Jan 12 00:55:31 2018 +0200 +++ b/src/glcamera.cpp Sat Jan 13 00:04:54 2018 +0200 @@ -275,3 +275,25 @@ // The adapter matrix would be inverted here, but it is its own inverse so let's not bother. return idealCoordinates.transformed(ldrawToIdealAdapterMatrix).transformed(m_rotationMatrix.inverted()); } + +GLRotationMatrix GLCamera::realMatrix() const +{ + /* glOrtho(-virtualSize.width(), virtualSize.width(), + -virtualSize.height(), virtualSize.height(), + -1000.0f, 1000.0f); */ + GLRotationMatrix ortho { + 1 / float(m_virtualSize.width()), 0, 0, 0, + 0, 1 / float(m_virtualSize.height()), 0, 0, + 0, 0, -0.0001, 0, + 0, 0, 0, 1 + }; + + GLRotationMatrix panningMatrix { + 1, 0, 0, float(m_panningX), + 0, 1, 0, float(m_panningY), + 0, 0, 1, 0, + 0, 0, 0, 1 + }; + + return ortho * panningMatrix * m_rotationMatrix; +}
--- a/src/glcamera.h Fri Jan 12 00:55:31 2018 +0200 +++ b/src/glcamera.h Sat Jan 13 00:04:54 2018 +0200 @@ -64,6 +64,7 @@ const QSizeF& virtualSize() const; double zoom() const; void zoomNotch(bool inward); + GLRotationMatrix realMatrix() const; private: QString m_name;
--- a/src/glcompiler.cpp Fri Jan 12 00:55:31 2018 +0200 +++ b/src/glcompiler.cpp Sat Jan 13 00:04:54 2018 +0200 @@ -421,6 +421,12 @@ << -normals[vert].y() << -normals[vert].z(); } + else if (complement == VboSubclass::InvertedNormals) + { + vbodata << -normals[vert].x(); + vbodata << +normals[vert].y(); + vbodata << +normals[vert].z(); + } else { vbodata << ((GLfloat) color.red()) / 255.0f
--- a/src/glrenderer.cpp Fri Jan 12 00:55:31 2018 +0200 +++ b/src/glrenderer.cpp Sat Jan 13 00:04:54 2018 +0200 @@ -375,12 +375,8 @@ { glMatrixMode (GL_PROJECTION); glPushMatrix(); - glLoadIdentity(); - const QSizeF& virtualSize = currentCamera().virtualSize(); - glOrtho(-virtualSize.width(), virtualSize.width(), -virtualSize.height(), virtualSize.height(), -1000.0f, 1000.0f); - glTranslatef(panning (X), panning (Y), 0.0f); - glMultMatrixf(currentCamera().transformationMatrix()); + glMultMatrixf(currentCamera().realMatrix()); glMultMatrixf(ldrawToGLAdapterMatrix); drawFixedCameraBackdrop(); } @@ -496,9 +492,16 @@ break; } + VboSubclass normals; + + if (colors != VboSubclass::BfcBackColors) + normals = VboSubclass::Normals; + else + normals = VboSubclass::InvertedNormals; + int surfaceVboNumber = m_compiler->vboNumber(surface, VboSubclass::Surfaces); int colorVboNumber = m_compiler->vboNumber(surface, colors); - int normalVboNumber = m_compiler->vboNumber(surface, VboSubclass::Normals); + int normalVboNumber = m_compiler->vboNumber(surface, normals); m_compiler->prepareVBO(surfaceVboNumber); m_compiler->prepareVBO(colorVboNumber); m_compiler->prepareVBO(normalVboNumber);