void MultiTrackPlotter::updateTransform() { qreal y_scaling = 1.0; y_scaling *= m_height * 0.5; if (!m_overlay && m_channel_count > 1) y_scaling /= m_channel_count; qreal x_scaling = m_width; if (m_frame_count > 1) x_scaling /= (m_frame_count - 1); for (int idx = 0; idx < m_channel_count; ++idx) { qreal y_translation = 1.0; if (!m_overlay) y_translation += idx * 2.0; QMatrix4x4 matrix; matrix.scale(x_scaling, y_scaling); matrix.translate(0.0, y_translation); matrix.scale(1.0, -m_scaling); // flip y axis! QSGTransformNode *transformNode = static_cast<QSGTransformNode*>( childAtIndex(idx) );; transformNode->setMatrix(matrix); } }
template <typename R> void call(R *r) { using V = decltype(declval<typename R::Cell>().getPosition()); const auto &view = r->getViewMatrix(); const auto &projection = r->getProjectionMatrix(); shader.bind(); disk.vao.bind(); QVector4D color(0.9f, 0.9f, 0.05f, 1.0f); shader.setUniformValue(shader.uniformLocation("color"), color); shader.setUniformValue(shader.uniformLocation("projection"), projection); shader.setUniformValue(shader.uniformLocation("view"), view); for (auto &con : r->getScenario().getWorld().cellCellConnections) { auto &cc = con.second; QMatrix4x4 model; model.translate( toQV3D(cc.cells.first->getPosition() + cc.normal * cc.midpoint.first)); auto rot = V::getRotation(V(0, 0, 1), cc.normal); model.rotate(rot.teta * 180.0 / M_PI, toQV3D(rot.n)); float rad = static_cast<float>(sqrt(cc.sqradius)); model.scale(rad, rad, rad); QMatrix4x4 nmatrix = (model).inverted().transposed(); shader.setUniformValue(shader.uniformLocation("model"), model); shader.setUniformValue(shader.uniformLocation("normalMatrix"), nmatrix); GL->glDrawElements(GL_TRIANGLES, disk.indices.size(), GL_UNSIGNED_INT, 0); } color = QVector4D(0.1f, 0.7f, 0.f, 1.0f); shader.setUniformValue(shader.uniformLocation("color"), color); for (auto &con : r->getScenario().getWorld().cellCellConnections) { auto &cc = con.second; QMatrix4x4 model; model.translate(toQV3D(cc.cells.first->getPosition() + cc.icb.first.currentBasis.X * cc.midpoint.first)); auto rot = V::getRotation(V(0, 0, 1), cc.icb.first.currentBasis.X); model.rotate(rot.teta * 180.0 / M_PI, toQV3D(rot.n)); float rad = static_cast<float>(sqrt(cc.sqradius)); model.scale(rad, rad, rad); QMatrix4x4 nmatrix = (model).inverted().transposed(); shader.setUniformValue(shader.uniformLocation("model"), model); shader.setUniformValue(shader.uniformLocation("normalMatrix"), nmatrix); GL->glDrawElements(GL_TRIANGLES, disk.indices.size(), GL_UNSIGNED_INT, 0); } color = QVector4D(0.f, 0.1f, 0.7f, 1.0f); shader.setUniformValue(shader.uniformLocation("color"), color); for (auto &con : r->getScenario().getWorld().cellCellConnections) { auto &cc = con.second; QMatrix4x4 model; model.translate(toQV3D(cc.cells.second->getPosition() + cc.icb.second.currentBasis.X * cc.midpoint.second)); auto rot = V::getRotation(V(0, 0, 1), cc.icb.second.currentBasis.X); model.rotate(rot.teta * 180.0 / M_PI, toQV3D(rot.n)); float rad = static_cast<float>(sqrt(cc.sqradius)); model.scale(rad, rad, rad); QMatrix4x4 nmatrix = (model).inverted().transposed(); shader.setUniformValue(shader.uniformLocation("model"), model); shader.setUniformValue(shader.uniformLocation("normalMatrix"), nmatrix); GL->glDrawElements(GL_TRIANGLES, disk.indices.size(), GL_UNSIGNED_INT, 0); } disk.vao.release(); shader.release(); }
QMatrix4x4 Canvas::view_matrix() const { QMatrix4x4 m; if (width() > height()) { m.scale(-height() / float(width()), 1, 0.5); } else { m.scale(-1, width() / float(height()), 0.5); } m.scale(zoom, zoom, 1); return m; }
template <typename R> void call(R *r) { const auto &view = r->getViewMatrix(); const auto &projection = r->getProjectionMatrix(); for (auto &con : r->getScenario().getWorld().cellCellConnections) { auto &cc = con.second; shader.bind(); cube.vao.bind(); QColor color = QColor::fromHsvF(0.7, 0.7, 0.7); shader.setUniformValue(shader.uniformLocation("color"), color); shader.setUniformValue(shader.uniformLocation("projection"), projection); shader.setUniformValue(shader.uniformLocation("view"), view); // first QMatrix4x4 model; auto ab = toQV3D(cc.targets.first.b.X.rotated(cc.cells.first->getOrientationRotation()) * cc.targets.first.d); model.translate(toQV3D(cc.cells.first->getPosition()) + ab * 0.5); auto dp = ab.normalized().x(); if (dp != 1 && dp != -1) { model.rotate(acos(dp) * 180.0 / M_PI, QVector3D::crossProduct(QVector3D(1, 0, 0), ab)); model.scale(ab.length() * 0.5, 1.0, 1.0); QMatrix4x4 nmatrix = (model).inverted().transposed(); shader.setUniformValue(shader.uniformLocation("model"), model); shader.setUniformValue(shader.uniformLocation("normalMatrix"), nmatrix); GL->glDrawElements(GL_TRIANGLES, cube.indices.size(), GL_UNSIGNED_INT, 0); } // second color = QColor::fromHsvF(0.3, 0.7, 0.7); shader.setUniformValue(shader.uniformLocation("color"), color); model = QMatrix4x4(); ab = toQV3D( cc.targets.second.b.X.rotated(cc.cells.second->getOrientationRotation()) * cc.targets.second.d); model.translate(toQV3D(cc.cells.second->getPosition()) + ab * 0.5); dp = ab.normalized().x(); if (dp != 1 && dp != -1) { model.rotate(acos(dp) * 180.0 / M_PI, QVector3D::crossProduct(QVector3D(1, 0, 0), ab)); model.scale(ab.length() * 0.5, 1.0, 1.0); QMatrix4x4 nmatrix = (model).inverted().transposed(); shader.setUniformValue(shader.uniformLocation("model"), model); shader.setUniformValue(shader.uniformLocation("normalMatrix"), nmatrix); GL->glDrawElements(GL_TRIANGLES, cube.indices.size(), GL_UNSIGNED_INT, 0); } cube.vao.release(); shader.release(); } }
void HgTransformedQuad::transformQuad(int index, const QMatrix4x4& projView, HgQuad* quad, qreal mirroringPlaneY, const QVector2D& translate, const QPointF& center, const QSizeF& windowSize) { mIndex = index; mQuad = quad; QMatrix4x4 tm; tm.setToIdentity(); tm.rotate(quad->outerRotation()); if (mQuad->mirrorImageEnabled()) { computeMirroredPoints(tm, projView, mirroringPlaneY, translate, center, windowSize); } tm.translate(quad->position()); tm.rotate(quad->rotation()); tm.scale(quad->scale().x(), quad->scale().y()); tm = projView * tm; perspectiveTransformPoints(mTransformedPoints, tm, center, windowSize); for (int i = 0; i < 4; i++) mTransformedPoints[i] += translate; }
void Widget::paintGL() { glClearColor(.3, .4, .5, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); myShader.bind(); QMatrix4x4 modelview; modelview.perspective(70, 1.0 * this->width() / this->height(), 0.1, 100); QVector3D to = QVector3D(sin(yaw) * cos(pitch), cos(yaw) * cos(pitch), sin(pitch)); move(); modelview.lookAt(from, from + to, QVector3D(0, 0, 1)); myShader.setUniformValue("mvp", modelview); groundMesh.draw(this, &myShader); modelview.scale(2); myShader.setUniformValue("mvp", modelview); torusMesh.draw(this, &myShader); myShader.release(); // TODO: use QOpenGLDebugLogger }
void QSGAnimatorNode::preprocess() { QSGNode::preprocess(); if (m_controller->isInitialized()) { if (m_transformNode) { qreal x = m_controller->registeredProperty("x")->value().toReal(); qreal y = m_controller->registeredProperty("y")->value().toReal(); QMatrix4x4 m = m_controller->transformMatrix(); QPointF transformOrigin = m_controller->registeredProperty("transformOriginPoint")->value().toPointF(); qreal scale = m_controller->registeredProperty("scale")->value().toReal(); qreal rotation = m_controller->registeredProperty("rotation")->value().toReal(); m.translate(transformOrigin.x(), transformOrigin.y()); m.translate(x, y); m.scale(scale); m.rotate(rotation, 0, 0, 1); m.translate(-transformOrigin.x(), -transformOrigin.y()); m_transformNode->setMatrix(m); if (m_controller->isUpdating()) m_transformNode->markDirty(QSGNode::DirtyMatrix); } if (m_opacityNode) { qreal opacity = m_controller->registeredProperty("opacity")->value().toReal(); m_opacityNode->setOpacity(qMin(qreal(MAX_OPACITY), qMax(qreal(MIN_OPACITY), opacity))); if (m_controller->isUpdating()) m_opacityNode->markDirty(QSGNode::DirtyOpacity); } } }
void SurfaceGraph::paintGL() { // Clear color and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); texture->bind(); // Calculate model view transformation QMatrix4x4 matrix; matrix.translate(0.0, 0.0, -5.0); matrix.rotate(rotation); matrix.scale(zoom,zoom,zoom); // Set modelview-projection matrix program.setUniformValue("mvp_matrix", projection * matrix); // Use texture unit 0 (which file to use) program.setUniformValue("texture", 0); // Draw geometry geometries->drawGeometry(&program); if (display_lines) { geometries->drawLineGeometry(&program); geometries->drawPointGeometry(&program); } }
void AvatarVoxelSystem::applyScaleAndBindProgram(bool texture) { _skinProgram.bind(); // the base matrix includes centering and scale QMatrix4x4 baseMatrix; baseMatrix.scale(_treeScale); baseMatrix.translate(-0.5f, -0.5f, -0.5f); // bone matrices include joint transforms QMatrix4x4 boneMatrices[NUM_AVATAR_JOINTS]; for (int i = 0; i < NUM_AVATAR_JOINTS; i++) { glm::vec3 position; glm::quat orientation; _avatar->getBodyBallTransform((AvatarJointID)i, position, orientation); boneMatrices[i].translate(position.x, position.y, position.z); orientation = orientation * glm::inverse(_avatar->getSkeleton().joint[i].absoluteBindPoseRotation); boneMatrices[i].rotate(QQuaternion(orientation.w, orientation.x, orientation.y, orientation.z)); const glm::vec3& bindPosition = _avatar->getSkeleton().joint[i].absoluteBindPosePosition; boneMatrices[i].translate(-bindPosition.x, -bindPosition.y, -bindPosition.z); boneMatrices[i] *= baseMatrix; } _skinProgram.setUniformValueArray(_boneMatricesLocation, boneMatrices, NUM_AVATAR_JOINTS); glBindBuffer(GL_ARRAY_BUFFER, _vboBoneIndicesID); glVertexAttribPointer(_boneIndicesLocation, BONE_ELEMENTS_PER_VERTEX, GL_UNSIGNED_BYTE, false, 0, 0); _skinProgram.enableAttributeArray(_boneIndicesLocation); glBindBuffer(GL_ARRAY_BUFFER, _vboBoneWeightsID); _skinProgram.setAttributeBuffer(_boneWeightsLocation, GL_FLOAT, 0, BONE_ELEMENTS_PER_VERTEX); _skinProgram.enableAttributeArray(_boneWeightsLocation); }
template <typename R> void call(R *r) { const auto &view = r->getViewMatrix(); const auto &projection = r->getProjectionMatrix(); shader.bind(); sphere.vao.bind(); texture->bind(0); shader.setUniformValue(shader.uniformLocation("projection"), projection); shader.setUniformValue(shader.uniformLocation("view"), view); for (auto &n : r->getScenario().nutrientSources) { QMatrix4x4 model; model.translate(n.pos.x(), n.pos.y(), n.pos.z()); double c = n.content / n.initialcontent; double l = 15.0 + sqrt(n.sqradius * c) * 0.05; model.scale(l, l, l); QMatrix4x4 nmatrix = (model).inverted().transposed(); shader.setUniformValue(shader.uniformLocation("model"), model); shader.setUniformValue(shader.uniformLocation("normalMatrix"), nmatrix); auto hsv = QColor::fromHsvF(c * 0.35, 0.9, 0.9); QVector4D col(hsv.redF(), hsv.greenF(), hsv.blueF(), 0.5); std::cerr << "c = " << c << ", r = " << col.x() << std::endl; shader.setUniformValue(shader.uniformLocation("color"), col); GL->glDrawElements(GL_TRIANGLES, sphere.indices.size(), GL_UNSIGNED_INT, 0); } sphere.vao.release(); shader.release(); }
void LogoRenderer::vao_vbo_glDrawArrays() { // Render glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Draw our first triangle glUseProgram(shaderProgram); QMatrix4x4 modelview; modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f); modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f); modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f); modelview.scale(m_fScale); modelview.translate(0.0f, -0.2f, 0.0f); // Uniform offset // Get matrix's uniform location and set matrix GLint transformLoc = glGetUniformLocation(shaderProgram, "transform"); glUniformMatrix4fv(transformLoc, 1, GL_FALSE, modelview.data()); // glUniform1f(glGetUniformLocation(ourShader.Program, "xOffset"), offset); glBindVertexArray(VAO); glDrawArrays(GL_TRIANGLES, 0, 3); glBindVertexArray(0); }
QMatrix4x4 centerIn(const QRectF& content, const QRectF& frame) { const qreal contentSize = std::max(content.width(), content.height()); const qreal frameSize = std::min(frame.width(), frame.height()); qreal scale{1}; if (frameSize < contentSize) { scale = frameSize / contentSize; } const QSizeF scaledContentSize = QSizeF(content.size()) * scale; const qreal dx = (frame.width() - scaledContentSize.width()) / 2.0; const qreal dy = (frame.height() - scaledContentSize.height()) / 2.0; QPointF translate = QPointF(-content.topLeft()); translate += (QPointF(dx, dy) * (1 / scale)); QMatrix4x4 matrix; matrix.scale(scale); matrix.translate(translate.x(), translate.y()); return matrix; }
ImageData::ImageData(const QSize &size, const Format::Id format, const GLubyte *const data) : TextureData(size, format, data), rect(QPoint(0, 0), size), projectionMatrix([this]() { const float halfWidth = (float)this->size.width() / 2.f; const float halfHeight = (float)this->size.height() / 2.f; QMatrix4x4 temp; temp.scale(1.f / (float)halfWidth, 1.f / (float)halfHeight); temp.translate(-halfWidth, -halfHeight); return temp; }()), vertexArray([this](){ GLuint vertexArray; glGenVertexArrays(1, &vertexArray); return vertexArray; }()), vertexBuffer([this](){ GLuint vertexBuffer; glGenBuffers((GLsizei)1, &vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); const GLfloat vertices[][2] = { {0.f, 0.f}, {(GLfloat)this->size.width(), 0.f}, {(GLfloat)this->size.width(), (GLfloat)this->size.height()}, {0.f, (GLfloat)this->size.height()}, }; glBufferData(GL_ARRAY_BUFFER, 4 * 2 * sizeof(GLfloat), vertices, GL_STATIC_DRAW); return vertexBuffer; }()) { }
QMatrix4x4 ModelInterface::getMatrix(const aiMatrix4x4* m) { QMatrix4x4 nodeMatrix; if(m->IsIdentity()) return nodeMatrix; aiQuaternion rotation; aiVector3D position; aiVector3D scale; m->Decompose(scale, rotation, position); QVector3D qscale(scale.x,scale.y, scale.z); QVector3D qposition(position.x, position.y, position.z); QQuaternion qrotation(rotation.w, rotation.x, rotation.y, rotation.z); if(!qscale.isNull()) nodeMatrix.scale(qscale); if(!qposition.isNull()) nodeMatrix.translate(qposition); if(!qrotation.isNull()) nodeMatrix.rotate(qrotation); return nodeMatrix; }
void BeamRendererComponent::draw( int /* timeLapse */ ) { QMatrix4x4 transform = gameObject()->transform(); transform.translate( 0, 0, 0.01f ); transform.scale( d->size.width() / 2, d->size.width() / 2 ); d->baseItem->setTransform( transform ); transform = gameObject()->transform(); transform.translate( 0, d->size.height() / 2 ); transform.scale( d->size.width() / 2, d->size.height() / 2 ); d->beamItem->setTransform( transform ); transform = gameObject()->transform(); transform.translate( 0, d->size.height(), 0.01f ); transform.scale( d->size.width() / 2, d->size.width() / 2 ); d->tipItem->setTransform( transform ); }
QMatrix4x4 Transformable::modelMatrix() const { QMatrix4x4 mat; mat.translate(m_position); mat.scale(m_scale); //mat.rotate(m_rotation); mat.rotate(m_rotation.scalar(), m_rotation.x(), m_rotation.y(), m_rotation.z()); return mat; }
void PhysicsTransform::updateMatrix(){ QMatrix4x4 m; m.translate(m_translation); m.rotate(m_rotation); m.scale(m_scale); m_transformMatrix = m; m_dirty=true; }
void TimelineRenderState::assembleNodeTree(const TimelineModel *model, int defaultRowHeight, int defaultRowOffset) { Q_D(TimelineRenderState); QTC_ASSERT(isEmpty(), return); for (int pass = 0; pass < d->passes.length(); ++pass) { const TimelineRenderPass::State *passState = d->passes[pass]; if (!passState) continue; if (passState->expandedOverlay()) d->expandedOverlayRoot->appendChildNode(passState->expandedOverlay()); if (passState->collapsedOverlay()) d->collapsedOverlayRoot->appendChildNode(passState->collapsedOverlay()); } int row = 0; for (int i = 0; i < model->expandedRowCount(); ++i) { QSGTransformNode *rowNode = new QSGTransformNode; for (int pass = 0; pass < d->passes.length(); ++pass) { const TimelineRenderPass::State *passState = d->passes[pass]; if (!passState) continue; const QVector<QSGNode *> &rows = passState->expandedRows(); if (rows.length() > row) { QSGNode *rowChildNode = rows[row]; if (rowChildNode) rowNode->appendChildNode(rowChildNode); } } d->expandedRowRoot->appendChildNode(rowNode); ++row; } for (int row = 0; row < model->collapsedRowCount(); ++row) { QSGTransformNode *rowNode = new QSGTransformNode; QMatrix4x4 matrix; matrix.translate(0, row * defaultRowOffset, 0); matrix.scale(1.0, static_cast<float>(defaultRowHeight) / static_cast<float>(TimelineModel::defaultRowHeight()), 1.0); rowNode->setMatrix(matrix); for (int pass = 0; pass < d->passes.length(); ++pass) { const TimelineRenderPass::State *passState = d->passes[pass]; if (!passState) continue; const QVector<QSGNode *> &rows = passState->collapsedRows(); if (rows.length() > row) { QSGNode *rowChildNode = rows[row]; if (rowChildNode) rowNode->appendChildNode(rowChildNode); } } d->collapsedRowRoot->appendChildNode(rowNode); } updateExpandedRowHeights(model, defaultRowHeight, defaultRowOffset); }
void ParticleRendererComponent::draw( int /* timeLapse */ ) { if( d->item ) { QMatrix4x4 transform = gameObject()->transform(); transform.scale( d->size.width() / 2, d->size.height() / 2 ); d->item->setTransform( transform ); } }
QMatrix4x4 Canvas::transform_matrix() const { QMatrix4x4 m; m.rotate(tilt, QVector3D(1, 0, 0)); m.rotate(yaw, QVector3D(0, 0, 1)); m.scale(scale); m.translate(-center); return m; }
const QMatrix4x4 &RaycastCube::matrix() { static QMatrix4x4 mat; mat.setToIdentity(); // mat.translate(0.5f, 0.5f, 0.5f); // mat.scale(width - 1, height - 1, depth - 1); mat.scale(width, height, depth); return mat; }
/** \brief Returns a matrix that can convert the normalize note coordinates to the physical page distance in meters. This is useful for converting normalized coordinates into reallife coordinates. */ QMatrix4x4 cwNote::metersOnPageMatrix() const { double dotsPerMeter = dotPerMeter(); double metersPerDot = 1.0 / dotsPerMeter; QMatrix4x4 metersPerDotsMatrix; metersPerDotsMatrix.scale(metersPerDot, metersPerDot, 1.0); return metersPerDotsMatrix * scaleMatrix(); }
void ShaderEffectItem::renderEffect(QPainter *painter, const QMatrix4x4 &matrix) { if (!painter || !painter->device()) return; if (!m_program.isLinked() || m_program_dirty) updateShaderProgram(); m_program.bind(); QMatrix4x4 combinedMatrix; combinedMatrix.scale(2.0 / painter->device()->width(), -2.0 / painter->device()->height(), 1.0); combinedMatrix.translate(-painter->device()->width() / 2.0, -painter->device()->height() / 2.0 ); combinedMatrix *= matrix; updateEffectState(combinedMatrix); for (int i = 0; i < m_attributeNames.size(); ++i) { m_program.enableAttributeArray(m_geometry.attributes()[i].position); } bindGeometry(); // Optimization, disable depth test when we know we don't need it. if (m_defaultVertexShader) { glDepthMask(false); glDisable(GL_DEPTH_TEST); } else { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_GREATER); glDepthMask(true); #if defined(QT_OPENGL_ES) glClearDepthf(0); #else glClearDepth(0); #endif glClearColor(0, 0, 0, 0); glClear(GL_DEPTH_BUFFER_BIT); } if (m_blending){ glEnable(GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } else { glDisable(GL_BLEND); } if (m_geometry.indexCount()) glDrawElements(m_geometry.drawingMode(), m_geometry.indexCount(), m_geometry.indexType(), m_geometry.indexData()); else glDrawArrays(m_geometry.drawingMode(), 0, m_geometry.vertexCount()); glDepthMask(false); glDisable(GL_DEPTH_TEST); for (int i = 0; i < m_attributeNames.size(); ++i) m_program.disableAttributeArray(m_geometry.attributes()[i].position); }
void LogoRenderer::render() { //glClearColor(0.5f, 0.5f, 0.7f, 1.0f); glClearColor(0, 0, 0, 1); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPointSize(5.0); //glClearDepth(1.0f); glDisable(GL_SCISSOR_TEST); glEnable(GL_STENCIL_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); handleEvents(); handleLogic(); drawStuff(); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); return; glDepthMask(true); glClearColor(0.5f, 0.5f, 0.7f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glFrontFace(GL_CW); glCullFace(GL_FRONT); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); QMatrix4x4 modelview; modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f); modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f); modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f); modelview.scale(m_fScale); modelview.translate(0.0f, -0.2f, 0.0f); program1.bind(); program1.setUniformValue(matrixUniform1, modelview); paintQtLogo(); program1.release(); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); m_fAngle += 1.0f; }
virtual void render(const RenderState&) { QMatrix4x4 renderMatrix = matrix() ? *matrix() : QMatrix4x4(); // Have to apply render scale manualy because it is not applied on page item. // http://trac.webkit.org/changeset/104450 renderMatrix.scale(m_scale); // FIXME: Support non-rectangular clippings. layerTreeRenderer()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect()); }
void XYPlotter::updateTransform() { qreal size_scale = qMin(m_width, m_height); QMatrix4x4 matrix; matrix.translate(m_width * 0.5, m_height * 0.5); matrix.scale(0.5 * size_scale * m_x_scaling, -0.5 * size_scale * m_y_scaling); // flip y axis! setMatrix(matrix); }
QMatrix4x4 Canvas::getMatrix() const { QMatrix4x4 M; // Remember that these operations are applied in reverse order. M.scale(scale, -scale, scale); M.rotate(pitch * 180 / M_PI, QVector3D(1, 0, 0)); M.rotate(yaw * 180 / M_PI, QVector3D(0, 0, 1)); M.translate(-center.x(), -center.y(), -center.z()); return M; }
// ColorRangeRGB(...)* static QMatrix4x4 ColorRangeRGB(ColorRange from, ColorRange to) { if (from == to) return QMatrix4x4(); static const qreal R2 = 235, R1 = 16; static const qreal s = 255; if (to == ColorRange_Limited) { qDebug("output rgb limited range"); QMatrix4x4 m; m.translate(R1/s, R1/s, R1/s); m.scale((R2 - R1)/s, (R2 - R1)/s, (R2 - R1)/s); return m; } if (to == ColorRange_Full) { // TODO: Unknown QMatrix4x4 m; m.scale(s/(R2 - R1), s/(R2 - R1), s/(R2 - R1)); m.translate(-s/R1, -s/R1, -s/R1); return m; } return QMatrix4x4(); }
QMatrix4x4 Transform::GetMatrix() const { QMatrix4x4 transformation; transformation.translate(m_pos); //Should use quaternions for the following transformation.rotate(m_rotation.z(),QVector3D(0.0f,0.0f,1.0f)); transformation.rotate(m_rotation.y(),QVector3D(0.0f,1.0f,0.0f)); transformation.rotate(m_rotation.x(),QVector3D(1.0f,0.0f,0.0f)); transformation.scale(m_scale); return transformation; }
void QgsQuickMapTransform::updateMatrix() { QMatrix4x4 matrix; float scaleFactor = static_cast<float>( 1.0 / mMapSettings->mapUnitsPerPixel() ); matrix.scale( scaleFactor, -scaleFactor ); matrix.translate( static_cast<float>( -mMapSettings->visibleExtent().xMinimum( ) ), static_cast<float>( -mMapSettings->visibleExtent().yMaximum() ) ); mMatrix = matrix; update(); }