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


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

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


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

示例1: rotationOfFlange

QMatrix4x4 CAD_arch_support::rotationOfFlange(quint8 num)
{
    if (num == 1)
        return matrix_rotation;
    else if(num == 2)
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(90.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
    else if(num == 3)
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(180.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
    else
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(270.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
}
开发者ID:sme-gmbh,项目名称:smepowercad,代码行数:26,代码来源:cad_arch_support.cpp

示例2: if

QMatrix4x4 CAD_electrical_busbarwithtapoffpoints2row::rotationOfFlange(quint8 num)
{
    if(num == 1)
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(180.0, 0.0, 1.0, 0.0);
        return matrix_rotation * m;
    }
    else if(num == 2)
        return matrix_rotation;
    else
    {
        QMatrix4x4 m;
        m.setToIdentity();
        if(num % 2 == 0)
        {
            m.rotate(-90.0, 0.0, 0.0, 1.0);
            m.rotate(180.0, 1.0, 0.0, 0.0);
        }
        else
            m.rotate(90.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
}
开发者ID:sme-gmbh,项目名称:smepowercad,代码行数:25,代码来源:cad_electrical_busbarwithtapoffpoints2row.cpp

示例3: rotationOfFlange

QMatrix4x4 CAD_Cleanroom_CeilingCornerPiece::rotationOfFlange(quint8 num)
{
    if(num == 1)
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(180.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
    else if(num == 2)
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(-90.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
    else if(num == 3)
    {
        QMatrix4x4 m;
        m.setToIdentity();
        m.rotate(180.0, 0.0, 0.0, 1.0);
        return matrix_rotation * m;
    }
    else
        return matrix_rotation;
}
开发者ID:sme-gmbh,项目名称:smepowercad,代码行数:26,代码来源:cad_cleanroom_ceilingcornerpiece.cpp

示例4: directionLightPass

void Scene::directionLightPass(RenderTarget *target)
{
    ShaderProgram * shader =ShaderPool::getInstance ()->get("dir_light_pass");
    shader->use ();
    int texture_offset = 5;

    for(int i = 0 ;i<4;i++)
    {
        directionLight.getCSM_FBO (i)->BindForReading(GL_TEXTURE0+i+texture_offset);
        char GLSL_shadowMap_name [30];
        sprintf(GLSL_shadowMap_name,"g_shadow_map[%d]",i);
        directionLight.getCSM_FBO (i)->applyShadowMapTexture (shader,i+texture_offset,GLSL_shadowMap_name);
    }

    QMatrix4x4 m;
    m.setToIdentity ();
    m_quad->setShaderProgram (shader);
    shader->setUniformMat4v ("g_MVP_matrix",m.data ());
    shader->setUniform2Float ("g_screen_size",1024,768);
    shader->setUniformInteger ("g_color_map",0);
    shader->setUniformInteger ("g_position_map",1);
    shader->setUniformInteger ("g_normal_map",2);

    shader->setUniformInteger ("g_depth_map",4);//for depth

    auto camera = target->camera ();
    if(camera)
    {
        shader->setUniform3Float ("g_eye_position",
                                  camera->pos ().x(),
                                  camera->pos ().y(),
                                  camera->pos ().z());
    }

    QMatrix4x4 lightView;
    lightView.setToIdentity();


    QVector3D lightDir = directionLight.getDirection ();
    QVector3D pos = QVector3D(0,0,0);
    lightView.lookAt(pos,lightDir,QVector3D(0,1,0));

    for(int i =0 ;i <4 ;i++)
    {
        if(!camera) break;
        auto split_frustum_aabb = camera->getSplitFrustumAABB (i);
        split_frustum_aabb.transForm (target->camera()->getModelTrans ());
        split_frustum_aabb.transForm (lightView);
        auto matrix = getCropMatrix (split_frustum_aabb);
        QMatrix4x4 light_vp;
        light_vp = matrix * lightView ;
        char GLSL_light_VP_name [30];
        sprintf(GLSL_light_VP_name,"g_light_vp_matrix[%d]",i);
        shader->setUniformMat4v (GLSL_light_VP_name,light_vp.data ());
    }
    this->directionLight.apply(shader);
    this->ambientLight.apply(shader);
    m_quad->draw (true);
}
开发者ID:HeeroNight,项目名称:Cube-Engine,代码行数:59,代码来源:scene.cpp

示例5: qglClearColor

void Dragon2Widget::paintGL()
{
    qglClearColor(Qt::white);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_ALPHA_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // use the OpenGL shader program for painting
    glUseProgram(_program);

    // set model matrix
    glUniformMatrix4fv(_modelMatrixLocation, 1, GL_FALSE, _modelMatrix.data());

    // set view matrix
    QMatrix4x4 viewMatrix;
    viewMatrix.setToIdentity();
    viewMatrix.lookAt(QVector3D(0, 0, -1000), QVector3D(0, 0, 0), QVector3D(0, -1, 0));
    glUniformMatrix4fv(_viewMatrixLocation, 1, GL_FALSE, viewMatrix.data());

    // set projection matrix
    QMatrix4x4 projectionMatrix;
    projectionMatrix.setToIdentity();
    projectionMatrix.perspective(30, (float)width()/height(), 0.01f, 1e5f);
    glUniformMatrix4fv(_projectionMatrixLocation, 1, GL_FALSE, projectionMatrix.data());

    // bind ArrayBuffer to _vertBuffer
    glBindBuffer(GL_ARRAY_BUFFER, _vertBuffer);
    // enable vertex attribute "position" (bound to 0 already)
    glEnableVertexAttribArray(0); 
    // set the data of vertex attribute "position" using current ArrayBuffer
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(_vertices.first()), 0);
    // enable vertex attribute "normal" (bound to 1 already)
    glEnableVertexAttribArray(1);
    // set the data of vertex attribute "normal" using current ArrayBuffer
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(_vertices.first()), (void*)(3 * sizeof(float)));

    // bind ElementArrayBuffer to _triangleIndicesBuffer
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _triangleIndicesBuffer);
    // draw mesh using the indices stored in ElementArrayBuffer
    glDrawElements(GL_TRIANGLES, _triangleIndices.size(), GL_UNSIGNED_INT, 0);

    // disable vertex attributes
    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);

    // unbind buffers
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    // restore states
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_ALPHA_TEST);
    glDisable(GL_BLEND);
}
开发者ID:weeks-yu,项目名称:OpenGLTutorials,代码行数:57,代码来源:dragon2widget.cpp

示例6: rotateView

void AwesomeCamera::rotateView(float z_angle,float x_angle){

//    rotM.setToIdentity();


    double cosPhi = cos(mouse_sens*(-z_angle)/180*M_PI);
    double sinPhi = sin(mouse_sens*(-z_angle)/180*M_PI);


    direction      = QVector3D(cosPhi*direction.x()+sinPhi*direction.z(),direction.y(),
                               cosPhi*direction.z()-sinPhi*direction.x());

    QMatrix4x4 rotMat;
    rotMat.setToIdentity();
    rotMat.rotate(mouse_sens*(-x_angle),QVector3D::crossProduct(direction,QVector3D(0,1,0)));
    QVector3D tmpVec = (rotMat*QVector4D(direction)).toVector3D();
    tmpVec.normalize();
    double angleTheta = QVector3D::dotProduct(tmpVec,QVector3D(0,1,0));
    if(qAbs(angleTheta) < 0.9){
        rotMat.setToIdentity();
        rotMat.rotate(mouse_sens*(-x_angle)*(1-qAbs(angleTheta)),QVector3D::crossProduct(direction,QVector3D(0,1,0)));
        QVector3D tmpVec = (rotMat*QVector4D(direction)).toVector3D();
        tmpVec.normalize();
        direction = tmpVec;
    }

    side_direction = QVector3D(cosPhi*side_direction.x()+sinPhi*side_direction.z(),0,
                               cosPhi*side_direction.z()-sinPhi*side_direction.x());

    updown_direction = QVector3D::crossProduct(direction,side_direction);



/*
    rot_angles[0] += mouse_sens*(z_angle);//przesuniecie X
    rot_angles[1] -= mouse_sens*(x_angle);//przesuniecie Y
    if(rot_angles[1] > 90) rot_angles[1] = 90;
    if(rot_angles[1] <-90) rot_angles[1] = -90;
//    przesuniecie do przodu
    direction = QVector3D(-sin(rot_angles[0]/180*M_PI),sin(rot_angles[1]/180*M_PI),cos(rot_angles[0]/180*M_PI));
//    przesuniece na boki
    side_direction = QVector3D(sin((rot_angles[0]+90)/180*M_PI),0,-cos((rot_angles[0]+90)/180*M_PI));
//    przesuwanie gora dol
    updown_direction = QVector3D::crossProduct(direction,side_direction);
*/

    direction.normalize();
    side_direction.normalize();
    updown_direction.normalize();

}
开发者ID:Calinou,项目名称:AwesomeBump,代码行数:51,代码来源:camera.cpp

示例7: GeometryMultiplier

void View3D::createCoordSystem(Qt3DCore::QEntity* parent)
{
    m_pCoordSysEntity = QSharedPointer<Qt3DCore::QEntity>::create(parent);

    //create geometry
    QSharedPointer<Qt3DExtras::QCylinderGeometry> pAxis =  QSharedPointer<Qt3DExtras::QCylinderGeometry>::create();
    pAxis->setRadius(0.001f);
    pAxis->setLength(30);
    pAxis->setRings(100);
    pAxis->setSlices(20);

    //create mesh
    GeometryMultiplier *pCoordSysMesh = new GeometryMultiplier(pAxis);
    QVector<QColor> vColors;
    vColors.reserve(3);
    QVector<QMatrix4x4> vTransforms;
    vTransforms.reserve(3);
    QMatrix4x4 transformMat;

    // Y - red
    transformMat.setToIdentity();
    vTransforms.push_back(transformMat);
    vColors.push_back(QColor(255, 0, 0));

    // X - blue
    transformMat.setToIdentity();
    transformMat.rotate(90.0f, QVector3D(0,0,1));
    vTransforms.push_back(transformMat);
    vColors.push_back(QColor(0, 0, 255));

    // Z - green
    transformMat.setToIdentity();
    transformMat.rotate(90.0f, QVector3D(1,0,0));
    vTransforms.push_back(transformMat);
    vColors.push_back(QColor(0, 255, 0));

    //Set transforms and colors
    pCoordSysMesh->setTransforms(vTransforms);
    pCoordSysMesh->setColors(vColors);

    //Add material
    GeometryMultiplierMaterial* pCoordSysMaterial = new GeometryMultiplierMaterial;
    pCoordSysMaterial->setAmbient(QColor(0,0,0));
    pCoordSysMaterial->setAlpha(1.0f);

    m_pCoordSysEntity->addComponent(pCoordSysMesh);
    m_pCoordSysEntity->addComponent(pCoordSysMaterial);
}
开发者ID:GBeret,项目名称:mne-cpp,代码行数:48,代码来源:view3D.cpp

示例8: resetModel

void Renderer::resetModel()
{
    m_theta_x=0;
    m_theta_y=0;

    rotation.setToIdentity();
}
开发者ID:PedroRestrepo,项目名称:CSPS453,代码行数:7,代码来源:renderer.cpp

示例9: paintGL

void MyGLWidget::paintGL()
{

    // Clear buffer to set color and alpha
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);







    shaderProgram.setUniformValue(unifMatrixPerspective,projectionMatrix);






    // VIEW TRANSFORMATION
    QMatrix4x4 viewMatrix ;
    viewMatrix.lookAt(cameraPos,cameraPos+cameraFront,cameraUp);
    shaderProgram.setUniformValue(unifMatrixView,viewMatrix);

    // MODEL TRANSFORMATION (Neues OpenGL)
    QMatrix4x4 modelMatrix ;
    // Initialisierung des Modells
    modelMatrix.setToIdentity();
    modelMatrixStack.push(modelMatrix);


    // Zeit zwischen den Render Bildern
    elapsedTime = tmrRender.elapsed();
    //qDebug() << elapsedTime ;
    tmrRender.start();


    // glBindTexture(GL_TEXTURE_2D,tList[sun]);
    //qTex->bind();
    textures[1]->bind();
    textures[1]->bind();


    // Übergebe die Textur an die Uniform Variable
    // Die 0 steht dabei für die verwendete Unit (0=Standard)
    //shaderProgram.setUniformValue("texture",0);



    // Triggern des Renderns
    sonne.render();

    // Stack wieder säubern.
    modelMatrixStack.pop();

    //qTex->release();



}
开发者ID:velox1992,项目名称:ARProject,代码行数:60,代码来源:MyGLWidget.cpp

