DEV Community

j1ngzoue
j1ngzoue

Posted on

Build USD and bring USD up to date in usdz tool

We use the latest versions of OpenUSD and usdPython as of 2024/03/01.

Introduction

  • Apple's usdPython python version is stuck at 3.7.9, so build and use USD with the latest python version available for OpenUSD.

Available Python versions can be found here.

The version as of 2024/03/01 was 3.9.13.

Step 1 Preparation before build

  • Since we are using 3.7.9 python, install the latest version with pyenv
  • The latest was 3.12.2
pyenv install 3.12.2
Enter fullscreen mode Exit fullscreen mode
pyenv local 3.12.2
Enter fullscreen mode Exit fullscreen mode

In python, we also want to be able to run python3, so run the following

alias python="python3"
Enter fullscreen mode Exit fullscreen mode
  • In USD, the usdView command uses pyside6, so install it.
  • You can also use pyside2.
python -m pip install pyside6
Enter fullscreen mode Exit fullscreen mode

Step 2 Build

  • Peel off unnecessary things with option (be patient as it takes time to build)
python USD/build_scripts/build_usd.py /path/to/my_usd_install_dir --no-examples --no-tests --no-docs --no-ptex --no-openvdb --no-draco --no --materialx --no-examples
Enter fullscreen mode Exit fullscreen mode

Dealing with build errors

  • Install pyOpenGL to deal with the error.
PyOpenGL is not installed; if pip is installed, run "pip install PyOpenGL" to install it, then re-run this script.
If PyOpenGL is already installed, you may need to update your PYTHONPATH to indicate where PyOpenGL is located.
Enter fullscreen mode Exit fullscreen mode
pip install PyOpenGL
Enter fullscreen mode Exit fullscreen mode

Step 3 Replace

  • The U.S. dollar/ distribution is replaced. After replacing, see here.

Step 4 Run usdzconvert

usdzconvert . /cube.glb ~/cube.usdz
Enter fullscreen mode Exit fullscreen mode

I get an error.

Input file: /Users/xxxxxx/Documents/cube.glb
Traceback (most recent call last):
  File "/Users/xxxxxx/projects/USDPython/./usdzconvert/usdzconvert", line 860, in <module>
    errorValue = main()
  File "/Users/xxxxxx/projects/USDPython/./usdzconvert/usdzconvert", line 855, in main
    return tryProcess(sys.argv[1:])
  File "/Users/xxxxxx/projects/USDPython/./usdzconvert/usdzconvert", line 810, in tryProcess
    ret = process(argumentList)
  File "/Users/xxxxxx/projects/USDPython/./usdzconvert/usdzconvert", line 650, in process
    usdStage = usdStageWithGlTF_module.usdStageWithGlTF(srcPath, tmpPath, legacyModifier, openParameters)
  File "/Users/xxxxxx/projects/USDPython/usdzconvert/usdStageWithGlTF.py", line 1529, in usdStageWithGlTF
    return converter.makeUsdStage()
  File "/Users/xxxxxx/projects/USDPython/usdzconvert/usdStageWithGlTF.py", line 1512, in makeUsdStage
    self.processNodeChildren(self.gltf['scenes'][0]['nodes'], self.asset.getGeomPath(), None)
  File "/Users/xxxxxx/projects/USDPython/usdzconvert/usdStageWithGlTF.py", line 1399, in processNodeChildren
    self.processNode(nodeIdx, path, underSkeleton, indent)
  File "/Users/xxxxxx/projects/USDPython/usdzconvert/usdStageWithGlTF.py", line 1366, in processNode
    usdGeom = self.processMesh(nodeIdx, newPath, underSkeleton)
  File "/Users/xxxxxx/projects/USDPython/usdzconvert/usdStageWithGlTF.py", line 1316, in processMesh
    usdGeom = self.processPrimitive(nodeIdx, gltfPrimitives[0], path, skinIdx, underSkeleton)
  File "/Users/xxxxxx/projects/USDPython/usdzconvert/usdStageWithGlTF.py", line 1142, in processPrimitive
    normalPrimvar = usdGeom.CreatePrimvar('normals', Sdf.ValueTypeNames.Normal3fArray, UsdGeom.Tokens.vertex)
AttributeError: 'Mesh' object has no attribute 'CreatePrimvar'
Enter fullscreen mode Exit fullscreen mode

Check the issue and fix usdzconvert/usdStageWithGlTF.py.
https://github.com/PixarAnimationStudios/OpenUSD/issues/2628
https://github.com/activeguild/USDPython/commit/482afe50eba109c7d68b082edef003af4ec2e279

Confirmation that usdzconverter terminates normally with the above modification.

Top comments (0)