Swift 如何使用Xcode转换器创建USDZ文件?
在2018年WWDC上,苹果宣布引入新的USDZ文件格式 关于创建USDZ文件,声明如下: 为了创建您自己的usdz文件,一个usdz_转换器作为Xcode 10测试版的一部分捆绑在一起。它是一个命令行工具,用于从OBJ文件、单帧Alembic(ABC)文件、USD文件(usda或USD.c)创建usdz文件 基本命令行是Swift 如何使用Xcode转换器创建USDZ文件?,swift,bash,augmented-reality,arkit,realitykit,Swift,Bash,Augmented Reality,Arkit,Realitykit,在2018年WWDC上,苹果宣布引入新的USDZ文件格式 关于创建USDZ文件,声明如下: 为了创建您自己的usdz文件,一个usdz_转换器作为Xcode 10测试版的一部分捆绑在一起。它是一个命令行工具,用于从OBJ文件、单帧Alembic(ABC)文件、USD文件(usda或USD.c)创建usdz文件 基本命令行是 xcrun usdz_converter myFile.obj myFile.usdz 我已经安装了Xcode 10 beta,但在2018年6月4日推出的Xcode 1
xcrun usdz_converter myFile.obj myFile.usdz
我已经安装了Xcode 10 beta,但在2018年6月4日推出的Xcode 10 beta捆绑包(build 10L176w)中无法运行甚至无法找到usdz_转换器
注意:我仍然在macOS highSierra上运行,我还没有安装macOS Mojave 10.14测试版。。。但我不认为这就是原因
还有其他人能让这个xcrun usdz_转换器工作吗
如果是,请分享这些步骤 您必须在Xcode首选项中激活命令行工具,以防它们尚未激活(这就是我的情况)。请参见本主题:
更新日期:2021年1月15日 在Xcode 13的RC 1.5中导出命令 在macOS 11 Big Sur和Reality Composer 1.5中,对于Xcode 13,您现在可以直接从Reality Composer的UI导出一个
usdz
模型。为此,您只需在RealityComposer–首选项菜单中激活USDZ导出
你也可以使用
Xcode 13、12和11中的usdzconvert命令 在macOS 11 Big Sur和macOS 10.15 Catalina
USDZ converter
中,与以前的版本相比,具有丰富的命令集并支持更多的转换输入格式。但在使用它之前,你需要下载。不要忘记为Python usdz工具设置一个全局变量。以下是在终端中新命令的外观:
- 在macOS Big Sur和macOS Catalina中,默认命令shell为ZSH
.zshrc
:
touch ~/.zshrc
然后,您必须使用以下方法打开此文件:
open ~/.zshrc
现在,您可以将这些行添加到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."
保存并重新启动终端
usdzconvert
是一个Python脚本,它将以下资产转换为usdz
:
- obj
- gltf
- fbx
- abc
- 美国农业部
- 美国农业部
- 美元
FBX
格式转换,则必须下载并安装
然后在.zshrc
文件中再添加一行:
export PYTHONPATH="/Applications/Autodesk/FBXPythonSDK/2020.0.1/lib/Python27_ub:$PYTHONPATH"
保存.zshrc
文件并重新启动终端
以下是您可以在终端中看到的选项的完整列表,键入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]
-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
- 在macOS Mojave中,默认命令shell是BASH
xcrun usdz_converter-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]
-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>Preferences>Locations上启用Xcode 10命令行工具
运行该命令时会得到什么?我没有要尝试转换的文件,但当我运行命令时,它会打印出使用说明,因此它至少在那里。xcrun:错误:找不到实用程序“usdz_converter”,而不是开发工具或路径确保xcrun在正确的位置查找,通过使用
xcode select
将active developer目录设置为xcode-beta.app中的目录,或者为其提供usdz_converter
Ok的完整路径,我有两个版本的xcode。。。所以我现在要调查一下。thanksxcode选择-p/Applications/Xcode.app/Contents/Developer应该是/Applications/Xcode beta 10.app/Contents/Developer-thanksI需要从使用v更改。9个命令行工具来使用10个beta命令行工具你对只使用Python工具而不使用XCode有什么建议吗?