USDAssetsの作り方、基本構造メモ
ipynbFile makefileVariant__USDAssetsの作り方、基本構造メモ.ipynb
USDのサンプル examples/usdMakeFileVariantModelAsset/usdMakeFIleVarinatModelAsset.py
の中身を確認する。
このサンプルはコマンドラインで実行できる。
python usdMakeFileVariantModelAsset\usdMakeFileVariantModelAsset.py --kind model -i D:/test.usda -v cube sphere testProps D:\USDsample\modelAsset\cube.usda D:\USDsample\modelAsset\sphere.usda
基本構造は
RootPrim - Variant - Payload -
- __class_assetName
VariantとPayloadとInheritsの組み合わせ。
以下はサンプルの気になる部分の実行テスト。
[1]:¶
from pxr import Tf, Kind, Sdf, Usd
[2]:¶
Tf.IsValidIdentifier('sample')
Success
True
[3]:¶
assetName = "sampleData"
[4]:¶
filename = f"D:/{assetName}.usd"
[5]:¶
layer = Sdf.Layer.CreateNew(filename,args= {'format':'usda'})
[6]:¶
stage = Usd.Stage.Open(layer)
[9]:¶
print(rootPath.AppendChild(assetName))
Success
/sampleData
[10]:¶
rootPath = Sdf.Path.absoluteRootPath
modelRootPrim = stage.DefinePrim(rootPath.AppendChild(assetName))
[27]:¶
modelAPI = Usd.ModelAPI(modelRootPrim)
[28]:¶
# Option用のResolvePathをセットする
# (あくまでもOptionとして使用されるもの?もの?)
modelAPI.SetAssetIdentifier('D:/test.usda')
# AssetPathで取得できる
print(modelAPI.GetAssetIdentifier())
modelAPI.SetAssetName(assetName)
[39]:¶
# 引数で指定したKindかどうかを判定
modelAPI.IsKind('model')
Success
True
[40]:¶
classPrim = stage.CreateClassPrim(rootPath.AppendChild("_class_"+assetName))
modelRootPrim.GetInherits().AddInherit(classPrim.GetPath())
Success
True
[42]:¶
print(stage.GetRootLayer().ExportToString())
Success
#usda 1.0
(
defaultPrim = "sampleData"
)
def "sampleData" (
assetInfo = {
asset identifier = @D:/test.usda@
}
prepend inherits = </_class_sampleData>
kind = "model"
)
{
}
class "_class_sampleData"
{
}
最終更新日: 2021-01-01 18:00:18