MCPcopy Create free account
hub / github.com/coldtype/coldtype / setup

Function setup

examples/blender/dominos3.py:17–70  ·  view source on GitHub ↗
(bpw:BpyWorld)

Source from the content-addressed store, hash-verified

15
16@b3d_runnable(playback=B3DPlayback.KeepPlaying)
17def setup(bpw:BpyWorld):
18 (bpw.delete_previous(materials=False)
19 .timeline(Timeline(frames, 30), resetFrame=0
20 , output=setup.output_folder / suffix)
21 .rigidbody(2.5, frames))
22
23 (BpyObj.Cube("Floor")
24 .dimensions(x=30, y=30, z=1)
25 .locate(z=-0.5)
26 .rigidbody("passive")
27 .material("floor_mat"))
28
29 curve = P().oval(Rect(10)).centerZero().repeat(1).subsegment(0, 0.505)
30
31 points = curve.samples(samples)
32 dominos = []
33
34 for idx, pt in enumerate(points[:-2]):
35 if rs1[idx] <= 1: #> 0.85:
36 dominos.append(
37 #BpyObj.Cube(f"Cube_{pt.idx}")
38 #.dimensions(x, y, z)
39 BpyObj.Curve(f"Cube_{pt.idx}")
40 .draw(StSt("A", "Lang", 4, wdth=1).pen())
41 .rotate(x=90)
42 .extrude(0.05)
43 .convert_to_mesh()
44 .locate(z=z/2)
45 .rotate(z=pt.tan)
46 .locate(x=pt.pt[0], y=pt.pt[1])
47 .material("letter_mat"))
48
49 pt = points[0]
50 a = pt.pt.project(pt.tan, -2).project(pt.tan-90, -0.5)
51 b = pt.pt.project(pt.tan, -2).project(pt.tan-90, 0.5)
52 c = pt.pt.project(pt.tan, -10)
53
54 (BpyObj.Cube("Catalyst")
55 .dimensions(2, 0.65, zz:=1.75)
56 .locate(x=-1, y=0, z=zz)
57 .origin_to_cursor()
58 .rotate(z=pt.tan+180)
59 .apply_transform()
60 .rigidbody("passive", animated=True, friction=1)
61 .hide()
62 .insert_keyframes("location",
63 (0, lambda bp: bp.locate(x=a.x, y=a.y, z=zz/2)),
64 (20, lambda bp: bp.locate(x=b.x, y=b.y, z=zz/2)),
65 (50, lambda bp: bp.locate(x=c.x, y=c.y, z=zz/2))))
66
67 for dm in dominos:
68 (dm.apply_transform()
69 .origin_to_geometry()
70 .rigidbody(mass=10, friction=0.35, deactivated=True))

Callers

nothing calls this directly

Calls 15

TimelineClass · 0.85
RectClass · 0.85
StStFunction · 0.85
timelineMethod · 0.80
delete_previousMethod · 0.80
materialMethod · 0.80
locateMethod · 0.80
dimensionsMethod · 0.80
CubeMethod · 0.80
CurveMethod · 0.80
insert_keyframesMethod · 0.80
origin_to_cursorMethod · 0.80

Tested by

no test coverage detected