--- a/src/glcamera.cpp Sat Feb 18 02:02:29 2017 +0200 +++ b/src/glcamera.cpp Mon Feb 20 07:56:21 2017 +0200 @@ -25,7 +25,7 @@ */ GLCamera::GLCamera(QString name, FixedCameraParameters&& bag) : m_name {name}, - m_glrotate {bag.glRotateX, bag.glRotateY, bag.glRotateZ}, + m_rotationMatrix {bag.rotationMatrix}, m_localX {bag.localX}, m_localY {bag.localY}, m_negatedX {bag.negatedX}, @@ -40,14 +40,6 @@ m_isFree {true} {} /* - * Returns OpenGL rotation information for this camera. - */ -int GLCamera::glRotate(Axis axis) const -{ - return m_glrotate[axis]; -} - -/* * Returns whether or not the given axis is negated on this camera. */ bool GLCamera::isAxisNegated(Axis axis) const @@ -243,35 +235,21 @@ return m_name; } +const GLRotationMatrix& GLCamera::transformationMatrix() const +{ + return m_rotationMatrix; +} + /* * Returns the camera's transformation matrix, scaled by the given scale value. */ -Matrix GLCamera::transformationMatrix(double scale) const +GLRotationMatrix GLCamera::transformationMatrix(double scale) const { - // Matrix templates. 2 is substituted with the scale value, 1 is inverted to -1 if needed. - static const Matrix templates[3] = - { - { 2, 0, 0, 0, 1, 0, 0, 0, 2 }, - { 2, 0, 0, 0, 0, 2, 0, 1, 0 }, - { 0, 1, 0, 2, 0, 0, 0, 0, 2 }, - }; - - Matrix transform; + GLRotationMatrix matrix = m_rotationMatrix; - if (m_localX == X and m_localY == Z) - transform = templates[0]; - else if (m_localX == X and m_localY == Y) - transform = templates[1]; - if (m_localX == Y and m_localY == Z) - transform = templates[2]; + for (int i = 0; i < 4; ++i) + for (int j = 0; j < 4; ++j) + matrix(i, j) *= scale; - for (double& value : transform) - { - if (value == 2) - value = scale; - else if (value == 1 and (glRotate(X) + glRotate(Y) + glRotate(Z)) < 0) - value = -1; - } - - return transform; + return matrix; }