简体   繁体   English

Assimp错误地导入了OBJ索引?

[英]Assimp incorrectly imports OBJ indices?

I have created my own Model class to abstract the process of importing a model in Assimp, and make it easy to add a model. 我创建了自己的Model类,以抽象化在Assimp中导入模型的过程,并使添加模型变得容易。 Currently, I haven't got this to work, and no model is shown. 目前,我还没有这个工作,也没有显示任何模型。 I believe this is due to the indices. 我相信这是由于指数。

I noticed during debugging that the indices vector related to a mesh in the model always has the same number of elements as the vertices vector (although it should be more). 我在调试过程中注意到,与模型中的网格相关的索引向量始终与顶点向量具有相同数量的元素(尽管应该更多)。 eg: 例如:

vertices.size() == indices.size() //<--- true

Additionally, for some reason, all indices vectors simply contain consecutive integers. 另外,由于某种原因,所有索引向量都只包含连续的整数。 eg: 例如:

std::vector<GLuint> indices; //<--- After processing contains: {0, 1, 2, 3, ...}

Here is the code I use to extract the indices from Assimp: 这是我用来从Assimp提取索引的代码:

//Process Indices
for (GLuint i = 0; i < mesh->mNumFaces; i++) {
    aiFace face = mesh->mFaces[i];
    for (GLuint j = 0; j < face.mNumIndices; j++) {
        GLuint index = face.mIndices[j];
        indices.push_back(index);
    }           
}

Also, here are my import flags (although I don't really know how these would affect indices): 另外,这是我的导入标志(尽管我真的不知道它们会如何影响索引):

const aiScene *scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenNormals);

Turns out I had to add the flag: 原来我必须添加标志:

aiProcess_JoinIdenticalVertices

This identifies and joins identical vertex data sets within all imported meshes. 这将在所有导入的网格内标识并合并相同的顶点数据集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM