Skip to content

Commit 8e40035

Browse files
TMHSDigitalclaude
andcommitted
fix(examples): stand the turntable monkey on a turntable
Render path only, after the check. The 500-face head read as faceted plates and hovered just above the floor. It now carries a subdivision modifier, is seated 10 mm into the platter of a turntable plinth from its own lowest evaluated vertex, and the copper is less glossy. Rotation keys, sampled frames and exit codes are unchanged; framing measured out of band (fill y 0.789, margin 0.050) since the path has no framing call. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com>
1 parent 5dfdfd3 commit 8e40035

6 files changed

Lines changed: 145 additions & 9 deletions

File tree

5.04 KB
Loading
53.7 KB
Loading

‎docs/gallery/turntable/index.html‎

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
<meta property="og:image" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/assets/turntable-hero.webp" />
1717
<meta property="og:image:width" content="1280" />
1818
<meta property="og:image:height" content="720" />
19-
<meta property="og:image:alt" content="A bronze monkey head (Suzanne) turned three-quarters on a dark studio floor." />
19+
<meta property="og:image:alt" content="A smooth copper monkey head (Suzanne) turned three-quarters on a black turntable with a brushed metal platter." />
2020
<meta property="og:site_name" content="Blender Developer Tools" />
2121
<meta name="twitter:card" content="summary_large_image" />
2222
<meta name="twitter:title" content="turntable — Examples — Blender Developer Tools" />
2323
<meta name="twitter:description" content="A slotted-actions Z-rotation turntable keyed through the cross-version channelbag path (get_channelbag_for_slot)." />
2424
<meta name="twitter:image" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/assets/turntable-hero.webp" />
25-
<meta name="twitter:image:alt" content="A bronze monkey head (Suzanne) turned three-quarters on a dark studio floor." />
25+
<meta name="twitter:image:alt" content="A smooth copper monkey head (Suzanne) turned three-quarters on a black turntable with a brushed metal platter." />
2626
<style>
2727
/* fonts are deployed by the landing build (docs/fonts/) */
2828
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap;
@@ -268,8 +268,8 @@ <h1>turntable</h1>
268268
<p>A slotted-actions Z-rotation turntable keyed through the cross-version channelbag path (get_channelbag_for_slot).</p>
269269
</header>
270270
<main id="main">
271-
<button class="detail-hero" id="heroZoom" type="button" aria-label="View full size: A bronze monkey head (Suzanne) turned three-quarters on a dark studio floor.">
272-
<img src="../assets/turntable-hero.webp" alt="A bronze monkey head (Suzanne) turned three-quarters on a dark studio floor." width="1280" height="720" />
271+
<button class="detail-hero" id="heroZoom" type="button" aria-label="View full size: A smooth copper monkey head (Suzanne) turned three-quarters on a black turntable with a brushed metal platter.">
272+
<img src="../assets/turntable-hero.webp" alt="A smooth copper monkey head (Suzanne) turned three-quarters on a black turntable with a brushed metal platter." width="1280" height="720" />
273273
</button>
274274
<p class="zoom-hint">Rendered headless by the example itself — click to zoom.</p>
275275
<div class="callout"><span class="tag">witnesses</span> Slotted-actions boundary: ensure-helper channelbag on 5.x, strip.channelbag on 4.4/4.5.</div>
@@ -291,6 +291,7 @@ <h2>Run</h2>
291291
blender --background --python turntable.py -- --output turntable.png
292292
blender --background --python turntable.py -- --output turntable.png --engine cycles</code></pre>
293293
<p>By default it runs only the <strong>frame-independent correctness check</strong>: it inserts the rotation keys, samples the object&#x27;s Z rotation at frame 1 vs a later frame, and asserts they <strong>differ</strong> (the keys drive playback). <code>--output</code> additionally renders a still; the full animated loop is a showcase extra, not part of the CI check.</p>
294+
<p>The still&#x27;s staging is render-only and runs after the check. The head gets a subdivision modifier (the 500-face monkey read as faceted plates) and is seated 10 mm into the platter of a turntable plinth, lifted from its own lowest evaluated vertex. It used to hover just above the floor with nothing under it. The rotation keys, the sampled frames and every exit code are unchanged. This render path does not call <code>gallery_framing.check_framing</code>, because adding it would add exit code 10. The framing was measured with the helper out of band instead: fill y 0.789, minimum margin 0.050, ok.</p>
294295
<h2>Exit codes</h2>
295296
<p>Per-script sequential checks. <code>9</code> is a valid check code; there is no rule against it.</p>
296297
<div class="table-wrap"><table><thead><tr><th scope="col">Code</th><th scope="col">Meaning</th></tr></thead><tbody><tr><td>0</td><td>Success</td></tr><tr><td>1</td><td>Uncaught exception (FATAL wrapper)</td></tr><tr><td>2</td><td>argparse / usage</td></tr><tr><td>3</td><td>Rotation keys do not drive playback (<code>--no-keys</code> lands here)</td></tr><tr><td>4</td><td><code>--output</code> produced no file</td></tr><tr><td>5</td><td>Wrong-era EEVEE engine id was accepted</td></tr></tbody></table></div>
@@ -376,9 +377,72 @@ <h2>Source</h2>
376377
print(<span class="s">f&quot;</span><span class="s">branch=</span>{branch}<span class="s"> rot_z f1=</span>{r1}<span class="s"> fmid=</span>{rmid}<span class="s"> fend=</span>{rend}<span class="s"> drives=</span>{drives}<span class="s">&quot;</span>)
377378
<span class="k">return</span> drives
378379

