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


C++ Trackball::computeViewMatrix方法代码示例

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


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

示例1: render

/** This method is called in the main rendering loop everytime the OpenGL windows has to be refreshed. */
void render(GLFWwindow* window)
{
    // clear the buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear all buffers

    //Draw PointCloud
    mBlinn.activate();

    glUniformMatrix4fv(mBlinn.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
    glUniformMatrix4fv(mBlinn.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
    Vector4f light_pos;
    light_pos << mLightPos , 1.0f;
    Vector4f light_pos2;
    light_pos2 << mLightPos2 , 1.0f;
    glUniform4fv(mBlinn.getUniformLocation("light_pos"),1,light_pos.data());
    glUniform4fv(mBlinn.getUniformLocation("light_pos2"),1,light_pos2.data());

    glUniformMatrix4fv(mBlinn.getUniformLocation("object_matrix"),1,false,/*pc*//*mesh*/mMeshes[mCurrentMesh]->getTransformationMatrix().data());
    Matrix3f normal_matrix = (mCamera.computeViewMatrix()*/*pc*//*mesh*/mMeshes[mCurrentMesh]->getTransformationMatrix()).linear().inverse().transpose();
    glUniformMatrix3fv(mBlinn.getUniformLocation("normal_matrix"),1,false,normal_matrix.data());


    mMeshes[mCurrentMesh]->draw(&mBlinn/*,true*/);

    //pc->draw(&mBlinn);


//    Vector4f light_pos_mesh;

//    mMesh.activate();
//    glUniformMatrix4fv(mMesh.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
//    glUniformMatrix4fv(mMesh.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());

//    light_pos_mesh << mLightPos , 1.0f;
//    glUniform4fv(mMesh.getUniformLocation("light_pos"),1,light_pos_mesh.data());

//    glUniformMatrix4fv(mMesh.getUniformLocation("object_matrix"),1,false,mesh->getTransformationMatrix().data());
//    Matrix3f normal_matrix = (mCamera.computeViewMatrix()*mesh->getTransformationMatrix()).linear().inverse().transpose();
//    glUniformMatrix3fv(mMesh.getUniformLocation("normal_matrix"),1,false,normal_matrix.data());



//    mesh->draw(&mMesh);

    //Draw Octree
    if(octreeVisu >= 0)
    {
        mSimple.activate();
        glUniformMatrix4fv(mSimple.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
        glUniformMatrix4fv(mSimple.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
        std::vector<AlignedBox3f> aabbs = octree->getAABBs(octreeVisu);
        for(unsigned i=0; i<aabbs.size(); ++i)
        {
            Affine3f object_matrix;
            object_matrix = Translation3f(aabbs[i].center()) * Scaling((aabbs[i].max() - aabbs[i].min())/2.0);
            glUniformMatrix4fv(mSimple.getUniformLocation("object_matrix"),1,false, object_matrix.data());
            wirecube->draw(&mSimple);
        }
    }

    mHole.activate();
    glUniformMatrix4fv(mHole.getUniformLocation("object_matrix"),1,false,/*mesh*/mMeshes[mCurrentMesh]->getTransformationMatrix().data());
    glUniformMatrix3fv(mHole.getUniformLocation("normal_matrix"),1,false,normal_matrix.data());
    //mesh->drawEdges(&mHole);

    // check OpenGL errors
    GL_TEST_ERR;

    glfwSwapBuffers(window);
}
开发者ID:Patagouin,项目名称:Mod,代码行数:71,代码来源:main.cpp

示例2: render

/** This method is called in the main rendering loop everytime the OpenGL windows has to be refreshed. */
void render(GLFWwindow* window)
{
    // clear the buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear all buffers

    //Draw PointCloud
    mBlinn.activate();

    glUniformMatrix4fv(mBlinn.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
    glUniformMatrix4fv(mBlinn.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
    Vector4f light_pos;
    light_pos << mLightPos , 1.0f;
    glUniform4fv(mBlinn.getUniformLocation("light_pos"),1,light_pos.data());

    glUniformMatrix4fv(mBlinn.getUniformLocation("object_matrix"),1,false,pc->getTransformationMatrix().data());
    Matrix3f normal_matrix = (mCamera.computeViewMatrix()*pc->getTransformationMatrix()).linear().inverse().transpose();
    glUniformMatrix3fv(mBlinn.getUniformLocation("normal_matrix"),1,false,normal_matrix.data());

    pc->draw(&mBlinn);



    //Draw Octree
//    mSimple.activate();
    //mCamera.updateViewMatrix();

//     glUniformMatrix4fv(mSimple.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
//     glUniformMatrix4fv(mSimple.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
     glUniformMatrix4fv(mBlinn.getUniformLocation("object_matrix"),1,false, ball->getTransformationMatrix().data());
     glUniform3f(mBlinn.getUniformLocation("colorV"),1.f,1.f,1.f);
        ball->draw();
     glUniform3f(mBlinn.getUniformLocation("colorV"),0.2,0.3,0.8);

     mSimple.activate();


       glUniformMatrix4fv(mSimple.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
       glUniformMatrix4fv(mSimple.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
       glUniformMatrix4fv(mSimple.getUniformLocation("object_matrix"),1,false, surface->getTransformationMatrix().data());
        glUniform3f(mSimple.getUniformLocation("color"),1.,0.,0.);
       surface->draw();
       // glUniform3f(mBlinn.getUniformLocation("colorV"),0.2,0.3,0.8);


    if(octreeVisu >= 0)
    {
        //mSimple.activate();
//        glUniformMatrix4fv(mSimple.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
//        glUniformMatrix4fv(mSimple.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
        std::vector<AlignedBox3f> aabbs = octree->getAABBs(octreeVisu);
        for(unsigned i=0; i<aabbs.size(); ++i)
        {
            Affine3f object_matrix;
            object_matrix = Translation3f(aabbs[i].center()) * Scaling((aabbs[i].max() - aabbs[i].min())/2.0);
            glUniformMatrix4fv(mSimple.getUniformLocation("object_matrix"),1,false, object_matrix.data());
            wirecube->draw(&mSimple);
        }
    }




    //draw faces

//     glUniformMatrix4fv(mSimple.getUniformLocation("projection_matrix"),1,false,mCamera.computeProjectionMatrix().data());
//     glUniformMatrix4fv(mSimple.getUniformLocation("modelview_matrix"),1,false,mCamera.computeViewMatrix().data());
//     glUniformMatrix4fv(mSimple.getUniformLocation("object_matrix"),1,false, surface->getTransformationMatrix().data());
//     glUniform3f(mSimple.getUniformLocation("color"),1.f,0.f,0.f);
//     surface->draw();
//     glUniform3f(mSimple.getUniformLocation("color"),1.f,1.f,1.f);


    // check OpenGL errors
    GL_TEST_ERR;

    glfwSwapBuffers(window);
}
开发者ID:MYJY971,项目名称:sagacious-octo-waddle,代码行数:78,代码来源:main.cpp


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