当前位置: 首页>>代码示例>>C++>>正文


C++ QMatrix4x4::scale方法代码示例

本文整理汇总了C++中QMatrix4x4::scale方法的典型用法代码示例。如果您正苦于以下问题:C++ QMatrix4x4::scale方法的具体用法?C++ QMatrix4x4::scale怎么用?C++ QMatrix4x4::scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMatrix4x4的用法示例。


在下文中一共展示了QMatrix4x4::scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateTransform

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);
    }
}
开发者ID:jleben,项目名称:quickcollider,代码行数:26,代码来源:oscilloscope.cpp

示例2: color

	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();
	}
开发者ID:jdisset,项目名称:seacells,代码行数:59,代码来源:drawextensions.hpp

示例3: view_matrix

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;
}
开发者ID:SHINOTECH,项目名称:fstl,代码行数:14,代码来源:canvas.cpp

示例4: call

	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();
		}
	}
开发者ID:jdisset,项目名称:seacells,代码行数:49,代码来源:drawextensions.hpp

示例5: transformQuad

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;

}
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:28,代码来源:hgtransformedquad.cpp

示例6: paintGL

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
}
开发者ID:sancha-3000,项目名称:cg15,代码行数:26,代码来源:widget.cpp

示例7: preprocess

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);
        }
    }
}
开发者ID:shrikantd,项目名称:playground-scenegraph,代码行数:31,代码来源:qsganimatornode.cpp

示例8: paintGL

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);
    }
}
开发者ID:gareins,项目名称:surface-reconstruction,代码行数:28,代码来源:surfacegraph.cpp

示例9: applyScaleAndBindProgram

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);
}
开发者ID:heracek,项目名称:hifi,代码行数:31,代码来源:AvatarVoxelSystem.cpp

示例10: col

	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();
	}
开发者ID:jdisset,项目名称:seacells,代码行数:26,代码来源:drawextensions.hpp

示例11: centerIn

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;
}
开发者ID:denesb,项目名称:warmonger,代码行数:25,代码来源:MapUtil.cpp

示例12: TextureData

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; }())

{
}
开发者ID:not-surt,项目名称:SimPix,代码行数:28,代码来源:data.cpp

示例13: getMatrix

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;
}
开发者ID:glararan,项目名称:QEditor,代码行数:28,代码来源:modelinterface.cpp

示例14: draw

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 );
}
开发者ID:pranavrc,项目名称:gluon,代码行数:17,代码来源:beamrenderercomponent.cpp

示例15: modelMatrix

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;
}
开发者ID:nmikhailov,项目名称:opengl,代码行数:8,代码来源:transformable.cpp


注:本文中的QMatrix4x4::scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。