I've been having this problem for a while and I'm certain I've got something fundamentally wrong. Assimp is built from source from the most recent commit on github, but I have also tried on v5.0.0/1/2.
I can import an fbx file almost to completion in Assimp (converted so all meshes are made of triangles), but when accessing the face data from a mesh, the face is null (or points to invalid memory).
The entire code:
void recursive_explorer(aiNode *n, const aiScene *s) {
if (n) {
if (n->mNumChildren != 0) {
for (unsigned i = 0; i < n->mNumChildren; i++) {
recursive_explorer(n->mChildren[i], s);
}
} else {
printf("%d\n", n->mNumMeshes);
for (unsigned j = 0; j < n->mNumMeshes; j++) {
const struct aiMesh *m = s->mMeshes[n->mMeshes[j]];
printf("\t%d\n", m->mNumFaces);
if (m->HasFaces()) {
for (unsigned k = 0; k < m->mNumFaces; k++) {
printf("\t\t%p\n", &m->mFaces[k]);
}
}
}
}
}
}
int main() {
Assimp::Importer importer;
std::fstream f("../maps/de_dust2.fbx");
const aiScene *s = importer.ReadFile("../maps/de_dust2.fbx",
aiProcess_SortByPType | aiProcess_JoinIdenticalVertices |
aiProcess_Triangulate);
printf("Root has %d children\n", s->mRootNode->mNumChildren);
for (unsigned i = 0; i < s->mRootNode->mNumChildren; i++) {
printf("[%u] %s\n", i, s->mRootNode->mChildren[i]->mName.C_Str());
recursive_explorer(s->mRootNode->mChildren[i], s);
}
return 0;
}
Results in:
Root has 3 children
[0] CINEMA_4D_Editor
0
[1] Sky
0
0
0
0
0
[2] de_dust2
2
4
0x1b1b1b1b1b1b1b1b
0x1b1b1b1b1b1b1b2b
0x1b1b1b1b1b1b1b3b
...
If I try access a face (to get the mNumIndices or mIndices), I get a segfault.
I have experimented with different preprocessing options though I haven't yet found the right combination.
I know this CAN work as I have managed to get this specific map to work before, though I'm sure I've missed something very obvious. Thanks in advance!