0

我正在玩 Xcode 4.5 中的 OpenGL ES 模板。我在 Google Sketchup 中绘制了一个立方体并导出到 collada。我将顶点和法线数据复制到 Xcode 中的 open gl 模板中,如下所示:

GLfloat gCubeVertexData[] =
{
    // Data layout for each line below is:
    // positionX, positionY, positionZ,     normalX, normalY, normalZ,
//    0.5f, -0.5f, -0.5f,        1.0f, 0.0f, 0.0f,
//    0.5f, 0.5f, -0.5f,         1.0f, 0.0f, 0.0f,
//    0.5f, -0.5f, 0.5f,         1.0f, 0.0f, 0.0f,
//    0.5f, -0.5f, 0.5f,         1.0f, 0.0f, 0.0f,
//    0.5f, 0.5f, -0.5f,         1.0f, 0.0f, 0.0f,
//    0.5f, 0.5f, 0.5f,          1.0f, 0.0f, 0.0f,
//    
//    0.5f, 0.5f, -0.5f,         0.0f, 1.0f, 0.0f,
//    -0.5f, 0.5f, -0.5f,        0.0f, 1.0f, 0.0f,
//    0.5f, 0.5f, 0.5f,          0.0f, 1.0f, 0.0f,
//    0.5f, 0.5f, 0.5f,          0.0f, 1.0f, 0.0f,
//    -0.5f, 0.5f, -0.5f,        0.0f, 1.0f, 0.0f,
//    -0.5f, 0.5f, 0.5f,         0.0f, 1.0f, 0.0f,
//    
//    -0.5f, 0.5f, -0.5f,        -1.0f, 0.0f, 0.0f,
//    -0.5f, -0.5f, -0.5f,       -1.0f, 0.0f, 0.0f,
//    -0.5f, 0.5f, 0.5f,         -1.0f, 0.0f, 0.0f,
//    -0.5f, 0.5f, 0.5f,         -1.0f, 0.0f, 0.0f,
//    -0.5f, -0.5f, -0.5f,       -1.0f, 0.0f, 0.0f,
//    -0.5f, -0.5f, 0.5f,        -1.0f, 0.0f, 0.0f,
//    
//    -0.5f, -0.5f, -0.5f,       0.0f, -1.0f, 0.0f,
//    0.5f, -0.5f, -0.5f,        0.0f, -1.0f, 0.0f,
//    -0.5f, -0.5f, 0.5f,        0.0f, -1.0f, 0.0f,
//    -0.5f, -0.5f, 0.5f,        0.0f, -1.0f, 0.0f,
//    0.5f, -0.5f, -0.5f,        0.0f, -1.0f, 0.0f,
//    0.5f, -0.5f, 0.5f,         0.0f, -1.0f, 0.0f,
//    
//    0.5f, 0.5f, 0.5f,          0.0f, 0.0f, 1.0f,
//    -0.5f, 0.5f, 0.5f,         0.0f, 0.0f, 1.0f,
//    0.5f, -0.5f, 0.5f,         0.0f, 0.0f, 1.0f,
//    0.5f, -0.5f, 0.5f,         0.0f, 0.0f, 1.0f,
//    -0.5f, 0.5f, 0.5f,         0.0f, 0.0f, 1.0f,
//    -0.5f, -0.5f, 0.5f,        0.0f, 0.0f, 1.0f,
//    
//    0.5f, -0.5f, -0.5f,        0.0f, 0.0f, -1.0f,
//    -0.5f, -0.5f, -0.5f,       0.0f, 0.0f, -1.0f,
//    0.5f, 0.5f, -0.5f,         0.0f, 0.0f, -1.0f,
//    0.5f, 0.5f, -0.5f,         0.0f, 0.0f, -1.0f,
//    -0.5f, -0.5f, -0.5f,       0.0f, 0.0f, -1.0f,
//    -0.5f, 0.5f, -0.5f,        0.0f, 0.0f, -1.0f


    9.8425197/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197,    0.0000000, 0.0000000, -1.0000000,
    0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197,    0.0000000, 0.0000000, -1.0000000,
    0.0000000/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197,    0.0000000, 0.0000000, -1.0000000,
    9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197,    0.0000000, 0.0000000, -1.0000000,
    0.0000000/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197,    -1.0000000, 0.0000000, 0.0000000,
    0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197,    -1.0000000, 0.0000000, 0.0000000,

    0.0000000/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197,    -1.0000000, 0.0000000, 0.0000000,
    0.0000000/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197,    -1.0000000, 0.0000000, 0.0000000,
    0.0000000/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197,    -0.0000000, 1.0000000, 0.0000000,
    9.8425197/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197,    -0.0000000, 1.0000000, 0.0000000,
    0.0000000/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197,    -0.0000000, 1.0000000, 0.0000000,
    9.8425197/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197,    -0.0000000, 1.0000000, 0.0000000,

    9.8425197/9.8425197, 9.8425197/9.8425197, 0.0000000/9.8425197,    1.0000000, 0.0000000, 0.0000000,
    9.8425197/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197,    1.0000000, 0.0000000, 0.0000000,
    9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197,    1.0000000, 0.0000000, 0.0000000,
    9.8425197/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197,    1.0000000, 0.0000000, 0.0000000,
    9.8425197/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197,    -0.0000000, -1.0000000, -0.0000000,
    0.0000000/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197,    -0.0000000, -1.0000000, -0.0000000,

    9.8425197/9.8425197, 0.0000000/9.8425197, 0.0000000/9.8425197,    -0.0000000, -1.0000000, -0.0000000,
    0.0000000/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197,    -0.0000000, -1.0000000, -0.0000000,
    9.8425197/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197,    0.0000000, 0.0000000, 1.0000000,
    0.0000000/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197,    0.0000000, 0.0000000, 1.0000000,
    0.0000000/9.8425197, 0.0000000/9.8425197, 8.2677165/9.8425197,    0.0000000, 0.0000000, 1.0000000,
    9.8425197/9.8425197, 9.8425197/9.8425197, 8.2677165/9.8425197,    0.0000000, 0.0000000, 1.0000000
};

在此处输入图像描述

当我运行时,我在下面有渲染的立方体,所以有些不对劲。

=======

看起来如果我使用法线,我不需要提供索引来渲染 3D 对象。但在我的情况下,顶点数据或正常数据似乎有问题......有人知道这两个数据在collada中是如何排列的吗?我通读了文档,但找不到答案...谢谢

4

0 回答 0