Skip to content

Commit 7b30839

Browse files
authored
fix: remodel vertex-weight-limit's mech arm as an actual machine (#80)
The previous asset read as stacked barrels with a pool-float elbow and horn claws: the 'boot' hid the joint, the prongs were thin spikes, and the forearm was stubby while the upper arm was long. Rebuilt as a machine: bolted pedestal and shoulder fairing, shoulder hub, upper arm ending in clevis cheeks, the elbow hinge pin capped through a ribbed flex bellows, a long plated forearm, wrist bellows and collar, palm, and a three-finger two-segment gripper. The teal accent still marks the pruned-weight zones (bellows at the elbow hinge and wrist). Every check contract holds on the remodel: the flex bellows keep the z ranges the five-bone bumps are tuned for (pre_max=5), and measured values are identical on 5.1.2 and 4.5.11 (verts=1840, limited=128, sum 2.98e-08, pose 2.73e-03, lbs 2.67e-07). Re-falsified: probe A exit 4, probe B exit 6 (1.269e-02), probe C exit 8 (1.796). No tolerance loosened. Signed-off-by: fOuttaMyPaint <TMhospitalitystrategies@gmail.com>
1 parent 849f6a6 commit 7b30839

7 files changed

Lines changed: 204 additions & 122 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ as the caught failure mode.
506506
</tr>
507507
<tr>
508508
<td width="46%" valign="middle">
509-
<a href="examples/vertex-weight-limit/"><img src="examples/vertex-weight-limit/preview.webp" alt="Vertex weight limit: a posed mech arm on a dark studio floor - orange armor shells, black ribbed elbow boot, glowing teal forearm ring, claw gripper - deformed by weights pruned to the four-influence engine cap" /></a>
509+
<a href="examples/vertex-weight-limit/"><img src="examples/vertex-weight-limit/preview.webp" alt="Vertex weight limit: a posed mech arm on a dark studio floor - orange armor shells, a glowing teal elbow bellows around the hinge pin, long plated forearm, three-finger gripper - deformed by weights pruned to the four-influence engine cap" /></a>
510510
</td>
511511
<td valign="middle">
512512

-1.84 KB
Loading
-642 Bytes
Loading

‎docs/gallery/vertex-weight-limit/index.html‎

Lines changed: 98 additions & 58 deletions
Large diffs are not rendered by default.

‎examples/vertex-weight-limit/README.md‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Vertex Weight Limit
22

3-
A runnable example that rigs a mech arm — pedestal mount and pauldron, orange
4-
armor shells, ribbed flex boots, wrist, three claw prongs — with deliberately
5-
rich five-bone weight bumps in the boots, then enforces the game-engine
3+
A runnable example that rigs a mech arm — bolted pedestal and shoulder
4+
fairing, a shoulder hub and clevis-ended upper arm, the elbow hinge pin inside
5+
a ribbed flex bellows, a long plated forearm, wrist bellows and collar, and a
6+
three-finger gripper — with deliberately rich five-bone weight bumps in the
7+
bellows, then enforces the game-engine
68
**maximum of four bone influences per vertex** through the data API, following
79
[`mesh-editing-and-bmesh`](../../skills/mesh-editing-and-bmesh/SKILL.md) and
810
building on the linear-blend-skinning precedent of
@@ -35,10 +37,10 @@ The vertex-group API (`v.groups`, `VertexGroup.add`/`remove`) is stable between
3537
Blender 4.5 LTS and 5.1 — the example runs identically on both, which is itself
3638
the version witness (measured values match to the digit).
3739

38-
The render shows the pruned arm mid-pose: the flex boots carry the teal
39-
accent — the five-influence zones the limit prunes glow at the elbow and
40-
wrist, sealed by the bright ring on the elbow boot — proof that the limited
41-
weights still deform as authored.
40+
The render shows the pruned arm mid-pose: the flex bellows carry the teal
41+
accent — the five-influence zones the limit prunes glow at the elbow hinge
42+
and wrist, sealed by the bright ring on the elbow bellows — proof that the
43+
limited weights still deform as authored.
4244

4345
## Run
4446

-1.8 KB
Loading

‎examples/vertex-weight-limit/vertex_weight_limit.py‎

Lines changed: 96 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,37 @@ def lathe_part(bm, rings, mat):
7676
return out
7777

7878

79+
def box_part(bm, size, loc, rot, mat, part_of, bone):
80+
"""One box shell (rot in degrees XYZ); tags `bone` for its verts."""
81+
n0f, n0v = len(bm.faces), len(bm.verts)
82+
m = (mathutils.Matrix.Translation(loc)
83+
@ mathutils.Euler(tuple(math.radians(a) for a in rot)).to_matrix().to_4x4()
84+
@ mathutils.Matrix.Diagonal((*size, 1.0)))
85+
bmesh.ops.create_cube(bm, size=1.0, matrix=m)
86+
for f in bm.faces[n0f:]:
87+
f.material_index = mat
88+
part_of.extend([bone] * (len(bm.verts) - n0v))
89+
90+
91+
def cone_part(bm, r1, r2, depth, loc, rot, mat, part_of, bone):
92+
"""One cylinder/cone shell along a rotated axis; tags `bone` for its verts."""
93+
n0f, n0v = len(bm.faces), len(bm.verts)
94+
m = (mathutils.Matrix.Translation(loc)
95+
@ mathutils.Euler(tuple(math.radians(a) for a in rot)).to_matrix().to_4x4())
96+
bmesh.ops.create_cone(bm, cap_ends=True, cap_tris=False, segments=24,
97+
radius1=r1, radius2=r2, depth=depth, matrix=m)
98+
for f in bm.faces[n0f:]:
99+
f.material_index = mat
100+
part_of.extend([bone] * (len(bm.verts) - n0v))
101+
102+
79103
def build_arm():
80-
"""The mech arm: mount + pauldron, upper arm, elbow boot + ball, forearm,
81-
wrist boot + ball, hand plate, three claw prongs — every ring closed form."""
104+
"""The mech arm, built as a machine: bolted pedestal and shoulder fairing
105+
(Root), a shoulder hub and upper arm ending in clevis cheeks (Shoulder),
106+
the elbow hinge pin inside a ribbed flex bellows (the >4-influence zone),
107+
a long plated forearm (Elbow), wrist bellows and collar (Wrist), and a
108+
palm with three two-segment fingers (Claw). Every part is closed form;
109+
the flex bellows keep the z ranges the five-bone bumps are tuned for."""
82110
me = bpy.data.meshes.new("MechArm")
83111
part_of = [] # creation-order bone name (or 'FLEX') per mesh vertex
84112
bm = bmesh.new()
@@ -88,59 +116,71 @@ def tag(rings_verts, bone):
88116
for v in ring:
89117
part_of.append(bone)
90118

91-
# pedestal mount + pauldron cap (rigid on Root)
92-
tag(lathe_part(bm, [(-0.35, 0.32), (-0.05, 0.32), (0.0, 0.48),
93-
(0.10, 0.50), (0.22, 0.34), (0.28, 0.14)],
94-
GUNMETAL), "Root")
95-
# upper arm armor with two plate ridges (rigid on Shoulder)
96-
tag(lathe_part(bm, [(0.10, 0.26), (0.30, 0.30), (0.38, 0.33),
97-
(0.46, 0.30), (0.70, 0.29), (0.78, 0.32),
98-
(0.86, 0.29), (1.10, 0.27), (1.15, 0.26)],
99-
ORANGE), "Shoulder")
100-
# elbow flex boot (broad blend — the >4-influence region)
101-
tag(lathe_part(bm, [(1.15, 0.25), (1.22, 0.20), (1.28, 0.24),
102-
(1.35, 0.20), (1.42, 0.24), (1.48, 0.21), (1.55, 0.24)], RUBBER), "FLEX")
103-
n0 = len(bm.verts)
104-
bmesh.ops.create_uvsphere(bm, u_segments=24, v_segments=12, radius=0.23)
105-
for v in bm.verts[n0:]:
106-
v.co.z += 1.35
107-
part_of.append("Elbow")
108-
# forearm armor with ridges + teal accent ring (rigid on Elbow)
109-
tag(lathe_part(bm, [(1.55, 0.24), (1.70, 0.26), (1.76, 0.28),
110-
(1.82, 0.26), (2.00, 0.24), (2.10, 0.27),
111-
(2.16, 0.27), (2.22, 0.24), (2.45, 0.22)],
112-
ORANGE), "Elbow")
113-
# teal accent ring sealing the elbow boot — the primary
114-
# five-influence zone the limit prunes
115-
tag(lathe_part(bm, [(1.33, 0.245), (1.39, 0.245)], ACCENT), "Elbow")
116-
# wrist flex boot + ball (second >4-influence region)
117-
tag(lathe_part(bm, [(2.45, 0.21), (2.52, 0.17), (2.60, 0.20),
118-
(2.68, 0.16), (2.76, 0.19), (2.84, 0.16), (2.95, 0.15)], RUBBER), "FLEX")
119-
n0 = len(bm.verts)
120-
bmesh.ops.create_uvsphere(bm, u_segments=24, v_segments=12, radius=0.20)
121-
for v in bm.verts[n0:]:
122-
v.co.z += 2.72
123-
part_of.append("Wrist")
124-
# hand plate (rigid on Wrist)
125-
tag(lathe_part(bm, [(2.55, 0.16), (2.90, 0.17)], GUNMETAL), "Wrist")
126-
# three claw prongs, splayed at 120 deg (rigid on Claw)
127-
for k in range(3):
128-
a = 2 * math.pi * k / 3
129-
dx, dy = math.cos(a), math.sin(a)
130-
rings = []
131-
for z, r, off in ((2.90, 0.10, 0.13), (3.12, 0.08, 0.19),
132-
(3.40, 0.03, 0.28)):
133-
rings.append([bm.verts.new((off * dx + r * math.cos(2 * math.pi * s / 12),
134-
off * dy + r * math.sin(2 * math.pi * s / 12), z))
135-
for s in range(12)])
136-
for j in range(len(rings) - 1):
137-
for s in range(12):
138-
f = bm.faces.new((rings[j][s], rings[j][(s + 1) % 12],
139-
rings[j + 1][(s + 1) % 12], rings[j + 1][s]))
119+
# bolted pedestal + shoulder fairing (rigid on Root)
120+
tag(lathe_part(bm, [(-0.35, 0.34), (-0.05, 0.34), (0.0, 0.40),
121+
(0.06, 0.42)], GUNMETAL), "Root")
122+
tag(lathe_part(bm, [(0.02, 0.40), (0.10, 0.44), (0.22, 0.33),
123+
(0.30, 0.17), (0.34, 0.07)], GUNMETAL), "Root")
124+
for k in range(6): # the fairing's bolt ring
125+
a = 2 * math.pi * k / 6
126+
cone_part(bm, 0.05, 0.04, 0.06,
127+
(0.36 * math.cos(a), 0.36 * math.sin(a), 0.03),
128+
(0, 0, 0), GUNMETAL, part_of, "Root")
129+
# shoulder hub poking through the fairing (rigid on Shoulder)
130+
cone_part(bm, 0.19, 0.19, 0.56, (0.0, 0.0, 0.62), (90, 0, 0),
131+
GUNMETAL, part_of, "Shoulder")
132+
# upper arm shell, slimmer than the old barrel (rigid on Shoulder)
133+
tag(lathe_part(bm, [(0.45, 0.19), (0.60, 0.23), (0.80, 0.24),
134+
(1.00, 0.23), (1.15, 0.21)], ORANGE), "Shoulder")
135+
# clevis cheeks the hinge pin rides in (rigid on Shoulder)
136+
for sy in (-1, 1):
137+
box_part(bm, (0.12, 0.05, 0.42), (0.0, sy * 0.165, 1.24),
138+
(0, 0, 0), ORANGE, part_of, "Shoulder")
139+
# elbow flex bellows: the five-influence zone the limit prunes
140+
tag(lathe_part(bm, [(1.15, 0.17), (1.20, 0.20), (1.26, 0.16),
141+
(1.33, 0.20), (1.40, 0.16), (1.47, 0.20),
142+
(1.55, 0.17)], RUBBER), "FLEX")
143+
# the hinge pin through the cheeks, capped both ends (rides Elbow)
144+
cone_part(bm, 0.15, 0.15, 0.46, (0.0, 0.0, 1.35), (90, 0, 0),
145+
GUNMETAL, part_of, "Elbow")
146+
for sy in (-1, 1):
147+
cone_part(bm, 0.18, 0.18, 0.05, (0.0, sy * 0.225, 1.35),
148+
(90, 0, 0), GUNMETAL, part_of, "Elbow")
149+
# bright seal ring on the bellows middle — the accent marking the
150+
# primary pruned-weight zone
151+
tag(lathe_part(bm, [(1.33, 0.215), (1.37, 0.215)], ACCENT), "Elbow")
152+
# long plated forearm with two ridges (rigid on Elbow)
153+
tag(lathe_part(bm, [(1.55, 0.19), (1.75, 0.21), (1.80, 0.23),
154+
(1.86, 0.21), (2.05, 0.20), (2.18, 0.22),
155+
(2.24, 0.20), (2.45, 0.18)], ORANGE), "Elbow")
156+
# armor blade along the forearm's back (rigid on Elbow)
157+
box_part(bm, (0.10, 0.05, 0.60), (0.0, 0.235, 2.02),
158+
(0, 0, 0), ORANGE, part_of, "Elbow")
159+
# wrist flex bellows (second blend zone) + collar
160+
tag(lathe_part(bm, [(2.45, 0.16), (2.51, 0.19), (2.57, 0.15),
161+
(2.64, 0.18), (2.70, 0.15), (2.75, 0.16)],
162+
RUBBER), "FLEX")
163+
tag(lathe_part(bm, [(2.75, 0.16), (2.85, 0.175), (2.90, 0.16)],
164+
GUNMETAL), "Wrist")
165+
# palm block (rigid on Wrist)
166+
box_part(bm, (0.26, 0.20, 0.14), (0.0, 0.0, 2.99),
167+
(0, 0, 0), GUNMETAL, part_of, "Wrist")
168+
# three two-segment fingers, splayed (rigid on Claw)
169+
for a_deg in (90.0, 210.0, 330.0):
170+
a = math.radians(a_deg)
171+
for pos, tilt, size in (((0.09, 3.11), 12.0, (0.075, 0.11, 0.22)),
172+
((0.15, 3.28), 26.0, (0.06, 0.095, 0.18))):
173+
off, z = pos
174+
m = (mathutils.Matrix.Translation((0.0, 0.0, z))
175+
@ mathutils.Matrix.Rotation(a, 4, 'Z')
176+
@ mathutils.Matrix.Translation((off, 0.0, 0.0))
177+
@ mathutils.Matrix.Rotation(math.radians(tilt), 4, 'Y')
178+
@ mathutils.Matrix.Diagonal((*size, 1.0)))
179+
n0f, n0v = len(bm.faces), len(bm.verts)
180+
bmesh.ops.create_cube(bm, size=1.0, matrix=m)
181+
for f in bm.faces[n0f:]:
140182
f.material_index = GUNMETAL
141-
for ring in rings:
142-
for v in ring:
143-
part_of.append("Claw")
183+
part_of.extend(["Claw"] * (len(bm.verts) - n0v))
144184
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
145185
bm.to_mesh(me)
146186
finally:
@@ -371,10 +411,10 @@ def light(name, loc, energy, size, col, rot):
371411
cam_data = bpy.data.cameras.new("Cam")
372412
cam_data.lens = 52.0
373413
cam = bpy.data.objects.new("Cam", cam_data)
374-
cam.location = (5.3, -6.2, 2.1)
414+
cam.location = (5.8, -6.9, 2.2)
375415
scene.collection.objects.link(cam)
376416
target = bpy.data.objects.new("Aim", None)
377-
target.location = (0.55, 0.0, 1.45)
417+
target.location = (0.45, 0.0, 1.5)
378418
scene.collection.objects.link(target)
379419
con = cam.constraints.new('TRACK_TO')
380420
con.target = target

0 commit comments

Comments
 (0)