Выстроена готовая 3Д сцена

This commit is contained in:
Даниил Грабарь
2026-09-13 14:26:50 +03:00
parent 397e33bd08
commit ae30c02ddd
12 changed files with 129 additions and 32 deletions
+8
View File
@@ -57,6 +57,14 @@ def export():
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(SOURCE / "resource/meshes" / relative, target)
mesh.set("filename", ("meshes/" if path.parent.name == "urdf" else "../urdf/meshes/") + relative)
# Genesis/trimesh retain COLLADA units as metadata, without scaling vertices.
# Convert millimetre-authored visual meshes into the URDF's metres explicitly.
if target.suffix.lower() == ".dae":
unit = ET.parse(target).find(".//{*}unit")
metres = float(unit.get("meter", "1")) if unit is not None else 1.0
if metres != 1.0:
scale = [float(v) * metres for v in mesh.get("scale", "1 1 1").split()]
mesh.set("scale", " ".join(f"{v:g}" for v in scale))
ET.indent(robot)
ET.ElementTree(robot).write(path, encoding="utf-8", xml_declaration=True)