5

我尝试使用以下代码在 C++ 上使用 Assimp 库加载 Blender 文件,但它失败了,因为它根本没有任何网格。我使用的搅拌机文件是使用搅拌机本身保存的默认立方体。

Assimp::Importer importer;
const aiScene * scene = importer.ReadFile( path, aiProcessPreset_TargetRealtime_Fast );

if( !scene ) {
    fprintf( stderr, importer.GetErrorString() );
    return false;
}

const aiMesh * mesh = scene->mMeshes[0]; // Fails here since mMeshes is NULL

我在这里做错了什么,我是否需要包含特殊标志才能加载搅拌器对象?还是我需要以某种方式导出 Blender 对象?

4

2 回答 2

9

Blender 文件很难被任何非 Blender 的东西阅读和解释。原因是,Blender 文件实际上是 Blender 进程的结构化内存转储。除非您打算将整个 Blender 实例嵌入到您的程序中,否则您几乎无法解析它。

相反,您应该使用 Blender 将模型导出为易于处理的、有据可查的文件格式。Blender 附带了大量 3D 文件格式的集合。

于 2013-11-18T12:08:49.407 回答
3

您需要打开文件 .blend 并将其导出为 .3ds、.obj 等。

我尝试过使用 .blend 文件,但无法读取任何网格,否则可以与我尝试过的任何其他格式(.3ds、.obj)一起使用。

于 2013-11-26T18:14:27.300 回答