kcoley / gltf2usd

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

Getting error when running this script... #1

Closed enzyme69 closed 6 years ago

enzyme69 commented 6 years ago
192-168-1-4:Source jimmygunawan$ python gltf2usd.py -g /Users/jimmygunawan/tentacle.gltf  -o tentacle.usda
Traceback (most recent call last):
  File "gltf2usd.py", line 1081, in <module>
    convert_to_usd(args.gltf_file, args.usd_file, args.fps, args.verbose)
  File "gltf2usd.py", line 1070, in convert_to_usd
    GLTF2USD(gltf_file=gltf_file, usd_file=usd_file, fps=fps, verbose=verbose)
  File "gltf2usd.py", line 62, in __init__
    self.convert()
  File "gltf2usd.py", line 1056, in convert
    self.convert_nodes_to_xform()
  File "gltf2usd.py", line 98, in convert_nodes_to_xform
    self._convert_node_to_xform(node, node_index, xform_name)
  File "gltf2usd.py", line 149, in _convert_node_to_xform
    self._convert_node_to_xform(self.gltf_loader.json_data['nodes'][child_index], child_index, xform_path + '/node{}'.format(child_index))
  File "gltf2usd.py", line 145, in _convert_node_to_xform
    self._convert_mesh_to_xform(self.gltf_loader.json_data['meshes'][node['mesh']], usd_parent_node, node_index)
  File "gltf2usd.py", line 169, in _convert_mesh_to_xform
    self._convert_primitive_to_mesh(name=mesh_primitive_name, primitive=mesh_primitive, usd_parent_node=usd_parent_node, node_index=node_index, double_sided = double_sided)
  File "gltf2usd.py", line 230, in _convert_primitive_to_mesh
    self._convert_skin_to_usd(gltf_node, node_index, usd_parent_node, mesh)
  File "gltf2usd.py", line 687, in _convert_skin_to_usd
    skeleton.CreateBindTransformsAttr().Set(bind_matrices)
AttributeError: 'Skeleton' object has no attribute 'CreateBindTransformsAttr'
enzyme69 commented 6 years ago

Second trial after exporting GLTF with different settings:

192-168-1-4:Source jimmygunawan$ python gltf2usd.py -g /Users/jimmygunawan/tentacle.gltf  -o tentacle.usda
Traceback (most recent call last):
  File "gltf2usd.py", line 1081, in <module>
    convert_to_usd(args.gltf_file, args.usd_file, args.fps, args.verbose)
  File "gltf2usd.py", line 1070, in convert_to_usd
    GLTF2USD(gltf_file=gltf_file, usd_file=usd_file, fps=fps, verbose=verbose)
  File "gltf2usd.py", line 62, in __init__
    self.convert()
  File "gltf2usd.py", line 1056, in convert
    self.convert_nodes_to_xform()
  File "gltf2usd.py", line 98, in convert_nodes_to_xform
    self._convert_node_to_xform(node, node_index, xform_name)
  File "gltf2usd.py", line 149, in _convert_node_to_xform
    self._convert_node_to_xform(self.gltf_loader.json_data['nodes'][child_index], child_index, xform_path + '/node{}'.format(child_index))
  File "gltf2usd.py", line 145, in _convert_node_to_xform
    self._convert_mesh_to_xform(self.gltf_loader.json_data['meshes'][node['mesh']], usd_parent_node, node_index)
  File "gltf2usd.py", line 169, in _convert_mesh_to_xform
    self._convert_primitive_to_mesh(name=mesh_primitive_name, primitive=mesh_primitive, usd_parent_node=usd_parent_node, node_index=node_index, double_sided = double_sided)
  File "gltf2usd.py", line 202, in _convert_primitive_to_mesh
    data = self.gltf_loader.get_data(buffer=self.buffer, accessor=accessor)
  File "/Users/jimmygunawan/gltf2usd-master/Source/gltf2loader.py", line 106, in get_data
    with open(os.path.join(self.root_dir, buffer['uri']), 'rb') as buffer_fptr:
