The gltf2 importer does not work for me when reading from memory instead of a file. I've tried with multiple files, but it seems to throw an exception somewhere in the importer in the latter case only. Here's code to reproduce it with 4.1.0-Release, the gltf file used here is simply Blender's default scene (cube, lamp, camera) exported with https://github.com/KhronosGroup/glTF-Blender-Exporter.
#include <assimp/Importer.hpp>
#include <iostream>
#include <fstream>
#include <vector>
int main()
{
const char* filename = "d:/default-scene.gltf";
Assimp::Importer importer;
#if 1
// FAILS: read into buffer first, then pass to ReadFileFromMemory
std::ifstream input(filename, std::ios::binary);
std::vector<char> buffer((
std::istreambuf_iterator<char>(input)),
(std::istreambuf_iterator<char>()));
auto ai_scene = importer.ReadFileFromMemory(buffer.data(), buffer.size(), 0, "gltf");
if (!ai_scene) {
std::cout << importer.GetErrorString() << std::endl;
// No suitable reader found for the file format of file "$$$___magic___$$$.gltf".
}
#else
// WORKS: read file directly
auto ai_scene = importer.ReadFile(filename, 0);
#endif
}
When loading the gltf from memory, it cannot find the associated .bin.
So this closely linked to #1945.
Any news on that for the next release ? :/
Most helpful comment
Any news on that for the next release ? :/