model/blend: vertex and triangle parents, parent_type / parent_bone / parent_vertices / matrix_parent_inverse, widget flags, modifier stacks with Blender's type names and the armature modifier's settings

This commit is contained in:
4DBug committed 2026-11-03 04:57:53 -06:00
1 parent a9874e9f54
commit 2c2a52e4b3
11 files changed
+1003 -405

No files matched your search

+33 -1
View File
@@ -15,7 +15,8 @@
# action constraint; transform / armature / floor / limit distance / track to / locked
# track constraints; bone inheritance and b-bone settings; a saved pose basis; drivers
# (every variable type, keys, modifiers) on the rig, its data and the shape keys; custom
# properties on pose bones, bones and objects
# properties on pose bones, bones and objects; vertex, vertex-triangle and lattice parents,
# an object parented to a bone
# mat_<ver>.blend material graphs: images through Mix / MixRGB, Hue-Saturation, Bright-Contrast, Gamma,
# Invert, RGB Curves, Color Ramp, reroutes and node groups; roughness images linked directly
# or through a ramp; vertex colours; bump; unresolved links; a UDIM image with two tiles
@@ -732,6 +733,37 @@ def ctl_file():
smile.value = v
smile.keyframe_insert("value", frame=f)
smile.value = 1.5
# vertex / triangle / lattice / bone parents
from mathutils import Matrix
anchor = link(bpy.data.objects.new("Anchor", mesh("AnchorMesh", [(0, 0, 0), (1, 0.2, 0), (0.3, 1, 0.4), (0.5, 0.5, 1)], [(0, 1, 2), (0, 2, 3)])))
anchor.location, anchor.rotation_euler, anchor.scale = (2, -2, 1), (0.3, 0.2, 0.5), (1, 1.5, 1)
update()
vkid = link(bpy.data.objects.new("VertKid", None))
vkid.parent, vkid.parent_type = anchor, "VERTEX"
vkid.parent_vertices = (2, 0, 0)
vkid.location = (0.1, 0.2, 0.3)
vkid.matrix_parent_inverse = Matrix.Translation((0.5, 0, -0.25))
tkid = link(bpy.data.objects.new("TriKid", None))
tkid.parent, tkid.parent_type = anchor, "VERTEX_3"
tkid.parent_vertices = (1, 2, 3)
tkid.location, tkid.rotation_euler = (0.2, 0, 0.1), (0.1, 0.4, 0)
lat = link(bpy.data.objects.new("Lat", bpy.data.lattices.new("LatData")))
lat.location = (-2, 1, 0)
caged = link(bpy.data.objects.new("Caged", mesh("CagedMesh", [(0, 0, 0), (1, 0, 0), (0, 1, 0)], [(0, 1, 2)])))
caged.parent = lat
setp(caged, "parent_type", "LATTICE")
caged.location = (0.25, 0, 0)
caged.modifiers.new("Lattice", "LATTICE").object = lat
bkid = link(bpy.data.objects.new("BoneKid", None))
bkid.parent, bkid.parent_type, bkid.parent_bone = rig, "BONE", "lower"
bkid.location = (0.1, 0.05, 0)
face.modifiers["Armature"].use_multi_modifier = True
am = caged.modifiers.new("Unbound", "ARMATURE") # no object: deforms nothing, its settings are data
am.use_deform_preserve_volume, am.use_bone_envelopes, am.use_vertex_groups = True, True, False
am.vertex_group, am.invert_vertex_group = "spine", True
am.show_viewport = False
sub = wbox.modifiers.new("Smooth", "SUBSURF")
sub.show_render = False
# custom properties (ID properties)
props = pose["root"]
props["ik_arm"] = 1.0
+16 -1
View File
@@ -283,6 +283,16 @@ def action_info(act):
return {"frame_range": [r6(act.frame_range[0]), r6(act.frame_range[1])], "curves": curves}
def modifier_info(m):
e = {"type": m.type, "name": m.name, "show_viewport": m.show_viewport, "show_render": m.show_render}
if m.type == "ARMATURE":
e.update({"object": m.object.name if m.object else "", "use_vertex_groups": m.use_vertex_groups,
"use_bone_envelopes": m.use_bone_envelopes, "use_deform_preserve_volume": m.use_deform_preserve_volume,
"use_multi_modifier": m.use_multi_modifier, "vertex_group": m.vertex_group,
"invert_vertex_group": m.invert_vertex_group})
return e
def props_info(owner):
out = {}
for k in owner.keys():
@@ -422,6 +432,9 @@ def dump(path):
"parent_bone": ob.parent_bone, "world": [r6(x) for x in mat(ob.matrix_world)],
"collections": [c.name for c in ob.users_collection], "hide_viewport": ob.hide_viewport,
"hide_render": ob.hide_render, "props": props_info(ob), "drivers": drivers_of(ob),
"parent_info": {"matrix_parent_inverse": [r6(x) for x in mat(ob.matrix_parent_inverse)],
"parent_vertices": list(ob.parent_vertices)} if ob.parent else {},
"modifier_info": [modifier_info(m) for m in ob.modifiers],
"data_drivers": drivers_of(ob.data) if ob.data is not None and ob.type in ("ARMATURE", "MESH") else [],
"shape_key_drivers": drivers_of(ob.data.shape_keys) if ob.type == "MESH" and ob.data.shape_keys else []}
if ob.type == "MESH":
@@ -465,6 +478,8 @@ def dump(path):
for c in pb.constraints:
c.mute = True
sc.frame_set(sc.frame_current)
for o in ref["objects"]:
o["worldMuted"] = [r6(x) for x in mat(bpy.data.objects[o["name"]].matrix_world)]
ref["posedBones"] = {ob.name + "/" + pb.name: [r6(x) for x in mat(ob.matrix_world @ pb.matrix)]
for ob in obs if ob.type == "ARMATURE" for pb in ob.pose.bones}
poses = []
@@ -479,7 +494,7 @@ def dump(path):
p["bones"][ob.name + "/" + pb.name] = [r6(x) for x in mat(ob.matrix_world @ pb.matrix)]
if ob.type == "MESH" and ob.data.shape_keys:
p["shapes"][ob.name] = [r6(b.value) for b in ob.data.shape_keys.key_blocks]
if ob.type == "MESH" and any(m.type == "ARMATURE" for m in ob.modifiers) and f == math.floor(f):
if ob.type == "MESH" and any(m.type == "ARMATURE" and m.object and m.show_viewport for m in ob.modifiers) and f == math.floor(f):
ev = ob.evaluated_get(bpy.context.evaluated_depsgraph_get())
em = ev.to_mesh()
w = ob.matrix_world