vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

Question: How best to split a model, based on `KHRMaterialVariants`? #186

Closed carlreid closed 1 year ago

carlreid commented 1 year ago

Lets say I have a single GLB, which has 3 variants (e.g. MaterialVariantsShoe) and would like to use SharpGLTF to load the source GLB and produce 3 GLBs, how best should I use the library to do this?

At the moment, it seems the only option is to somehow rebuild the entire GLB using a new ModelRoot.CreateModel() and then looping through each Logical* resource to recreate the structure.

Is there possible a way to "Clone" the contents, and change the parent reference. Possibly something even simpler that I missed?

vpenades commented 1 year ago

To begin with, SharpGLTF does not support Variants extension... it could be possible to implement it, but only for informational purposes.

And yes, the only way is to rebuild the entire GLB... keep in mind that glTF is a "last mile" format, its internal structures are heavily entangled and are very hard to edit, to the point it's much easier to create new models from scratch, than try to edit an existing one.

carlreid commented 1 year ago

Thanks for taking the time to respond. I'll continue as I was then. It just seemed very verbose as to iterate through everything but if that's how it has to be, then so be it 😀