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.

eugene
  • 31
  • 2
  • 5
  • I've just made small console app and tested your function with different models and it works fine. Looks like the problem is somewhere else. What exactly error message says? – Ivan Aksamentov - Drop Apr 16 '13 at 03:58
  • very strange! This my error: cxx0030 - The debugger's expression evaluator could not obtain a value for the expression as written. It error occurs when I'm trying to get faces from pMesh. But coordinates and normals position calculate fine. very strange. – eugene Apr 16 '13 at 07:45
  • Try to test this function isolated: create a clean console app and call LoadModel() from main(). If it fails, check pMesh->HasFaces(). If it will return false, there may be a problem with your model file (try another) or a bug in Assimp if you using dev version (try another version, I tested your code with 3.0.1270). Also try put a braces where operators chaining: (pMesh->mFaces[0]).mNumIndices; – Ivan Aksamentov - Drop Apr 16 '13 at 21:15
  • I did as you said, but the same errors occurs. Do you use either assimp32.dll or assimp32d.dll in your project? And what OS do you have? – eugene Apr 18 '13 at 18:52
  • I'm usin static linkage ("debug" and "release" configurations in the included .vcproj). Visual Studio 2012 update2 and Windows 8. – Ivan Aksamentov - Drop Apr 22 '13 at 17:44
  • I'm using static linkage, but the program require assimp32.dll. Look strange. Anyway thank you for help and sorry for you wasted time( – eugene Apr 22 '13 at 18:12
  • In assimp\workspaces\vc9 I am using "debug" and "release" configs. Probably you are using "debug-dll" and "release-dll", they require a tiny static lib too. Here are my app with your function and pre-built assimp: http://www.sendspace.com/filegroup/GyXJLISlj7HIV0l2mJcL6A (huge size btw ;). You will need VS2012 ( "Express" version is free) Hope it help. – Ivan Aksamentov - Drop Apr 22 '13 at 18:36
  • Thank you very much!!! It really help me. No any errors! – eugene Apr 23 '13 at 09:16

0 Answers0