fix(USD): correct coordinate transform (Z-up stage) and store canonical_material in DB
- export_step_to_usd.py: change stage from Y-up to Z-up, keep (X,-Z,Y) transform — matches GLB orientation exactly (verified: bounding box match) - export_glb.py: include canonical_material in resolved_material_assignments DB field (was being dropped during manifest parsing) - import_usd.py: use pxr customData read (not string primvars — Blender ignores those, confirmed by testing) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -768,7 +768,11 @@ def generate_usd_master_task(self, cad_file_id: str) -> dict:
|
|||||||
if manifest_parts:
|
if manifest_parts:
|
||||||
try:
|
try:
|
||||||
resolved = {
|
resolved = {
|
||||||
p["part_key"]: {"source_name": p["source_name"], "prim_path": p["prim_path"]}
|
p["part_key"]: {
|
||||||
|
"source_name": p["source_name"],
|
||||||
|
"prim_path": p["prim_path"],
|
||||||
|
"canonical_material": p.get("canonical_material"),
|
||||||
|
}
|
||||||
for p in manifest_parts
|
for p in manifest_parts
|
||||||
}
|
}
|
||||||
eng3 = _ce(sync_url)
|
eng3 = _ce(sync_url)
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ def main() -> None:
|
|||||||
|
|
||||||
# ── Create USD stage ──────────────────────────────────────────────────────
|
# ── Create USD stage ──────────────────────────────────────────────────────
|
||||||
stage = Usd.Stage.CreateNew(str(output_path))
|
stage = Usd.Stage.CreateNew(str(output_path))
|
||||||
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.y)
|
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)
|
||||||
UsdGeom.SetStageMetersPerUnit(stage, 0.001) # mm; Blender handles m conversion on import
|
UsdGeom.SetStageMetersPerUnit(stage, 0.001) # mm; Blender handles m conversion on import
|
||||||
|
|
||||||
root_prim = UsdGeom.Xform.Define(stage, "/Root")
|
root_prim = UsdGeom.Xform.Define(stage, "/Root")
|
||||||
@@ -705,7 +705,10 @@ def main() -> None:
|
|||||||
mesh = UsdGeom.Mesh.Define(stage, mesh_path)
|
mesh = UsdGeom.Mesh.Define(stage, mesh_path)
|
||||||
mesh.CreateSubdivisionSchemeAttr(UsdGeom.Tokens.none)
|
mesh.CreateSubdivisionSchemeAttr(UsdGeom.Tokens.none)
|
||||||
|
|
||||||
# OCC (X, Y, Z) mm Z-up → USD (X, -Z, Y) mm Y-up
|
# OCC is Z-up (mm) but Y-forward. Blender is Z-up, Y-backward.
|
||||||
|
# GLB export uses: Blender(X, -Z_occ, Y_occ) × 0.001
|
||||||
|
# USD stage is Z-up with metersPerUnit=0.001, so Blender applies
|
||||||
|
# only the scale. Write (X, -Z, Y) to match GLB orientation.
|
||||||
mesh.CreatePointsAttr(Vt.Vec3fArray([
|
mesh.CreatePointsAttr(Vt.Vec3fArray([
|
||||||
Gf.Vec3f(x, -z, y) for (x, y, z) in vertices
|
Gf.Vec3f(x, -z, y) for (x, y, z) in vertices
|
||||||
]))
|
]))
|
||||||
|
|||||||
Reference in New Issue
Block a user