示例10: 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

示例11: pointLightPass

void Scene::pointLightPass(RenderTarget *target)
{
    if(!this->pointLights.empty ())
    {
        for(int i =0;i<pointLights.size ();i++)
        {
            ShaderProgram * shader = ShaderPool::getInstance ()->get("point_light_pass");
            shader->use ();
            PointLight * light = this->pointLights[i];
            light->apply (shader,0);

            m_quad->setShaderProgram (shader);
            QMatrix4x4 m;
            m.setToIdentity ();
            auto camera = target->camera ();
            shader->setUniformMat4v ("g_MVP_matrix",m.data ());
            shader->setUniform2Float ("g_screen_size",1024,768);
            shader->setUniformInteger ("g_color_map",0);
            shader->setUniformInteger ("g_position_map",1);
            shader->setUniformInteger ("g_normal_map",2);
            shader->setUniform3Float ("g_eye_position",
                                      camera->pos ().x(),
                                      camera->pos ().y(),
                                      camera->pos ().z());
            m_quad->draw (true);
        }
    }
}
开发者ID:HeeroNight,项目名称:Cube-Engine,代码行数:28,代码来源:scene.cpp

示例12: if

QMatrix4x4 Exercise12::rotateClockwise(int frame)
{
    /////////////////////////////////////////////////////////////////////////////////////////////////
    // TODO: Aufgabe 12
    // Apply correct transformations (rotate, translate, scale) with respect to the current frame
    /////////////////////////////////////////////////////////////////////////////////////////////////

    QMatrix4x4 transform;
    int degree = frame % 360;
    transform.setToIdentity();
    if(degree < 90) {
      transform.translate(0.5, 0.5, 0.0);
      transform.rotate(-2 * degree, 0.0, 0.0, 1.0);
      transform.translate(-0.5, 0.5, 0.0);
    } else if(degree < 180) {
      transform.translate(0.5, -0.5, 0.0);
      transform.rotate(-2 * degree, 0.0, 0.0, 1.0);
      transform.translate(-0.5, -0.5, 0.0);
    } else if(degree < 270) {
      transform.translate(-0.5, -0.5, 0.0);
      transform.rotate(-2 * degree, 0.0, 0.0, 1.0);
      transform.translate(0.5, -0.5, 0.0);
    } else if(degree < 360) {
      transform.translate(-0.5, 0.5, 0.0);
      transform.rotate(-2 * degree, 0.0, 0.0, 1.0);
      transform.translate(0.5, 0.5, 0.0);
    }
    return transform;
}
开发者ID:Boffmann,项目名称:3D_Grafik,代码行数:29,代码来源:exercise12.cpp

