KhronosGroup / glTF-CSharp-Loader

C# Reference Loader for glTF
Other
219 stars 58 forks source link

When saving as binary, how do I embed the textures into the model ? #23

Closed xfischer closed 5 years ago

xfischer commented 5 years ago

Hi ! And thanks for that helpful library. I'm trying to save a model with associated texture. But I cannot see in the API how I can embed the texture inside the generated binary file. I see the loader can load such models (avocado for example), but I cannot see any sample generating them. I'll meanwhile try to add it myself into bufferview and set proper index and offset and clear the Uri, but I wonder if there's something obvious I'm missing.

bghgary commented 5 years ago

I don't think the interface has any helper methods that makes this easier. If you come up with something, a PR would be appreciated.

xfischer commented 5 years ago

Thanks for the quick reply. I'll try (fingers crossed...). And sure I'll make a PR if it's done.

xfischer commented 5 years ago

Hi @bghgary. If found a nice repo from yourself: https://github.com/bghgary/glTF-Shell-Extensions. I think there is everything I need here to pack textures into the generated file. Shall I borrow some code into a PR for this repo ?

bghgary commented 5 years ago

Sure. My repo used to depend on this project, but I removed that dependency mainly because I didn't want any validation checks. It might be useful to look at the history to see when I was using this project as a dependency.

xfischer commented 5 years ago

It's done. Your code was all I needed. Thank you for this.