3

I'm newcomer in this forum. I'm trying load 3d model im my programm using assimp, but there is some errors occured. There is my code:

bool Model::LoadModel(const char* fileName)
{
Assimp::Importer imp;
const aiScene* pScene = NULL;
const aiMesh* pMesh = NULL;

pScene = imp.ReadFile(fileName, aiProcess_Triangulate);
if(!pScene)
{
    MessageBox(NULL, "Error read file", "Error", MB_OK);
    return false;
}
else
    MessageBox(NULL, "read file OK", "Error", MB_OK);

pMesh = pScene->mMeshes[0];
if(!pMesh)
{
    MessageBox(NULL, "Failed to find meshes", "Error", MB_OK);
    return false;
}

for(unsigned int i = 0; i < pMesh->mNumFaces; i++)
{
    if(pMesh->mFaces[i].mNumIndices == 3)
        numIndices_ = numIndices_ + 3;
    else
    {
        MessageBox(NULL, "Failed to parsing faces", "Error", MB_OK);
        return false;
    }
}

return true;
}

When programm starts execute line pMesh->mFaces[i].mNumIndices == 3, runtime error occurs. Debug log file tell me that is can't calculate mNumIndices. Maybe anyone can help me? I have no idea why this happens.

4

0 回答 0