示例13: setLookAt

/**
  * Sets mvMatrix to a lookAt transformation.
  * Call setPMatrix or setPerspective first.
  */
void GLESRenderer::setLookAt(const QVector3D & eye,const QVector3D & center,const QVector3D & up )
{
    QMatrix4x4 m;
    m.setToIdentity();
    m.lookAt(eye, center, up);
    setMvMatrix(m);
}
开发者ID:gnuty,项目名称:qmlqles,代码行数:11,代码来源:glesrenderer.cpp

示例14: adjustRatios

void CombinedNavRenderer::adjustRatios()
{
    m_ratio = static_cast< float >( m_width ) / static_cast< float >( m_height );
    glViewport( 0, 0, m_width, m_height );

    // Reset projection
    QMatrix4x4 pMatrix;
    pMatrix.setToIdentity();

    float xb = m_nx * m_dx;
    float yb = m_ny * m_dy;
    float zb = m_nz * m_dz;

    if ( m_ratio > 1.5 )
    {
        float textureRatio =  ( xb + xb + yb ) / yb;
        float mult = textureRatio / m_ratio;
        if ( m_ratio > textureRatio )
        {
            pMatrix.ortho( 0, ( xb + xb + yb ) / mult, 0, yb, -3000, 3000 );
        }
        else
        {
            pMatrix.ortho( 0, xb + xb + yb, 0, yb * mult , -3000, 3000 );
        }
    }
    else if ( m_ratio < 0.66 )
    {
        float textureRatio = yb / ( yb + zb + zb );
        float mult = textureRatio / m_ratio;
        //qDebug() << "ratio: " << m_ratio << " trat: " << textureRatio << " mult: " << mult;
        if ( m_ratio > textureRatio )
        {
            pMatrix.ortho( 0, yb / mult, 0, ( yb + zb + zb ), -3000, 3000 );
        }
        else
        {
            pMatrix.ortho( 0, yb, 0, ( yb + zb + zb ) * mult, -3000, 3000 );
        }


    }
    else
    {
        float mult = 1.0 / m_ratio;
        //qDebug() << "ratio: " << m_ratio << " trat: " << textureRatio << " mult: " << mult;
        if ( m_ratio > 1.0 )
        {
            pMatrix.ortho( 0, ( xb + yb ) / mult, 0, xb + yb, -3000, 3000 );
        }
        else
        {
            pMatrix.ortho( 0, xb + yb, 0, ( xb + yb ) * mult, -3000, 3000 );
        }
    }

     m_mvpMatrix = pMatrix;
}
开发者ID:yangguang-ecnu,项目名称:fibernavigator2,代码行数:58,代码来源:combinednavrenderer.cpp

示例15:

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;
}
开发者ID:marwan-abdellah,项目名称:VolRen,代码行数:9,代码来源:raycastcube.cpp


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