CesiumGS / cesium-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to save Meshoptimizer compressed models as uncompressed glb models

xinghaoyujianni opened this issue · comments

I have the following code and the saved decompress.glb is not getting loaded!

GltfReader reader;
GltfReaderResult result = reader.readGltf(readFile("C:\Users\EXT_meshopt_compression.glb"));
Model& model = result.model.value();

CesiumGltfWriter::GltfWriter writer;
CesiumGltfWriter::GltfWriterOptions options;
options.binaryChunkByteAlignment = 4;

const std::vectorstd::byte readModelBuffer = model.buffers[0].cesium.data;
CesiumGltfWriter::GltfWriterResult writeResult =
writer.writeGlb(model, gsl::span(readModelBuffer), options);
const std::vectorstd::byte& glbBytesDefaultPadding = writeResult.gltfBytes;

std::ofstream ofs("C:\Users\decompress.glb", std::ios::binary | std::ios::trunc | std::ios::out);
ofs.write(
(const char*)glbBytesDefaultPadding.data(),
glbBytesDefaultPadding.size());
ofs.flush();
ofs.close();

Can you do a little debugging on your end here? It's not clear the failures you are seeing or what line is failing?

It's ok if you discover a bug in the cesium-native code, and want to share an example problem that reproduces it.

But in this case, it's not clear whether the problem is in cesium-native, or your test setup.

Hey @xinghaoyujianni,

Are you still experiencing this issue? If so, can you provide more details? In particular, it's not clear what you mean by the "glb is not getting loaded".

Otherwise, if this is no longer relevant, or if we don't receive a response, I'll close this issue.