Fixes problem when mesh in glTF file doesn't have a name

a "unnamed_X" name will be genrated.

This fixes the loading of Trinagle.gltf from khronos

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
This commit is contained in:
Arthur Brainville (Ybalrid)
2018-02-23 15:15:33 +01:00
parent 55bff342c2
commit 0da2b35085
3 changed files with 28 additions and 14 deletions

View File

@@ -773,6 +773,14 @@ int main(int argc, char **argv) {
for (size_t n = 0; n < gAsset.meshes.size(); n++) {
nanosg::Node<float, example::Mesh<float> > node(&gAsset.meshes[n]);
// case where the name of a mesh isn't defined in the loaded file
if (gAsset.meshes[n].name.empty()) {
std::string generatedName = "unnamed_" + std::to_string(n);
gAsset.meshes[n].name = generatedName;
meshes[n].name = generatedName;
}
node.SetName(meshes[n].name);
node.SetLocalXform(meshes[n].pivot_xform); // Use mesh's pivot transform
// as node's local transform.