Closed FlyingBamboo closed 6 months ago
I'm afraid the only way to do what you want is to use the lower level APIs to construct the mesh on your own.
The way to do so is to create the vertex and index buffers, create the accessors, and then the mesh primitives and the mesh
Thanks for your quick reply! I can't give up on using the toolkit, so I'm going to try modifying the generated ModelRoot before saving to a glTF file.
MeshBuilder uses a unique vertex definition for the whole mesh for two reasons: 1- it simplifies the mesh building process. 2- a single vertex format guarantees that all the vertex buffers used by the mesh can be merged into a single vertex buffer. Actually, if all the meshes of the model share the same vertex format, it could lead to use a single vertex buffer for the whole model.
Having said that, the post processor that converts the meshbuilder to a glTF mesh could be improved to identify attributes that have been filled with zeros, and re-arrange the data to remove unused attributes. The bad news is that this is one of the trickiest parts of the whole library and it would not be easy to deal with.
I am using the toolkit to generate glTF files. It's really easy to use and works well except for one problem. In my case, it is necessary to create some primitives using materials with or without texture, which means they may have TEXCOORD_0 or not. The primitives may belong to one mesh. I can only use MeshBuilder<VertexPositionNormal, VertexTexture1> to create the meshBuilder to support both conditions, but in this way, unused TEXCOORD attribute is generated, the accessor point to some empty part of the buffer view. Please look at the example below showing the issue:
The generated glTF:
Is it possible to remove the TEXCOORD_0 in the first primitive?