jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.42k stars 135 forks source link

How to enable draco support? #215

Open AllenDang opened 1 year ago

AllenDang commented 1 year ago

I noticed in the README states the draco is supported. But I cannot find any instruction but only a #define CGLTF_EXTENSION_FLAG_DRACO_MESH_COMPRESSION seems related.

How to enable it?

zeux commented 1 year ago

cgltf will parse files with Draco data, but it doesn't have the automatic decompression integrated; similarly to EXT_meshopt_compression, you need to integrate Draco library, and give it the byte stream that you can get from the buffer_view for the mesh with Draco data. If you're looking for examples, Filament should have one (see https://github.com/google/filament/tree/main/libs/gltfio/src)

raysan5 commented 1 year ago

Ignore message, commented on this issue while trying to comment on raylib one :P

abwood commented 1 year ago

I think we should probably provide some documentation on how to do this in the Readme. In the meantime, I added this functionality to cgltf and tinygltf. If you have a look at tinygltf source, you'll see how the bufferviews are retrieved from the datamodel and fed into the draco library here: https://github.com/syoyo/tinygltf/blob/c201efb9985c89d9d8935a560e0ce92f1acbd165/tiny_gltf.h#L4709

For cgltf, the decoding should look similar.