Closed FSandner closed 3 years ago
Without making modifications to the library, the solution that comes to mind is this:
Don't use SceneBuilder, use MeshBuilder to create your individual meshes.
Then, Add the MeshBuilders to a ModelRoot object, one by one using the CreateMesh extension. Internally, this will create new independent buffers for every mesh you add.
Finally, when saving your model, save it as glTF, NOT as GLB, and be sure to pass the WriteSettings property with MergeBuffers set to false.
If I did not forget anything else, this will do the trick.
Hi, i can't use gltf. But i found different problem. When i use CreateMesh one by one with same MaterialBuilder object, these Materials will be duplicated in ModelRoot.LogicalMaterials. Is there a possibility to avoid this?
Yes, by using CreateMesh with material evaluator.
You can pass a lambda that wraps a dictionary of materials, so instead of reprocessing already existing materials, you can pass the materials previously cached... you can find that lambda implementation here
Why you can't use gltf? I mean... the reason why GLB exists is to embed a single big buffer into the GLB. If you're going to save the buffers into external files, it makes no sense writing to GLB.
do you have an example for the usage of material Evaluator?
You just copy the lambda I've linked in my previous post, and pass it as an argument to the CreateMesh method.
👍 material evaluator is working. back to first question.... can i estimate size of glb before i use ModelRoot.WriteGLB()
I think this:
long totalSize = ModelRoot.LogicalBuffers.Sum(buffer => (long)buffer.Content.Length);
would give a good estimate of the total size of the file.
Hi, we are using SharpGLTF for converting internal 3D Modeldata to glb. Now we came to the problem, that large model data creates too large glb files. Is there a possibility to split it into different chunks? or how can i evaluate size of MESH or NODES before i add it to the ModelRoot. Thanks for answer Fritz