GPT: Constraints

This commit is contained in:
chk
2026-05-29 17:20:01 +02:00
parent 1008c9f7fd
commit dd95d56790
15 changed files with 2321 additions and 145 deletions

View File

@@ -29,6 +29,8 @@ DEFAULT_MATERIALS = {
STATE_KEYS = ["x", "y", "z", "a", "b", "c", "e"]
marker_export = []
# ============================================================
# JSON LOADING
# ============================================================
@@ -691,6 +693,44 @@ for link_name, link_info in links_def.items():
else:
plate_obj.data.materials[0] = pla_mat
# Weltmatrix holen (inkl. ALLER Transformationen!)
mw = marker_obj.matrix_world
world_pos = mw.translation
world_rot = mw.to_quaternion()
# Optional: Normal in Weltkoordinaten
world_normal = (world_rot @ mathutils.Vector((0, 0, 1))).normalized()
marker_export.append({
"name": marker_name,
"id": marker_id,
"link": link_name,
"position_m": [world_pos.x, world_pos.y, world_pos.z],
# oft nützlich für Computer Vision:
"position_mm": [
world_pos.x / scale_factor,
world_pos.y / scale_factor,
world_pos.z / scale_factor
],
"rotation_quaternion": [
world_rot.w,
world_rot.x,
world_rot.y,
world_rot.z
],
"normal": [
world_normal.x,
world_normal.y,
world_normal.z
]
})
# ============================================================
# DEBUG WORLD AXES
@@ -753,4 +793,13 @@ create_axis_arrow("AxisZ", (0, 0, 1), (0, 0, 1))
# ============================================================
bpy.ops.render.render(write_still=True)
print("Finished rendering:", OUTPUT_FILE)
print("Finished rendering:", OUTPUT_FILE)
MARKER_OUTPUT = str(Path(OUTPUT_FILE).with_name("markers.json"))
with open(MARKER_OUTPUT, "w", encoding="utf-8") as f:
json.dump(marker_export, f, indent=2)
print("Saved marker positions:", MARKER_OUTPUT)