Files
grass-cutters/ArtSource/Blender/scripts/gc_farm_machines.py
NiemandKG d1c3761e58 Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:44:40 +06:00

1970 lines
105 KiB
Python

"""GRASS CUTTER - "Herbaria homestead" farm machinery. Rebuilds the processing rig as cheerful chunky farm kit: timber
frames, cast iron, galvanised tin, barn-red and tractor-green paint, belts and flywheels, rope, burlap and hay.
Same footprints, pivots, input/output heights and named parts as the models they replace (os_machines.py, gc_machines.py,
v3_belts.py, v4_robots.py). Authored directly in Blender space: metres, Z up, front = -Y (Unity +Z), Unity +X = Blender -X.
Named parts the game looks up (Assets/Editor/ProjectBuilder.Prefabs.cs):
SM_Hopper Mouth SM_WaterTank Fill (origin at its bottom, scaled along local Z)
SM_Filler Lamp, Out SM_Vaporizer Lamp, Out, Vent
SM_CryoPress Lamp, Out, Press SM_Pump Rotor (spins about local Z)
SM_Belt Belt, EndIn, EndOut SM_BeltTurn Belt, EndIn, EndOut
SM_BeltSorter Belt, EndIn, EndOut, Pusher, Scanner
SM_BeltSplitter EndIn, Paddle SM_Launcher Plate
SM_DronePad Lamp SM_DroneHub Land
SM_Drone Claw, Lamp, Rotor0..3 SM_RainDrone Tank, Rotor_1..4
Belts: the mesh named "Belt" keeps the v2/v3 layout (U 0..1 across, V in metres along the flow) because Conveyor scrolls
it through _BaseMap_ST. It uses M_SlatBelt (ArtSource/materials_farm_machines.json, Assets/Art/Textures/T_SlatBelt.png),
a canvas belt with timber slats. Regenerate that texture with the "_texture" argument.
Run (from project root):
blender -b --factory-startup --python ArtSource/Blender/scripts/gc_farm_machines.py -- [SM_Hopper SM_Belt ... | _chain | _texture]
Set GC_VIEWS=<dir> to also render back/side/top review angles into that directory, GC_CULL=1 to render with backface culling
(Unity culls back faces, Blender does not by default). Check the exports with verify_gc_farm_machines.py.
"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import common
import numpy as np
import os_machines as OM
from os_machines import * # noqa: F401,F403 (helpers + material names)
import v3_belts as V3
from gc_machines import hemp_icon, leaf_pts
TIM, DECK, CRM, RED = "M_Timber", "M_WoodDeck", "M_HullWhite", "M_BarnRed"
GRN, IRON, TIN, STL = "M_Teal", "M_Navy", "M_Tin", "M_Steel"
HAY, STRAW, ROPE, BUR, TWINE = "M_Hay", "M_Straw", "M_Rope", "M_Burlap", "M_Twine"
PRED, GOLD, INK, RUB, LEA = "M_PaintRed", "M_PaintYellow", "M_PaintWhite", "M_Rubber", "M_Leather"
SOOT, GLOW, BLADE, LEAF, LEAFD, CLIP = "M_Soot", "M_HeatGlow", "M_Blade", "M_Leaf", "M_LeafDark", "M_GrassFill"
BELTM = "M_SlatBelt"
FONT_SIGN = "C:/Windows/Fonts/georgiab.ttf"
# board pattern period (in UV) of the textures whose grain runs along V; thin parts are centred on one board
BOARDS = {TIM: 0.25, RED: 1 / 7, CRM: 1 / 7}
# ======================================================================= uv + finishing
def grain(o, d):
"""Set the direction the wood grain runs in on a part."""
o["grain"] = list(Vector(d).normalized())
return o
def uv_keep(o):
o["uvm"] = "keep"
return o
def uv_wall(o):
"""Plain box projection: wide walls keep the board pattern of the texture."""
o["uvm"] = "wall"
return o
def uv_part(o, uv=1.0):
"""Grain-aligned projection, part by part: V runs along the part, each one samples a different stretch of board."""
mode = o.get("uvm")
if mode == "keep":
return
me = o.data
names = [m.name if m else "" for m in me.materials]
if mode == "wall":
uv_box(o, uv)
return
g = o.get("grain")
if g is None:
vs = [v.co for v in me.vertices]
dims = [max(p[i] for p in vs) - min(p[i] for p in vs) for i in range(3)]
g = [0.0, 0.0, 0.0]
g[dims.index(max(dims))] = 1.0
g = Vector(g)
dv = random.random()
bm = bmesh.new()
bm.from_mesh(me)
bm.normal_update()
uvl = bm.loops.layers.uv.verify()
for f in bm.faces:
nm = names[f.material_index] if f.material_index < len(names) else ""
n = f.normal
t = g - n * g.dot(n)
if t.length < 0.3:
t = n.orthogonal()
t.normalize()
s = t.cross(n)
ss = [l.vert.co.dot(s) for l in f.loops]
tt = [l.vert.co.dot(t) for l in f.loops]
du = 0.0
per = BOARDS.get(nm)
if per and (max(ss) - min(ss)) * uv < per * 0.92:
du = per * (random.randrange(int(round(1 / per))) + 0.5) - (max(ss) + min(ss)) / 2 * uv
for l, a, b in zip(f.loops, ss, tt):
a, b = a * uv + du, b * uv + dv
l[uvl].uv = (b, a) if nm == DECK else (a, b)
bm.to_mesh(me)
bm.free()
def ffin(P, name, uv=1.0, ang=38, wn=True):
P = [o for o in P if o is not None]
for o in P:
uv_part(o, uv)
o = join(P, name)
smooth(o, ang)
if wn:
weighted(o)
return o
def fpart(P, name, origin, **kw):
o = ffin(P, name, **kw)
set_origin(o, origin)
return o
# ======================================================================= carpentry
def bx(x0, x1, y0, y1, z0, z1, m=TIM, bev=0.014, segs=1, name="bx"):
o = box(name, x0, x1, y0, y1, z0, z1, m, bev=bev, segs=segs)
return o
def beam(p0, p1, w, h=None, m=TIM, bev=0.012, segs=1, over=0.0, roll=0.0, name="beam"):
"""Rounded rectangular timber from p0 to p1. w across (roughly horizontal), h across (roughly vertical)."""
p0, p1 = Vector(p0), Vector(p1)
h = h or w
d = (p1 - p0).normalized()
p0, p1 = p0 - d * over, p1 + d * over
L = (p1 - p0).length
o = rbox(name, (w, h, L), (0, 0, 0), bevel=bev, segs=segs, m=m)
q = d.to_track_quat("Z", "Y")
if roll:
q = q @ Matrix.Rotation(roll, 4, "Z").to_quaternion()
o.rotation_mode = "QUATERNION"
o.rotation_quaternion = q
o.location = (p0 + p1) / 2
apply_xform(o)
o.rotation_mode = "XYZ"
o.rotation_euler = (0, 0, 0)
return grain(o, d)
def board(a, b, c, d, t, m=TIM, bev=0.008, along="ab", name="board"):
"""Plank through the quad a b c d (counter-clockwise seen from outside), t thick (inward of the quad's normal)."""
q = [Vector(p) for p in (a, b, c, d)]
n = (q[1] - q[0]).cross(q[3] - q[0]).normalized()
bm = bmesh.new()
fv = [bm.verts.new(p) for p in q]
bv = [bm.verts.new(p - n * t) for p in q]
bm.faces.new(fv)
bm.faces.new(list(reversed(bv)))
for i in range(4):
j = (i + 1) % 4
bm.faces.new((fv[j], fv[i], bv[i], bv[j]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
o = mesh_obj(name, bm)
set_mats(o, m)
if bev > 0:
be = o.modifiers.new("bev", "BEVEL")
be.width = bev
be.segments = 1
be.limit_method = "ANGLE"
be.angle_limit = math.radians(30)
bake(o)
return grain(o, q[1] - q[0] if along == "ab" else q[3] - q[0])
def rivet(P, p, nrm, r=0.014, h=0.012, m=STL):
p, nrm = Vector(p), Vector(nrm).normalized()
P.append(cyl_between("rivet", p - nrm * 0.004, p + nrm * h, r, m, v=6, r2=r * 0.55))
def rivets(P, a, b, n, nrm, **kw):
a, b = Vector(a), Vector(b)
for k in range(n):
rivet(P, a + (b - a) * (k / max(1, n - 1)), nrm, **kw)
def rope_band(P, c, axis, r, n=3, t=0.012, m=ROPE, segs=14):
"""Tight rope lashing: n turns around an axis through c."""
c = Vector(c)
d, u, v = basis({"X": (1, 0, 0), "Y": (0, 1, 0), "Z": (0, 0, 1)}.get(axis, axis))
for k in range(n):
o = torus("lash", r, t, (0, 0, 0), "Z", seg=segs, rseg=4, m=m)
o.rotation_mode = "QUATERNION"
o.rotation_quaternion = d.to_track_quat("Z", "Y")
o.location = c + d * ((k - (n - 1) / 2) * t * 1.7)
apply_xform(o)
o.rotation_mode = "XYZ"
o.rotation_euler = (0, 0, 0)
P.append(o)
def rope_coil(P, c, r=0.14, turns=4, t=0.02):
"""A coil of rope lying on something."""
for k in range(turns):
rr = r * (1.0 - 0.06 * k)
P.append(torus("coil", rr, t, (c[0] + 0.006 * k, c[1] - 0.004 * k, c[2] + t + k * t * 1.5), "Z", seg=14, rseg=5, m=ROPE))
def rope_line(P, pts, r=0.012, m=ROPE, sag=0.0, n=8):
a, b = Vector(pts[0]), Vector(pts[1])
path = [a + (b - a) * (i / n) - Vector((0, 0, sag * math.sin(PI * i / n))) for i in range(n + 1)]
P.append(ptube("rope", path, r, m, segs=5))
def tuft(P, x, y, z, L=0.14, n=5, sp=0.5, m=None, r=0.012, az=None):
"""Hay wisps fanning out of a point (az: main heading in radians, None = upward fan)."""
for k in range(n):
a = az + random.uniform(-0.7, 0.7) if az is not None else random.uniform(0, 2 * PI)
tilt = random.uniform(0.35, 1.0) * sp if az is None else random.uniform(1.15, 1.95) # with a heading the wisps droop over an edge
ln = L * random.uniform(0.7, 1.15)
d = Vector((math.sin(tilt) * math.cos(a), math.sin(tilt) * math.sin(a), math.cos(tilt)))
P.append(cyl_between("wisp", (x, y, z), Vector((x, y, z)) + d * ln, r, m or random.choice((HAY, STRAW, STRAW)), v=4, r2=0.002))
def hay_heap(P, c, rx, ry, h, m=HAY, tufts=10):
"""Lumpy mound of hay with wisps poking out."""
o = sphere("heap", 1.0, (0, 0, 0), seg=14, rings=7, m=m, scale=(rx, ry, h))
for v in o.data.vertices:
v.co *= 1.0 + random.uniform(-0.09, 0.09)
xf(o, t=c)
P.append(uv_wall(o))
for k in range(tufts):
a = random.uniform(0, 2 * PI)
q = random.uniform(0.2, 0.92)
x, y = rx * q * math.cos(a), ry * q * math.sin(a)
z = h * math.sqrt(max(0.0, 1 - q * q))
tuft(P, c[0] + x, c[1] + y, c[2] + z * 0.92, L=random.uniform(0.09, 0.16), n=3)
def bale(P, c, sx=0.5, sy=0.34, sz=0.3, rz=0.0, twine=TWINE):
"""Stacked hay bale with two twine bands."""
G = [uv_wall(rbox("bale", (sx, sy, sz), (0, 0, 0), bevel=0.03, segs=2, m=HAY))]
for s in (-1, 1):
G.append(box("twine", s * sx * 0.25 - 0.012, s * sx * 0.25 + 0.012, -sy / 2 - 0.005, sy / 2 + 0.005, -sz / 2 - 0.005, sz / 2 + 0.005, twine, bev=0.004, segs=1))
for o in G:
P.append(xf(o, rz=rz, t=c))
for k in range(4):
a = rz + random.uniform(-0.8, 0.8) + (PI if k % 2 else 0)
tuft(P, c[0] + sx * 0.45 * math.cos(rz) * (1 if k % 2 else -1), c[1] + sx * 0.45 * math.sin(rz) * (1 if k % 2 else -1), c[2] + random.uniform(-0.08, 0.08), L=0.07, n=2, az=a + PI)
def sack(P, c, r=0.17, h=0.34, rz=0.0, lean=0.0):
"""Tied burlap sack."""
prof = [(0, 0.0), (r * 0.82, 0.0), (r, h * 0.12), (r * 1.04, h * 0.42), (r * 0.82, h * 0.7), (r * 0.42, h * 0.84), (r * 0.26, h * 0.9), (r * 0.42, h), (r * 0.3, h * 1.06), (0, h * 1.05)]
o = revm("sack", prof, BUR, segs=10)
for v in o.data.vertices:
v.co.x *= 1.0 + 0.1 * math.sin(v.co.z * 19 + c[0] * 7)
v.co.y *= 1.0 + 0.1 * math.cos(v.co.z * 13 + c[1] * 7)
xf(o, ry=lean, rz=rz, t=c)
P.append(uv_wall(o))
P.append(torus("tie", r * 0.3, 0.012, (c[0], c[1], c[2] + h * 0.9), "Z", seg=10, rseg=4, m=TWINE))
def spoked(P, c, axis="X", R=0.5, w=0.07, n=6, rim=IRON, spoke=PRED, hub=IRON, rw=None, segs=32):
"""Cast-iron spoked wheel in the plane normal to axis. Rim is a chunky T section."""
rw = rw or R * 0.14
G = [revm("rim", [(R - rw, -w * 0.32), (R - rw * 0.55, -w * 0.5), (R, -w * 0.5), (R, w * 0.5), (R - rw * 0.55, w * 0.5), (R - rw, w * 0.32)],
rim, segs=segs, closed=True),
cyl("hub", R * 0.17, w * 1.5, (0, 0, 0), "Z", verts=14, bevel=0.012, segs=1, m=hub),
cyl("hubcap", R * 0.1, w * 1.9, (0, 0, 0), "Z", verts=10, m=STL)]
for k in range(n):
a = 2 * PI * k / n
ca, sa = math.cos(a), math.sin(a)
G.append(cyl_between("spoke", (R * 0.15 * ca, R * 0.15 * sa, 0), ((R - rw * 0.8) * ca, (R - rw * 0.8) * sa, 0), R * 0.07, spoke, v=8, r2=R * 0.04))
rot = {"X": dict(ry=PI / 2), "Y": dict(rx=PI / 2), "Z": {}}[axis]
for o in G:
P.append(xf(o, t=c, **rot))
def flat_belt(name, x, a, ra, b, rb, w=0.08, t=0.014, m=LEA, n=10):
"""Flat drive belt around two pulleys in a YZ plane at x. a, b = (y, z) centres."""
a, b = Vector(a), Vector(b)
d = b - a
L = d.length
base = math.atan2(d.y, d.x)
phi = math.asin(max(-1.0, min(1.0, (ra - rb) / L)))
pts = []
# around pulley b then pulley a (outer open belt)
for i in range(n + 1):
th = base + (PI / 2 - phi) * (1 - 2 * i / n)
pts.append(Vector((b.x + rb * math.cos(th), b.y + rb * math.sin(th))))
for i in range(n + 1):
th = base - (PI / 2 - phi) - (PI + 2 * phi) * (i / n)
pts.append(Vector((a.x + ra * math.cos(th), a.y + ra * math.sin(th))))
bm = bmesh.new()
rows = []
N = len(pts)
for i, p in enumerate(pts):
q0, q1 = pts[i - 1], pts[(i + 1) % N]
tg = (q1 - q0).normalized()
nr = Vector((-tg.y, tg.x))
if nr.dot(p - (a + b) / 2) < 0:
nr = -nr
rows.append([bm.verts.new((x + sx * w / 2, (p + nr * k * t).x, (p + nr * k * t).y)) for (sx, k) in ((-1, 0), (1, 0), (1, 1), (-1, 1))])
for i in range(N):
r0, r1 = rows[i], rows[(i + 1) % N]
for k in range(4):
bm.faces.new((r0[k], r0[(k + 1) % 4], r1[(k + 1) % 4], r1[k]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
o = mesh_obj(name, bm)
set_mats(o, m)
return uv_wall(o)
def sign_text(P, s, size, m, c, facing="-Y", ext=0.0):
t = text("label", s, size, m, ext=ext, font=FONT_SIGN if os.path.exists(FONT_SIGN) else None)
P.append(orient(t, facing, c))
def lantern(P, x, y, z, m="M_LightGreen", r=0.062, origin=None, cage=IRON):
"""Hurricane lantern: iron base and cap join the body, the glowing glass is the 'Lamp' child (origin at its base)."""
P.append(cz("lbase", r * 1.25, z, z + 0.05, x, y, cage, v=10, bev=0.012, segs=1))
for k in range(4):
a = PI / 4 + k * PI / 2
cx_, cy_ = x + r * 1.15 * math.cos(a), y + r * 1.15 * math.sin(a)
P.append(cz("lbar", 0.007, z + 0.04, z + 0.19, cx_, cy_, cage, v=4))
P.append(revm("lcap", [(r * 1.28, z + 0.18), (r * 0.8, z + 0.215), (r * 0.3, z + 0.235), (0, z + 0.24)], cage, segs=10, loc=(x, y, 0)))
P.append(torus("lring", r * 0.5, 0.006, (x, y, z + 0.238 + r * 0.5), "Y", seg=10, rseg=4, m=cage))
lo = revm("Lamp", [(0, 0.05), (r * 0.7, 0.05), (r * 1.02, 0.09), (r * 1.08, 0.125), (r * 0.98, 0.15), (r * 0.62, 0.18), (0, 0.185)], m, segs=12)
xf(lo, t=(x, y, z))
set_origin(lo, origin if origin is not None else (x, y, z + 0.05))
lo.name = "Lamp"
uv_box(lo, 4.0)
smooth(lo, 60)
return lo
def farm_chute(P, y0, y1, w, z_top, xo, legs=(), n=None, rail=TIM, roll=TIM):
"""Timber roller chute running out along -Y: wooden dowels between two side boards, top of the dowels at z_top."""
rr = 0.042
zc = z_top - rr
L = y0 - y1
n = n or max(3, int(L / 0.14))
for k in range(n):
y = y1 + 0.07 + (L - 0.12) * k / (n - 1)
P.append(grain(cx("dowel", rr, xo - w / 2, xo + w / 2, y, zc, roll, v=10), (1, 0, 0)))
for s in (-1, 1):
xi, xe = xo + s * (w / 2 + 0.008), xo + s * (w / 2 + 0.082)
P.append(bx(min(xi, xe), max(xi, xe), y1, y0, zc - 0.11, z_top + 0.08, rail, bev=0.016, name="crail"))
P.append(bx(min(xi, xe) - 0.004, max(xi, xe) + 0.004, y1 - 0.002, y1 + 0.05, zc - 0.115, z_top + 0.085, IRON, bev=0.008, name="crailend"))
for k in range(max(2, int(L / 0.32))):
y = y0 - (k + 0.5) * L / max(2, int(L / 0.32))
rivet(P, (xe, y, zc + 0.03), (s, 0, 0), r=0.016)
for y in legs:
P.append(bx(min(xi, xe) + 0.008, max(xi, xe) - 0.008, y - 0.038, y + 0.038, 0.0, zc - 0.1, TIM, bev=0.012, name="cleg"))
P.append(bx(min(xi, xe) - 0.02, max(xi, xe) + 0.02, y - 0.07, y + 0.07, 0.0, 0.035, TIM, bev=0.012, name="cfoot"))
P.append(bx(xo - w / 2, xo + w / 2, y1 + 0.03, y0, zc - 0.1, zc - 0.075, IRON, bev=0.004, name="cpan"))
for y in legs:
P.append(beam((xo - w / 2 - 0.04, y, 0.05), (xo + w / 2 + 0.04, y, zc - 0.13), 0.05, 0.03, name="cbrace"))
P.append(bx(xo - w / 2, xo + w / 2, y - 0.03, y + 0.03, zc - 0.16, zc - 0.11, TIM, bev=0.008, name="cross"))
def farm_skid(P, x0, x1, y0, y1, h=0.13, n=3):
"""Timber sledge the machines stand on: two runners and cross ties."""
w = 0.15
for x in (x0 + w / 2, x1 - w / 2):
P.append(bx(x - w / 2, x + w / 2, y0, y1, 0.0, h, TIM, bev=0.024, segs=2, name="runner"))
for y in (y0 + 0.08, y1 - 0.08):
rivet(P, (x, y, h), (0, 0, 1), r=0.02, h=0.014)
for k in range(n):
y = y0 + 0.06 + (y1 - y0 - 0.12) * k / max(1, n - 1)
P.append(bx(x0 + 0.02, x1 - 0.02, y - 0.05, y + 0.05, h - 0.03, h + 0.03, TIM, bev=0.012, name="tie"))
def iron_corner(P, x, y, z0, z1, sx, sy, w=0.1, t=0.012):
"""L-shaped iron strap on a vertical box corner, outward direction (sx, sy)."""
P.append(box("corner", min(x, x - sx * w), max(x, x - sx * w), min(y, y + sy * t), max(y, y + sy * t), z0, z1, IRON, bev=0.003, segs=1))
P.append(box("corner", min(x, x + sx * t), max(x, x + sx * t), min(y, y - sy * w), max(y, y - sy * w), z0, z1, IRON, bev=0.003, segs=1))
for k in range(2):
z = z0 + (z1 - z0) * (0.25 + 0.5 * k)
rivet(P, (x - sx * w * 0.6, y + sy * t, z), (0, sy, 0), r=0.012)
rivet(P, (x + sx * t, y - sy * w * 0.6, z), (sx, 0, 0), r=0.012)
# ======================================================================= conveyor kit
# Flow runs along -Y (entry at +Y, Unity -Z). Belt top z = 0.35, belt half width 0.42, cell |x|, |y| <= 0.5.
HW = 0.42
RAIL = TIM # upper guide rail
BODY = TIM # lower stringer
def rail_x(P, s, y0, y1, guard=True, low=False):
"""One straight side: stringer + iron band + guide rail on its cleats."""
x0, x1 = sorted((s * 0.424, s * 0.492))
P.append(bx(x0, x1, y0, y1, 0.206, 0.318 if low else 0.352, BODY, bev=0.012, name="stringer"))
if guard:
P.append(bx(min(s * 0.404, s * 0.498), max(s * 0.404, s * 0.498), y0, y1, 0.392, 0.462, RED, bev=0.016, segs=2, name="guard"))
P.append(box("guardedge", min(s * 0.402, s * 0.414), max(s * 0.402, s * 0.414), y0, y1, 0.404, 0.45, IRON, bev=0.003, segs=1))
def cleats(P, s, ys):
for y in ys:
x0, x1 = sorted((s * 0.432, s * 0.486))
P.append(bx(x0, x1, y - 0.03, y + 0.03, 0.34, 0.4, TIM, bev=0.008, name="cleat"))
P.append(box("strap", min(s * 0.49, s * 0.497), max(s * 0.49, s * 0.497), y - 0.036, y + 0.036, 0.21, 0.455, IRON, bev=0.002, segs=1))
rivet(P, (s * 0.497, y, 0.29), (s, 0, 0), r=0.012, h=0.006)
rivet(P, (s * 0.497, y, 0.425), (s, 0, 0), r=0.012, h=0.006)
def trestle(P, y=0.0, xs=(-0.452, 0.452), brace=True):
"""Timber legs + X brace at one station along the belt."""
for x in xs:
fx = x * 1.02
P.append(beam((fx, y, 0.0), (x, y, 0.235), 0.07, 0.07, bev=0.012, name="leg"))
P.append(bx(fx - 0.046, fx + 0.046, y - 0.058, y + 0.058, 0.0, 0.03, IRON, bev=0.008, name="foot"))
P.append(bx(xs[0] + 0.02, xs[1] - 0.02, y - 0.03, y + 0.03, 0.205, 0.262, TIM, bev=0.012, name="bearer"))
if brace:
for s in (-1, 1):
P.append(beam((s * 0.43, y + 0.016 * s, 0.05), (-s * 0.43, y + 0.016 * s, 0.205), 0.03, 0.05, bev=0.006, name="xbrace"))
def belt_mesh(fn):
o = fn()
set_mats(o, BELTM)
return o
def end_cap(name, ang, roller=True):
"""Entry-end cap built at +Y, rotated about Z to its end. BeltLinks hides it where a neighbour joins."""
P = []
for s in (-1, 1):
P.append(bx(min(s * 0.402, s * 0.5), max(s * 0.402, s * 0.5), 0.488, 0.514, 0.386, 0.47, IRON, bev=0.01, name="railshoe"))
P.append(bx(min(s * 0.42, s * 0.5), max(s * 0.42, s * 0.5), 0.49, 0.514, 0.2, 0.36, PRED, bev=0.01, name="endboard"))
rivet(P, (s * 0.46, 0.514, 0.3), (0, 1, 0), r=0.014, h=0.008)
rivet(P, (s * 0.46, 0.514, 0.25), (0, 1, 0), r=0.014, h=0.008)
if roller:
x = s * 0.5
P.append(grain(cyl("hub", 0.034, 0.012, (x - s * 0.002, 0.46, 0.312), "X", verts=10, m=IRON), (0, 0, 1)))
P.append(cyl("hubnut", 0.016, 0.018, (x, 0.46, 0.312), "X", verts=6, m=STL))
P.append(bx(-HW + 0.005, HW - 0.005, 0.484, 0.514, 0.244, 0.282, TIM, bev=0.012, name="endbar"))
o = ffin(P, name, wn=False)
if ang:
xf(o, rz=ang)
return o
def belt_frame(P, open_pos=None, open_neg=None):
"""Straight frame. open_pos / open_neg: (y0, y1) opening in the guide rail on the +X / -X side."""
for s, op in ((1, open_pos), (-1, open_neg)):
if op is None:
rail_x(P, s, -0.5, 0.5)
cleats(P, s, (-0.25, 0.25))
else:
y0, y1 = op
rail_x(P, s, -0.5, y0)
rail_x(P, s, y1, 0.5)
rail_x(P, s, y0, y1, guard=False, low=s > 0)
cleats(P, s, (-0.43, 0.43))
for y, d in ((y0, 1), (y1, -1)):
P.append(bx(min(s * 0.402, s * 0.5), max(s * 0.402, s * 0.5), min(y, y - d * 0.022), max(y, y - d * 0.022), 0.386, 0.47, IRON, bev=0.008, name="railstop"))
for y in (-0.34, 0.34):
P.append(bx(-0.43, 0.43, y - 0.03, y + 0.03, 0.222, 0.262, TIM, bev=0.008, name="crossbar"))
trestle(P)
def belt():
belt_mesh(V3.belt_object)
P = []
belt_frame(P)
ffin(P, "Frame", wn=False)
end_cap("EndIn", 0.0)
end_cap("EndOut", PI)
return dict(elev=30, azim=-40)
# ----------------------------------------------------------------------- turn: centre of the arc at Blender (-0.5, 0.5)
TC = (-0.5, 0.5)
TRI, TRO = 0.08, 0.92
def tp(rad, t):
"""Point on the arc: t 0 at the entry (x = 0 side, y = 0.5), t 1 at the exit (x = -0.5, y = 0)."""
th = -(PI / 2) * (1 - t) + 0.0
return TC[0] + rad * math.cos(th), TC[1] + rad * math.sin(th), math.cos(th), math.sin(th)
def arc_prism(name, prof, r_ref, m, n=16, sign=1.0):
"""Sweep prof ((d, z), d outward from r_ref) around the turn."""
path = []
for i in range(n + 1):
x, y, nx, ny = tp(r_ref, i / n)
path.append((x, y, nx * sign, ny * sign))
bm = bmesh.new()
rings = [[bm.verts.new((px + nx * d, py + ny * d, z)) for (d, z) in prof] for (px, py, nx, ny) in path]
k = len(prof)
for a, b in zip(rings, rings[1:]):
for i in range(k):
j = (i + 1) % k
bm.faces.new((a[i], a[j], b[j], b[i]))
bm.faces.new(rings[0])
bm.faces.new(list(reversed(rings[-1])))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
o = mesh_obj(name, bm)
set_mats(o, m)
# V along the arc (the grain follows the curve)
bm = bmesh.new()
bm.from_mesh(o.data)
uvl = bm.loops.layers.uv.verify()
for f in bm.faces:
for l in f.loops:
p = l.vert.co
r_ = math.hypot(p.x - TC[0], p.y - TC[1])
a = math.atan2(p.y - TC[1], p.x - TC[0])
u = (r_ if abs(f.normal.z) > 0.5 else p.z) * 0.5 + (0.1 if name == "stringer" else 0.36)
l[uvl].uv = (u, a * r_ref)
bm.to_mesh(o.data)
bm.free()
return uv_keep(o)
def rr_prof(d0, d1, z0, z1, r=0.014, n=2):
return V3.rrect(d0, d1, z0, z1, r, n)
def turn_side(P, r_ref, sign, n, ts):
P.append(arc_prism("stringer", rr_prof(0.004, 0.072, 0.206, 0.352), r_ref, BODY, n=n, sign=sign))
P.append(arc_prism("guard", rr_prof(-0.016, 0.078, 0.392, 0.462, 0.018), r_ref, RED, n=n, sign=sign))
for t in ts:
x, y, nx, ny = tp(r_ref, t)
nx, ny = nx * sign, ny * sign
rz = math.atan2(ny, nx)
G = [bx(0.012, 0.066, -0.03, 0.03, 0.34, 0.4, TIM, bev=0.008, name="cleat"),
box("strap", 0.07, 0.078, -0.036, 0.036, 0.21, 0.455, IRON, bev=0.002, segs=1)]
for o in G:
P.append(xf(o, rz=rz, t=(x, y, 0)))
rivet(P, (x + nx * 0.078, y + ny * 0.078, 0.29), (nx, ny, 0), r=0.012, h=0.006)
rivet(P, (x + nx * 0.078, y + ny * 0.078, 0.425), (nx, ny, 0), r=0.012, h=0.006)
def belt_turn():
belt_mesh(V3.turn_belt)
P = []
turn_side(P, TRO, 1.0, 16, (0.2, 0.5, 0.8))
turn_side(P, TRI, -1.0, 6, (0.5,))
# floor bearers fanning out under the belt
for t in (0.14, 0.5, 0.86):
xo, yo, _, _ = tp(0.9, t)
xi, yi, _, _ = tp(0.08, t)
P.append(beam((xi, yi, 0.242), (xo, yo, 0.242), 0.06, 0.04, bev=0.008, name="crossbar"))
# legs: outer rail at mid arc, inner corner post
xo, yo, nx, ny = tp(0.955, 0.5)
xi, yi, _, _ = tp(0.09, 0.5)
for (x, y) in ((xo, yo), (xi, yi)):
P.append(beam((x, y, 0.0), (x, y, 0.235), 0.07, 0.07, bev=0.012, name="leg"))
P.append(xf(bx(-0.046, 0.046, -0.058, 0.058, 0.0, 0.03, IRON, bev=0.008, name="foot"), rz=math.atan2(ny, nx), t=(x, y, 0)))
P.append(beam((xo, yo, 0.232), (xi, yi, 0.232), 0.06, 0.056, bev=0.012, name="bearer"))
P.append(beam((xo, yo, 0.05), (xi, yi, 0.2), 0.03, 0.05, bev=0.006, name="xbrace"))
ffin(P, "Frame", wn=False)
end_cap("EndIn", 0.0, roller=False)
end_cap("EndOut", PI / 2, roller=False)
return dict(elev=40, azim=-30)
# ----------------------------------------------------------------------- sorter
def belt_sorter():
belt_mesh(V3.belt_object)
P = []
belt_frame(P, open_pos=(-0.35, 0.35), open_neg=(-0.33, 0.33))
TOP = 1.1
# two timber goal posts with knee braces (entry +Y, exit -Y), a round rail across for the kicker, ridge beams along Y
for y, s_y in ((0.43, 1), (-0.43, -1)):
for s in (-1, 1):
x0, x1 = sorted((s * 0.43, s * 0.498))
P.append(bx(x0, x1, y - 0.06, y + 0.06, 0.2, TOP - 0.02, TIM, bev=0.014, name="post"))
P.append(bx(min(s * 0.426, s * 0.5), max(s * 0.426, s * 0.5), y - 0.064, y + 0.064, 0.47, 0.5, IRON, bev=0.004, name="postband"))
P.append(beam((s * 0.44, y, 0.86), (s * 0.28, y, 0.985), 0.05, 0.06, bev=0.006, name="knee"))
P.append(bx(-0.5, 0.5, y - 0.066, y + 0.066, 0.96, TOP + 0.03, TIM if s_y < 0 else RED, bev=0.022, segs=2, name="lintel"))
for s in (-1, 1):
x0, x1 = sorted((s * 0.438, s * 0.492))
P.append(bx(x0, x1, -0.37, 0.37, 1.04, TOP + 0.02, TIM, bev=0.012, name="ridge"))
P.append(bx(x0, x1, -0.05, 0.05, 0.9, 1.04, TIM, bev=0.01, name="hanger"))
P.append(grain(cx("railrod", 0.03, -0.47, 0.47, 0.0, 0.94, STL, v=10), (1, 0, 0)))
# the entry lintel carries the sign bracket for the two scanner lanterns
for x in (-0.3, 0.3):
P.append(box("hook", x - 0.01, x + 0.01, 0.42, 0.44, 0.9, 0.97, IRON, bev=0.003, segs=1))
P.append(cz("lanterncap", 0.05, 0.875, 0.905, x, 0.43, IRON, v=8, bev=0.008, segs=1))
P.append(cz("lanternbase", 0.045, 0.74, 0.76, x, 0.43, IRON, v=8))
# stop block for the kicker on the -X side, hay caught on the lintel
P.append(bx(-0.5, -0.478, -0.12, 0.12, 0.3, 0.44, IRON, bev=0.008, name="stop"))
tuft(P, 0.2, -0.44, TOP + 0.02, L=0.06, n=4, az=-PI / 2)
ffin(P, "Frame", wn=False)
# Scanner: lantern glasses + the glowing strip on the lintel face, tinted by the sorter filter
S = [cz("glass", 0.038, 0.76, 0.875, x, 0.43, "M_Emissive", v=8) for x in (-0.3, 0.3)]
S.append(box("strip", -0.2, 0.2, 0.494, 0.5, 1.0, 1.06, "M_Emissive", bev=0))
S.append(box("strip2", -0.2, 0.2, 0.36, 0.366, 1.0, 1.06, "M_Emissive", bev=0))
sc = join(S, "Scanner")
uv_box(sc, 1)
end_cap("EndIn", 0.0)
end_cap("EndOut", PI)
# Pusher: a red kicker board facing +X (Blender) hung from a carriage that rides the rail. Origin (-0.47, 0, 0.42)
Q = [bx(-0.47, -0.43, -0.3, 0.3, 0.375, 0.555, PRED, bev=0.014, segs=2, name="plate"),
box("pad", -0.432, -0.418, -0.28, 0.28, 0.39, 0.54, LEA, bev=0.006, segs=1),
bx(-0.48, -0.465, -0.04, 0.04, 0.4, 0.53, IRON, bev=0.004, name="rib"),
beam((-0.451, 0, 0.55), (-0.451, 0, 0.9), 0.04, 0.04, bev=0.006, name="rod"),
bx(-0.466, -0.3, -0.03, 0.03, 0.88, 0.912, IRON, bev=0.006, name="arm"),
bx(-0.37, -0.28, -0.06, 0.06, 0.9, 0.985, RED, bev=0.014, segs=2, name="carriage")]
for s in (-1, 1):
Q.append(beam((-0.451, s * 0.2, 0.55), (-0.451, 0, 0.72), 0.028, 0.02, bev=0.004, name="strut"))
for k in (-1, 1):
rivet(Q, (-0.47, s * 0.22, 0.465 + k * 0.05), (-1, 0, 0), r=0.012)
fpart(Q, "Pusher", (-0.47, 0, 0.42), wn=False)
return dict(elev=28, azim=140)
# ----------------------------------------------------------------------- splitter
def belt_splitter():
P = []
WY = -0.44 # back wall inner face (Blender y), entry at +Y, exits at +-X
# plank deck, boards run across the flow
n = 7
for k in range(n):
y0 = WY + (0.478 - WY) * k / n
y1 = WY + (0.478 - WY) * (k + 1) / n
P.append(bx(-0.478, 0.478, y0 + 0.003, y1 - 0.003, 0.3, 0.342, DECK, bev=0.008, name="plank"))
for s in (-1, 1):
P.append(box("deckstrap", s * 0.3 - 0.02, s * 0.3 + 0.02, WY, 0.478, 0.339, 0.345, IRON, bev=0.002, segs=1))
for y in (-0.3, 0.05, 0.38):
rivet(P, (s * 0.3, y, 0.345), (0, 0, 1), r=0.012, h=0.005)
# painted arrows to both exits
for d in (1, -1):
for cx_ in (0.15, 0.28, 0.41):
V3.chevron_xz(P, -d * cx_, 0.0, d, 0.34, 0.347, h=0.05, t=0.03, m=INK)
# skirts below the deck top so neighbouring belts butt in cleanly
P.append(bx(-0.45, 0.45, 0.422, 0.478, 0.2, 0.3, TIM, bev=0.012, name="skirt"))
for s in (-1, 1):
x0, x1 = sorted((s * 0.422, s * 0.478))
P.append(bx(x0, x1, -0.44, 0.45, 0.2, 0.3, TIM, bev=0.012, name="skirt"))
# corner posts where the neighbours' rails butt in
for s in (-1, 1):
P.append(bx(s * 0.45 - 0.032, s * 0.45 + 0.032, 0.418, 0.482, 0.2, 0.44, TIM, bev=0.012, name="post"))
P.append(bx(s * 0.45 - 0.036, s * 0.45 + 0.036, 0.414, 0.486, 0.42, 0.455, IRON, bev=0.01, name="pcap"))
# back wall: barn boards with a cream X brace
P.append(uv_wall(bx(-0.5, 0.5, -0.5, WY, 0.2, 0.62, RED, bev=0.02, segs=2, name="wall")))
P.append(bx(-0.5, 0.5, -0.506, -0.43, 0.6, 0.65, TIM, bev=0.014, name="wallcap"))
P.append(bx(-0.46, 0.46, -0.504, -0.492, 0.226, 0.26, CRM, bev=0.004, name="wtrim"))
for s in (-1, 1):
P.append(beam((s * 0.1, -0.5, 0.25), (s * 0.45, -0.5, 0.59), 0.05, 0.012, CRM, bev=0.003, name="brace"))
P.append(beam((s * 0.1, -0.5, 0.59), (s * 0.45, -0.5, 0.25), 0.05, 0.012, CRM, bev=0.003, name="brace"))
P.append(bx(s * 0.47 - 0.03, s * 0.47 + 0.03, -0.51, -0.43, 0.2, 0.655, TIM, bev=0.012, name="wallpost"))
# leather buffer the bales roll against, inside face
P.append(box("buffer", -0.42, 0.42, -0.442, -0.426, 0.36, 0.43, LEA, bev=0.006, segs=1))
for x in (-0.36, 0.36):
rivet(P, (x, -0.426, 0.395), (0, 1, 0), r=0.014, h=0.006)
# flap head: timber bracket over the hinge pin with an iron bearing
P.append(bx(-0.09, 0.09, -0.5, -0.23, 0.53, 0.65, TIM, bev=0.02, segs=2, name="head"))
P.append(beam((0, -0.45, 0.46), (0, -0.28, 0.53), 0.09, 0.05, bev=0.008, name="headbrace"))
P.append(cz("bearing", 0.05, 0.525, 0.54, 0, -0.32, IRON, v=12))
P.append(cz("pincap", 0.03, 0.65, 0.675, 0, -0.32, IRON, v=10, bev=0.006, segs=1))
# crank handle on top of the head, so the flap looks hand-thrown
P.append(cz("crank", 0.012, 0.65, 0.73, 0, -0.32, STL, v=6))
P.append(box("crankarm", -0.012, 0.012, -0.32, -0.2, 0.71, 0.73, IRON, bev=0.004, segs=1))
P.append(cz("crankgrip", 0.02, 0.72, 0.77, 0, -0.2, PRED, v=8, bev=0.006, segs=1))
# legs
for (x, y) in ((-0.452, 0.0), (0.452, 0.0)):
P.append(beam((x, y, 0.0), (x, y, 0.21), 0.07, 0.07, bev=0.012, name="leg"))
P.append(bx(x - 0.046, x + 0.046, y - 0.058, y + 0.058, 0.0, 0.03, IRON, bev=0.008, name="foot"))
for x in (-0.452, 0.452):
P.append(beam((x, -0.465, 0.0), (x, -0.465, 0.21), 0.07, 0.06, bev=0.012, name="leg"))
P.append(bx(x - 0.046, x + 0.046, -0.5, -0.43, 0.0, 0.03, IRON, bev=0.008, name="foot"))
P.append(bx(-0.45, 0.45, -0.03, 0.03, 0.2, 0.3, TIM, bev=0.01, name="bearer"))
P.append(beam((-0.43, 0.016, 0.05), (0.43, 0.016, 0.2), 0.03, 0.05, bev=0.006, name="xbrace"))
P.append(beam((0.43, -0.016, 0.05), (-0.43, -0.016, 0.2), 0.03, 0.05, bev=0.006, name="xbrace"))
tuft(P, 0.28, -0.44, 0.65, L=0.1, n=3)
# signal lantern on the wall (not driven by code, kept as its own part like the old model)
P.append(cz("lbracket", 0.05, 0.62, 0.66, -0.36, -0.43, IRON, v=8, bev=0.008, segs=1))
lo = lantern(P, -0.36, -0.43, 0.65, m="M_Emissive", r=0.052, origin=(0, 0, 0))
ffin(P, "Frame", wn=False)
# EndIn: rail shoes and a nose bar at the entry
E = [bx(-0.42, 0.42, 0.48, 0.514, 0.244, 0.29, TIM, bev=0.012, name="nosebar")]
for x in (-0.45, 0.45):
E.append(bx(x - 0.036, x + 0.036, 0.478, 0.494, 0.2, 0.42, PRED, bev=0.006, name="endboard"))
rivet(E, (x, 0.494, 0.34), (0, 1, 0), r=0.014, h=0.008)
ffin(E, "EndIn", wn=False)
# Paddle: pivot (0, -0.32, 0.35), reaches toward the entry (+Y), a hinged barn-red flap on an iron pin
Q = [cz("barrel", 0.042, 0.35, 0.53, 0, -0.32, IRON, v=12, bev=0.01, segs=1),
cz("collar", 0.05, 0.5, 0.53, 0, -0.32, STL, v=12),
bx(-0.022, 0.022, -0.31, 0.23, 0.358, 0.5, PRED, bev=0.016, segs=2, name="flap"),
bx(-0.028, 0.028, 0.19, 0.235, 0.36, 0.5, LEA, bev=0.014, segs=1, name="tip"),
box("flapband", -0.026, 0.026, -0.2, -0.17, 0.356, 0.502, IRON, bev=0.002, segs=1),
box("flapband", -0.026, 0.026, 0.06, 0.09, 0.356, 0.502, IRON, bev=0.002, segs=1)]
for y in (-0.185, 0.075):
rivet(Q, (-0.026, y, 0.43), (-1, 0, 0), r=0.012, h=0.006)
rivet(Q, (0.026, y, 0.43), (1, 0, 0), r=0.012, h=0.006)
fpart(Q, "Paddle", (0, -0.32, 0.35), wn=False)
return dict(elev=38, azim=145)
# ======================================================================= shared farm dressing
def pitchfork(P, foot, top, m=TIM):
foot, top = Vector(foot), Vector(top)
d = (top - foot).normalized()
P.append(cyl_between("forkshaft", foot, top, 0.02, m, v=8))
u = d.cross(Vector((0, 1, 0)) if abs(d.y) < 0.9 else Vector((1, 0, 0))).normalized()
P.append(beam(top - u * 0.08, top + u * 0.08, 0.026, 0.02, STL, bev=0.005, name="forkbar"))
for k in (-1, 0, 1):
b = top + u * (0.08 * k)
P.append(cyl_between("tine", b, b + d * 0.24 + u * (0.012 * k), 0.012, STL, v=5, r2=0.003))
def slats(P, c, facing, w, z0, z1, n, m=CRM, back=IRON, t=0.018, frame=TIM, fw=0.05):
"""Louvred vent: a dark backing, angled slats and a timber frame, built facing -Y then turned to `facing`."""
G = [bx(-w / 2, w / 2, 0.0, 0.016, z0, z1, back, bev=0.004)]
gap = (z1 - z0) / n
for k in range(n):
z = z0 + (k + 0.5) * gap
s = rbox("slat", (w, gap * 1.25, t), (0, 0, 0), bevel=0.005, segs=1, m=m)
grain(s, (1, 0, 0))
G.append(xf(s, rx=math.radians(62), t=(0, -0.016, z)))
for x in (-w / 2 - fw / 2, w / 2 + fw / 2):
G.append(bx(x - fw / 2, x + fw / 2, -0.04, 0.016, z0 - fw, z1 + fw, frame, bev=0.01, name="sframe"))
for z in (z0 - fw / 2, z1 + fw / 2):
G.append(bx(-w / 2, w / 2, -0.04, 0.016, z - fw / 2, z + fw / 2, frame, bev=0.01, name="sframe"))
rz = {"-Y": 0, "+X": PI / 2, "+Y": PI, "-X": -PI / 2}[facing]
for o in G:
g_ = o.get("grain")
xf(o, rz=rz, t=c)
if g_ is not None:
grain(o, Matrix.Rotation(rz, 3, "Z") @ Vector(g_))
P.append(o)
def roof_ridge_y(P, x0, x1, y0, y1, z_eave, z_ridge, m=TIN, t=0.05):
"""Gable tin roof with its ridge along Y."""
xm = (x0 + x1) / 2
for (xa, xb) in ((x0, xm), (x1, xm)):
a, b, c, d = (xa, y0, z_eave), (xb, y0, z_ridge), (xb, y1, z_ridge), (xa, y1, z_eave)
if xa > xb:
a, b, c, d = d, c, b, a
P.append(uv_keep_slope(board(a, b, c, d, t, m, bev=0.01, along="ab", name="roof"), (a, b)))
P.append(bx(xm - 0.05, xm + 0.05, y0 - 0.01, y1 + 0.01, z_ridge - 0.02, z_ridge + 0.012, IRON, bev=0.008, name="ridgecap"))
def roof_ridge_x(P, x0, x1, y0, y1, z_eave, z_ridge, m=TIN, t=0.05):
"""Gable tin roof with its ridge along X."""
ym = (y0 + y1) / 2
for (ya, yb) in ((y0, ym), (y1, ym)):
a, b, c, d = (x0, ya, z_eave), (x1, ya, z_eave), (x1, yb, z_ridge), (x0, yb, z_ridge)
if ya > yb:
a, b, c, d = d, c, b, a
P.append(uv_keep_slope(board(a, b, c, d, t, m, bev=0.01, along="ad", name="roof"), (a, d)))
P.append(bx(x0 - 0.01, x1 + 0.01, ym - 0.05, ym + 0.05, z_ridge - 0.02, z_ridge + 0.012, IRON, bev=0.008, name="ridgecap"))
def uv_keep_slope(o, ab):
"""Corrugations run down the slope of a roof panel."""
return grain(o, Vector(ab[1]) - Vector(ab[0]))
def plank_funnel(P, cx_, cy_, z0, z1, h0, h1, rows, mats, t=0.034):
"""Square inverted-pyramid funnel of horizontal planks. h0/h1 half widths at z0/z1, mats cycles row by row."""
for side in range(4):
G = []
for k in range(rows):
a0, a1 = k / rows, (k + 1) / rows
za, zb = z0 + (z1 - z0) * a0 + 0.004, z0 + (z1 - z0) * a1 - 0.004
ha, hb = h0 + (h1 - h0) * a0, h0 + (h1 - h0) * a1
G.append(board((-ha, -ha, za), (ha, -ha, za), (hb, -hb, zb), (-hb, -hb, zb), t, mats[k % len(mats)], bev=0.008))
rz = side * PI / 2
for o in G:
g_ = Vector(o["grain"])
xf(o, rz=rz, t=(cx_, cy_, 0))
grain(o, Matrix.Rotation(rz, 3, "Z") @ g_)
P.append(o)
def wood_arch(name, x, z, w, h, n=6):
"""Arched opening outline (x, z), counter-clockwise."""
r = w / 2
pts = [(x - r, z), (x + r, z)]
for i in range(n + 1):
a = PI * i / n
pts.append((x + r * math.cos(a), z + h - r + r * math.sin(a)))
return pts
def chevron_flat(P, y, w, h, t, z0, z1, m=INK, xo=0.0):
"""Painted chevron on a horizontal surface pointing -Y (front)."""
for s in (-1, 1):
pts = [(xo + s * w, y), (xo, y - h), (xo, y - h - t), (xo + s * w, y - t)]
if s < 0:
pts = list(reversed(pts))
P.append(prism("chev", pts, "XY", z0, z1, m))
# ======================================================================= hopper: a big wooden feed funnel on timber legs
def hopper():
P = []
Z0, Z1, H0, H1 = 0.44, 1.03, 0.2, 0.84
plank_funnel(P, 0, 0, Z0, Z1, H0, H1, 7, (TIM, DECK, TIM, TIM, DECK, TIM, DECK))
hay_heap(P, (0, 0, 0.58), 0.38, 0.38, 0.17, tufts=14)
# chunky red rim with iron corners
RO, RI = 0.92, 0.8
for rz in (0, PI / 2, PI, -PI / 2):
o = bx(-RO, RO, -RO, -RI, Z1 - 0.01, 1.124, RED, bev=0.024, segs=2, name="rim")
xf(o, rz=rz)
grain(o, Matrix.Rotation(rz, 3, "Z") @ Vector((1, 0, 0)))
P.append(o)
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
x0, x1 = sorted((sx * (RO + 0.008), sx * (RO - 0.13)))
y0, y1 = sorted((sy * (RO + 0.008), sy * (RO - 0.13)))
P.append(box("rimcorner", x0, x1, y0, y1, Z1 - 0.02, 1.13, IRON, bev=0.01, segs=1))
# stout legs, splayed a little
P.append(beam((sx * 0.88, sy * 0.88, 0.0), (sx * 0.84, sy * 0.84, Z1), 0.13, 0.13, bev=0.022, segs=2, name="leg"))
fx, fy = sx * 0.87, sy * 0.87
P.append(bx(fx - 0.08, fx + 0.08, fy - 0.08, fy + 0.08, 0.0, 0.04, IRON, bev=0.012, name="foot"))
# iron strap down each corner of the funnel
P.append(beam((sx * (H0 + 0.01), sy * (H0 + 0.01), Z0 + 0.0), (sx * (H1 + 0.01), sy * (H1 + 0.01), Z1 - 0.03), 0.075, 0.016, IRON, bev=0.004, roll=PI / 4 * sx * sy, name="cornerstrap"))
# strut from the leg up under the funnel
P.append(beam((sx * 0.84, sy * 0.84, 0.26), (sx * 0.28, sy * 0.28, 0.5), 0.07, 0.07, bev=0.012, name="strut"))
# low side rails, X braces on the flanks only: the funnel has to read from eye level
for rz in (0, PI / 2, PI, -PI / 2):
G = [grain(bx(-0.84, 0.84, -0.88, -0.8, 0.2, 0.28, TIM, bev=0.014, name="rail"), (1, 0, 0))]
if rz in (PI / 2, -PI / 2):
G.append(beam((-0.78, -0.84, 0.05), (0.78, -0.84, 0.2), 0.05, 0.07, bev=0.008, name="brace"))
G.append(beam((0.78, -0.84, 0.05), (-0.78, -0.84, 0.2), 0.05, 0.07, bev=0.008, name="brace"))
for o in G:
g_ = Vector(o["grain"])
xf(o, rz=rz)
grain(o, Matrix.Rotation(rz, 3, "Z") @ g_)
P.append(o)
# the feed chute down to the deck: plank box with iron hoops and a sliding gate
P.append(uv_wall(bx(-0.2, 0.2, -0.2, 0.2, 0.05, Z0 + 0.03, TIM, bev=0.02, segs=2, name="chute")))
for z in (0.14, 0.4):
P.append(box("hoop", -0.212, 0.212, -0.212, 0.212, z - 0.022, z + 0.022, IRON, bev=0.006, segs=1))
for s in (-1, 1):
rivet(P, (s * 0.12, -0.212, z), (0, -1, 0))
P.append(bx(-0.36, 0.36, -0.36, 0.36, 0.0, 0.055, TIM, bev=0.016, name="slab"))
P.append(bx(0.2, 0.42, -0.14, 0.14, 0.2, 0.24, STL, bev=0.006, name="gate"))
P.append(bx(0.4, 0.44, -0.16, 0.16, 0.18, 0.26, IRON, bev=0.008, name="gatebar"))
P.append(beam((0.42, 0, 0.22), (0.56, 0, 0.5), 0.03, 0.03, IRON, bev=0.006, name="gatelever"))
P.append(sphere("gateknob", 0.04, (0.565, 0, 0.51), seg=10, rings=6, m=PRED))
# stencil on the front of the rim
sign_text(P, "DROP GRASS", 0.082, INK, (0, -0.923, 1.07))
# hay spilling over the rim
for (x, y, az) in ((-0.62, -0.8, -PI / 2), (0.4, -0.8, -PI / 2), (0.8, 0.3, 0.0), (-0.8, -0.2, PI), (0.1, 0.8, PI / 2)):
tuft(P, x, y, 1.125, L=0.15, n=6, az=az)
# yard dressing
sack(P, (-0.5, -0.52, 0.0), r=0.16, h=0.34, rz=0.4)
sack(P, (-0.22, -0.62, 0.0), r=0.13, h=0.27, rz=1.2)
rope_coil(P, (0.5, -0.5, 0.0), r=0.15, turns=4)
pitchfork(P, (0.86, -0.36, 0.0), (0.86, -0.7, 0.9))
ffin(P, "Body")
empty("Mouth", (0, 0, 1.1))
return dict(elev=30, azim=-35)
# ======================================================================= grass silo: corrugated tin with a conical roof and ladder
def water_tank():
P = []
RT = 0.8
WA0, WA1 = 258.75, 281.25 # window opening (front, -Y)
WZ0, WZ1 = 0.62, 2.42
# timber footing and a skirt of staves
P.append(uv_wall(revm("plinth", [(0, 0.1), (0.86, 0.1), (0.9, 0.08), (0.9, 0.02), (0.87, 0.0)], TIM, segs=24)))
for k in range(18):
a = k * 20
o = arc_band("stave", 0.795, 0.84, 0.1, 0.42, a + 1, a + 19, TIM, segs=2)
P.append(grain(o, (0, 0, 1)))
for z in (0.17, 0.36):
P.append(revm("skirthoop", [(0.84, z - 0.022), (0.848, z - 0.016), (0.848, z + 0.016), (0.84, z + 0.022)], IRON, segs=36))
bolt_ring(P, 12, 0.88, 0.1, r=0.016, h=0.012, a0=0)
# corrugated shell (real ribs, the tin texture wraps around so its ridges follow them), window opening cut out
step = 0.1
prof = [(RT + (0.014 if i % 2 else -0.006), 0.42 + i * step) for i in range(21)]
prof = [(0.79, 0.4)] + prof
sh = revm("shell", prof, TIN, segs=32)
bm = bmesh.new()
bm.from_mesh(sh.data)
kill = []
for f in bm.faces:
c = f.calc_center_median()
a = math.degrees(math.atan2(c.y, c.x)) % 360
if WA0 < a < WA1 and WZ0 < c.z < WZ1:
kill.append(f)
bmesh.ops.delete(bm, geom=kill, context="FACES")
uvl = bm.loops.layers.uv.verify()
for f in bm.faces:
c = f.calc_center_median()
ac = math.atan2(c.y, c.x)
for l in f.loops:
p = l.vert.co
a = math.atan2(p.y, p.x)
if a - ac > PI:
a -= 2 * PI
elif ac - a > PI:
a += 2 * PI
l[uvl].uv = (p.z * 0.5, a * RT * 0.5)
bm.to_mesh(sh.data)
bm.free()
P.append(uv_keep(sh))
# dark liner so the window shows an interior
ln = revm("liner", [(0.77, 0.45), (0.77, 2.55)], IRON, segs=24, cap_top=True, cap_bot=True)
for p in ln.data.polygons:
p.flip()
bm = bmesh.new()
bm.from_mesh(ln.data)
kill = [f for f in bm.faces if len(f.verts) == 4 and 248 < math.degrees(math.atan2(f.calc_center_median().y, f.calc_center_median().x)) % 360 < 292]
bmesh.ops.delete(bm, geom=kill, context="FACES")
bm.to_mesh(ln.data)
bm.free()
P.append(ln)
# inspection slot: timber frame and bars, glass behind (the Fill column rises inside)
P.append(arc_band("glass", RT - 0.012, RT - 0.004, WZ0, WZ1, WA0, WA1, GL, segs=2))
for z0, z1 in ((WZ0 - 0.08, WZ0), (WZ1, WZ1 + 0.08)):
P.append(grain(arc_band("wframe", RT - 0.01, RT + 0.05, z0, z1, WA0 - 4, WA1 + 4, TIM, segs=4), (1, 0, 0)))
for (a0, a1) in ((WA0 - 4, WA0), (WA1, WA1 + 4)):
P.append(grain(arc_band("wframe", RT - 0.01, RT + 0.05, WZ0, WZ1, a0, a1, TIM, segs=1), (0, 0, 1)))
for k in range(1, 6):
z = WZ0 + (WZ1 - WZ0) * k / 6
P.append(grain(arc_band("wbar", RT + 0.002, RT + 0.03, z - 0.022, z + 0.022, WA0, WA1, TIM, segs=2), (1, 0, 0)))
# iron hoops (gap at the window) with their bolts
for z in (0.74, 1.34, 1.94):
P.append(arc_band("hoop", RT + 0.004, RT + 0.03, z - 0.032, z + 0.032, WA1 + 4, WA0 - 4 + 360, IRON, segs=32))
for a in (WA1 + 6, WA0 - 6):
ar = math.radians(a)
P.append(cyl_between("hnut", (0.82 * math.cos(ar), 0.82 * math.sin(ar), z), (0.85 * math.cos(ar), 0.85 * math.sin(ar), z), 0.022, STL, v=6))
P.append(revm("hooptop", [(0.82, 2.44), (0.832, 2.45), (0.832, 2.5), (0.82, 2.51)], IRON, segs=32))
# sign + leaf on the left flank
wp = decal(rrect(0, 1.09, 0.72, 0.26, 0.04), 0.0, 0.012, RED)
P.append(uv_wall(wrap_cyl(wp, RT + 0.016, 205, step=0.05)))
t = text("label", "GRASS", 0.17, INK, font=FONT_SIGN)
orient(t, "-Y", (0, -0.014, 1.09))
P.append(wrap_cyl(t, RT + 0.016, 205))
d = decal(leaf_pts(0.15, 0, 1.56, n=10), 0.0, 0.012, GRN)
P.append(wrap_cyl(d, RT + 0.016, 205, step=0.04))
# conical roof with an eave, ribs and a turned tin ventilator
ZE, ZA = 2.47, 3.0
P.append(revm("cone", [(0.76, 2.52), (0.93, ZE), (0.95, ZE + 0.02), (0.13, ZA)], [IRON, RED, RED], segs=32))
for k in range(12):
a = 2 * PI * (k + 0.5) / 12
ca, sa = math.cos(a), math.sin(a)
P.append(cyl_between("rib", (0.94 * ca, 0.94 * sa, ZE + 0.03), (0.14 * ca, 0.14 * sa, ZA + 0.01), 0.016, TIN, v=5))
P.append(revm("eave", [(0.94, ZE - 0.015), (0.965, ZE + 0.005), (0.965, ZE + 0.03), (0.93, ZE + 0.05)], TIN, segs=32))
P.append(revm("vent", [(0.15, ZA - 0.03), (0.15, ZA + 0.02), (0.1, ZA + 0.05), (0.09, ZA + 0.05)], IRON, segs=14))
P.append(cz("ventneck", 0.075, ZA + 0.03, ZA + 0.1, m=TIN, v=12))
P.append(revm("ventcap", [(0.06, ZA + 0.08), (0.17, ZA + 0.08), (0.17, ZA + 0.095), (0.09, ZA + 0.14), (0, ZA + 0.15)], TIN, segs=14, cap_bot=True))
# timber ladder on +X, iron hand grabs over the eave
for ys in (-0.17, 0.17):
P.append(bx(0.905, 0.955, ys - 0.03, ys + 0.03, 0.1, 2.44, TIM, bev=0.012, name="lrail"))
P.append(ptube("grab", rpath([(0.93, ys, 2.42), (0.93, ys, 2.72), (0.96, ys, 2.86), (0.72, ys, 2.84), (0.62, ys, 2.68)], 0.08, 4), 0.018, IRON, segs=6))
P.append(bx(0.895, 0.965, ys - 0.04, ys + 0.04, 0.1, 0.13, IRON, bev=0.008, name="lfoot"))
for z in (0.8, 1.9):
P.append(bx(0.8, 0.905, ys - 0.016, ys + 0.016, z - 0.018, z + 0.018, IRON, bev=0.005, name="stand"))
for k in range(9):
z = 0.34 + k * 0.255
P.append(grain(cy("rung", 0.02, -0.15, 0.15, 0.93, z, TIM, v=8), (0, 1, 0)))
# grain leg: tin elevator pipe down the back
for z in (0.5, 1.5, 2.5):
P.append(cz("legband", 0.085, z - 0.03, z + 0.03, 0.35, 0.9, IRON, v=12))
pipe(P, [(0.35, 0.36, 2.68), (0.35, 0.36, 3.08), (0.35, 0.9, 3.08), (0.35, 0.9, 0.04)], 0.062, STL, rad=0.18, segs=10)
deck_flange(P, 0.35, 0.9, 0.09, nb=5, m=IRON)
P.append(bx(0.29, 0.41, 0.8, 0.86, 2.0, 2.06, IRON, bev=0.01, name="pclamp"))
# outlet spout with a slide gate, front left
oa = math.radians(232)
ox, oy = math.cos(oa), math.sin(oa)
pipe(P, [(0.74 * ox, 0.74 * oy, 0.58), (0.93 * ox, 0.93 * oy, 0.42), (0.93 * ox, 0.93 * oy, 0.04)], 0.06, STL, rad=0.1, segs=10)
handwheel(P, (0.93 * ox, 0.93 * oy, 0.6), "+Z", R=0.08, stem=0.1, m=PRED)
P.append(cyl_between("gatevalve", (0.93 * ox, 0.93 * oy, 0.42), (0.93 * ox, 0.93 * oy, 0.5), 0.085, IRON, v=10))
# a bale and a sack at the foot, hay stuck under the eave
sack(P, (-0.72, 0.5, 0.1), r=0.14, h=0.3, rz=1.0)
tuft(P, -0.5, -0.76, 2.46, L=0.13, n=4, az=-PI / 2)
tuft(P, 0.8, 0.45, 2.46, L=0.11, n=3, az=0.5)
ffin(P, "Body")
# Fill: cut grass column inside (origin at its bottom, scale Z 0..1 in game)
f = revm("Fill", [(0, 0.45), (0.76, 0.45), (0.76, 2.5), (0, 2.5)], CLIP, segs=24)
uv_box(f, 1.0)
smooth(f, 30)
set_origin(f, (0, 0, 0.45))
return dict(elev=20, azim=-30)
# ======================================================================= baler: a green-and-red stationary hay baler with a flywheel
def filler():
P = []
FX = -0.5 # bales leave on one 1 m grid lane, so they roll straight onto a belt cell
farm_skid(P, -0.95, 0.95, -0.14, 0.95)
# bale chamber: long tractor-green box along Y
P.append(bx(-0.92, -0.08, -0.1, 0.93, 0.3, 1.22, GRN, bev=0.05, segs=2, name="chamber"))
for x in (-0.82, -0.18):
P.append(bx(x - 0.07, x + 0.07, 0.05, 0.85, 0.15, 0.31, IRON, bev=0.02, name="bolster"))
P.append(box("chamberbase", -0.935, -0.065, -0.115, 0.945, 0.29, 0.37, IRON, bev=0.012, segs=1))
P.append(box("pin", -0.927, -0.073, -0.108, 0.938, 1.09, 1.11, GOLD, bev=0.003, segs=1))
for y in (0.12, 0.5, 0.86):
P.append(box("band", -0.934, -0.066, y - 0.03, y + 0.03, 0.31, 1.235, IRON, bev=0.006, segs=1))
for z in (0.5, 0.8, 1.04):
rivet(P, (-0.934, y, z), (-1, 0, 0))
rivet(P, (-0.5, y, 1.235), (0, 0, 1))
# name board on the flank (back half of the chamber)
nb = plate("nboard", 0.62, 0.2, 0.012, PRED, r=0.03)
P.append(orient(nb, "-X", (-0.934, 0.31, 0.72)))
sign_text(P, "BALE-O-MATIC", 0.066, INK, (-0.948, 0.31, 0.72), "-X")
# front: bale mouth + iron frame, a finished bale nosing out onto the chute
P.append(bx(-0.86, -0.14, -0.13, -0.09, 0.44, 1.14, IRON, bev=0.016, name="mouth"))
P.append(bx(-0.78, -0.22, -0.142, -0.12, 0.5, 1.02, "M_Soot", bev=0.006, name="mouthdark"))
bale(P, (FX, -0.34, 0.68), sx=0.54, sy=0.46, sz=0.36)
for s in (-1, 1):
P.append(cy("guiderod", 0.016, -0.56, -0.12, FX + s * 0.2, 0.9, STL, v=6))
# needle arch: a red hoop over the chamber
P.append(ptube("arch", rpath([(-0.945, 0.0, 0.34), (-0.945, 0.0, 1.32), (-0.055, 0.0, 1.32), (-0.055, 0.0, 0.34)], 0.14, 4), 0.034, PRED, segs=8))
P.append(cy("archaxle", 0.03, -0.05, 0.05, -0.5, 1.325, STL, v=8))
# feed hopper on top: red plank funnel, heaped with hay
HC = (-0.5, 0.55)
plank_funnel(P, HC[0], HC[1], 1.22, 1.79, 0.32, 0.42, 4, (RED,), t=0.03)
k = math.sqrt(2)
P.append(uv_wall(revm("hopinner", [(0.3 * k, 1.24), (0.4 * k, 1.8), (0.385 * k, 1.8), (0.28 * k, 1.5), (0, 1.5)], IRON, segs=4, a0=45, a1=405, loc=(HC[0], HC[1], 0))))
hay_heap(P, (HC[0], HC[1], 1.72), 0.36, 0.34, 0.24, tufts=14)
for rz in (0, PI / 2, PI, -PI / 2):
o = bx(-0.45, 0.45, -0.45, -0.38, 1.77, 1.82, IRON, bev=0.012, name="hoprim")
xf(o, rz=rz, t=(HC[0], HC[1], 0))
grain(o, Matrix.Rotation(rz, 3, "Z") @ Vector((1, 0, 0)))
P.append(o)
tuft(P, HC[0] - 0.36, HC[1] + 0.1, 1.82, L=0.08, n=5, az=PI)
# hay hoist: a post and jib with a rope hanging into the hopper
P.append(bx(-0.05, 0.05, 0.87, 0.95, 0.13, 2.2, TIM, bev=0.016, name="hoistpost"))
P.append(beam((0.0, 0.91, 2.14), (-0.5, 0.56, 2.14), 0.07, 0.07, name="jib"))
P.append(beam((0.0, 0.91, 1.8), (-0.26, 0.74, 2.12), 0.05, 0.05, name="jibbrace"))
P.append(cz("sheave", 0.05, 2.06, 2.09, -0.5, 0.56, IRON, v=10))
rope_line(P, ((-0.5, 0.56, 2.09), (-0.5, 0.56, 1.9)), r=0.012)
rope_line(P, ((-0.46, 0.585, 2.11), (0.0, 0.9, 1.5)), r=0.01, sag=0.06)
# flywheel stand, shaft and crank
FWY, FWZ, FWR = 0.25, 1.0, 0.71
FWX = 0.62
P.append(cx("shaft", 0.045, -0.07, 0.88, FWY, FWZ, STL, v=12))
for x in (0.26, 0.84):
for s in (-1, 1):
P.append(beam((x, FWY + s * 0.46, 0.16), (x, FWY, FWZ - 0.03), 0.09, 0.07, IRON, bev=0.014, name="pedestal"))
P.append(bx(x - 0.07, x + 0.07, FWY - 0.09, FWY + 0.09, FWZ - 0.08, FWZ + 0.08, IRON, bev=0.02, segs=2, name="bearing"))
P.append(bx(x - 0.07, x + 0.07, FWY - 0.56, FWY + 0.56, 0.13, 0.19, TIM, bev=0.012, name="sill"))
P.append(cx("crankdisc", 0.2, 0.02, 0.07, FWY, FWZ, PRED, v=16, bev=0.012, segs=1))
P.append(cx("crankpin", 0.03, -0.02, 0.09, FWY + 0.13, FWZ - 0.04, STL, v=8))
P.append(beam((0.0, FWY + 0.13, FWZ - 0.04), (-0.03, 0.72, 0.82), 0.05, 0.05, PRED, bev=0.01, name="pitman"))
P.append(bx(-0.08, -0.03, 0.62, 0.82, 0.74, 0.9, IRON, bev=0.008, name="slotplate"))
# little single-cylinder engine driving the flywheel with a flat leather belt
P.append(bx(0.34, 0.95, -0.82, -0.12, 0.0, 0.12, TIM, bev=0.02, name="enginebed"))
P.append(bx(0.71, 0.93, -0.72, -0.14, 0.12, 0.56, GRN, bev=0.04, segs=2, name="engine"))
P.append(box("enginepin", 0.706, 0.934, -0.724, -0.136, 0.2, 0.22, GOLD, bev=0.003, segs=1))
PY, PZ, PR = -0.36, 0.7, 0.12
P.append(cx("pulleyshaft", 0.03, 0.56, 0.88, PY, PZ, STL, v=8))
P.append(cx("pulley", PR, 0.57, 0.67, PY, PZ, IRON, v=16, bev=0.008, segs=1))
P.append(bx(0.74, 0.86, PY - 0.08, PY + 0.08, 0.54, PZ + 0.08, IRON, bev=0.02, name="engbearing"))
P.append(cy("cylinder", 0.13, -0.72, -0.5, 0.82, 0.68, IRON, v=14, bev=0.012, segs=1))
for k_ in range(3):
y = -0.7 + k_ * 0.07
P.append(cy("cfin", 0.155, y, y + 0.024, 0.82, 0.68, IRON, v=14))
P.append(cy("cylhead", 0.11, -0.78, -0.72, 0.82, 0.68, PRED, v=14, bev=0.012, segs=1))
P.append(cx("sparkbar", 0.014, 0.9, 0.95, -0.75, 0.68, "M_Brass", v=6))
P.append(cz("stack", 0.04, 0.8, 1.42, 0.82, -0.62, IRON, v=10))
P.append(revm("stackcap", [(0.04, 1.42), (0.075, 1.46), (0.08, 1.52), (0.05, 1.55), (0, 1.56)], SOOT, segs=10, loc=(0.82, -0.62, 0)))
P.append(cyl_between("stackbend", (0.82, -0.62, 0.8), (0.82, -0.62, 0.66), 0.04, IRON, v=10))
P.append(cy("fueltank", 0.09, -0.44, -0.16, 0.84, 0.92, TIN, v=12, bev=0.02, segs=1))
for y in (-0.4, -0.2):
P.append(bx(0.8, 0.88, y - 0.016, y + 0.016, 0.56, 0.84, IRON, bev=0.005, name="tankstrap"))
P.append(flat_belt("drive", FWX, (FWY, FWZ), FWR + 0.002, (PY, PZ), PR, w=0.085))
# chute: wooden rollers + side boards, top at the old height
farm_chute(P, -0.09, -1.0, 0.6, 0.5, FX, legs=(-0.85,), n=7)
lo = lantern(P, -0.66, 0.2, 1.79)
ffin(P, "Body")
# Flywheel: its own part with the origin on the shaft, so a Spin can be added later
G = []
spoked(G, (FWX, FWY, FWZ), "X", R=FWR, w=0.12, n=6)
fpart(G, "Flywheel", (FWX, FWY, FWZ))
empty("Out", (FX, -0.98, 0.5))
return dict(elev=26, azim=-35)
# ======================================================================= herb dryer: a timber drying kiln with a stovepipe and slatted vents
def log(P, x, y0, y1, z, r=0.072):
o = cy("log", r, y0, y1, x, z, "M_Bark", v=8)
P.append(uv_wall(o))
P.append(cy("logend", r * 0.82, y0 - 0.004, y0 + 0.002, x, z, ROPE, v=8))
def herb_bundle(P, x, y, z, L=0.26):
"""A bunch of herbs hung to dry: stems tied at the top, the leafy heads flare out and droop below."""
P.append(cz("herbstem", 0.018, z - 0.06, z, x, y, STRAW, v=5))
P.append(cz("herbtie", 0.024, z - 0.075, z - 0.05, x, y, TWINE, v=6))
for k in range(7):
a = 2 * PI * k / 7 + random.uniform(-0.3, 0.3)
spread = 0.05 if k % 2 else 0.085
lo_ = Vector((x + spread * math.cos(a), y + spread * math.sin(a), z - L * random.uniform(0.78, 1.05)))
P.append(cyl_between("sprig", (x, y, z - 0.06), lo_, 0.012, LEAF if k % 3 else LEAFD, v=5, r2=0.032))
P.append(sphere("leafhead", 0.034, lo_, seg=6, rings=3, m=LEAFD if k % 3 else LEAF, scale=(1, 1, 1.5)))
def vaporizer():
P = []
farm_skid(P, -0.95, 0.95, -0.32, 0.95)
hx, hy = -0.2, 0.55
X, Y0, Y1 = 0.8, -0.26, 0.9 # kiln walls
ZF, ZE, ZR = 0.56, 1.88, 2.5 # top of the firebox, eaves, ridge
# cast-iron firebox with glowing draught slits and a round stove door
P.append(bx(-X - 0.02, X + 0.02, Y0 - 0.02, Y1 + 0.02, 0.14, ZF, IRON, bev=0.03, segs=2, name="firebox"))
for zz in (0.27, 0.37):
for x in (-0.56, -0.32, 0.32):
if x < 0 or zz > 0:
P.append(box("slit", x - 0.09, x + 0.09, Y0 - 0.026, Y0 - 0.01, zz - 0.016, zz + 0.016, GLOW, bev=0))
for s in (-1, 1):
for y in (0.1, 0.5):
P.append(box("slit", min(s * (X + 0.026), s * (X + 0.01)), max(s * (X + 0.026), s * (X + 0.01)), y - 0.1, y + 0.1, zz - 0.016, zz + 0.016, GLOW, bev=0))
door = [revm("door", [(0, 0.0), (0.17, 0.0), (0.18, 0.02), (0.17, 0.045), (0.135, 0.05), (0.125, 0.034), (0, 0.034)],
[IRON, IRON, IRON, IRON, IRON, GLOW], segs=16)]
for k in range(3):
door.append(box("dbar", -0.125, 0.125, -0.012 + (k - 1) * 0.07, 0.012 + (k - 1) * 0.07, 0.03, 0.055, STL, bev=0.005, segs=1))
door.append(box("dhandle", 0.1, 0.22, -0.015, 0.015, 0.05, 0.08, "M_Brass", bev=0.008, segs=1))
for o in door:
P.append(orient(o, "-Y", (-0.06, Y0 - 0.02, 0.35)))
P.append(bx(-X - 0.05, X + 0.05, Y0 - 0.05, Y1 + 0.05, ZF - 0.02, ZF + 0.04, TIM, bev=0.016, name="sill"))
# kiln house: barn-red boards below, slatted vents above, timber frame over everything
P.append(uv_wall(bx(-X + 0.02, X - 0.02, Y0 + 0.02, Y1 - 0.02, ZF, ZE, RED, bev=0.012, name="kiln")))
ZV = 1.16 # top of the board wall, slats above
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
xc, yc = sx * (X - 0.06), (Y1 - 0.06) if sy > 0 else (Y0 + 0.06)
P.append(bx(xc - 0.075, xc + 0.075, yc - 0.075, yc + 0.075, ZF, ZE, TIM, bev=0.018, name="post"))
for z in (ZV - 0.03, ZE - 0.03):
for rz, ln, oy in ((0, X, Y0 - 0.02), (PI, X, Y1 + 0.02)):
o = bx(-ln, ln, -0.04, 0.04, z - 0.045, z + 0.045, TIM, bev=0.014, name="wrail")
xf(o, t=(0, oy, 0))
grain(o, (1, 0, 0))
P.append(o)
for s in (-1, 1):
P.append(bx(s * X - 0.04, s * X + 0.04, Y0, Y1, z - 0.045, z + 0.045, TIM, bev=0.014, name="wrail"))
slats(P, (-0.0, Y0 - 0.02, 0), "-Y", 1.26, ZV + 0.06, ZE - 0.12, 7, CRM)
W_SIDE = 0.86
for fc, s in (("+X", 1), ("-X", -1)):
slats(P, (s * (X + 0.02), (Y0 + Y1) / 2, 0), fc, W_SIDE, ZV + 0.06, ZE - 0.12, 7, CRM)
slats(P, (0, Y1 + 0.02, 0), "+Y", 1.26, ZV + 0.06, ZE - 0.12, 7, CRM)
# plank door on the left of the front, with a cream X brace and iron hinges
DX0, DX1 = -0.68, -0.14
P.append(uv_wall(bx(DX0, DX1, Y0 - 0.03, Y0 + 0.02, ZF + 0.04, ZV - 0.075, RED, bev=0.012, name="door")))
for (a, b) in (((DX0 + 0.02, ZF + 0.08), (DX1 - 0.02, ZV - 0.115)), ((DX1 - 0.02, ZF + 0.08), (DX0 + 0.02, ZV - 0.115))):
d_ = Vector((b[0] - a[0], 0, b[1] - a[1])).normalized()
n_ = Vector((-d_.z, 0, d_.x)) * 0.03
pa, pb = Vector((a[0], Y0 - 0.044, a[1])), Vector((b[0], Y0 - 0.044, b[1]))
P.append(board(pa - n_, pb - n_, pb + n_, pa + n_, 0.016, CRM, bev=0.004, name="dbrace"))
for z in (ZF + 0.14, ZV - 0.17):
P.append(box("hinge", DX0 - 0.03, DX0 + 0.18, Y0 - 0.044, Y0 - 0.028, z - 0.018, z + 0.018, IRON, bev=0.004, segs=1))
P.append(cy("dknob", 0.022, Y0 - 0.06, Y0 - 0.03, DX1 - 0.07, 0.86, "M_Brass", v=8))
# output hatch over the chute on the right: iron-bound opening with a flap
XN, YN = 0.5, -0.6
P.append(bx(0.22, 0.78, Y0 - 0.036, Y0 + 0.01, 0.46, 0.98, TIM, bev=0.016, name="hatchframe"))
P.append(bx(0.28, 0.72, Y0 - 0.044, Y0 - 0.02, 0.5, 0.92, SOOT, bev=0.006, name="hatchdark"))
P.append(board((0.27, Y0 - 0.05, 0.94), (0.73, Y0 - 0.05, 0.94), (0.73, Y0 - 0.26, 0.82), (0.27, Y0 - 0.26, 0.82), 0.024, TIN, bev=0.006, along="ad", name="flap"))
# gable roof, ridge along Y: tin panels over red gable ends
roof_ridge_y(P, -0.95, 0.95, -0.46, 0.96, ZE - 0.03, ZR)
for y, s in ((Y0 + 0.02, -1), (Y1 - 0.02, 1)):
o = prism("gable", [(-X, ZE), (X, ZE), (0, ZR - 0.05)], "XZ", y - 0.04, y + 0.04, RED)
P.append(uv_wall(o))
P.append(beam((-X - 0.08, y + s * 0.05, ZE - 0.04), (0, y + s * 0.05, ZR - 0.03), 0.09, 0.05, TIM, bev=0.012, roll=0.0, name="rake"))
P.append(beam((X + 0.08, y + s * 0.05, ZE - 0.04), (0, y + s * 0.05, ZR - 0.03), 0.09, 0.05, TIM, bev=0.012, roll=0.0, name="rake"))
o2 = orient(cyl("gvent", 0.13, 0.02, (0, 0, 0.01), "Z", verts=14, m=IRON), "-Y" if s < 0 else "+Y", (0, y + s * 0.04, ZE + 0.22))
P.append(o2)
P.append(orient(torus("gring", 0.14, 0.022, (0, 0, 0.02), "Z", seg=16, rseg=5, m=TIM), "-Y" if s < 0 else "+Y", (0, y + s * 0.04, ZE + 0.22)))
for dz in (-0.07, 0.0, 0.07):
P.append(box("gslat", -0.115, 0.115, y + s * 0.06 - 0.008, y + s * 0.06 + 0.008, ZE + 0.22 + dz - 0.022, ZE + 0.22 + dz + 0.022, CRM, bev=0.003, segs=1))
# slatted ridge cupola
CY0, CY1, CZ = -0.1, 0.26, ZR - 0.14
P.append(bx(-0.17, 0.17, CY0, CY1, CZ, CZ + 0.3, TIM, bev=0.012, name="cupola"))
for x in (-0.175, 0.175):
for k in range(3):
z = CZ + 0.16 + k * 0.05
P.append(box("cslat", min(x, x * 1.08), max(x, x * 1.08), CY0 + 0.04, CY1 - 0.04, z - 0.014, z + 0.014, CRM, bev=0.003, segs=1))
roof_ridge_y(P, -0.24, 0.24, CY0 - 0.06, CY1 + 0.06, CZ + 0.3, CZ + 0.44, t=0.03)
# stovepipe with a conical rain cap (the Vent point sits at its mouth)
ZB = 2.15
P.append(revm("flashing", [(0.24, ZB + 0.16), (0.2, ZB + 0.28), (0.15, ZB + 0.3), (0.125, ZB + 0.3)], IRON, segs=14, loc=(hx, hy, 0)))
P.append(revm("chimney", [(0.12, ZB + 0.1), (0.12, 2.76), (0.135, 2.78), (0.135, 2.84), (0.1, 2.85), (0.1, 2.6)],
[SOOT, SOOT, SOOT, SOOT, SOOT], segs=14, loc=(hx, hy, 0)))
for z in (2.46, 2.66):
P.append(cz("pipeband", 0.128, z - 0.02, z + 0.02, hx, hy, IRON, v=14))
P.append(revm("chcap", [(0.06, 2.92), (0.27, 2.94), (0.26, 2.96), (0.13, 3.01), (0, 3.03)], IRON, segs=16, cap_bot=True, loc=(hx, hy, 0)))
for k in range(3):
a = 2 * PI * k / 3 + 0.3
P.append(cyl_between("chstrut", (hx + 0.12 * math.cos(a), hy + 0.12 * math.sin(a), 2.8), (hx + 0.2 * math.cos(a), hy + 0.2 * math.sin(a), 2.945), 0.016, IRON, v=5))
# herbs drying under the front eave
P.append(cx("herbrail", 0.016, -0.7, 0.72, -0.38, 1.8, TIM, v=6))
for k, x in enumerate((-0.62, -0.42, -0.22, -0.02, 0.18, 0.38, 0.6)):
herb_bundle(P, x, -0.38, 1.79, L=0.2 + 0.05 * (k % 3))
# chute (front right, top at the old height)
farm_chute(P, -0.28, -1.0, 0.44, 0.5, XN, legs=(-0.86,), n=5)
# firewood stack + lantern post (front left)
P.append(bx(-0.94, -0.5, -0.6, -0.26, 0.0, 0.08, TIM, bev=0.014, name="woodskid"))
for (x, z) in ((-0.86, 0.15), (-0.72, 0.15), (-0.58, 0.15), (-0.79, 0.275), (-0.65, 0.275), (-0.72, 0.4)):
log(P, x, -0.58, -0.38, z)
P.append(bx(-0.75, -0.67, -0.35, -0.27, 0.08, 1.085, TIM, bev=0.012, name="lamppost"))
P.append(beam((-0.71, -0.31, 0.68), (-0.71, -0.24, 0.84), 0.04, 0.04, name="lpstrut"))
lo = lantern(P, -0.71, -0.31, 1.08)
ffin(P, "Body")
empty("Vent", (hx, hy, 2.86))
empty("Out", (XN, -0.98, 0.5))
return dict(elev=24, azim=-35)
# ======================================================================= brick press: a cast-iron screw press in a timber frame
def threaded(z0, z1, r0=0.078, r1=0.1, step=0.05, m=STL, c=(0, 0)):
prof = []
n = int((z1 - z0) / (step / 2))
for i in range(n + 1):
prof.append((r1 if i % 2 else r0, z0 + i * step / 2))
return revm("screw", prof, m, segs=10, loc=(c[0], c[1], 0))
def cryo_press():
P = []
farm_skid(P, -0.95, 0.95, -0.52, 0.95)
ZC0, ZC1 = 1.85, 2.13 # crown beam
# cast-iron bed, brick mould crate full of hay
P.append(bx(-0.64, 0.64, -0.46, 0.46, 0.13, 0.4, IRON, bev=0.05, segs=2, name="bed"))
P.append(box("bedpin", -0.645, 0.645, -0.465, 0.465, 0.22, 0.24, GOLD, bev=0.004, segs=1))
P.append(bx(-0.56, 0.56, -0.43, 0.43, 0.38, 0.44, STL, bev=0.015, name="platen"))
M = 0.4
for rz in (0, PI / 2, PI, -PI / 2):
o = bx(-M, M, -M, -M + 0.05, 0.44, 0.86, TIM, bev=0.012, name="mould")
xf(o, rz=rz)
grain(o, Matrix.Rotation(rz, 3, "Z") @ Vector((1, 0, 0)))
P.append(o)
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
iron_corner(P, sx * M, sy * M, 0.44, 0.86, sx, sy)
for z in (0.56, 0.76):
P.append(box("mband", -M - 0.008, M + 0.008, -M - 0.008, M + 0.008, z - 0.018, z + 0.018, IRON, bev=0.004, segs=1))
hay_heap(P, (0, 0, 0.78), 0.34, 0.34, 0.09, tufts=10)
for (x, y, az) in ((-0.38, -0.4, -PI / 2), (0.26, -0.4, -PI / 2), (0.4, 0.1, 0.0), (-0.4, 0.2, PI)):
tuft(P, x, y, 0.84, L=0.12, n=4, az=az)
# timber portal: paired posts each side, iron bound, with X bracing on the flanks
for s in (-1, 1):
x0, x1 = sorted((s * 0.66, s * 0.93))
fc = "+X" if s > 0 else "-X"
for y0, y1 in ((-0.46, -0.2), (0.24, 0.5)):
P.append(bx(x0, x1, y0, y1, 0.13, ZC0 + 0.02, TIM, bev=0.03, segs=2, name="post"))
for z in (0.5, 1.6):
P.append(box("postband", x0 - 0.006, x1 + 0.006, y0 - 0.006, y1 + 0.006, z - 0.03, z + 0.03, IRON, bev=0.005, segs=1))
rivet(P, ((x0 + x1) / 2, y0 - 0.006, z), (0, -1, 0))
rivet(P, ((x0 + x1) / 2, y1 + 0.006, z), (0, 1, 0))
# centre guide post the press head runs on, rising through the crown as a horn
hx0, hx1 = sorted((s * 0.645, s * 0.86))
P.append(bx(hx0, hx1, -0.12, 0.2, 0.3, 2.5, TIM, bev=0.03, segs=2, name="guidepost"))
P.append(box("hornband", hx0 - 0.006, hx1 + 0.006, -0.126, 0.206, 2.36, 2.42, IRON, bev=0.005, segs=1))
gx0, gx1 = sorted((s * 0.64, s * 0.66))
P.append(box("guide", gx0, gx1, -0.05, 0.13, 0.46, 1.84, STL, bev=0.004, segs=1))
# flank braces between the posts
xb = s * 0.93
for (a, b) in (((-0.2, 0.5), (0.24, 1.6)), ((-0.2, 1.6), (0.24, 0.5))):
P.append(beam((xb, a[0], a[1]), (xb, b[0], b[1]), 0.07, 0.05, bev=0.01, name="fbrace"))
P.append(bx(min(xb, xb - s * 0.1), max(xb, xb - s * 0.1), -0.2, 0.24, 1.0, 1.1, TIM, bev=0.014, name="fbar"))
# crown: a massive beam with a sign board, iron straps and the cast-iron nut block
P.append(bx(-0.97, 0.97, -0.5, 0.56, ZC0, ZC1, TIM, bev=0.04, segs=2, name="crown"))
for x in (-0.82, 0.82):
P.append(box("crownstrap", x - 0.05, x + 0.05, -0.506, 0.566, ZC0 - 0.008, ZC1 + 0.008, IRON, bev=0.006, segs=1))
for dz in (0.06, 0.2):
rivet(P, (x, -0.506, ZC0 + dz), (0, -1, 0), r=0.018)
sb = plate("signboard", 1.16, 0.2, 0.014, RED, r=0.03)
P.append(uv_wall(orient(sb, "-Y", (0, -0.5, (ZC0 + ZC1) / 2))))
sign_text(P, "PRESS", 0.16, INK, (0, -0.517, (ZC0 + ZC1) / 2))
for s in (-1, 1):
hemp_icon(P, (s * 0.46, -0.516, (ZC0 + ZC1) / 2 + 0.01), "-Y", s=0.72, m=GOLD, t=0.006)
P.append(revm("nut", [(0.26, ZC1), (0.26, ZC1 + 0.03), (0.2, ZC1 + 0.07), (0.17, ZC1 + 0.08), (0.11, ZC1 + 0.08)], IRON, segs=8))
bolt_ring(P, 6, 0.22, ZC1 + 0.03, r=0.02, h=0.016, a0=22.5)
P.append(revm("nutcollar", [(0.11, ZC0 - 0.1), (0.2, ZC0 - 0.08), (0.22, ZC0 - 0.03), (0.22, ZC0)], IRON, segs=8))
# lantern on the left horn, a hoist block on the right one
lo = lantern(P, -0.7, 0.05, 2.5)
P.append(cz("hornplate", 0.08, 2.5, 2.52, -0.7, 0.05, IRON, v=8))
P.append(cz("hornplate", 0.08, 2.5, 2.52, 0.74, 0.04, IRON, v=8))
P.append(cz("hoistpin", 0.022, 2.52, 2.6, 0.74, 0.04, STL, v=6))
P.append(cy("hoistwheel", 0.075, 0.0, 0.08, 0.74, 2.62, IRON, v=12, bev=0.008, segs=1))
rope_line(P, ((0.815, 0.04, 2.62), (0.815, 0.04, 1.62)), r=0.012)
# back: a yard stack of finished bricks and bales
for k, (x, y, z, rz) in enumerate(((-0.42, 0.72, 0.135, 0.0), (0.02, 0.72, 0.135, 0.0), (-0.2, 0.72, 0.26, 0.0), (-0.42, 0.72, 0.385, 0.06), (0.04, 0.74, 0.26, 0.5))):
o = rbox("brick", (0.4, 0.3, 0.12), (0, 0, 0), bevel=0.018, segs=1, m="M_Brick")
xf(o, rz=rz, t=(x, y, z + 0.06))
P.append(uv_wall(o))
bale(P, (0.58, 0.74, 0.31), sx=0.5, sy=0.36, sz=0.34, rz=0.04)
rope_coil(P, (-0.72, 0.72, 0.13), r=0.13, turns=4)
# side wheel and pinion on +X, iron on the crank
spoked(P, (0.955, 0.04, 1.3), "X", R=0.3, w=0.05, n=5)
P.append(cx("wheelshaft", 0.03, 0.9, 0.99, 0.04, 1.3, STL, v=8))
P.append(cyl_between("wcrank", (0.985, 0.04, 1.3), (0.985, 0.2, 1.5), 0.012, IRON, v=6))
P.append(cx("wgrip", 0.022, 0.96, 0.998, 0.2, 1.5, PRED, v=8))
# chute (front right)
farm_chute(P, -0.46, -1.0, 0.6, 0.46, 0.5, legs=(-0.86,), n=5)
ffin(P, "Body")
# Press head: moves straight down in game, origin at the bottom centre of the die (same as before). The screw and capstan ride with it.
Q = [bx(-0.56, 0.56, -0.4, 0.4, 1.3, 1.5, IRON, bev=0.05, segs=2, name="head"),
bx(-0.5, 0.5, -0.34, 0.34, 1.48, 1.56, PRED, bev=0.03, segs=2, name="headtop"),
box("headpin", -0.565, 0.565, -0.405, 0.405, 1.385, 1.405, GOLD, bev=0.004, segs=1),
bx(-0.36, 0.36, -0.36, 0.36, 1.24, 1.31, TIM, bev=0.02, segs=2, name="die"),
box("dieshoe", -0.37, 0.37, -0.37, 0.37, 1.235, 1.26, STL, bev=0.006, segs=1),
revm("collar", [(0.17, 1.55), (0.17, 1.6), (0.12, 1.66), (0.09, 1.68)], IRON, segs=10),
uv_wall(threaded(1.66, 2.5)),
cz("capshaft", 0.095, 2.5, 2.57, m=STL, v=10),
cz("caphub", 0.12, 2.56, 2.66, m=IRON, v=12, bev=0.02, segs=1)]
for s in (-1, 1):
Q.append(bx(s * 0.6 - 0.04, s * 0.6 + 0.04, -0.13, 0.13, 1.28, 1.52, IRON, bev=0.015, name="shoe"))
for a in (0.6, 0.6 + PI):
ca, sa = math.cos(a), math.sin(a)
Q.append(cyl_between("capbar", (0, 0, 2.61), (0.56 * ca, 0.56 * sa, 2.61), 0.03, IRON, v=8))
Q.append(sphere("capball", 0.07, (0.56 * ca, 0.56 * sa, 2.61), seg=10, rings=6, m=PRED))
for k in range(4):
aa = PI / 4 + k * PI / 2
Q.append(cyl_between("boltcap", (0.24 * math.cos(aa), 0.24 * math.sin(aa), 1.56), (0.24 * math.cos(aa), 0.24 * math.sin(aa), 1.58), 0.02, STL, v=6))
fpart(Q, "Press", (0, 0, 1.24))
empty("Out", (0.5, -0.98, 0.46))
return dict(elev=24, azim=-35)
# ======================================================================= edge mower: the cutter arm reaching down into the meadow
def edge_mower():
P = []
# timber sled (1 x 2) + iron hook clamped over the front edge of the deck
for s in (-1, 1):
x0, x1 = sorted((s * 0.34, s * 0.47))
P.append(bx(x0, x1, -0.97, 0.95, 0.0, 0.1, TIM, bev=0.022, segs=2, name="runner"))
for k in range(7):
y = -0.92 + k * 0.3
P.append(bx(-0.47, 0.47, y - 0.09, y + 0.09, 0.08, 0.115, DECK, bev=0.008, name="plank"))
P.append(bx(-0.32, 0.32, -1.04, -0.97, -0.34, 0.12, IRON, bev=0.02, name="clamp"))
P.append(box("clamppad", -0.28, 0.28, -1.045, -1.03, -0.3, -0.14, LEA, bev=0.006, segs=1))
for x in (-0.22, 0.22):
bolt(P, (x, -1.04, 0.0), "-Y", r=0.022, h=0.014)
for (x, y) in ((-0.4, -0.9), (0.4, -0.9), (-0.4, 0.88), (0.4, 0.88)):
bolt(P, (x, y, 0.115), "+Z", r=0.02, m=IRON)
# clippings bin at the back: a slatted crate heaped with cut grass
Y0, Y1 = 0.42, 0.93
P.append(uv_wall(bx(-0.42, 0.42, Y0, Y1, 0.115, 0.7, RED, bev=0.02, segs=2, name="bin")))
for z in (0.17, 0.66):
P.append(box("binband", -0.428, 0.428, Y0 - 0.008, Y1 + 0.008, z - 0.03, z + 0.03, TIM, bev=0.006, segs=1))
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
iron_corner(P, sx * 0.428, (Y1 + 0.008) if sy > 0 else (Y0 - 0.008), 0.12, 0.7, sx, sy)
hay_heap(P, (0, (Y0 + Y1) / 2, 0.68), 0.38, 0.24, 0.17, m=CLIP, tufts=0)
for k in range(9):
tuft(P, random.uniform(-0.3, 0.3), random.uniform(Y0 + 0.06, Y1 - 0.06), 0.78, L=0.14, n=4, m=random.choice((LEAF, LEAFD)), r=0.016)
# small upright engine + twin flywheels between the bin and the hinge
EY, AXZ = 0.18, 0.42
P.append(bx(-0.2, 0.2, EY - 0.17, EY + 0.17, 0.11, 0.66, GRN, bev=0.04, segs=2, name="crankcase"))
P.append(box("casepin", -0.205, 0.205, EY - 0.175, EY + 0.175, 0.2, 0.22, GOLD, bev=0.003, segs=1))
P.append(cz("cylinder", 0.14, 0.66, 0.96, 0, EY, IRON, v=14))
for k in range(5):
P.append(cz("cfin", 0.178, 0.69 + k * 0.05, 0.712 + k * 0.05, 0, EY, IRON, v=14))
P.append(cz("cylhead", 0.15, 0.95, 1.03, 0, EY, PRED, v=14, bev=0.016, segs=1))
P.append(cx("axle", 0.04, -0.42, 0.42, EY, AXZ, STL, v=10))
for s in (-1, 1):
spoked(P, (s * 0.355, EY, AXZ), "X", R=0.3, w=0.075, n=6, spoke=IRON, hub=IRON)
# exhaust stack and tin fuel can
P.append(cz("stack", 0.04, 0.95, 1.27, 0.0, EY - 0.17, IRON, v=10))
P.append(cyl_between("stackbend", (0, EY - 0.17, 0.92), (0, EY - 0.06, 0.88), 0.04, IRON, v=10))
P.append(revm("stackcap", [(0.04, 1.26), (0.07, 1.28), (0.075, 1.31), (0.05, 1.325), (0, 1.33)], SOOT, segs=10, loc=(0, EY - 0.17, 0)))
P.append(cy("fuelcan", 0.075, EY + 0.05, EY + 0.3, 0.0, 1.1, TIN, v=12, bev=0.012, segs=1))
P.append(box("fuelstrap", -0.09, 0.09, EY + 0.15, EY + 0.18, 1.02, 1.1, IRON, bev=0.004, segs=1))
# boom: A-frame mast at the hinge, two laminated timber arms bent at an iron knee, down to the cutter deck
ZH = 0.42
YC, ZC = -1.62, -0.96 # cutter centre (over the meadow, the deck edge is at y = -1)
P.append(bx(-0.2, 0.2, -0.3, 0.0, 0.11, ZH + 0.14, IRON, bev=0.03, segs=2, name="hinge"))
P.append(cx("pivot", 0.07, -0.24, 0.24, -0.15, ZH, STL, v=14))
KY, KZ = -1.12, 0.62
EY_, EZ_ = YC + 0.02, ZC + 0.2
for s in (-1, 1):
x = s * 0.13
P.append(beam((x, -0.15, ZH), (x, KY, KZ), 0.075, 0.11, bev=0.016, over=0.04, name="boom"))
P.append(beam((x, KY, KZ), (x, EY_, EZ_), 0.075, 0.11, bev=0.016, over=0.04, name="boom"))
P.append(beam((x, -0.55, ZH + 0.1), (x, -1.3, 0.1), 0.05, 0.06, bev=0.008, name="boomstrut"))
kp = prism("kneeplate", [(KY - 0.17, KZ - 0.12), (KY + 0.18, KZ - 0.1), (KY + 0.18, KZ + 0.07), (KY + 0.02, KZ + 0.13), (KY - 0.14, KZ + 0.06)], "YZ", x + s * 0.0375 - 0.005, x + s * 0.0375 + 0.005, IRON)
P.append(kp)
for (dy, dz) in ((-0.08, -0.05), (0.1, 0.0), (0.02, 0.07)):
rivet(P, (x + s * 0.043, KY + dy, KZ + dz), (s, 0, 0), r=0.016, h=0.008)
for (y, z) in ((-0.55, ZH + 0.1), (KY, KZ), (-1.42, -0.3)):
P.append(cx("crossbar", 0.03, -0.17, 0.17, y, z, IRON, v=8))
# mast and stay rope
for s in (-1, 1):
P.append(beam((s * 0.17, -0.2, 0.11), (0, -0.28, 1.08), 0.06, 0.06, bev=0.01, name="mast"))
P.append(cy("mastblock", 0.04, -0.32, -0.24, 0, 1.08, IRON, v=8))
rope_line(P, ((0, -0.28, 1.08), (0, KY, KZ + 0.1)), r=0.012, sag=0.03)
# belt drive along the arms
P.append(cx("hpulley", 0.1, -0.05, 0.05, -0.15, ZH, IRON, v=14))
P.append(flat_belt("drive1", 0.0, (-0.15, ZH), 0.1, (KY, KZ), 0.09, w=0.05, t=0.012))
P.append(cx("kpulley", 0.09, -0.05, 0.05, KY, KZ, PRED, v=14))
P.append(flat_belt("drive2", 0.0, (KY, KZ), 0.09, (YC + 0.05, ZC + 0.34), 0.07, w=0.05, t=0.012))
P.append(cx("gpulley", 0.07, -0.05, 0.05, YC + 0.05, ZC + 0.34, PRED, v=14))
P.append(bx(-0.07, 0.07, YC - 0.04, YC + 0.12, ZC + 0.22, ZC + 0.4, IRON, bev=0.02, name="gearbox"))
# cutter deck: tin dome with a red rim, the blade disc spins underneath
P.append(revm("guard", [(0.0, ZC + 0.24), (0.2, ZC + 0.23), (0.4, ZC + 0.17), (0.5, ZC + 0.08), (0.53, ZC + 0.02), (0.53, ZC - 0.02)],
[TIN, TIN, PRED, PRED, PRED], segs=32, loc=(0, YC, 0)))
P.append(revm("guardin", [(0.52, ZC - 0.02), (0.48, ZC + 0.06), (0.36, ZC + 0.14), (0.1, ZC + 0.19), (0.0, ZC + 0.195)], IRON, segs=24, loc=(0, YC, 0)))
P.append(torus("skirt", 0.53, 0.028, (0, YC, ZC - 0.02), "Z", seg=32, rseg=5, m=IRON))
for k in range(12):
a = 2 * PI * (k + 0.5) / 12
rivet(P, (0.525 * math.cos(a), YC + 0.525 * math.sin(a), ZC + 0.025), (math.cos(a), math.sin(a), 0.2), r=0.016, h=0.01)
for k in range(10):
a = 2 * PI * k / 10
P.append(arc_band("gdash", 0.42, 0.47, ZC + 0.135, ZC + 0.155, math.degrees(a) + 4, math.degrees(a) + 20, INK, segs=2, c=(0, YC)))
# tin blower pipe carrying the clippings back up to the bin, in sections with iron collars
duct = rpath([(0.32, YC + 0.1, ZC + 0.2), (0.32, YC + 0.3, ZC + 0.62), (0.4, -1.22, 0.3), (0.38, -0.9, 0.62), (0.38, 0.0, 0.92), (0.3, Y0 + 0.14, 0.92), (0.3, Y0 + 0.14, 0.76)], 0.16, 4)
P.append(uv_wall(ptube("duct", duct, 0.062, TIN, segs=10)))
for k in range(3, len(duct) - 2, 4):
d_ = (duct[k + 1] - duct[k - 1])
P.append(cyl_between("ductband", duct[k] - d_.normalized() * 0.02, duct[k] + d_.normalized() * 0.02, 0.07, IRON, v=10))
ffin(P, "Body")
# Rotor: the blade disc (spins about its vertical axis), origin at its hub
Q = [cz("hub", 0.07, ZC - 0.01, ZC + 0.06, 0, YC, IRON, v=14, bev=0.01, segs=1),
cz("disc", 0.3, ZC - 0.005, ZC + 0.015, 0, YC, STL, v=24)]
for k in range(3):
bl = prism("blade", [(0.08, -0.05), (0.46, -0.05), (0.49, -0.02), (0.49, 0.03), (0.44, 0.045), (0.08, 0.05)], "XY", -0.008, 0.008, BLADE)
xf(bl, rx=0.06)
xf(bl, rz=k * 2 * PI / 3, t=(0, YC, ZC + 0.005))
Q.append(bl)
tip = prism("btip", [(0.4, -0.05), (0.49, -0.02), (0.49, 0.03), (0.4, 0.045)], "XY", -0.009, 0.009, PRED)
xf(tip, rz=k * 2 * PI / 3, t=(0, YC, ZC + 0.005))
Q.append(tip)
fpart(Q, "Rotor", (0, YC, ZC), wn=False)
return dict(elev=14, azim=-60)
# ======================================================================= launcher: a low timber catapult pitcher
def launcher():
P = []
# crib: runners, deck planks, heavy end beams
for s in (-1, 1):
x0, x1 = sorted((s * 0.38, s * 0.5))
P.append(bx(x0, x1, -0.5, 0.5, 0.0, 0.14, TIM, bev=0.022, segs=2, name="runner"))
for k in range(5):
y = -0.4 + k * 0.2
P.append(bx(-0.46, 0.46, y - 0.092, y + 0.092, 0.12, 0.165, DECK, bev=0.008, name="plank"))
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
iron_corner(P, sx * 0.5, sy * 0.5, 0.012, 0.13, sx, sy, w=0.09, t=0.006)
# the throwing arm beds on a timber saddle with leather stops at the front
P.append(bx(-0.3, 0.3, -0.12, 0.12, 0.16, 0.25, TIM, bev=0.02, name="saddle"))
P.append(box("saddlepad", -0.26, 0.26, -0.09, 0.09, 0.245, 0.262, BUR, bev=0.006, segs=1))
for s in (-1, 1):
P.append(bx(s * 0.36 - 0.05, s * 0.36 + 0.05, -0.46, -0.38, 0.16, 0.29, TIM, bev=0.014, name="stop"))
P.append(box("stoppad", s * 0.36 - 0.045, s * 0.36 + 0.045, -0.455, -0.385, 0.285, 0.298, LEA, bev=0.004, segs=1))
# torsion skein at the hinge: rope wound round the axle between the hinge blocks
for s in (-1, 1):
P.append(bx(s * 0.385 - 0.055, s * 0.385 + 0.055, 0.4, 0.5, 0.14, 0.34, TIM, bev=0.018, name="hblock"))
P.append(bx(s * 0.08 - 0.03, s * 0.08 + 0.03, 0.42, 0.5, 0.14, 0.31, TIM, bev=0.012, name="hblock"))
for k in range(5):
P.append(torus("skein", 0.05 + 0.008 * (k % 2), 0.018, (0, 0, 0), "X", seg=10, rseg=4, m=ROPE))
xf(P[-1], t=(s * (0.13 + k * 0.038), 0.425, 0.262))
P.append(grain(cx("hpin", 0.022, -0.47, 0.47, 0.46, 0.3, STL, v=10), (1, 0, 0)))
# catapult cheeks: triangular timber uprights at both sides of the back
PK = 0.6
for s in (-1, 1):
x = s * 0.47
P.append(beam((x, 0.42, 0.13), (x, 0.42, PK), 0.056, 0.09, bev=0.012, name="cheek"))
P.append(beam((x, -0.12, 0.13), (x, 0.42, PK - 0.03), 0.056, 0.07, bev=0.012, name="cheekstrut"))
P.append(bx(x - 0.03, x + 0.03, 0.37, 0.47, PK - 0.02, PK + 0.03, IRON, bev=0.01, name="cheekcap"))
P.append(box("cheekband", x - 0.031, x + 0.031, 0.372, 0.468, 0.39, 0.45, IRON, bev=0.004, segs=1))
rivet(P, (s * 0.498, 0.42, 0.24), (s, 0, 0), r=0.012, h=0.006)
ffin(P, "Body")
# Plate: hinged at the back, planks along the throw, chevrons point the way
X = 0.43
Q = []
for k in range(6):
x0 = -X + 2 * X * k / 6
x1 = -X + 2 * X * (k + 1) / 6
Q.append(bx(x0 + 0.003, x1 - 0.003, -0.46, 0.424, 0.3, 0.356, RED if k in (0, 5) else TIM, bev=0.01, name="pplank"))
for y in (-0.3, 0.0, 0.3):
Q.append(bx(-X - 0.004, X + 0.004, y - 0.03, y + 0.03, 0.27, 0.302, TIM, bev=0.008, name="prib"))
Q.append(box("frontlip", -X - 0.006, X + 0.006, -0.468, -0.43, 0.296, 0.372, IRON, bev=0.006, segs=1))
for s in (-1, 1):
Q.append(box("sidelip", s * X - 0.012, s * X + 0.012, -0.45, 0.42, 0.34, 0.372, IRON, bev=0.005, segs=1))
Q.append(cx("knuckle", 0.04, s * 0.24 - 0.085, s * 0.24 + 0.085, 0.46, 0.3, IRON, v=12, bev=0.006, segs=1))
Q.append(box("hingestrap", s * 0.24 - 0.04, s * 0.24 + 0.04, 0.1, 0.45, 0.352, 0.362, IRON, bev=0.003, segs=1))
for y in (0.15, 0.3):
rivet(Q, (s * 0.24, y, 0.362), (0, 0, 1), r=0.014, h=0.006)
for yb in (0.33, 0.09, -0.15):
chevron_flat(Q, yb, 0.29, 0.13, 0.075, 0.352, 0.361)
fpart(Q, "Plate", (0, 0.46, 0.3))
return dict(elev=22, azim=-35)
# ======================================================================= drone pad: a wooden perch
def drone_pad():
P = []
# plank platform on a timber kerb
for k in range(8):
y = -0.42 + k * 0.12
P.append(bx(-0.44, 0.44, y - 0.057, y + 0.057, 0.07, 0.122, DECK, bev=0.008, name="plank"))
for rz in (0, PI / 2, PI, -PI / 2):
o = bx(-0.475, 0.475, -0.475, -0.42, 0.0, 0.124, TIM, bev=0.016, name="kerb")
xf(o, rz=rz)
grain(o, Matrix.Rotation(rz, 3, "Z") @ Vector((1, 0, 0)))
P.append(o)
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
iron_corner(P, sx * 0.475, sy * 0.475, 0.012, 0.11, sx, sy, w=0.08, t=0.006)
# painted ring + leaf + drop chevrons toward the front
cy_ = 0.05
P.append(arc_band("ring", 0.245, 0.29, 0.12, 0.128, 0, 360, INK, segs=32, c=(0, cy_)))
P.append(prism("leafpaint", leaf_pts(0.1, 0, cy_ - 0.09, h=1.9, n=8), "XY", 0.12, 0.128, GRN))
chevron_flat(P, -0.265, 0.13, 0.045, 0.035, 0.12, 0.128)
chevron_flat(P, -0.335, 0.13, 0.045, 0.035, 0.12, 0.128)
# corner marker lamps on pegs
for (sx, sy) in ((1, -1), (-1, -1), (-1, 1)):
x, y = sx * 0.37, sy * 0.37
P.append(cz("peg", 0.036, 0.12, 0.14, x, y, IRON, v=8))
P.append(revm("light", [(0.028, 0.14), (0.026, 0.155), (0.015, 0.167), (0, 0.17)], "M_Emissive", segs=8, loc=(x, y, 0)))
# the perch: a stout post at the back corner with a cross arm, a nest box and a burlap sock
px, py = 0.42, 0.42
P.append(bx(px - 0.06, px + 0.06, py - 0.06, py + 0.06, 0.12, 0.17, IRON, bev=0.012, name="flange"))
P.append(beam((px, py, 0.14), (px, py, 1.1), 0.075, 0.075, bev=0.012, name="pole"))
P.append(beam((px - 0.36, py, 0.96), (px + 0.03, py, 0.96), 0.05, 0.05, bev=0.01, name="perch"))
P.append(beam((px, py, 0.76), (px - 0.2, py, 0.95), 0.04, 0.04, bev=0.008, name="perchbrace"))
P.append(cx("perchend", 0.03, px - 0.38, px - 0.36, py, 0.96, IRON, v=8))
# little dovecote box on the post
nx = px - 0.06
P.append(bx(nx - 0.11, nx + 0.11, py - 0.11, py + 0.03, 0.42, 0.66, CRM, bev=0.012, name="nestbox"))
a = prism("nesthole", wood_arch("h", nx, 0.47, 0.1, 0.15), "XZ", py - 0.117, py - 0.106, IRON)
P.append(a)
P.append(cy("nestperch", 0.012, py - 0.18, py - 0.11, nx, 0.45, TIM, v=6))
roof_ridge_x(P, nx - 0.14, nx + 0.14, py - 0.15, py + 0.07, 0.65, 0.74, m=RED, t=0.02)
# windsock on the cross arm: burlap and red hoops
sx0 = px - 0.2
xs = [sx0, sx0 - 0.075, sx0 - 0.15, sx0 - 0.225]
rs = [0.052, 0.045, 0.038, 0.03]
zs = [0.89, 0.875, 0.855, 0.83]
P.append(cz("sockhang", 0.006, 0.92, 0.96, sx0, py, IRON, v=4))
P.append(torus("sockring", 0.05, 0.007, (sx0, py, 0.89), "X", seg=12, rseg=4, m=IRON))
for k in range(3):
o = cyl_between("sock", (xs[k], py, zs[k]), (xs[k + 1], py, zs[k + 1]), rs[k], PRED if k % 2 == 0 else INK, v=10, r2=rs[k + 1])
P.append(o)
lo = lantern(P, px, py, 1.1, m="M_Emissive", r=0.056)
tuft(P, -0.34, 0.3, 0.125, L=0.1, n=4)
tuft(P, 0.22, -0.4, 0.125, L=0.08, n=3)
ffin(P, "Body")
return dict(elev=30, azim=-35)
# ======================================================================= drone hub: a landing deck in front of a dovecote loft
def drone_hub():
P = []
# timber base and plank landing deck
for s in (-1, 1):
P.append(bx(min(s * 0.95, s * 0.8), max(s * 0.95, s * 0.8), -0.95, 0.95, 0.0, 0.11, TIM, bev=0.022, segs=2, name="runner"))
for y in (-0.8, -0.2, 0.4):
P.append(bx(-0.84, 0.84, y - 0.07, y + 0.07, 0.04, 0.16, TIM, bev=0.016, name="bearer"))
n = 11
YD0, YD1 = -0.95, 0.66
for k in range(n):
y0 = YD0 + (YD1 - YD0) * k / n
y1 = YD0 + (YD1 - YD0) * (k + 1) / n
P.append(bx(-0.95, 0.95, y0 + 0.004, y1 - 0.004, 0.16, 0.22, DECK, bev=0.01, name="plank"))
for x in (-0.86, 0.86):
P.append(box("deckstrap", x - 0.03, x + 0.03, YD0, YD1, 0.218, 0.224, IRON, bev=0.002, segs=1))
# landing ring, cream paint, chevrons to the centre
P.append(arc_band("ring", 0.62, 0.68, 0.219, 0.226, 0, 360, INK, segs=40))
for k in range(4):
a = math.radians(45 + 90 * k)
ch = prism("chev", chevron_down(0, 0.0, 0.08, 0.07, 0.04), "XY", 0.219, 0.226, GOLD)
xf(ch, rz=a - PI / 2, t=(0.47 * math.cos(a), 0.47 * math.sin(a), 0))
P.append(ch)
# iron unloading grate in the centre with a leaf cast in it
P.append(revm("hatchring", [(0.3, 0.22), (0.3, 0.232), (0.27, 0.236), (0.24, 0.228), (0.24, 0.2)], IRON, segs=24))
P.append(cz("hatchpit", 0.24, 0.195, 0.2, m=SOOT, v=20))
for rr in (0.2, 0.12):
P.append(torus("grate", rr, 0.01, (0, 0, 0.215), "Z", seg=18, rseg=4, m=IRON))
for k in range(4):
b = box("gbar", -0.235, 0.235, -0.012, 0.012, 0.204, 0.226, IRON, bev=0)
xf(b, rz=k * PI / 4)
P.append(b)
P.append(prism("leafcast", leaf_pts(0.05, 0, -0.04, n=8), "XY", 0.222, 0.232, GOLD))
# dovecote loft along the back edge: cream boards, two rows of arched pigeon holes, tin roof
LY0, LY1 = 0.66, 0.95
ZL, ZE, ZR = 0.22, 1.0, 1.26
P.append(uv_wall(bx(-0.93, 0.93, LY0, LY1, ZL - 0.02, ZE, CRM, bev=0.016, name="loft")))
for x in (-0.93, 0.93):
P.append(bx(x - 0.05, x + 0.05, LY0 - 0.03, LY0 + 0.05, ZL - 0.02, ZE + 0.02, TIM, bev=0.014, name="corner"))
P.append(bx(x - 0.05, x + 0.05, LY1 - 0.05, LY1, ZL - 0.02, ZE + 0.02, TIM, bev=0.014, name="corner"))
for z in (ZL + 0.02, 0.6):
P.append(bx(-0.9, 0.9, LY0 - 0.03, LY0 + 0.006, z - 0.03, z + 0.03, RED, bev=0.01, name="ledge"))
P.append(bx(-0.9, 0.9, LY0 - 0.03, LY0 + 0.006, ZE - 0.05, ZE + 0.0, TIM, bev=0.01, name="plate"))
for row, (z, nh) in enumerate(((0.3, 5), (0.66, 5))):
for k in range(nh):
x = -0.68 + 1.36 * k / (nh - 1)
P.append(prism("archframe", wood_arch("f", x, z, 0.235, 0.27), "XZ", LY0 - 0.014, LY0 + 0.004, RED))
P.append(prism("archhole", wood_arch("h", x, z + 0.012, 0.17, 0.22), "XZ", LY0 - 0.02, LY0 - 0.01, IRON))
P.append(grain(cy("peg", 0.012, LY0 - 0.09, LY0 - 0.01, x, z + 0.0, TIM, v=6), (0, 1, 0)))
roof_ridge_x(P, -1.0 + 0.02, 1.0 - 0.02, LY0 - 0.08, LY1 + 0.0, ZE - 0.02, ZR - 0.005, t=0.04)
for x, s in ((-0.93, -1), (0.93, 1)):
o = prism("gable", [(LY0, ZE), (LY1, ZE), ((LY0 + LY1) / 2, ZR - 0.05)], "YZ", x - 0.03, x + 0.03, RED)
P.append(uv_wall(o))
# dove tower on the ridge: little arched lantern with a pointed tin cap and a vane
TY = (LY0 + LY1) / 2 - 0.04
P.append(bx(-0.17, 0.17, TY - 0.15, TY + 0.15, ZR - 0.1, ZR + 0.2, CRM, bev=0.012, name="tower"))
P.append(bx(-0.185, 0.185, TY - 0.165, TY + 0.165, ZR + 0.19, ZR + 0.225, TIM, bev=0.01, name="towercap"))
for x in (-0.085, 0.085):
P.append(prism("towerarch", wood_arch("t", x, ZR + 0.0, 0.1, 0.17, n=4), "XZ", TY - 0.158, TY - 0.146, IRON))
P.append(revm("towerroof", [(0.24, ZR + 0.215), (0.0, ZR + 0.45)], RED, segs=4, a0=45, a1=405, loc=(0, TY, 0)))
P.append(cz("vanepost", 0.01, ZR + 0.42, ZR + 0.56, 0, TY, IRON, v=5))
P.append(cy("vanebar", 0.008, TY - 0.13, TY + 0.13, 0, ZR + 0.53, IRON, v=5))
P.append(prism("vanetail", [(TY + 0.08, ZR + 0.505), (TY + 0.15, ZR + 0.49), (TY + 0.15, ZR + 0.57), (TY + 0.08, ZR + 0.555)], "YZ", -0.005, 0.005, PRED))
P.append(sphere("vanebird", 0.03, (0, TY - 0.12, ZR + 0.54), seg=8, rings=5, m=INK, scale=(0.8, 1.5, 0.9)))
# rope rail round the front corners, hay and a sack
for (x, y) in ((-0.88, -0.88), (0.88, -0.88), (-0.88, 0.55), (0.88, 0.55)):
P.append(beam((x, y, 0.2), (x, y, 0.52), 0.07, 0.07, bev=0.012, name="rpost"))
P.append(cz("rpostcap", 0.046, 0.52, 0.545, x, y, IRON, v=8, bev=0.006, segs=1))
for (a, b) in (((-0.88, -0.88), (-0.88, 0.55)), ((0.88, -0.88), (0.88, 0.55))):
rope_line(P, ((a[0], a[1], 0.5), (b[0], b[1], 0.5)), r=0.016, sag=0.07)
tuft(P, -0.74, -0.8, 0.22, L=0.1, n=4)
tuft(P, 0.78, 0.3, 0.22, L=0.1, n=4)
sack(P, (0.74, -0.74, 0.22), r=0.11, h=0.22, rz=0.7)
ffin(P, "Body")
empty("Land", (0, 0, 0.22))
return dict(elev=32, azim=-35)
# ======================================================================= cargo drone: tin-and-timber crop duster
def prop_blade(L, w, tip_m, wood=TIM, pitch=0.22, r0=0.02):
"""One wooden propeller blade along +X from the hub."""
pts = [(r0, -w * 0.55), (L * 0.55, -w), (L * 0.9, -w * 0.7), (L, -w * 0.15), (L, w * 0.3), (L * 0.85, w * 0.65), (r0, w * 0.55)]
o = prism("blade", pts, "XY", -0.0065, 0.0065, wood)
grain(o, (1, 0, 0))
tip = prism("btip", [(L * 0.78, -w * 0.88), (L * 0.9, -w * 0.72), (L, -w * 0.16), (L, w * 0.31), (L * 0.85, w * 0.67), (L * 0.78, w * 0.7)], "XY", -0.0072, 0.0072, tip_m)
return [xf(o, rx=pitch), xf(tip, rx=pitch)]
DRONE_C = [(-0.3, -0.3), (0.3, -0.3), (0.3, 0.3), (-0.3, 0.3)] # Rotor0..3, same corners as before
RZ = 0.125 # rotor hub plane
def drone():
P = []
# fuselage: tin barrel along Y, red nose cowl, cream tail cone
prof = [(0, -0.245), (0.075, -0.24), (0.115, -0.2), (0.132, -0.15), (0.14, -0.08), (0.14, 0.09), (0.125, 0.16), (0.09, 0.215), (0.04, 0.24), (0, 0.245)]
f = revm("fuselage", prof, [PRED, PRED, PRED, TIN, TIN, TIN, INK, INK, INK], segs=18)
xf(f, rx=-PI / 2, s=(1.32, 1.0, 1.0))
f.scale = (1, 1, 1)
uv_cyl(f, 1, circ_scale=3.0, len_scale=1.0)
P.append(uv_keep(f))
for y in (-0.15, 0.1):
o = torus("hoop", 0.139, 0.012, (0, 0, 0), "Y", seg=18, rseg=4, m=IRON)
xf(o, t=(0, y, 0), s=(1.32, 1.0, 1.0))
P.append(o)
# goggle eyes on the cowl
for s in (-1, 1):
G = [revm("gog", [(0.0, 0.0), (0.05, 0.0), (0.058, 0.014), (0.05, 0.028), (0.04, 0.022), (0.0, 0.022)], ["M_Brass"] * 3 + ["M_Brass"] * 2, segs=14),
cyl("eye", 0.036, 0.012, (0, 0, 0.022), "Z", verts=14, m="M_Emissive"),
sphere("pupil", 0.02, (s * 0.006, 0.004, 0.028), seg=8, rings=5, m="M_Pupil", scale=(1, 1, 0.3))]
for o in G:
xf(o, rx=PI / 2 + 0.16, rz=s * 0.34, t=(s * 0.092, -0.242, 0.034))
P.append(o)
# tail fin + stubby tailplane
P.append(prism("fin", [(0.1, 0.09), (0.3, 0.2), (0.345, 0.2), (0.3, 0.08), (0.22, 0.05)], "YZ", -0.012, 0.012, PRED, bev=0.004))
P.append(prism("finstripe", [(0.25, 0.145), (0.323, 0.17), (0.315, 0.125), (0.24, 0.1)], "YZ", -0.0135, 0.0135, INK))
P.append(beam((-0.17, 0.26, 0.02), (0.17, 0.26, 0.02), 0.055, 0.016, TIM, bev=0.005, name="tailplane"))
# timber keel, cross spars lashed to it, tin motor cans
P.append(bx(-0.05, 0.05, -0.17, 0.19, -0.145, -0.1, TIM, bev=0.012, name="keel"))
for (mx, my) in DRONE_C:
sx, sy = (1 if mx > 0 else -1), (1 if my > 0 else -1)
P.append(beam((sx * 0.08, sy * 0.08, 0.0), (mx, my, 0.03), 0.05, 0.036, bev=0.01, over=0.02, name="spar"))
rope_band(P, (sx * 0.15, sy * 0.15, 0.012), (sx, sy, 0.1), 0.04, n=3, t=0.008)
P.append(cz("can", 0.056, 0.0, 0.092, mx, my, TIN, v=12, bev=0.012, segs=1))
P.append(cz("canband", 0.058, 0.03, 0.05, mx, my, PRED, v=12))
P.append(cz("cancap", 0.036, 0.09, 0.106, mx, my, IRON, v=10, bev=0.004, segs=1))
P.append(cz("shaft", 0.012, 0.1, 0.122, mx, my, STL, v=6))
P.append(sphere("canbot", 0.05, (mx, my, 0.0), seg=10, rings=4, m=IRON, scale=(1, 1, 0.45)))
# sled skids
for s in (-1, 1):
x = s * 0.15
P.append(beam((x, -0.2, -0.178), (x, 0.16, -0.178), 0.03, 0.026, bev=0.008, name="skid"))
P.append(beam((x, -0.2, -0.178), (x, -0.235, -0.14), 0.03, 0.026, bev=0.008, name="skidtip"))
for y in (-0.1, 0.1):
P.append(beam((x, y, -0.178), (s * 0.05, y * 0.8, -0.12), 0.024, 0.024, IRON, bev=0.005, name="skidstrut"))
# rope winch under the belly (the claw hangs at z = -0.13)
P.append(cz("winch", 0.042, -0.145, -0.125, 0, 0, IRON, v=12, bev=0.005, segs=1))
lo = lantern(P, 0.0, 0.06, 0.125, m="M_Emissive", r=0.044)
ffin(P, "Body", uv=1.0)
# rotors: two-blade wooden props, red tips
for i, (mx, my) in enumerate(DRONE_C):
R = [cz("hub", 0.032, -0.012, 0.012, m=IRON, v=12, bev=0.006, segs=1),
revm("spinner", [(0.026, 0.012), (0.022, 0.028), (0.012, 0.036), (0, 0.038)], "M_Brass", segs=10)]
for s in (0, PI):
for o in prop_blade(0.168, 0.03, PRED):
g_ = o.get("grain")
xf(o, rz=s + i * PI / 4)
if g_ is not None:
grain(o, (math.cos(s + i * PI / 4), math.sin(s + i * PI / 4), 0))
R.append(o)
ro = ffin(R, "Rotor%d" % i, uv=2.0, wn=False)
xf(ro, t=(mx, my, RZ))
set_origin(ro, (mx, my, RZ))
# claw: rope and a block with three iron hay hooks. Origin at the top attach point
C = [cz("cable", 0.012, -0.22, -0.14, m=ROPE, v=8),
cz("swivel", 0.022, -0.155, -0.13, m=IRON, v=10),
cz("block", 0.05, -0.258, -0.213, m=TIM, v=12, bev=0.012, segs=1),
cz("blockcap", 0.036, -0.27, -0.256, m=IRON, v=10)]
for k in range(3):
a = math.radians(k * 120 + 60)
sa, ca = math.sin(a), math.cos(a)
pts = [(0.038 * ca, 0.038 * sa, -0.245), (0.078 * ca, 0.078 * sa, -0.285), (0.068 * ca, 0.068 * sa, -0.33), (0.034 * ca, 0.034 * sa, -0.35)]
C.append(ptube("prong", rpath(pts, 0.03, 3), 0.012, IRON, segs=5))
C.append(sphere("knuckle", 0.018, pts[0], seg=8, rings=4, m=STL))
C.append(sphere("ptip", 0.013, pts[-1], seg=6, rings=3, m=PRED))
fpart(C, "Claw", (0, 0, -0.13), uv=4.0, wn=False)
return dict(elev=30, azim=-35)
# ======================================================================= mowing drone: tin-and-timber crop duster with a grass sack
DRONE_R = [(-1, -1), (1, -1), (1, 1), (-1, 1)] # Rotor_1 front-left, Rotor_2 front-right, Rotor_3 back-right, Rotor_4 back-left
DM = 0.4
def rain_drone():
P = []
# pod: tin belly, red cowl, iron seam, timber hatch
prof = [(0.0, 0.21), (0.15, 0.215), (0.24, 0.25), (0.29, 0.31), (0.305, 0.37), (0.3, 0.43), (0.27, 0.5), (0.2, 0.56), (0.1, 0.595), (0.0, 0.605)]
pod = revm("pod", prof, [PRED, PRED, PRED, PRED, TIN, TIN, TIN, TIN, TIN], segs=24)
uv_cyl(pod, 2, circ_scale=5.0, len_scale=1.0)
P.append(uv_keep(pod))
P.append(torus("seam", 0.306, 0.012, (0, 0, 0.37), "Z", seg=24, rseg=3, m=IRON))
P.append(revm("hatch", [(0.15, 0.585), (0.155, 0.6), (0.14, 0.615), (0.0, 0.62)], TIM, segs=16))
P.append(cz("hatchknob", 0.022, 0.615, 0.65, m=IRON, v=8))
P.append(arc_band("stripe", 0.298, 0.308, 0.4, 0.43, -50, 230, PRED, segs=18))
for k in range(10):
a = 2 * PI * (k + 0.5) / 10
rivet(P, (0.296 * math.cos(a), 0.296 * math.sin(a), 0.33), (math.cos(a), math.sin(a), -0.1), r=0.012, h=0.008)
# big friendly eye with a brass bezel
E = [revm("eyebez", [(0.0, -0.02), (0.13, -0.02), (0.15, 0.0), (0.15, 0.03), (0.13, 0.05), (0.115, 0.045), (0.11, 0.03)], "M_Brass", segs=20),
revm("eyelens", [(0.11, 0.025), (0.1, 0.05), (0.07, 0.07), (0.0, 0.078)], "M_Pupil", segs=20),
torus("iris", 0.075, 0.011, (0, 0, 0.066), "Z", seg=20, rseg=4, m="M_LightBlue"),
sphere("glint", 0.022, (-0.035, 0.04, 0.072), seg=8, rings=4, m="M_EyeWhite"),
sphere("glint", 0.01, (0.035, -0.03, 0.074), seg=6, rings=3, m="M_EyeWhite")]
for o in E:
xf(o, rx=math.radians(8))
P.append(orient(o, "-Y", (0, -0.25, 0.42)))
# tail fin
P.append(prism("fin", [(0.2, 0.5), (0.5, 0.74), (0.56, 0.74), (0.5, 0.5), (0.3, 0.42)], "YZ", -0.018, 0.018, PRED, bev=0.006))
P.append(prism("finstripe", [(0.42, 0.64), (0.53, 0.7), (0.52, 0.6), (0.4, 0.55)], "YZ", -0.02, 0.02, INK))
# little wind vane on the antenna
P.append(ptube("antenna", [(0.08, 0.1, 0.6), (0.1, 0.14, 0.7), (0.14, 0.2, 0.76)], 0.008, IRON, segs=5))
P.append(sphere("antball", 0.025, (0.14, 0.2, 0.77), seg=10, rings=5, m=PRED))
# timber spars lashed to the pod, tin motor cans, hoop guards, nav lanterns
for i, (sx, sy) in enumerate(DRONE_R):
mx, my = sx * DM, sy * DM
d = Vector((sx, sy, 0)).normalized()
a0 = d * 0.2
P.append(beam((a0.x, a0.y, 0.42), (mx, my, 0.47), 0.066, 0.05, bev=0.012, over=0.02, name="spar"))
rope_band(P, (mx * 0.62, my * 0.62, 0.45), (sx, sy, 0.05), 0.05, n=3, t=0.01)
P.append(revm("motor", [(0, 0.42), (0.05, 0.42), (0.066, 0.44), (0.066, 0.5), (0.055, 0.52), (0.03, 0.525), (0, 0.525)],
[IRON, IRON, TIN, TIN, IRON, IRON], segs=12, loc=(mx, my, 0)))
P.append(torus("guard", 0.2, 0.018, (mx, my, 0.51), "Z", seg=20, rseg=4, m=PRED))
for k in range(3):
ga = math.atan2(-sy, -sx) + (k - 1) * 2.1
P.append(ptube("gstrut", [(mx + 0.06 * math.cos(ga), my + 0.06 * math.sin(ga), 0.47), (mx + 0.19 * math.cos(ga), my + 0.19 * math.sin(ga), 0.505)], 0.01, TIM, segs=4))
lm = "M_LightRed" if sx < 0 else "M_LightGreen"
P.append(sphere("nav", 0.02, (mx + sx * 0.045, my + sy * 0.045, 0.445), seg=8, rings=4, m=lm))
# timber sled and a sickle bar across the nose
for s in (-1, 1):
x = s * 0.22
P.append(beam((x, -0.31, 0.026), (x, 0.3, 0.026), 0.05, 0.05, bev=0.012, name="skid"))
P.append(beam((x, -0.31, 0.026), (x, -0.36, 0.09), 0.05, 0.04, bev=0.01, name="skidtip"))
P.append(box("skidshoe", x - 0.03, x + 0.03, -0.2, 0.2, 0.0, 0.012, IRON, bev=0.004, segs=1))
for y in (-0.15, 0.15):
P.append(beam((x, y, 0.04), (s * 0.15, y * 0.8, 0.24), 0.03, 0.03, IRON, bev=0.006, name="strut"))
P.append(box("sicklebar", -0.34, 0.34, -0.43, -0.39, 0.05, 0.075, IRON, bev=0.006, segs=1))
for k in range(9):
x = -0.32 + k * 0.08
P.append(prism("tooth", [(x - 0.034, -0.43), (x + 0.034, -0.43), (x, -0.5)], "XY", 0.056, 0.068, BLADE))
for s in (-1, 1):
P.append(beam((s * 0.22, -0.34, 0.08), (s * 0.22, -0.41, 0.065), 0.03, 0.03, IRON, bev=0.006, name="sicklearm"))
# leather straps the sack hangs in
for y in (-0.1, 0.1):
P.append(torus("strap", 0.122, 0.012, (0, y, 0.17), "Y", seg=14, rseg=4, m=LEA))
ffin(P, "Body", uv=2.0)
# Tank: a burlap sack of clippings, origin at its bottom centre, swells in game with the load
T = [revm("sackbody", [(0, -0.285), (0.06, -0.272), (0.095, -0.232), (0.112, -0.17), (0.112, 0.16), (0.09, 0.22), (0.052, 0.25), (0.036, 0.262), (0.05, 0.285), (0.0, 0.29)], BUR, segs=12)]
for v in T[0].data.vertices:
v.co.x *= 1.0 + 0.05 * math.sin(v.co.z * 17)
xf(T[0], rx=-PI / 2, t=(0, 0, 0.17))
uv_wall(T[0])
T.append(torus("sacktie", 0.038, 0.011, (0, 0.262, 0.17), "Y", seg=10, rseg=4, m=TWINE))
tuft(T, 0, 0.285, 0.17, L=0.08, n=5, az=PI / 2, m=LEAF)
fpart(T, "Tank", (0, 0, 0.06), uv=2.0)
# rotors: three wooden blades, cream tips
for i, (sx, sy) in enumerate(DRONE_R):
mx, my = sx * DM, sy * DM
R = [cz("hub", 0.035, 0.525, 0.55, mx, my, IRON, v=12),
revm("spinner", [(0.03, 0.55), (0.026, 0.565), (0.014, 0.578), (0, 0.582)], PRED, segs=10, loc=(mx, my, 0))]
for k in range(3):
for o in prop_blade(0.178, 0.03, INK, pitch=0.3 * (1 if (sx * sy) > 0 else -1), r0=0.03):
a = k * 2 * PI / 3 + i * 0.5
g_ = o.get("grain")
xf(o, rz=a, t=(mx, my, 0.54))
if g_ is not None:
grain(o, (math.cos(a), math.sin(a), 0))
R.append(o)
fpart(R, "Rotor_%d" % (i + 1), (mx, my, 0.54), uv=2.0, wn=False)
return dict(elev=28, azim=-35)
# ======================================================================= slat belt texture (numpy, no extra packages)
def slat_texture():
"""T_SlatBelt: cream canvas with timber slats. U across, V along the flow, tiles in V. 3 slats per tile (2 tiles per metre)."""
S = 1024
rng = np.random.default_rng(11)
yy, xx = np.mgrid[0:S, 0:S]
v = yy / S
u = xx / S
def noise(fx, fy, oct_=4):
out = np.zeros((S, S))
amp = 1.0
for i in range(oct_):
nx, ny = int(fx * 2 ** i), int(fy * 2 ** i)
g = rng.random((ny, nx))
x = u * nx
y = v * ny
x0, y0 = np.floor(x).astype(int) % nx, np.floor(y).astype(int) % ny
x1, y1 = (x0 + 1) % nx, (y0 + 1) % ny
tx, ty = x - np.floor(x), y - np.floor(y)
tx, ty = tx * tx * (3 - 2 * tx), ty * ty * (3 - 2 * ty)
out += amp * (g[y0, x0] * (1 - tx) * (1 - ty) + g[y0, x1] * tx * (1 - ty) + g[y1, x0] * (1 - tx) * ty + g[y1, x1] * tx * ty)
amp *= 0.55
return out / out.max()
# canvas: warm cream with a soft weave
weave = 0.5 + 0.25 * np.sin(u * 2 * PI * 180) * np.sin(v * 2 * PI * 180) + 0.25 * np.sin((u + v) * 2 * PI * 90)
blot = noise(6, 6)
img = np.zeros((S, S, 3))
cream = np.array((0.88, 0.80, 0.62))
img[:] = cream
img *= (0.9 + 0.1 * weave)[..., None] * (0.86 + 0.2 * blot)[..., None]
# slats
n = 3
sv = (v * n) % 1.0
half = 0.17
d = np.abs(sv - 0.5) / half # 0 centre .. 1 edge of the slat
streak = noise(3, 40, 3) # grain along U
wood = np.stack((0.44 + 0.2 * streak, 0.28 + 0.13 * streak, 0.15 + 0.07 * streak), axis=-1)
slat = d < 1.0
shade = 1.04 - 0.34 * np.clip((d - 0.72) / 0.28, 0, 1) ** 2
img[slat] = (wood * shade[..., None])[slat]
# contact shadow just past each slat, on the canvas
sh = (d >= 1.0) & (d < 1.32)
img[sh] *= (0.55 + 0.45 * (d[sh] - 1.0) / 0.32)[..., None]
# stitched canvas edges + a dark iron strap along both edges of the belt
for c in (0.055, 0.945):
e = np.abs(u - c) < 0.03
img[e] = img[e] * 0.55 + np.array((0.13, 0.10, 0.07)) * 0.45
for k in range(n):
vc = (k + 0.5) / n
for c in (0.055, 0.945, 0.5):
r = np.hypot((u - c) * 1.0, (v - vc) * 1.0)
m_ = r < 0.016
img[m_] = np.array((0.22, 0.2, 0.19)) + 0.16 * (1 - r[m_] / 0.016)[..., None]
img = np.clip(img, 0, 1)
path = os.path.join(common.TEXTURES, "T_SlatBelt.png")
im = bpy.data.images.new("T_SlatBelt", S, S, alpha=False)
rgba = np.ones((S, S, 4))
# bpy stores rows bottom-up; the belt tiles in V, so only the look (not the phase) matters
rgba[..., :3] = img[::-1]
im.pixels = rgba.ravel()
im.filepath_raw = path
im.file_format = "PNG"
im.save()
print("wrote", path)
# ======================================================================= run
BUILDERS = {
"SM_Hopper": hopper,
"SM_WaterTank": water_tank,
"SM_Filler": filler,
"SM_Vaporizer": vaporizer,
"SM_CryoPress": cryo_press,
"SM_Pump": edge_mower,
"SM_Belt": belt,
"SM_BeltTurn": belt_turn,
"SM_BeltSorter": belt_sorter,
"SM_BeltSplitter": belt_splitter,
"SM_Launcher": launcher,
"SM_DronePad": drone_pad,
"SM_DroneHub": drone_hub,
"SM_Drone": drone,
"SM_RainDrone": rain_drone,
}
def chain_test():
"""Not exported: a belt run through every piece, to check that the joints read as one conveyor."""
reset()
placed = set()
def place(fn, rz, t, hide=()):
fn()
for o in list(bpy.context.scene.objects):
if o.name in placed or o.type != "MESH":
continue
if any(o.name.startswith(h) for h in hide):
bpy.data.objects.remove(o)
continue
apply_xform(o)
xf(o, rz=rz, t=t)
o.name = "c_" + o.name
placed.add(o.name)
place(belt, 0, (0, 2, 0), hide=("EndOut",))
place(belt, 0, (0, 1, 0), hide=("EndIn", "EndOut"))
place(belt_sorter, 0, (0, 0, 0), hide=("EndIn", "EndOut"))
place(belt, 0, (0, -1, 0), hide=("EndIn", "EndOut"))
place(belt_turn, 0, (0, -2, 0), hide=("EndIn", "EndOut"))
place(belt, -PI / 2, (-1, -2, 0), hide=("EndIn",))
place(belt_splitter, 0, (2.2, 0, 0))
preview("_gc_belt_chain", elev=38, azim=-45)
preview("_gc_belt_chain_close", elev=30, azim=-60, target=(-0.2, -1.5, 0.35), radius=1.0)
def run_all():
args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
if "_texture" in args:
args.remove("_texture")
slat_texture()
if not args:
return
if "_chain" in args:
args.remove("_chain")
old = common.PREVIEWS
common.PREVIEWS = os.environ.get("GC_VIEWS") or old
chain_test()
common.PREVIEWS = old
if not args:
return
names = args or list(BUILDERS.keys())
views = os.environ.get("GC_VIEWS")
for n in names:
reset()
random.seed(sum(map(ord, n)))
res = BUILDERS[n]() or {}
for o in bpy.context.scene.objects:
if o.type == "MESH":
print(f" [{n}] {o.name:<10} tris={tri_count([o])}")
if os.environ.get("GC_CULL"):
for m_ in bpy.data.materials:
m_.use_backface_culling = True
finish(n, **res)
if views:
old = common.PREVIEWS
common.PREVIEWS = views
for tag, el, az in (("back", 25, 150), ("side", 12, 80), ("top", 60, -20)):
preview(n + "_" + tag, elev=el, azim=az, res=480)
common.PREVIEWS = old
if __name__ == "__main__":
run_all()