如何使用Xcode转换器创建USDZ文件? [英] How to create USDZ file using Xcode converter?
问题描述
在2018年WWDC上,Apple宣布引入新的USDZ文件格式.
At the 2018 WWDC Apple annouced the introduction of new USDZ file format.
https://developer.apple.com/videos/play/wwdc2018/603/
关于创建USDZ文件,有人说:
In relation to creating USDZ file the following was said:
要创建自己的usdz文件,将usdz_converter捆绑在一起作为Xcode 10 beta的一部分.它是用于从OBJ文件,单帧Alembic(ABC)文件,USD文件(.usda或usd.c)创建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)
基本命令行是
xcrun usdz_converter myFile.obj myFile.usdz
我已经安装了Xcode 10 beta,但无法运行甚至无法在2018年6月4日提供的Xcode 10 beta捆绑包(内部版本10L176w)中找到usdz_converter.
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).
注意:我仍在macOS highSierra上运行,我还没有安装macOS Mojave 10.14 beta版...但是不认为那是原因.
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.
还有其他人能够使此xcrun usdz_converter正常工作吗?
Has anyone else been able to get this xcrun usdz_converter to work?
如果是,请分享步骤.
If so please share the steps.
推荐答案
更新时间:2020年6月26日.
在 Xcode 12 <
和 Reality Composer 1.5 中/strong> ,您现在可以直接从Reality Composer的UI导出 usdz
模型.为此,您只需要在首选项"菜单中激活USDZ导出即可.
In macOS 10.16 Big Sur and Reality Composer 1.5 for Xcode 12 you can now export a
usdz
model right from Reality Composer's UI. For that you just need to activate a USDZ export in Preferences menu.
在 macOS 10.15 Catalina 和 Xcode 11
USDZ converter
中,命令集丰富,并支持更多输入的格式要比以前的版本转换.但是在使用它之前,您需要下载 usdz工具.并且不要忘记为Python usdz工具设置全局变量.这是新命令在 Terminal (终端)中的样子:
In macOS 10.15 Catalina and 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 variables for Python usdz tools. Here's how a new command looks like in Terminal:
usdzconvert ~/Desktop/file.gltf -diffuseColor albedo.png -metallic brass.jpg
- 在macOS Catalina中,默认命令shell是 ZSH .
因此,如果要使用 USDPython
工具,则需要使用以下终端命令创建Shell资源文件.zshrc
:
So, if you want to use USDPython
tools you need to create a Shell Resource file .zshrc
using the following Terminal command:
touch ~/.zshrc
然后,您必须使用以下命令打开此文件:
Then you have to open this file using:
open ~/.zshrc
现在,您可以将以下行添加到zsh资源文件中:
Now you can add these lines into zsh resource file:
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."
保存并重新启动终端.
usdzconvert
是一个Python脚本,可将以下资产转换为usdz
:
usdzconvert
is a Python script that converts the following assets into usdz
:
- obj
- gltf
- fbx
- abc
- usda
- usdc
- 美元
如果需要使用FBX
格式转换,则必须下载并安装 FBX Python SDK .
If you need to use FBX
format conversion you have to download and install FBX Python SDK.
然后在.zshrc
文件中再添加一行:
Then add to .zshrc
file one more line:
export PYTHONPATH="/Applications/Autodesk/FBXPythonSDK/2020.0.1/lib/Python27_ub:$PYTHONPATH"
保存.zshrc
文件并重新启动终端.
Save .zshrc
file and restart Terminal.
这里是您可以在终端机中看到的选项的完整列表,键入 usdzconvert -h
:
Here's a full list of options you can see in Terminal, typing usdzconvert -h
:
# DON'T USE usdzconvert 0.63 BECAUSE IT CAUSES ERRORS.
# DO USE usdzconvert 0.62
# or
# DO USE usdzconvert 0.64
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 Converter app (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.
在 macOS 10.14 Mojave 和 Xcode 10
USDZ converter
中,参数和标志的设置略有不同.这是旧命令在终端中的样子:
In macOS 10.14 Mojave and Xcode 10
USDZ converter
has a slightly different set of arguments and flags. Here's how an old command looks like in Terminal:
xcrun usdz_converter file.obj file.usdz -color_map color.jpg -ao_map ao.png
- 在macOS Mojave中,默认命令外壳为 BASH .
这里是您可以在终端机中看到的选项的完整列表,键入 xcrun usdz_converter -h
:
Here's a full list of options you can see in Terminal, typing 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
这篇关于如何使用Xcode转换器创建USDZ文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!