Assimp访问节点名称时出错

Assimp Error acessing aiNode name

本文关键字:出错 访问 节点 Assimp      更新时间:2023-10-16

我正在尝试加载一个动画网格(骨骼)与assimp,但我有一些问题。

当我试图访问(根节点)aiNode*的名称时,程序崩溃了。在Visual Studio的输出中,它说它无法读取字符串字符。

(我遵循这个教程)

void Mesh::ReadNodeHierarchy(float AnimationTime, aiScene* scene, aiNode* pNode, const aiMatrix4x4& ParentTransform) {
if (pNode == NULL) {
    std::cerr << "NODE NULLn";
    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
(...)
}

如果有人有同样的问题,我刚刚发现,当Assimp::Importer类被销毁时,场景也是。

我的导入器类是本地的,所以它被销毁了,从而导致了错误。