1

I'm trying to load an animated mesh (skeletal) with assimp but I'm having some problems.

When I try to access (the root Node) aiNode*'s name, the programs crashes. In Visual Studio's output, it says it failed to read string characters.

(I'm following this tutorial.)

void Mesh::ReadNodeHierarchy(float AnimationTime, aiScene* scene, aiNode* pNode, const aiMatrix4x4& ParentTransform) {
if (pNode == NULL) {
    std::cerr << "NODE NULL\n";
    return;
}

std::cerr << pNode->mName.length; // I tried to check the length of the string but it caused the same error

std::string NodeName(pNode->mName.data); // Throws error
(...)
}
Laurel
  • 5,965
  • 14
  • 31
  • 57
Ricardo Antunes
  • 397
  • 2
  • 11
  • it's good to check against NULL but is the `pNode` variable properly initialized? – Jean-François Fabre Sep 02 '16 at 20:04
  • Yes it is, pNode is the root node in the scene and assimp says it is always initialized, except if the file failed to load. (The file is loading, if i deactivate the animation i can see the model perfectly) – Ricardo Antunes Sep 02 '16 at 20:09

1 Answers1

2

If anyone is having the same problem i just discovered that when the Assimp::Importer class is destroyed, the scene is too.

My importer class was local so it was destroyed, thus causing the error.

Ricardo Antunes
  • 397
  • 2
  • 11