kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
263 stars 39 forks source link

Sanitise node names #182

Closed ghost closed 4 years ago

ghost commented 4 years ago

This glTF does not convert and trow this error:

Warning: in SdfPath at line 97 of /tmp/USD-19.11/pxr/usd/lib/sdf/path.cpp -- Ill-formed SdfPath </root/Hay_+undefined__101>: syntax error
Traceback (most recent call last):
  File "/usr/local/gltf2usd/Source/gltf2usd.py", line 923, in <module>
    convert_to_usd(os.path.expanduser(args.gltf_file), os.path.abspath(os.path.expanduser(args.usd_file)), args.fps, args.scale, args.arkit, args.verbose, args.use_euler_rotation, args.optimize_textures, args.generate_texture_transform_texture, args.scale_texture)
  File "/usr/local/gltf2usd/Source/gltf2usd.py", line 832, in convert_to_usd
    usd = GLTF2USD(gltf_file=gltf_file, usd_file=temp_usd_file, fps=fps, scale=scale, verbose=verbose, use_euler_rotation=use_euler_rotation, optimize_textures=optimize_textures, generate_texture_transform_texture=generate_texture_transform_texture, scale_texture=scale_texture)
  File "/usr/local/gltf2usd/Source/gltf2usd.py", line 75, in __init__
    self.convert()
  File "/usr/local/gltf2usd/Source/gltf2usd.py", line 801, in convert
    self.convert_nodes_to_xform()
  File "/usr/local/gltf2usd/Source/gltf2usd.py", line 91, in convert_nodes_to_xform
    self._convert_node_to_xform(node, parent_transform)
  File "/usr/local/gltf2usd/Source/gltf2usd.py", line 102, in _convert_node_to_xform
    xformPrim = UsdGeom.Xform.Define(self.stage, '{0}/{1}'.format(usd_xform.GetPath(), GLTF2USDUtils.convert_to_usd_friendly_node_name(node.name)))
pxr.Tf.ErrorException: 
    Error in 'pxrInternal_v0_19__pxrReserved__::UsdStage::_IsValidPathForCreatingPrim' at line 3019 in file /tmp/USD-19.11/pxr/usd/lib/usd/stage.cpp : 'Path must be an absolute path: <>'

It appears to be related to the node name "Hay-+undefined-". The + sign seems to break it and it shouldn't because it is valid for the glTF spec.

ephb commented 4 years ago

The same is true for the the exclamation mark ! and underscore _ sign as well as any umlauts like"äöü".

ghost commented 4 years ago

This is quote blocking for us, any chance you could look at it @kcoley :) ?

ephb commented 4 years ago

@sayduck-daniel can't you change your node names? This is the way I currently work around this.

kcoley commented 4 years ago

The issue here is that the USD API has more restrictions on supported characters than glTF. It may be better in this case to try to change your node names

ghost commented 4 years ago

We did it on our side. But I still think the gltf2usd should always work when we give him a valid glTF, specially when this glTF could come from a user and pass a glTF validator test.