我的金字塔直立的正确 GLfloat 顶点是什么?[关闭]

What are the correct GLfloat vertices for my Pyramid to sit upright? [closed]

提问人:D Morris Watch Dog Tutorials 提问时间:11/13/2023 最后编辑:D Morris Watch Dog Tutorials 更新时间:11/13/2023 访问量:26

问:


编辑问题以包括所需的行为、特定问题或错误以及重现问题所需的最短代码。这将帮助其他人回答这个问题。

5天前关闭。

我为我的金字塔添加的坐标都有效,它只是以奇怪的角度加载。我需要切换什么坐标才能使金字塔像坐在水平地面上一样直立。

这是它目前的样子。

单击此处查看当前表示的图像

我以为这是我的纹理坐标的问题。

以下是我正在使用的顶点和纹理坐标:

// Implements the UCreateMesh function
void UCreateMesh(GLMesh &mesh)
{
     // Vertex Data
    GLfloat verts[] = {
         //Positions              //Texture Coordinates
        -1.0f, -1.0f,  0.5773f,   -1.0f,-1.0f,
         0.0f, -1.0f, -1.15475f,   0.0f, 0.0f,
         1.0f, -1.0f,  0.5773f,    1.0f,-1.0f,
         0.0f,  1.0f,  0.0f,       0.0f, 1.0f,
        -1.0f, -1.0f,  0.5773f,   -1.0f, 0.0f,
         0.0f, -1.0f, -1.15475f,   0.0f, 0.0f,
         1.0f, -1.0f,  0.5773f,    1.0f, 1.0f,
        -1.0f, -1.0f,  0.5773f,   -1.0f, 0.0f,
         0.0f, -1.0f, -1.15475f,   0.0f, 0.0f,
         1.0f, -1.0f,  0.5773f,    1.0f, 1.0f,
         0.0f,  1.0f,  0.0f,       0.0f, 1.0f,
        -1.0f, -1.0f,  0.5773f,   -1.0f, 0.0f,
         0.0f, -1.0f, -1.15475f,   0.0f, 0.0f,
         1.0f, -1.0f,  0.5773f,    1.0f, 1.0f,
         0.0f,  1.0f,  0.0f,       0.0f, 1.0f,
    };

    const GLuint floatsPerVertex = 3;
    const GLuint floatsPerUV = 2;

    mesh.nVertices = sizeof(verts) / (sizeof(verts[0]) * (floatsPerVertex + floatsPerUV));

    glGenVertexArrays(1, &mesh.vao); // we can also generate multiple VAOs or buffers at the same time
    glBindVertexArray(mesh.vao);
OpenGL 3D 纹理映射

评论


答: 暂无答案