bash 如何使用 Xcode 转换器创建 USDZ 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50846627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create USDZ file using Xcode converter?
提问by Clay
At the 2018 WWDC Apple annouced the introduction of new USDZ file format.
在 2018 年的 WWDC 上,Apple 宣布推出新的 USDZ 文件格式。
https://developer.apple.com/videos/play/wwdc2018/603/
https://developer.apple.com/videos/play/wwdc2018/603/
In relation to creating USDZ file the following was said:
关于创建 USDZ 文件,如下所述:
To create your own usdz files, a usdz_converter has been bundled as part of Xcode 10 beta. Its a command line tool for creating the usdz file from OBJ files, Single-frame Alembic (ABC) files, USD file (either .usda or usd.c)
为了创建您自己的 usdz 文件,一个 usdz_converter 已作为 Xcode 10 beta 的一部分捆绑在一起。它是一个命令行工具,用于从 OBJ 文件、单帧 Alembic (ABC) 文件、USD 文件(.usda 或 usd.c)创建 usdz 文件
the basic command line is
基本的命令行是
xcrun usdz_converter myFile.obj myFile.usdz
I have installed Xcode 10 beta, but have been unable to run or even find usdz_converter in the Xcode 10 beta bundle made available on the 4th June 2018 (build 10L176w).
我已经安装了 Xcode 10 测试版,但在 2018 年 6 月 4 日提供的 Xcode 10 测试版捆绑包(构建 10L176w)中无法运行甚至无法找到 usdz_converter。
note: I'm still running on macOS highSierra, I have not installed macOS Mojave 10.14 beta yet... but didn't think that should be the reason why.
注意:我仍然在 macOS highSierra 上运行,我还没有安装 macOS Mojave 10.14 beta ......但我认为这不是原因。
Has anyone else been able to get this xcrun usdz_converter to work?
有没有其他人能够让这个 xcrun usdz_converter 工作?
If so please share the steps.
如果是这样,请分享步骤。
回答by Andy
Updated: March 30, 2020.
更新时间:2020 年 3 月 30 日。
usdzconvert
command for Xcode 11
usdzconvert
Xcode 11 的命令
In macOS 10.15 Catalinaand Xcode 11
USDZ converter
has a rich set of commands and supports more input formats for conversion than previous version. But before using it you need to download usdz Tools. And don't forget to setup a global variablesfor Python usdz tools. Here's how a new command looks like in Terminal:
在macOS 10.15 中,Catalina和Xcode 11
USDZ converter
拥有丰富的命令集,并且比以前的版本支持更多的输入格式进行转换。但在使用它之前,您需要下载usdz Tools。并且不要忘记为 Python usdz 工具设置全局变量。下面是一个新命令在终端中的样子:
usdzconvert ~/Desktop/file.gltf -diffuseColor albedo.png -metallic brass.jpg
- In macOS Catalina the default command shell isZSH.
- 在 macOS Catalina 中,默认的命令外壳是ZSH。
So, if you want to use USDPython
toolsyou need to create a Shell Resource file .zshrc
using the following Terminal command:
因此,如果要使用USDPython
工具,则需要.zshrc
使用以下终端命令创建 Shell 资源文件:
touch ~/.zshrc
Then you have to open this file using:
然后你必须使用以下命令打开这个文件:
open ~/.zshrc
Now you can add these lines into zsh resource file:
现在您可以将这些行添加到 zsh 资源文件中:
export PATH="/Users/yourUserName/usdpython/USD:$PATH"
export PATH="/Users/yourUserName/usdpython/usdzconvert:$PATH"
export PYTHONPATH="/Users/yourUserName/usdpython/USD/lib/python:$PYTHONPATH"
echo "Now I can use USDPython commands here."
Save it and restart Terminal.
保存并重新启动终端。
usdzconvert
is a Python script that converts the following assets into usdz
:
usdzconvert
是一个 Python 脚本,可将以下资产转换为usdz
:
- obj
- gltf
- fbx
- abc
- usda
- usdc
- usd
- 对象
- 格特夫
- fbx
- 美国广播公司
- 美国农业部
- 美元
- 美元
If you need to use FBX
format conversion you have to download and install FBX Python SDK.
如果您需要使用FBX
格式转换,您必须下载并安装FBX Python SDK。
Then add to .zshrc
file one more line:
然后在.zshrc
文件中再添加一行:
export PYTHONPATH="/Applications/Autodesk/FBXPythonSDK/2020.0.1/lib/Python27_ub:$PYTHONPATH"
Save .zshrc
file and restart Terminal.
保存.zshrc
文件并重新启动终端。
Here's a full list of options you can see in Terminal, typing usdzconvert -h
:
这是您可以在终端中看到的完整选项列表,键入usdzconvert -h
:
DON'T USE usdzconvert 0.63 BECAUSE IT CAUSES ERRORS.
usdzconvert 0.62
outputFile Output .usd/usda/usdc/usdz files.
-h, --help Show this help message and exit.
-f <file> Read arguments from <file>
-v Verbose output.
-url <url> Add URL metadata
-copyright "copyright message" Add copyright metadata
-copytextures Copy texture files (for .usd/usda/usdc) workflows
-metersPerUnit value Set metersPerUnit attribute with float value
-loop Set animation loop flag to 1
-no-loop Set animation loop flag to 0
-m materialName Subsequent material arguments apply to this material.
-iOS12 Make output file compatible with iOS 12 frameworks
-texCoordSet name The name of the texture coordinates to use for current material.
-diffuseColor r,g,b Set diffuseColor to constant color r,g,b with values in the range [0 .. 1]
-diffuseColor <file> fr,fg,fb Use <file> as texture for diffuseColor.
fr,fg,fb: (optional) constant fallback color, with values in the range [0..1].
-normal x,y,z Set normal to constant value x,y,z in tangent space [(-1, -1, -1), (1, 1, 1)].
-normal <file> fx,fy,fz Use <file> as texture for normal.
fx,fy,fz: (optional) constant fallback value, with values in the range [-1..1].
-emissiveColor r,g,b Set emissiveColor to constant color r,g,b with values in the range [0..1]
-emissiveColor <file> fr,fg,fb Use <file> as texture for emissiveColor.
fr,fg,fb: (optional) constant fallback color, with values in the range [0..1].
-metallic c Set metallic to constant c, in the range [0..1]
-metallic ch <file> fc Use <file> as texture for metallic.
ch: (optional) texture color channel (r, g, b or a).
fc: (optional) fallback constant in the range [0..1]
-roughness c Set roughness to constant c, in the range [0..1]
-roughness ch <file> fc Use <file> as texture for roughness.
ch: (optional) texture color channel (r, g, b or a).
fc: (optional) fallback constant in the range [0..1]
-occlusion c Set occlusion to constant c, in the range [0..1]
-occlusion ch <file> fc Use <file> as texture for occlusion.
ch: (optional) texture color channel (r, g, b or a).
fc: (optional) fallback constant in the range [0..1]
-opacity c Set opacity to constant c, in the range [0..1]
-opacity ch <file> fc Use <file> as texture for opacity.
ch: (optional) texture color channel (r, g, b or a).
fc: (optional) fallback constant in the range [0..1]
-clearcoat c Set clearcoat to constant c, in the range [0..1]
-clearcoat ch <file> fc Use <file> as texture for clearcoat.
ch: (optional) texture color channel (r, g, b or a).
fc: (optional) fallback constant in the range [0..1]
-clearcoatRoughness c Set clearcoat roughness to constant c, in the range [0..1]
-clearcoatRoughness ch <file> fc Use <file> as texture for clearcoat roughness.
ch: (optional) texture color channel (r, g, b or a).
fc: (optional) fallback constant in the range [0..1]
Or, instead of using a command line conversion tool (CLI), you could use a Reality Converterapp (GUI). The new app makes it easy to convert, view, and customise .usdz
objects on Mac. Simply drag-and-drop common 3D file formats, such as .obj
, .gltf
and .usd
, to view the converted .usdz
result, customise material properties with your own textures, and edit file metadata. You can even preview your .usdz
object under a variety of lighting and environment conditions with built-in IBL options.
或者,您可以使用Reality Converter应用程序 (GUI) ,而不是使用命令行转换工具 (CLI )。新应用程序可以轻松地.usdz
在 Mac 上转换、查看和自定义对象。只需拖放常见的 3D 文件格式,例如.obj
、.gltf
和.usd
,即可查看转换.usdz
结果、使用您自己的纹理自定义材质属性以及编辑文件元数据。您甚至可以.usdz
使用内置的 IBL 选项在各种光照和环境条件下预览您的对象。
xcrun usdz_converter
command for Xcode 10
xcrun usdz_converter
Xcode 10 的命令
In macOS 10.14 Mojaveand Xcode 10
USDZ converter
has a slightly different set of arguments and flags. Here's how an old command looks like in Terminal:
在macOS 10.14 中,Mojave和Xcode 10
USDZ converter
的参数和标志集略有不同。这是旧命令在终端中的样子:
xcrun usdz_converter file.obj file.usdz -color_map color.jpg -ao_map ao.png
- In macOS Mojave the default command shell isBASH.
- 在 macOS Mojave 中,默认的命令外壳是BASH。
Here's a full list of options you can see in Terminal, typing xcrun usdz_converter -h
:
这是您可以在终端中看到的完整选项列表,键入xcrun usdz_converter -h
:
-g groupName [groupNames ...] Apply subsequent material properties to the named group(s).
-m materialName [materialNames ...] Apply subsequent material properties to the named material(s).
-h Display help.
-a Generate a .usda intermediate file. Default is .usdc.
-l Leave the intermediate .usd file in the source folder.
-v Verbose output.
-f filePath Read commands from a file.
-texCoordSet set The name of the texturemap coordinate set to use if multiple exist (no quotes).
-opacity o Floating point value 0.0...1.0
-color_default r g b a Floating point values 0.0...1.0
-normal_default r g b a Floating point values 0.0...1.0
-emissive_default r g b a Floating point values 0.0...1.0
-metallic_default r g b a Floating point values 0.0...1.0
-roughness_default r g b a Floating point values 0.0...1.0
-ao_default r g b a Floating point values 0.0...1.0
-color_map filePath
-normal_map filePath
-emissive_map filePath
-metallic_map filePath
-roughness_map filePath
-ao_map filePath
回答by Abraham Torres
You have to enable the Xcode 10 command line tools on Xcode > Preferences > Locations
您必须启用 Xcode 10 命令行工具 Xcode > Preferences > Locations
回答by Matthijs
You have to activate the command line tools in Xcode preferences, in case they're not actived yet (that was my case). See this topic:
您必须在 Xcode 首选项中激活命令行工具,以防它们尚未激活(这就是我的情况)。请参阅此主题: