model/blend: action / transform / stretch to / armature / floor / limit distance / track to / locked track constraint fields, copy scale add / uniform; bone inheritance and b-bone fields; stored pose basis; every action raw in meta.blend.actions (first layer / strip / channel bag for layered actions)

This commit is contained in:
4DBug committed 2026-11-02 23:18:18 -06:00
1 parent d1e2e25bdf
commit 56e1449b97
15 files changed
+1683 -560

No files matched your search

+108 -1
View File
@@ -11,7 +11,9 @@
# collections and colours (4.x), custom shapes (a hidden widget in the scene, one outside it),
# pose-bone constraints (IK, copy rotation / location / transforms, damped track, limit
# rotation, child of, stretch to), lock and IK flags; shape keys with slider ranges, mute,
# relative keys, a vertex group, and a shape-key action
# relative keys, a vertex group, and a shape-key action; an unassigned action driven by an
# action constraint; transform / armature / floor / limit distance / track to / locked
# track constraints; bone inheritance and b-bone settings; a saved pose basis
import bpy, sys, os, math
out = sys.argv[sys.argv.index("--") + 1]
@@ -461,6 +463,25 @@ def ctl_file():
b.parent = eb[parent]
b.use_connect = connect
b.use_deform = deform
up, lo = eb["hand_ik"], eb["lower"] # b-bone settings on a bone that deforms nothing (skinning stays linear)
setp(eb["upper"], "inherit_scale", "ALIGNED")
setp(eb["upper"], "use_inherit_scale", False)
setp(lo, "use_inherit_rotation", False)
setp(lo, "use_local_location", False)
setp(eb["limit"], "use_relative_parent", True)
up.bbone_segments = 4
up.bbone_x, up.bbone_z = 0.05, 0.08
setp(up, "bbone_easein", 0.5)
setp(up, "bbone_easeout", 1.5)
setp(up, "bbone_rollin", 0.2)
setp(up, "bbone_curveinx", 0.1)
setp(up, "bbone_curveinz", -0.1)
setp(up, "bbone_curveoutx", 0.3)
setp(up, "bbone_scalein", (1.0, 1.0, 1.2))
setp(up, "bbone_handle_type_start", "ABSOLUTE")
setp(up, "bbone_custom_handle_start", eb["spine"])
setp(up, "bbone_handle_type_end", "TANGENT")
setp(up, "bbone_custom_handle_end", eb["pole"])
bpy.ops.object.mode_set(mode="OBJECT")
bones = arm_data.bones
bones["root"].show_wire = True
@@ -587,6 +608,92 @@ def ctl_file():
c = pose["limit"].constraints.new("STRETCH_TO")
c.target = tgt
c.influence = 0.5
c.rest_length = 0.75
c.bulge = 1.5
c.volume = "VOLUME_X"
c.keep_axis = "PLANE_Z"
setp(c, "use_bulge_min", True)
setp(c, "bulge_min", 0.5)
setp(c, "use_bulge_max", True)
setp(c, "bulge_max", 2.0)
setp(c, "bulge_smooth", 0.3)
c = pose["limit"].constraints.new("TRANSFORM")
c.target = tgt
c.map_from, c.map_to = "ROTATION", "SCALE"
c.map_to_x_from, c.map_to_y_from, c.map_to_z_from = "Z", "X", "Y"
setp(c, "from_max_x_rot", 2.356194)
setp(c, "from_min_y_rot", -0.5)
setp(c, "to_max_y_scale", 0.65)
setp(c, "to_min_x_scale", 0.9)
setp(c, "mix_mode_scale", "MULTIPLY")
setp(c, "from_rotation_mode", "SWING_TWIST_Y")
setp(c, "to_euler_order", "ZXY")
c.use_motion_extrapolate = True
c = pose["limit"].constraints.new("FLOOR")
c.target = tgt
c.floor_location = "FLOOR_NEGATIVE_Y"
c.offset = 0.2
c.use_rotation = True
c = pose["pole"].constraints.new("TRACK_TO")
c.target, c.subtarget = rig, "upper"
c.track_axis, c.up_axis = "TRACK_NEGATIVE_Y", "UP_X"
c.use_target_z = True
c = pose["root"].constraints.new("LOCKED_TRACK")
c.target = tgt
c.track_axis, c.lock_axis = "TRACK_X", "LOCK_Z"
c = pose["root"].constraints.new("LIMIT_DISTANCE")
c.target = tgt
c.distance = 2.5
c.limit_mode = "LIMITDIST_OUTSIDE"
c = pose["upper"].constraints["Copy Scale"]
setp(c, "use_make_uniform", True)
setp(c, "use_add", True)
setp(c, "power", 0.5)
if V >= (2, 80):
c = pose["spine"].constraints.new("ARMATURE")
t = c.targets.new()
t.target, t.subtarget, t.weight = rig, "root", 0.75
c.use_deform_preserve_volume = True
c.use_bone_envelopes = True
c.use_current_location = True
# an action only the action constraint uses: keys on hand_ik / limit, then unassigned
for f, loc, eul in ((1, (0, 0, 0), (0, 0, 0)), (10, (0.5, 0.1, 0), (0.3, 0, -0.2)), (25, (0, 0.4, 0.2), (-0.4, 0.2, 0))):
pose["hand_ik"].location = loc
pose["hand_ik"].keyframe_insert("location", frame=f)
pose["limit"].rotation_euler = eul
pose["limit"].keyframe_insert("rotation_euler", frame=f)
act = rig.animation_data.action
act.name = "CtlAct"
act.use_fake_user = True
curves = act.fcurves if hasattr(act, "fcurves") and V < (5, 0) else [c for l in act.layers for st in l.strips for b in st.channelbags for c in b.fcurves]
for fc in curves:
if fc.data_path.endswith("location"):
for kp in fc.keyframe_points:
kp.interpolation = "LINEAR"
elif fc.array_index == 1:
fc.keyframe_points[1].interpolation = "QUAD"
fc.keyframe_points[1].easing = "EASE_OUT"
fc.extrapolation = "LINEAR"
rig.animation_data.action = None
pose["hand_ik"].location = (0, 0, 0)
pose["limit"].rotation_euler = (0, 0, 0)
c = pose["hand_ik"].constraints.new("ACTION")
c.target, c.subtarget = rig, "pole"
c.action = act
c.transform_channel = "LOCATION_Y"
c.target_space = "LOCAL"
c.frame_start, c.frame_end = 0, 40
c.min, c.max = -0.05, 0.05
setp(c, "mix_mode", "AFTER")
setp(c, "use_eval_time", False)
setp(c, "eval_time", 0.25)
c.influence = 0.5
# a saved pose basis
pose["spine"].location = (0.01, 0.02, 0.03) # no rotation above the hinge bone (not modelled by joint nodes)
pose["pole"].rotation_quaternion = (0.9, 0.1, 0.3, 0.2)
pose["lower"].rotation_euler = (0.1, -0.2, 0.3)
pose["hand_ik"].rotation_axis_angle = (0.4, 0, 0, 1)
pose["limit"].scale = (1, 1.25, 0.8)
# shape keys on a mesh parented to the rig
fv = [(x * 0.5, 0, z * 0.5) for z in range(3) for x in range(3)]
ff = [(0, 1, 4, 3), (1, 2, 5, 4), (3, 4, 7, 6), (4, 5, 8, 7)]