fereria
9/26/2019 - 4:13 PM

UsdGeomMesh


# -*- coding: utf-8 -*-

# %%
import os.path

from pxr import Usd, UsdGeom, Sdf, Gf

USD_PATH_ROOT = "I:/usd_test"
kitchenSetRoot = USD_PATH_ROOT + "/Kitchen_set/assets/"

stage = Usd.Stage.CreateInMemory()


UsdGeom.Xform.Define(stage, '/hoge')
mesh = UsdGeom.Mesh.Define(stage, '/hoge/hogehoge')

# %%

mesh.CreatePointsAttr([(-5, -5, 5), (5, -5, 5), (5, 5, 5), (-5, 5, 5)])
# 1Faceあたりの頂点数
mesh.CreateFaceVertexCountsAttr([3, 3])
# 結線情報?
mesh.CreateFaceVertexIndicesAttr([0, 1, 2, 0, 2, 3])
# BoundingBoxをセット?
mesh.CreateExtentAttr(UsdGeom.PointBased(mesh).ComputeExtent(mesh.GetPointsAttr().Get()))

# %%
print(stage.GetRootLayer().ExportToString())
# %%
stage.GetRootLayer().Export(USD_PATH_ROOT + "/hogehoge.usda")