4

I am working on a project where I import a 3D mesh of an avatar using ASSIMP library, update it and export the updated scene again using the same ASSIMP library. To achieve this, as the first step, I have written a code to import a scene and without making any changes I am passing the reference to the export function. But, the export function throws me an error. The main function is as follows (you can verify that I am not making any changes to the imported scene):

int main(int argc, char** argv)
{
    string filename = "../Content/PinocchioMesh/Model1.obj";

    Assimp::Importer Importer;
    //Importer.
    cout << "\tReading file using ASSIMP" << endl;
    const aiScene* aiscene = Importer.ReadFile(filename.c_str(), aiProcess_JoinIdenticalVertices | \
        aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_SortByPType | aiProcess_Triangulate);

    string str = Importer.GetErrorString();

    if (!aiscene) {
        printf("Error parsing '%s': '%s'\n", filename.c_str(), Importer.GetErrorString());
        return false;
    }


    Assimp::Exporter exporter;
    const aiExportFormatDesc* format = exporter.GetExportFormatDescription(0);
    int lIndex = filename.find_last_of('/');
    //const string path = Filename.substr(0,lIndex+1);
    string path = "../Content/PinocchioMesh/";
    cout << "\tExport path: " << path << endl;
    aiReturn ret = exporter.Export(aiscene, format->id, path, aiscene->mFlags);
    cout << exporter.GetErrorString() << endl;

    return 0;
}

The error is in the Export() function ans says:

First-chance exception at 0x1052591B (Assimp32.dll) in ImportRigExport.exe: 0xC0000005: Access violation reading location 0x00000000.

If anyone has used assimp to export scenes, please help me.

Nickal
  • 669
  • 2
  • 11
  • 25
  • Looks like it is trying to access null pointer somewhere in export (). Btw did you try to debug library code by putting breakpoint? – debonair Feb 29 '16 at 05:05
  • I am llinking a built library, I have not attached the assimp code to my project. so, i can't debug the assimp code, but I am sure the error is from the assimp export code. – Nickal Feb 29 '16 at 05:08
  • 1
    there might be bug in assimp library or may be it is trying to access any of the field in the scene which is null. I dont think there is any other way than debugging. Its not much pain to debug it. I have done it. – debonair Feb 29 '16 at 05:15
  • Probably with a little bit of effort I can make it work for myself. But my concern is: `is the assimp library not tested?` It is not exporting the scene imported by its own `import()` method. – Nickal Feb 29 '16 at 05:23
  • 1
    Sounds like a not well tested feature from us. Sorry for that. We will take care! – KimKulling Feb 29 '16 at 14:18

1 Answers1

2

It seems path doesn't include a file name, only the directory part, so that for export() is unlikely to be able to create an output file. Nevertheless, I agree, Assimp should manage this error case.