使用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 - 碼客