2

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. 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). e.g:

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

Additionally, for some reason, all indices vectors simply contain consecutive integers. e.g:

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

Here is the code I use to extract the indices from 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);
genpfault
  • 51,148
  • 11
  • 85
  • 139
Kyle Blue
  • 311
  • 1
  • 2
  • 11
  • What does the obj contain? Are there vertices that are used in multiple triangles? – BDL Dec 12 '17 at 16:44
  • Yes, there is. The obj file contains a crisis model asset (nanosuit.obj). Triangles should be connected. – Kyle Blue Dec 12 '17 at 16:46

1 Answers1

3

Turns out I had to add the flag:

aiProcess_JoinIdenticalVertices

This identifies and joins identical vertex data sets within all imported meshes.

Kyle Blue
  • 311
  • 1
  • 2
  • 11