IOError: [Errno 63] File name too long: u'/Users/jimmygunawan/data:application/octet-stream;base64,ghqzvjajjkCLhBm+G+mqPsp42D87ZUe/yqNnP2qp5jwAgFI0lgiHPneSOkD5iR2/rcoov3aSOkAAgOe0gHETP4NcS0CHwny+p7ahvhM9AkBfqjw/Y4QZvjajjkCQGrO+AIC1NJbnW0A/ihK/cPyTPmOEnEAAAJSzAABAtDiOs74cx1E/poQqvqIdpUBwXK89gpmevkTPhkB4mZ4+axynvnIcp746jkO/Oo5Dv3Icp75sHKc+AABAs0TPhkCqRdg+bn1Yv7iGaD8mkLm+tI/3PnaSOkCoj/e+JJC5PriGaD9wfVi//JgDP4AWKUD2mAO/kBcIPiAAlkAaxp6+VbLnPoRcS0BVsuc+QnI2PngooUA8cja+l+W/PjajjkAAAByzG0eKPqZvnED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aIdpUChhCo+eQQtvkTPhkCs2sm+014Cv9JeAr/QXgI/sKqavlVVGb9WVRk/y2y9vpQ47T79/ly/t4QqPqEdpUCfXK+90Gy9PpQ47T76/lw/3HZqPpXnW0BKxQi/AAAPNIrXqEAAAEG0qqokP6qqJL8AAEw0cn1YP7iGaD8ckLk+FcaeviAAlkBtFwg+ds60PX9Qp0BTzrQ9AABQNDiOs74cx1G/nLahPhM9AkBjqjw/Zhkqv7iGaD9yGSq/jOrhvhlRfUCWpEG+Qr4pv9IbJT1Kvim/LOTHPWt7oUC3Dma+8pgDv4AWKUD+mAO/O4oSv5bnW0AAANO0hxqzvjajjkBghBk+0DIkv7iGqD/eMiS/ndrJvkTPhkCkBC2+Sr4pv9IbJT1Cvik/ ...... LONG!
enzyme69 commented 6 years ago

I tried all kind of GLTF, and the error I kept getting is "File name too long"... not sure what's going on...

enzyme69 commented 6 years ago

When using monster.gltf animation from Khronos Group:

192-168-1-4:Source jimmygunawan$ python gltf2usd.py -g monster.gltf  -o monster.usda
Traceback (most recent call last):
  File "gltf2usd.py", line 1081, in <module>
    convert_to_usd(args.gltf_file, args.usd_file, args.fps, args.verbose)
  File "gltf2usd.py", line 1070, in convert_to_usd
    GLTF2USD(gltf_file=gltf_file, usd_file=usd_file, fps=fps, verbose=verbose)
  File "gltf2usd.py", line 62, in __init__
    self.convert()
  File "gltf2usd.py", line 1054, in convert
    self._convert_images_to_usd()
  File "gltf2usd.py", line 286, in _convert_images_to_usd
    shutil.copyfile(image_path, image_name)
  File "/Users/jimmygunawan/miniconda2/lib/python2.7/shutil.py", line 83, in copyfile
    raise Error("`%s` and `%s` are the same file" % (src, dst))
shutil.Error: `Monster.jpg` and `Monster.jpg` are the same file
kcoley commented 6 years ago

Hi @enzyme69, thanks for trying out this tool and flagging your issues!

Did you build your USD against version 18.09? Some of the API calls I am using, such as CreateBindTransformsAttr are not available in earlier versions of USD. Updating your USD should at least resolve this error.

The "File name too long" error is because I have not handled base64 strings yet during conversion, so it only handles glTF assets with external texture references. I plan on supporting that very soon.

The last error is a bug, since shutil.copyfile does not overwrite files in the same directory. As a temporary solution, can you try running this command?:

python gltf2usd.py -g monster.gltf -o monster/monster.usda

This should create a new directory called "monster" and export all the textures and USD file within it. I will work on fixing the shutil issue.

Again thanks for trying out this tool and I'll get to these bugs ASAP!

enzyme69 commented 6 years ago

@kcoley You are right with I am needing to update my USD and thanks for Monster example it converts the animation!!! Wooh~ This is exciting :D

Looking forward to future update!

enzyme69 commented 6 years ago

monster_test_001

Funny on iOS this USDZ is not animating :D MacOS works.. maybe a bug?

enzyme69 commented 6 years ago

Will file bug report to Apple~

kcoley commented 6 years ago

@enzyme69 great! Btw, I made some tweaks to gltf2usd this morning, so that the animations play on iOS now. Feel free to pull the latest master and see if that works for you.