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


C++ ModelNode::setMesh方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
                }else if(argMatch(argv[i], "VolumeForces")){
                    output[outputLength++] = VOLUME_FORCES;
                }else if(argMatch(argv[i], "NetForces")){
                    output[outputLength++] = NET_FORCES;
                }else if(argMatch(argv[i], "Points")){
                    output[outputLength++] = POINTS;
                }
            } while(lastChar(argv[i]) == ',');
        }
    }
    
    Mesh* mesh;
    
    switch(meshType){
        case TETRAHEDRON:
            mesh = new TetrahedronMesh(ceil(sqrt(idealTriangleCount/4.0)));
            break;
        case ICOSAHEDRON:
            if(idealTriangleCount <= 100){
                meshFile = "models/icosa1.obj";
            }else if(idealTriangleCount <= 1000){
                meshFile = "models/icosa2.obj";
            }else if(idealTriangleCount <= 10000){
                meshFile = "models/icosa3.obj";
            }else if(idealTriangleCount <= 100000){
                meshFile = "models/icosa4.obj";
            }else{
                meshFile = "models/icosa5.obj";
            }
            mesh = new ExternalMesh(meshFile);
            break;
        default:
            mesh = new ExternalMesh(meshFile);
            break;
    }
    
    // visualization only applies to GPU calculation, so:
    if(visualization){
        
    
        SceneManager manager(&device);
        CameraNode camera(&device, width, height);
        camera.getTransform().setTranslation(20.0f, 20.0f, 20.0f);
        manager.addNode(&camera);

        ModelNode mn;
        //mn.getTransform().setScale(0.025f, 0.025f, 0.025f);
        mn.getTransform().setScale(scale, scale, scale);
        mn.getTransform().setTranslation(0.0f, 0.0f, 0.0f);
        mn.setMesh(mesh);
        manager.addNode(&mn);

        ShaderProgram geometryProgram;
        Shader geometryVertexShader("shaders/geometry_pass.vert", VERTEX);
        Shader geometryFragShader("shaders/geometry_pass.frag", FRAGMENT);
        geometryProgram.attachShader(&geometryVertexShader);
        geometryProgram.attachShader(&geometryFragShader);
        geometryProgram.link();
        manager.setGeometryProgram(&geometryProgram);

        GPUEvolver evolver(mesh, 10);

        while (device.run()) {
            evolver.update();
            evolver.synchronizeToMesh();
            manager.drawAll();
            device.endScene();
        }
    } else {
        if (gpu) {
            GPUEvolver evolver(mesh, 10);
            evolver.setOutputFormat(output, outputLength);
            std::clock_t    start;

            start = std::clock();
                        
            for(int i=0; i < iterations; i++){
                evolver.update();
                evolver.outputData();
            }
            if (timing){
                std::cout << "Time: " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << std::endl;
            }
        } else {
            CPUEvolver evolver(mesh, 10);
            evolver.setOutputFormat(output, outputLength);
            std::clock_t    start;

            start = std::clock();
            for(int i=0; i < iterations; i++){
                evolver.update();
                evolver.outputData();
            }
            if (timing){
                std::cout << "Time: " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << std::endl;
            }
        }
    }
    return 0;
}
开发者ID:digitaltembo,项目名称:GPUSurfaceEvolver,代码行数:101,代码来源:main.cpp


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