使用ReadFileFromMemory函数加载模型的问题
使用ReadFileFromMemory函数无法加载obj和md3等模型数据分散在多个文件中的模型。obj模型通常有一部分数据(如纹理数据)在mtl文件中保存,如果只把obj文件加载到内存中,并通过ReadFileFromMemory读取模型,会失败。读不出来纹理。
源代码的注释如下:
* @note This is a straightforward way to decode models from memory* buffers, but it doesn't handle model formats that spread their* data across multiple files or even directories. Examples include* OBJ or MD3, which outsource parts of their material info into* external scripts. If you need full functionality, provide* a custom IOSystem to make Assimp find these files and use* the regular ReadFile() API.*/const aiScene *ReadFileFromMemory(const void *pBuffer,size_t pLength,unsigned int pFlags,const char *pHint = "");
这时就只能通过ReadFile函数来加载模型或者通过自定义的IOSystem。
Assimp无法导入OBJ模型的纹理的其他解决办法
见这篇文章Assimp不会导入纹理 - assimp - 码客