380+
PLINTH_R = <span class="n">1.15</span>
381+
PLINTH_H = <span class="n">0.28</span>
382+
PLATTER_R = <span class="n">1.05</span>
383+
PLATTER_H = <span class="n">0.05</span>
384+
SEAT = <span class="n">0.01</span>
385+
386+
387+
<span class="k">def</span> stage_turntable(obj):
388+
<span class="s">&quot;&quot;&quot;Render-only staging, after the check has run: a turntable to turn on.
389+
390+
The head is smoothed by a subdivision modifier (the 500-face monkey read
391+
as faceted plates), seated SEAT into a platter on a plinth, and lifted so
392+
its lowest evaluated vertex lands there. It used to hover just above the
393+
floor with nothing under it. Rotation keys and the correctness samples
394+
are untouched; only location and a modifier change here.
395+
&quot;&quot;&quot;</span>
396+
<span class="k">import</span> bmesh
397+
sub = obj.modifiers.new(<span class="s">&quot;Smooth&quot;</span>, <span class="s">&#x27;SUBSURF&#x27;</span>)
398+
sub.levels = <span class="n">2</span>
399+
sub.render_levels = <span class="n">2</span>
400+
dg = bpy.context.evaluated_depsgraph_get()
401+
ev = obj.evaluated_get(dg)
402+
me = ev.to_mesh()
403+
<span class="k">try</span>:
404+
zmin = min((ev.matrix_world @ v.co).z <span class="k">for</span> v <span class="k">in</span> me.vertices)
405+
<span class="k">finally</span>:
406+
ev.to_mesh_clear()
407+
obj.location.z += (PLINTH_H + PLATTER_H - SEAT) - zmin
408+
b = obj.active_material.node_tree.nodes[<span class="s">&#x27;Principled BSDF&#x27;</span>]
409+
<span class="c"># 0.25 blew every brow and ear edge out to white under the key</span>
410+
b.inputs[<span class="s">&#x27;Roughness&#x27;</span>].default_value = <span class="n">0.38</span>
411+
parts = []
412+
<span class="k">for</span> nm, r, z0, h, col, metal, rough <span class="k">in</span> (
413+
(<span class="s">&quot;Plinth&quot;</span>, PLINTH_R, <span class="n">0.0</span>, PLINTH_H, (<span class="n">0.035</span>, <span class="n">0.032</span>, <span class="n">0.03</span>), <span class="n">0.0</span>, <span class="n">0.55</span>),
414+
(<span class="s">&quot;Platter&quot;</span>, PLATTER_R, PLINTH_H - <span class="n">0.004</span>, PLATTER_H + <span class="n">0.004</span>,
415+
(<span class="n">0.42</span>, <span class="n">0.42</span>, <span class="n">0.44</span>), <span class="n">1.0</span>, <span class="n">0.45</span>),
416+
):
417+
mesh = bpy.data.meshes.new(nm)
418+
bm = bmesh.new()
419+
<span class="k">try</span>:
420+
bmesh.ops.create_cone(bm, cap_ends=<span class="k">True</span>, segments=<span class="n">64</span>, radius1=r,
421+
radius2=r, depth=h)
422+
bmesh.ops.translate(bm, vec=(<span class="n">0.0</span>, <span class="n">0.0</span>, z0 + h / <span class="n">2.0</span>), verts=bm.verts)
423+
bmesh.ops.bevel(bm, geom=[e <span class="k">for</span> e <span class="k">in</span> bm.edges <span class="k">if</span> len(e.link_faces) == <span class="n">2</span>
424+
<span class="k">and</span> e.calc_face_angle(<span class="n">0.0</span>) &gt; <span class="n">1.0</span>],
425+
offset=<span class="n">0.012</span>, segments=<span class="n">2</span>, affect=<span class="s">&#x27;EDGES&#x27;</span>)
426+
bm.to_mesh(mesh)
427+
<span class="k">finally</span>:
428+
bm.free()
429+
mesh.shade_smooth()
430+
mat = bpy.data.materials.new(nm); mat.use_nodes = <span class="k">True</span>
431+
pb = mat.node_tree.nodes[<span class="s">&#x27;Principled BSDF&#x27;</span>]
432+
pb.inputs[<span class="s">&#x27;Base Color&#x27;</span>].default_value = (*col, <span class="n">1.0</span>)
433+
pb.inputs[<span class="s">&#x27;Metallic&#x27;</span>].default_value = metal
434+
pb.inputs[<span class="s">&#x27;Roughness&#x27;</span>].default_value = rough
435+
mesh.materials.append(mat)
436+
ob = bpy.data.objects.new(nm, mesh)
437+
bpy.context.collection.objects.link(ob)
438+
parts.append(ob)
439+
<span class="k">return</span> parts
440+
441+
379442
<span class="k">def</span> render_still(obj, path, engine):
380443
<span class="k">import</span> bmesh
381444
sc = bpy.context.scene
445+
stage_turntable(obj)
382446
fme = bpy.data.meshes.new(<span class="s">&quot;Floor&quot;</span>); bm = bmesh.new()
383447
<span class="k">try</span>:
384448
bmesh.ops.create_grid(bm, x_segments=<span class="n">1</span>, y_segments=<span class="n">1</span>, size=<span class="n">30.0</span>); bm.to_mesh(fme)
@@ -396,8 +460,8 @@ <h2>Source</h2>
396460
wall.rotation_euler = (math.radians(<span class="n">90</span>), <span class="n">0</span>, <span class="n">0</span>); bpy.context.collection.objects.link(wall)
397461
w = bpy.data.worlds.new(<span class="s">&quot;W&quot;</span>); w.use_nodes = <span class="k">True</span>
398462
w.node_tree.nodes[<span class="s">&quot;Background&quot;</span>].inputs[<span class="n">0</span>].default_value = (<span class="n">0.02</span>, <span class="n">0.021</span>, <span class="n">0.025</span>, <span class="n">1</span>); sc.world = w
399-
aim = bpy.data.objects.new(<span class="s">&quot;Aim&quot;</span>, <span class="k">None</span>); aim.location = (<span class="n">0</span>, <span class="n">0</span>, <span class="n">1.0</span>); bpy.context.collection.objects.link(aim)
400-
cam = bpy.data.objects.new(<span class="s">&quot;cam&quot;</span>, bpy.data.cameras.new(<span class="s">&quot;cam&quot;</span>)); cam.location = (<span class="n">0</span>, -<span class="n">5.9</span>, <span class="n">2.4</span>)
463+
aim = bpy.data.objects.new(<span class="s">&quot;Aim&quot;</span>, <span class="k">None</span>); aim.location = (<span class="n">0</span>, <span class="n">0</span>, <span class="n">1.1</span>); bpy.context.collection.objects.link(aim)
464+
cam = bpy.data.objects.new(<span class="s">&quot;cam&quot;</span>, bpy.data.cameras.new(<span class="s">&quot;cam&quot;</span>)); cam.location = (<span class="n">0</span>, -<span class="n">8.0</span>, <span class="n">3.4</span>)
401465
bpy.context.collection.objects.link(cam); sc.camera = cam
402466
c = cam.constraints.new(<span class="s">&#x27;TRACK_TO&#x27;</span>); c.target = aim; c.track_axis = <span class="s">&#x27;TRACK_NEGATIVE_Z&#x27;</span>; c.up_axis = <span class="s">&#x27;UP_Y&#x27;</span>
403467
<span class="k">for</span> nm, loc, en, size, col <span class="k">in</span> [(<span class="s">&quot;K&quot;</span>, (-<span class="n">4</span>, -<span class="n">5</span>, <span class="n">7</span>), <span class="n">620</span>, <span class="n">5.0</span>, (<span class="n">1.0</span>, <span class="n">0.96</span>, <span class="n">0.9</span>)),
@@ -472,7 +536,7 @@ <h2>Source</h2>
472536
</main>
473537
<dialog class="lightbox" id="lightbox" aria-label="Full-size render">
474538
<button class="lightbox-close" type="button" autofocus>Close</button>
475-
<img src="../assets/turntable-hero.webp" alt="A bronze monkey head (Suzanne) turned three-quarters on a dark studio floor." />
539+
<img src="../assets/turntable-hero.webp" alt="A smooth copper monkey head (Suzanne) turned three-quarters on a black turntable with a brushed metal platter." />
476540
</dialog>
477541
<footer>
478542
<div class="statusbar">

‎examples/turntable/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ keys, samples the object's Z rotation at frame 1 vs a later frame, and asserts t
2929
(the keys drive playback). `--output` additionally renders a still; the full animated loop is
3030
a showcase extra, not part of the CI check.
3131

32+
The still's staging is render-only and runs after the check. The head gets a
33+
subdivision modifier (the 500-face monkey read as faceted plates) and is
34+
seated 10 mm into the platter of a turntable plinth, lifted from its own
35+
lowest evaluated vertex. It used to hover just above the floor with nothing
36+
under it. The rotation keys, the sampled frames and every exit code are
37+
unchanged. This render path does not call `gallery_framing.check_framing`,
38+
because adding it would add exit code 10. The framing was measured with the
39+
helper out of band instead: fill y 0.789, minimum margin 0.050, ok.
40+
3241
## Exit codes
3342

3443
Per-script sequential checks. `9` is a valid check code; there is no rule

‎examples/turntable/preview.webp‎

6.04 KB
Loading

‎examples/turntable/turntable.py‎

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,72 @@ def rz(f):
7272
print(f"branch={branch} rot_z f1={r1} fmid={rmid} fend={rend} drives={drives}")
7373
return drives
7474

75+
PLINTH_R = 1.15
76+
PLINTH_H = 0.28
77+
PLATTER_R = 1.05
78+
PLATTER_H = 0.05
79+
SEAT = 0.01
80+
81+
82+
def stage_turntable(obj):
83+
"""Render-only staging, after the check has run: a turntable to turn on.
84+
85+
The head is smoothed by a subdivision modifier (the 500-face monkey read
86+
as faceted plates), seated SEAT into a platter on a plinth, and lifted so
87+
its lowest evaluated vertex lands there. It used to hover just above the
88+
floor with nothing under it. Rotation keys and the correctness samples
89+
are untouched; only location and a modifier change here.
90+
"""
91+
import bmesh
92+
sub = obj.modifiers.new("Smooth", 'SUBSURF')
93+
sub.levels = 2
94+
sub.render_levels = 2
95+
dg = bpy.context.evaluated_depsgraph_get()
96+
ev = obj.evaluated_get(dg)
97+
me = ev.to_mesh()
98+
try:
99+
zmin = min((ev.matrix_world @ v.co).z for v in me.vertices)
100+
finally:
101+
ev.to_mesh_clear()
102+
obj.location.z += (PLINTH_H + PLATTER_H - SEAT) - zmin
103+
b = obj.active_material.node_tree.nodes['Principled BSDF']
104+
# 0.25 blew every brow and ear edge out to white under the key
105+
b.inputs['Roughness'].default_value = 0.38
106+
parts = []
107+
for nm, r, z0, h, col, metal, rough in (
108+
("Plinth", PLINTH_R, 0.0, PLINTH_H, (0.035, 0.032, 0.03), 0.0, 0.55),
109+
("Platter", PLATTER_R, PLINTH_H - 0.004, PLATTER_H + 0.004,
110+
(0.42, 0.42, 0.44), 1.0, 0.45),
111+
):
112+
mesh = bpy.data.meshes.new(nm)
113+
bm = bmesh.new()
114+
try:
115+
bmesh.ops.create_cone(bm, cap_ends=True, segments=64, radius1=r,
116+
radius2=r, depth=h)
117+
bmesh.ops.translate(bm, vec=(0.0, 0.0, z0 + h / 2.0), verts=bm.verts)
118+
bmesh.ops.bevel(bm, geom=[e for e in bm.edges if len(e.link_faces) == 2
119+
and e.calc_face_angle(0.0) > 1.0],
120+
offset=0.012, segments=2, affect='EDGES')
121+
bm.to_mesh(mesh)
122+
finally:
123+
bm.free()
124+
mesh.shade_smooth()
125+
mat = bpy.data.materials.new(nm); mat.use_nodes = True
126+
pb = mat.node_tree.nodes['Principled BSDF']
127+
pb.inputs['Base Color'].default_value = (*col, 1.0)
128+
pb.inputs['Metallic'].default_value = metal
129+
pb.inputs['Roughness'].default_value = rough
130+
mesh.materials.append(mat)
131+
ob = bpy.data.objects.new(nm, mesh)
132+
bpy.context.collection.objects.link(ob)
133+
parts.append(ob)
134+
return parts
135+
136+
75137
def render_still(obj, path, engine):
76138
import bmesh
77139
sc = bpy.context.scene
140+
stage_turntable(obj)
78141
fme = bpy.data.meshes.new("Floor"); bm = bmesh.new()
79142
try:
80143
bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=30.0); bm.to_mesh(fme)
@@ -92,8 +155,8 @@ def render_still(obj, path, engine):
92155
wall.rotation_euler = (math.radians(90), 0, 0); bpy.context.collection.objects.link(wall)
93156
w = bpy.data.worlds.new("W"); w.use_nodes = True
94157
w.node_tree.nodes["Background"].inputs[0].default_value = (0.02, 0.021, 0.025, 1); sc.world = w
95-
aim = bpy.data.objects.new("Aim", None); aim.location = (0, 0, 1.0); bpy.context.collection.objects.link(aim)
96-
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")); cam.location = (0, -5.9, 2.4)
158+
aim = bpy.data.objects.new("Aim", None); aim.location = (0, 0, 1.1); bpy.context.collection.objects.link(aim)
159+
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")); cam.location = (0, -8.0, 3.4)
97160
bpy.context.collection.objects.link(cam); sc.camera = cam
98161
c = cam.constraints.new('TRACK_TO'); c.target = aim; c.track_axis = 'TRACK_NEGATIVE_Z'; c.up_axis = 'UP_Y'
99162
for nm, loc, en, size, col in [("K", (-4, -5, 7), 620, 5.0, (1.0, 0.96, 0.9)),

0 commit comments

Comments
 (0)