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


C++ MeshPtr::createEmpty方法代码示例

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


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

示例1: createCube

GameObjectPtr createCube()
{
    GameObjectPtr cubeObj;
    
    GLfloat cubeStructure[]=
    {
        0.50, -0.50, -0.50, -0.00, 0.00,
        0.50, -0.50, 0.50, 0.33, 0.00,
        -0.50, -0.50, 0.50, 0.33, 0.33,
        -0.50, -0.50, -0.50, -0.00, 0.33,
        0.50, 0.50, -0.50, 0.67, 0.33,
        0.50, -0.50, -0.50, 0.33, 0.33,
        -0.50, -0.50, -0.50, 0.33, 0.00,
        -0.50, 0.50, -0.50, 0.67, 0.00,
        0.50, 0.50, 0.50, 0.67, 0.67,
        0.50, -0.50, 0.50, 0.33, 0.67,
        -0.50, 0.50, 0.50, 0.67, 1.00,
        -0.50, -0.50, 0.50, 0.33, 1.00,
        -0.50, 0.50, -0.50, 0.33, 1.00,
        -0.50, -0.50, -0.50, -0.00, 1.00,
        -0.50, -0.50, 0.50, -0.00, 0.67,
        -0.50, 0.50, 0.50, 0.33, 0.67,
        -0.50, 0.50, 0.50, -0.00, 0.67,
        0.50, 0.50, 0.50, -0.00, 0.33,
        0.50, 0.50, -0.50, 0.33, 0.33,
        -0.50, 0.50, -0.50, 0.33, 0.67,
    };
    
    GLushort cubeIndices[]=
    {
        0, 1, 2,
        2, 3, 0,
        4, 5, 6,
        6, 7, 4,
        8, 9, 5,
        5, 4, 8,
        10, 11, 9,
        9, 8, 10,
        12, 13, 14,
        14, 15, 12,
        16, 17, 18,
        18, 19, 16,
    };
    
    //create mesh
    MeshPtr mesh = new Mesh();
    
    //create geometry
    GeometryPtr geometry = mesh->createEmpty(MVF_POS_3F|MVF_TCOORD_2F, 20, 36, true);
    geometry->appendVertexData(0, cubeStructure, sizeof(cubeStructure));
    geometry->appendIndexData(cubeIndices, sizeof(cubeIndices));
    
    //create material
    MaterialPtr material = new Material();
    material->setShaderProgramFromFile("media/texture.vs","media/texture.fs").setTextureProperty("u_map","media/cube.tga").setTextureProperty("u_map2","media/cube2.tga");
    material->updateShaderProperites();
    
    mesh->setMaterial(material);
    
    //mesh renderer
    MeshRenderer* mesh_renderer = new MeshRenderer();
    mesh_renderer->setMesh(mesh);
    
    //game object with mesh renderer
    cubeObj = new GameObject();
    cubeObj->addComponent(mesh_renderer);
    
    return cubeObj;
}
开发者ID:happyfire,项目名称:gles2.0,代码行数:69,代码来源:LessonCube.cpp


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