Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality for writing glb files #139

Open
dov opened this issue Feb 22, 2021 · 3 comments
Open

Add functionality for writing glb files #139

dov opened this issue Feb 22, 2021 · 3 comments

Comments

@dov
Copy link

dov commented Feb 22, 2021

When generating my own mesh, I'd like to save the result together with the meta data in a glb file. That is currently not possible with cgltf.

@prideout
Copy link
Contributor

Yeah when I wrote cgltf_write I figured I could use an external tool to convert to glb, so I made it low priority.

However I think this is a good feature request. The GLB exporter could re-use what we already did for JSON, and it would not incur any additional dependencies (e.g. no compression library is required).

@jkuhlmann
Copy link
Owner

That should indeed be very straight-forward. As we already support reading GLB, writing it as well would make sense.

@WickedSmoke
Copy link

I spent some time trying to use cgltf_writer.h, but found it was easier to just write my own JSON code. Knitting together the C structures that match JSON 1-to-1 was very tedious and ended up being more verbose.

Instead, I put together some GLB utility functions to handle the chunk writing and
determine the min/max vec3 bounds. There's a UNIT_TEST in glb.c which serves as an
example of how to use the glb_* functions.

This method of writing GLB files adds less than 4% of the code required by cgltf to a project, and can avoid the gltf_validator TARGET warning caused by issue #193.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants