kcoley / gltf2usd

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

Latest converter update is confusing and has weird issues... #63

Closed enzyme69 closed 5 years ago

enzyme69 commented 5 years ago

I'm wondering what's the best way to install the Python module. In the past, I simply copy paste all the files in the source into the folder where the gltf asset is, and then run the Python tool:

screen shot 2018-09-29 at 09 55 47

But in the latest update the tools have grown and when I tested a conversion using the tests asset, I keep getting weird error:

TATATs-MacBook-Pro:Start_Walking jimmyg$ python gltf2usd.py -g Start_Walking.gltf -o Start_Walking.usdz
converted usd file extension from .usdz to .usdc: Start_Walking.usdc
Traceback (most recent call last):
  File "gltf2usd.py", line 726, in <module>
    convert_to_usd(args.gltf_file, args.usd_file, args.fps, args.scale, args.arkit, args.verbose, args.use_euler_rotation)
  File "gltf2usd.py", line 679, in convert_to_usd
    usd = GLTF2USD(gltf_file=gltf_file, usd_file=usd_file, fps=fps, scale=scale, verbose=verbose, use_euler_rotation=use_euler_rotation)
  File "gltf2usd.py", line 68, in __init__
    self.convert()
  File "gltf2usd.py", line 655, in convert
    self._convert_images_to_usd()
  File "gltf2usd.py", line 414, in _convert_images_to_usd
    shutil.copyfile(image_path, image_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 69, in copyfile
    raise Error("`%s` and `%s` are the same file" % (src, dst))
shutil.Error: `Boss_diffuse.png` and `/Users/jimmyg/Documents/PROJECT20180922/Madain_Saleh/anim3/tests/assets/Start_Walking/Boss_diffuse.png` are the same file

UPDATE: Regarding me being dumb copy pasting the script into the folder, I just realized I can keep the original Tool, then open terminal inside the source tool folder and then drag and drop the GLTF file to be converted and then simply just output the result inside any folder. I am still getting familiar with commands and terminal.

For example:

screen shot 2018-09-29 at 14 17 45
enzyme69 commented 5 years ago

Another example I am testing is this Two Tentacles animation.

screen shot 2018-09-29 at 10 04 02

ori.zip

Originally I have 2 separate armatures for each tentacle. It does not export correctly from Blender to GLTF. So I ensure armature are joined into a single armature with many branches.

GLTF works correctly at GLTF online viewer.

When I am converting the result is this weirdness:

screen shot 2018-09-29 at 10 08 36
kcoley commented 5 years ago

Hi @enzyme69 ! The tool has expanded into separate files. If you want to copy-paste, you would have to include all the files in the gltf2 directory, gltf2loader.py, gltf2usd.py gltf2usdUtils.py usd_material.py and gltf2UsdMaterialHelper.py.

Though, I will make an update where you would only have to set your PATH environment variable to the gltf2usd Source directory, and then things should just work from command line.

As for the error you are hitting, it's because shutil is trying to copy a file onto itself. This would happen if the source gltf file is in the same directory where you are writing out the usd file. I'll add some additional logic to prevent that from happening. In the meantime, you can export to a subdirectory within the same directory so the textures won't overlap.

Thanks for providing this model. I've been chasing down this issue and will look into that too.

enzyme69 commented 5 years ago

Even when converted: -- and the texture also seems to get copied into the folder of the tool.

screen shot 2018-09-29 at 10 18 48

Thanks @kcoley for continuing updates~

kcoley commented 5 years ago

Yep, this model is the issue I have been chasing down for a few weeks. I think your simpler model may help with troubleshooting as the walking animation is quite complex to analyze.

kcoley commented 5 years ago

Hi @enzyme69 do you have the original .blend file for the ori model?

kcoley commented 5 years ago

@enzyme69 actually, I was able to create a similar model in Maya and can now reproduce the issue. I think I know what is happening now and am working on a fix. Thanks again for the reference model!

enzyme69 commented 5 years ago

@kcoley Glad it is useful :) Your tools become defacto GLTF to USDZ conversion! two_tentacles_002.blend.zip

NOTE: Maybe use Blender 2.79 (most stable). Sometimes in near future, when Blender 2.8 is official, we can use Blender 2.8.

kcoley commented 5 years ago

Hi @enzyme69 . This took a while for me to get my copy of the Maya USD exporter to work, but now I know what I have to fix in the exporter to support multiple meshes sharing the same skeleton. Unfortunately, it looks like multiple skeletons currently do not animate on iOS or Mac OS, as alluded to by @wave-electron in this issue: https://github.com/kcoley/gltf2usd/issues/49

The only way to view the model would be through usdview, the Maya, or Houdini USD importers. @wave-electron mentioned a workaround by combining the meshes into one and sharing the same uv map to get it to work on iOS on that issue.

Here is a version of your model with two meshes in usdz (converted to fbx, imported to maya and exported as usd): two_tentacles_002.usdz.zip

Hopefully an upcoming iOS/Mac OS update will get this file to work.

kcoley commented 5 years ago

@enzyme69 I did some reorganization of the project in the lastest merge, so now you just need gltf2usd.py, __init__.py, and the _usdz folder. Hopefully that makes things easier to move around.

kcoley commented 5 years ago

Closing this for now