How do you load Blender files using Assimp?

淺唱寂寞╮ 提交于 2020-01-13 10:37:09

问题


I tried to load Blender file using Assimp library on C++ using the following code, but it fails since it doesn't have any meshes at all. The blender file I am using is the default cube saved using Blender itself.

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

What am I doing wrong here, do I need to include special flag in order to load blender object ? Or do I need to export the Blender object in certain way ?


回答1:


Blender files are difficult to read and interpret by anything that's not Blender. The reason for this is, that Blender files are in fact structured memory dumps of the Blender process. Unless you plan to embed a whole Blender instance into your program you'll hardly be able to parse it.

Instead you should export your model using Blender into someting easy to process, a well documented file format. Blender ships with a collection for a large number of 3D file formats.




回答2:


You need to open your file .blend and export it to .3ds, .obj etc..

I've tried using .blend files and could no read any meshes what so ever, otherwise works well with any of the other formats that I've tried (.3ds, .obj).



来源:https://stackoverflow.com/questions/20046553/how-do-you-load-blender-files-using-assimp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!