"""GRASS CUTTER - third upgrade round of the base, the crew and the hand tools. Round 2 lives in gc_up_base / gc_up_tools / gc_up_crew / gc_up_world / gc_up_machines and stays as it is. This file either rebuilds a model outright, or calls the round 2 builder and grafts new parts on, so names, pivots, footprints and children cannot drift. Tools blades now use the pack's own flat greys (P_G*), not metallic M_Blade / M_Steel, which went dark or vanished against the sky, and the T_Rust rectangles are gone: stains are small irregular blots. Order tools first: SM_SupplyWall traces its painted outlines from the tool FBX files. Run (absolute paths, the shell starts in another project): blender -b --factory-startup --python D:/PROJECTS/LOCAL/GrassCutter/ArtSource/Blender/scripts/gc_up3_base.py -- [SM_Name ...] [--quick] Review shots go to $GC_SHOTS. Check with gc_up_check.py (fpv, open, swing, wall, report). """ import sys, os, zlib sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import common from gc_up_kit import * # noqa: F401,F403 import gc_up_kit as KIT import os_crew as OC import gc_farm_tools as FT import gc_up_crew as UC # before the hooks below: it takes done() from gc_up_tools by value import gc_up_tools as UT import gc_up_machines as UM import gc_up_base as UB import gc_up_world as UW TAU = 2 * math.pi DEG = math.radians G1, G2, G3, G4, G5, WHT, BLK, DGY = "P_G1", "P_G2", "P_G3", "P_G4", "P_G5", "P_WHITE", "P_BLACK", "P_DGREY" BRASS, LEAT = "M_Brass", "M_Leather" RA, RB = "P_RUSTA", "P_RUSTB" PV_Y = UT.PV_Y # ======================================================================= finishing def tfin(P, name, uv=2.4, ang=30): """gc_farm_tools.done for parts that may be painted from the atlas: M_Steel turns into a flat pack grey, P_ materials get their UVs.""" P = [o for o in P if o is not None] for o in P: me = o.data for i, m_ in enumerate(me.materials): if m_ and m_.name == "M_Steel": me.materials[i] = mat("P_G4") if not o.get("uv_done"): uv_box(o, uv) UM.pack_uv(o) UM.one_uv(o) o = join(P, name) smooth(o, ang) return o def graft(name, P, uv=1.0, ang=35, wn=True, ms=None): """Add parts, built in world space, to the finished object `name`: same object name and origin, same place in the file.""" t = bpy.data.objects[name] org = t.matrix_world.translation.copy() pk = [o for o in P if o is not None] for o in pk: m0 = o.data.materials[0].name if o.data.materials and o.data.materials[0] else "" uv_part(o, (ms or {}).get(m0, uv)) UM.pack_uv(o) UM.one_uv(o) UM.one_uv(t) o = join([t] + pk, name) me = o.data if "custom_normal" in me.attributes: me.attributes.remove(me.attributes["custom_normal"]) smooth(o, ang) if wn: weighted(o) set_origin(o, org) return o def blot(P, F, c, w, h, rng, flip=False, key=RA, N=8): """A small irregular stain lying in the local XY plane of F, a hair off the steel.""" pts = [] for k in range(N): a = TAU * k / N q = rng.uniform(.55, 1.0) pts.append(F @ Vector((c[0] + math.cos(a) * q * w / 2, c[1] + math.sin(a) * q * h / 2, c[2]))) if flip: pts.reverse() o = mesh_obj("blot", verts=[tuple(p) for p in pts], faces=[tuple(range(N))]) set_mats(o, key) P.append(o) # ======================================================================= steel def forged3(spine, edge, z, t, body=G1, frame=None, rust=(), name="blade", ground=0.34, m_edge=WHT, m_spine=DGY, m_hollow=G3, rng=None, P=None, twist=0.0): """The round 2 blade with the pack's greys: a dark spine, a flat cheek, a lighter hollow, a bright hand-ground bevel whose top line wanders. rust: stations (i, 2) on the +Z cheek, (i, 5) on the -Z cheek get a blot. Needs P for those.""" n = len(spine) rng = rng or random.Random(5) F = frame if frame is not None else Matrix.Identity(4) bm = bmesh.new() R = [] Sv = [Vector((p[0], p[1], 0.0)) for p in spine] Ev = [Vector((p[0], p[1], 0.0)) for p in edge] for i in range(n): s, e = Sv[i], Ev[i] g = ground + rng.uniform(-.045, .045) b, m = e.lerp(s, g), e.lerp(s, min(.82, g + .2)) tt = t * (1.0 - 0.6 * (i / (n - 1)) ** 3) R.append([bm.verts.new(p + Vector((0, 0, z + dz + twist * (p - e).length))) for p, dz in ((e, 0.0), (b, tt * 0.42), (m, tt * 0.5), (s, tt * 0.5), (s, -tt * 0.5), (m, -tt * 0.5), (b, -tt * 0.42))]) idx = [] MAP = {0: 1, 6: 1, 1: 2, 5: 2, 2: 0, 4: 0, 3: 3} for i in range(n - 1): for j in range(7): k = (j + 1) % 7 bm.faces.new((R[i][j], R[i][k], R[i + 1][k], R[i + 1][j])) idx.append(MAP[j]) bm.faces.new(list(reversed(R[0]))) bm.faces.new(R[-1]) idx += [3, 3] bmesh.ops.recalc_face_normals(bm, faces=bm.faces) bmesh.ops.transform(bm, matrix=F, verts=bm.verts) o = mesh_obj(name, bm) set_mats(o, body, m_edge, m_hollow, m_spine) o.data.polygons.foreach_set("material_index", idx) o.data.update() smooth(o, 26) # stains on the flat, away from the bevel if P is not None: for (i, j) in rust: i = min(i, n - 2) sm = (Sv[i] + Sv[i + 1]) / 2 em = (Ev[i] + Ev[i + 1]) / 2 c = em.lerp(sm, .8) L = (Sv[i + 1] - Sv[i]).length W = (sm - em).length ang = math.atan2((Sv[i + 1] - Sv[i]).y, (Sv[i + 1] - Sv[i]).x) Fl = F @ Matrix.Translation((c.x, c.y, z)) @ Matrix.Rotation(ang, 4, "Z") up = 1 if j == 2 else -1 tt = t * (1.0 - 0.6 * (i / (n - 1)) ** 3) blot(P, Fl, (0, 0, up * (tt * .5 + .0012) + twist * W * .8), L * 1.1, W * .22, rng, flip=up < 0, key=RB) return o # gc_up_tools hooks: the blade makers of the round 2 tools call these through their module globals _steel = dict(body=G1, spine=DGY, hollow=G3, edge=WHT, P=None, rng=None) _extra = {} def forged_hook(spine, edge, z, t, body=None, frame=None, rust=(), name="blade", ground=0.34, m_edge=None): return forged3(spine, edge, z, t, body=_steel["body"], frame=frame, rust=rust, name=name, ground=ground, m_edge=_steel["edge"], m_spine=_steel["spine"], m_hollow=_steel["hollow"], rng=_steel["rng"], P=_steel["P"]) def done_hook(P, name, uv=3.0, ang=45): fn = _extra.get(name) if fn: fn(P) if _steel["P"]: P += _steel["P"] _steel["P"] = [] return tfin(P, name, uv=uv, ang=ang) def plate_hook(name, pts, z0, z1, m, bevel=0.0, frame=None): if name == "hazard": return None return _plate(name, pts, z0, z1, m, bevel, frame) _plate = UT.plate UT.forged = forged_hook UT.done = done_hook UT.plate = plate_hook class Blades: """Runs a round 2 tool builder with the new steel, collecting the stains into its part list.""" def __init__(self, P_hook=None, extra=None, seed=3, **steel): self.extra, self.seed, self.steel = extra or {}, seed, steel def __enter__(self): _extra.clear() _extra.update(self.extra) _steel.update(dict(body=G1, spine=DGY, hollow=G3, edge=WHT, P=[], rng=random.Random(self.seed))) _steel.update(self.steel) return self def __exit__(self, *a): _extra.clear() # ======================================================================= scissors and shears def scissor_outline(sx, py, ty, W, curve, prof, heel=0.03): """Spine and edge outlines from the heel to the tip. prof: (u, width as a share of W).""" S, E = [], [] for k, (u, q) in enumerate(prof): y = (py + heel) + (ty - (py + heel)) * u c = curve * max(0.0, (py - y) / (py - ty)) ** 2.2 E.append((c + sx * .003 * (1 - u), y)) S.append((c - sx * (W * q + .004), y)) return S, E def nail_blade(sx, py, ty, w0, curve, dz, t, body, rust, n=7, heel=0.03): prof = ((0, .62), (.09, 1.0), (.22, .98), (.42, .88), (.62, .68), (.78, .47), (.9, .27), (1, .02)) S, E = scissor_outline(sx, py, ty, .08, .095, prof, heel) return forged3(S, E, dz, t, name="blade", ground=.42, rng=_steel["rng"], P=_steel["P"], twist=.5, rust=({(3, 2)} if sx > 0 else ())) def shear_blade(sx, py, ty, w0, curve, dz, t, body, rust, n=7, heel=0.03): """Grass shears: straight tapering blades with the classic bite near the pivot for tough stalks.""" prof = ((0, .7), (.07, .98), (.14, 1.0), (.19, .84), (.25, .84), (.3, 1.0), (.5, .84), (.7, .62), (.86, .4), (.95, .2), (1, .02)) S, E = scissor_outline(sx, py, ty, .102, 0.0, prof, heel) # the bite is cut out of the edge, not the spine for i, d in ((2, .0), (3, .03), (4, .03), (5, 0.0)): E[i] = (E[i][0] - sx * d, E[i][1]) S[i] = (S[i][0] - sx * d * .4, S[i][1]) return forged3(S, E, dz, t, name="blade", ground=.4, rng=_steel["rng"], P=_steel["P"], twist=.35, rust=({(6, 2)} if sx > 0 else ())) def nail_scissors(): def extra_a(sx): def f(P): py = PV_Y dz = .0075 * (1 if sx > 0 else -1) # a thumb-rest ridge on the shank, a brass collar where the bow joins, a cream line inside the bow so the ring reads at a distance P.append(UT.disc("boss2", .03, .0165, (0, py, dz), G2, n=8)) c = Vector((sx * .062, .058, dz)) lp = torus("liner", .036, .0052, loc=(0, 0, 0), seg=10, rseg=3, m=GOLD) lp.data.transform(Matrix.Translation(c) @ Matrix.Scale(.82, 4, (1, 0, 0)) @ Matrix.Scale(1.14, 4, (0, 1, 0))) P.append(lp) P.append(UT.tube("shank", [(sx * .012, py + .042, dz + .0), (sx * .03, py + .09, dz)], lambda s: (.0145, .0092), G1, segs=6, ang=28, spin=PI / 2)) return f old = UT.scissor_blade UT.scissor_blade = nail_blade with Blades(extra={"BladeA": extra_a(1), "BladeB": extra_a(-1)}, seed=11): r = UT.nail_scissors() UT.scissor_blade = old return dict(elev=60, azim=-12, dist_mul=.72, views=[("_under", dict(elev=-55, azim=-12, dist_mul=.72))]) def garden_shears(): def extra_blade(sx): def f(P): py = PV_Y dz = .0105 * (1 if sx > 0 else -1) # a bumper block where the handles meet when the blades close, a leather grip, a brass band at the ferrule P.append(UT.tube("bump", [(sx * .012, -.012, dz), (sx * .006, -.006, dz)], lambda s: .0185, BLK, segs=6, ang=30)) P.append(UT.tube("hgrip", [(sx * .04, .05, dz), (sx * .049, .1, dz), (sx * .047, .135, dz)], lambda s: (.0325, .0265), LEAT, segs=8, per=2, ang=30, spin=PI / 2)) for y, q in ((.05, 0), (.135, 1)): x = sx * (.04 + .007 * q) P.append(UT.tube("hring", [(x, y - .005, dz), (x, y + .005, dz)], lambda s: (.0345, .0285), BRASS, segs=8, ang=30, spin=PI / 2)) P.append(UT.disc("boss2", .042, .0225, (0, py, dz), G3, n=10)) return f old = UT.scissor_blade UT.scissor_blade = shear_blade with Blades(extra={"BladeA": extra_blade(1), "BladeB": extra_blade(-1)}, seed=12): r = UT.garden_shears() UT.scissor_blade = old return dict(elev=60, azim=-12, dist_mul=.72, views=[("_under", dict(elev=-55, azim=-12, dist_mul=.72))]) # ======================================================================= sickle def sickle(): """Same grip, same reach, same pistol handle path as round 2. The crescent is half as wide again: it was a thin dark line in first person.""" P = [] rng = random.Random(21) z = 0.26 hp = [(0, 0.03, -0.3), (0, 0.012, -0.14), (0, 0, 0.02), (0, -0.04, 0.17), (0, -0.16, z - 0.005), (0, -0.335, z)] bulge = lambda s: math.sin(min(1, s * 1.5) * 3.1) P.append(UT.tube("handle", hp, lambda s: (0.064 + 0.03 * bulge(s), 0.058 + 0.03 * bulge(s)), TIM, segs=8, per=3, s=1.0, ang=30)) pth = UT.Path(hp, per=3) P.append(UT.tube("cap", [(0, 0.033, -0.33), (0, 0.03, -0.3), (0, 0.027, -0.25)], lambda s: 0.08 - 0.016 * abs(2 * s - 1), PRED, segs=8, per=1, ang=30)) P.append(UT.tube("capring", [(0, 0.0275, -0.255), (0, 0.027, -0.235)], lambda s: 0.081, BRASS, segs=8, ang=30)) for a, b in ((0.25, 0.3), (0.34, 0.39), (0.43, 0.48), (0.52, 0.57)): # rawhide bands under the fingers P.append(UT.tube("thong", [pth.at(a), pth.at((a + b) / 2), pth.at(b)], lambda s: 0.0965, LEAT, segs=8, per=2, ang=30, cap=False)) # brass ferrule, an iron collar and the tang plate into the blade P.append(UT.tube("ferrule", [(0, -0.285, z), (0, -0.375, z)], lambda s: 0.072 - 0.012 * s, BRASS, segs=8, ang=30)) P.append(UT.tube("collar", [(0, -0.37, z), (0, -0.395, z)], lambda s: 0.062, IRON, segs=8, ang=30)) for sx in (-1, 1): UT.stud(P, (sx * 0.062, -0.33, z), (sx, 0, 0), r=0.02, m=IRON, hexa=False, h=0.01) P.append(UT.tube("loop", [(0, 0.03, -0.335), (0.05, 0.08, -0.385), (0.0, 0.14, -0.41), (-0.05, 0.08, -0.385), (0, 0.03, -0.335)], lambda s: 0.0125, ROPE, segs=5, per=2, ang=40)) # crescent: spine outside, edge inside, a C that opens towards +X and hooks back at the tip c = Vector((0.335, -0.79, 0)) S, E = [], [] n = 15 for i in range(n + 1): u = i / n a = DEG(142 + 236 * u) r_o = 0.455 - 0.05 * u + 0.012 * math.sin(u * math.pi) w = 0.205 * (1 - u) ** 0.5 * (0.74 + 0.26 * math.sin(min(1.0, u * 2.4) * 1.57)) + 0.008 S.append((c.x + r_o * math.cos(a), c.y + r_o * math.sin(a))) E.append((c.x + (r_o - w) * math.cos(a), c.y + (r_o - w) * math.sin(a))) S[0], E[0] = (-0.05, -0.36), (0.05, -0.36) for i in (6, 11): # nicks from stones in the grass E[i] = (E[i][0] + (S[i][0] - E[i][0]) * 0.14, E[i][1] + (S[i][1] - E[i][1]) * 0.14) P.append(forged3(S, E, z, 0.04, name="blade", ground=.44, rng=rng, P=P, rust={(3, 2), (10, 2)})) # the spine rib, standing proud, a small maker's stamp rib = [(p[0], p[1], z + 0.015) for p in S[1:12]] P.append(UT.tube("rib", rib, lambda s: (0.015 * (1 - 0.6 * s), 0.009), BLK, segs=4, per=1, ang=30)) UM.star_badge(P, Vector((-0.012, -0.5, z + 0.0185)), .1, (0, 0, 1)) tfin(P, "Body", uv=2.4, ang=30) return dict(elev=62, azim=-10, dist_mul=.72, views=[("_side", dict(elev=10, azim=-78, dist_mul=.72)), ("_heel", dict(elev=30, azim=150, dist_mul=.74))]) # ======================================================================= hammer def hammer(): """Same grip, length, head line as round 2: handle along -Y, the head across it, the face on +X, the claw on -X.""" P = [] rng = random.Random(6) hy = -0.56 hp = [(0.0, 0.2, 0.0), (0.012, 0.06, 0.0), (0.004, -0.14, 0.0), (0.0, -0.36, 0.0), (0.0, hy - 0.05, 0.0)] swell = lambda s: math.exp(-((s - 0.2) / 0.2) ** 2) flare = lambda s: max(0.0, (s - .82) / .18) ** 2 P.append(UT.tube("handle", hp, lambda s: (0.036 + 0.014 * swell(s) + .01 * flare(s), 0.0245 + 0.01 * swell(s) + .004 * flare(s)), TIM, segs=8, per=3, s=0.9, ang=30)) pth = UT.Path(hp, per=3) # a wrapped leather grip: separate turns, so it catches the light in rings t0, t1 = .05, .36 N = 7 for k in range(N): a = t0 + (t1 - t0) * k / N b = a + (t1 - t0) / N * .86 P.append(UT.tube("turn", [pth.at(a), pth.at((a + b) / 2), pth.at(b)], lambda s: (0.0555 + .002 * math.sin(s * 3.14), 0.0405 + .002 * math.sin(s * 3.14)), LEAT, segs=8, per=1, ang=30, cap=False)) for t in (t0 - .012, t1 - .008): P.append(UT.tube("welt", [pth.at(t), pth.at(t + .012)], lambda s: (0.0585, 0.0435), BLK, segs=8, ang=30, cap=False)) P.append(UT.tube("buttcap", [(0.0, 0.216, 0.0), (0.0, 0.2, 0.0), (0.003, 0.178, 0.0)], lambda s: (0.0465 - .006 * abs(1 - 2 * s), 0.0325 - .004 * abs(1 - 2 * s)), PRED, segs=8, per=1, ang=30)) P.append(UT.tube("thong", [(0, 0.212, 0), (0.042, 0.244, 0), (0.04, 0.29, 0), (0.0, 0.306, 0), (-0.034, 0.276, 0), (-0.028, 0.24, 0), (0, 0.212, 0)], lambda s: 0.0078, LEAT, segs=5, per=2, ang=40)) # steel langets down the neck, brass pins, a red painted band on the timber for sz in (-1, 1): P.append(bx(-0.017, 0.017, hy + 0.05, hy + 0.21, sz * 0.0275 - 0.004, sz * 0.0275 + 0.004, G4, bev=0.002, name="langet")) for k in range(2): UT.stud(P, (0, hy + 0.09 + k * 0.08, sz * 0.031), (0, 0, sz), r=0.0085, m=BRASS, hexa=False, h=0.004) P.append(UT.tube("neckband", [pth.at(.6), pth.at(.625)], lambda s: (0.0385, 0.0275), PRED, segs=8, ang=30, cap=False)) # the head, in chamfered octagons along X, from the cheek out to the striking face W = 0.052 def oct_x(x, hy_, hz, ch=.3): c = min(hy_, hz) * ch return [(x, hy - hy_ + c, -hz), (x, hy - hy_, -hz + c), (x, hy - hy_, hz - c), (x, hy - hy_ + c, hz), (x, hy + hy_ - c, hz), (x, hy + hy_, hz - c), (x, hy + hy_, -hz + c), (x, hy + hy_ - c, -hz)] rings = [oct_x(-.082, .056, W * .94), oct_x(-.07, .064, W), oct_x(.07, .064, W), oct_x(.09, .05, W * .88), oct_x(.122, .041, .041), oct_x(.152, .048, .048), oct_x(.172, .062, .062), oct_x(.2, .066, .066), oct_x(.222, .066, .066, .4)] o = UM.loft(rings, G1, name="headbody") fl = o.data fl.polygons.foreach_set("material_index", [0] * len(fl.polygons)) fl.update() P.append(o) P.append(UM.loft([oct_x(.1, .0475, .0445), oct_x(.118, .0435, .0425)], PRED, name="neckpaint")) P.append(UM.loft([oct_x(.2, .0668, .0668), oct_x(.222, .0668, .0668, .4)], G3, name="poll")) P.append(UM.loft([oct_x(.222, .0668, .0668, .4), oct_x(.232, .052, .052, .4)], WHT, name="face")) # the handle end through the eye, an iron wedge, two pins P.append(bx(-0.036, 0.036, hy - 0.078, hy - 0.056, -0.027, 0.027, TIM, bev=0.003, name="eyetop")) P.append(bx(-0.03, 0.03, hy - 0.083, hy - 0.072, -0.0055, 0.0055, G5, bev=0.0015, name="wedge")) for x in (-0.018, 0.018): P.append(UT.disc("wedgedot", 0.0072, 0.006, (x, hy - 0.083, 0), IRON, n=6, axis="Y")) # the claw: two prongs curving back towards the hand, split by a V, bright at the tips where they have pulled nails prof = [(-0.07, 0.056), (-0.125, 0.05), (-0.185, 0.03), (-0.24, -0.015), (-0.285, -0.082), (-0.298, -0.122), (-0.27, -0.102), (-0.222, -0.058), (-0.175, -0.03), (-0.125, -0.022), (-0.07, -0.042)] pts = [(u, hy - v) for u, v in prof] P.append(UT.plate("clawroot", [(u, hy - v) for u, v in prof[:2] + [(-0.14, 0.0), (-0.125, -0.022)] + prof[-1:]], -W * 0.92, W * 0.92, G1)) for sz in (-1, 1): gap, thick = 0.0085, W * 0.92 - 0.0085 o = UT.plate("prong", pts, sz * gap if sz > 0 else -W * 0.92, W * 0.92 if sz > 0 else -gap, G1) for v in o.data.vertices: k = max(0.0, min(1.0, (-v.co.x - 0.12) / 0.18)) mid = sz * (gap + thick * 0.5) v.co.z = mid + (v.co.z - mid) * (1 - 0.62 * k) + sz * 0.007 * k P.append(o) # a stamped badge on the cheek, a little wear for sz in (-1, 1): UM.star_badge(P, Vector((-.004, hy, sz * (W + .0005))), .082, (0, 0, sz)) blot(P, Matrix.Identity(4), (.11, hy + .02, W * .87 + .0016), .03, .03, rng, key=RA) tfin(P, "Body", uv=4.0, ang=30) return dict(elev=64, azim=-14, dist_mul=.72, views=[("_head", dict(elev=30, azim=-120, target=(0, -0.56, 0), radius=0.3)), ("_back", dict(elev=20, azim=150, dist_mul=.72))]) # ======================================================================= scythes def scythe(): def extra(P): pts = [(0.012, 0.15, 0.116), (0.018, 0.07, 0.13), (0.0, -0.08, 0.125), (-0.02, -0.4, 0.13), (-0.012, -0.72, 0.105), (0.01, -1.02, 0.03), (0.0, -1.27, -0.05)] pth = UT.Path(pts, per=4) # two painted bands by the fore grip, and a whetstone in a cow horn hung off the snath, where the left hand finds it for t0, m in ((.47, PRED), (.495, CRM), (.52, PRED)): P.append(UT.tube("band", [pth.at(t0), pth.at(t0 + .016)], lambda s: .0325, m, segs=8, ang=30, cap=False)) hook = pth.at(pth.nearest_y(-.26)) P.append(UT.tube("hstrap", [hook + Vector((0, -.012, 0)), hook + Vector((0, .012, 0))], lambda s: .0345, LEAT, segs=8, ang=30, cap=False)) a = hook + Vector((.03, 0, -.02)) hn = [a, a + Vector((.012, 0, -.05)), a + Vector((.03, .004, -.11)), a + Vector((.05, .01, -.19))] P.append(UT.tube("horn", hn, lambda s: .03 * (1 - s) ** .7 + .005, "M_PaintCream", segs=7, per=2, ang=30)) P.append(rbox("hone", (.03, .03, .05), tuple(a + Vector((-.003, 0, .03))), bevel=.006, segs=1, m=G3)) with Blades(extra={"Body": extra}, seed=31): UT.scythe() return dict(elev=38, azim=-30, dist_mul=.7, views=[("_heel", dict(elev=30, azim=-20, target=(0.15, -1.25, -0.05), radius=0.34)), ("_grip", dict(elev=18, azim=120, target=(0, -0.05, 0.05), radius=0.3))]) def long_scythe(): with Blades(extra={}, seed=32): UT.long_scythe() return dict(elev=38, azim=-30, dist_mul=.7, views=[("_heel", dict(elev=30, azim=-20, target=(0.25, -1.4, 0.05), radius=0.46)), ("_grip", dict(elev=18, azim=120, target=(0, -0.05, 0.05), radius=0.3))]) def wide_scythe(): with Blades(extra={}, seed=33): UT.wide_scythe() return dict(elev=38, azim=-30, dist_mul=.7, views=[("_heel", dict(elev=30, azim=-20, target=(0.3, -1.65, 0.0), radius=0.55)), ("_grip", dict(elev=18, azim=120, target=(0, -0.05, 0.05), radius=0.34))]) # ======================================================================= the deck, the ladder, the ramp def bfin(P, name, uv=1.0, ang=35, ms=None, wn=True): """ffin that also writes the atlas UVs of P_ paints.""" Q = [o for o in P if o is not None] for o in Q: m0 = o.data.materials[0].name if o.data.materials and o.data.materials[0] else "" uv_part(o, (ms or {}).get(m0, uv)) UM.pack_uv(o) UM.one_uv(o) o = join(Q, name) smooth(o, ang) if wn: weighted(o) return o def flat_quads(name, rects, z, m): """Nail heads and the like: one quad each, two triangles.""" bm = bmesh.new() for (x0, x1, y0, y1) in rects: bm.faces.new([bm.verts.new((x0, y0, z)), bm.verts.new((x1, y0, z)), bm.verts.new((x1, y1, z)), bm.verts.new((x0, y1, z))]) o = mesh_obj(name, bm) set_mats(o, m) return uv_wall(o) _fence, _straws = UB.fence, UB.straws def fence3(alt): """The round 2 fence with a barn-red board along the bottom of each middle panel: colour at the height of the crew's eye line down the deck.""" Q = _fence(alt) Q.append(grain(plain(-0.86, 0.86, -2.94, -2.88, 0.06, 0.3, RED, "kickred"), (1, 0, 0))) return Q def deck_tile(): """Same boards, rails, stilts as round 2. Rows of nail heads where the boards cross the joists replace the straw, the fence gets a red kick panel.""" UB.fence, UB.straws = fence3, (lambda *a, **k: None) r = UB.deck_tile() UB.fence, UB.straws = _fence, _straws n, y0, pitch = 16, -2.84, 5.68 / 16 N = [] for i in range(n): yc = y0 + pitch * (i + 0.5) for x in (-0.78, 0.78): d = 0.014 if (i % 3) else -0.016 # some rows sit on the far side of the joist for dy in (-0.06, 0.06): N.append((x + d - 0.016, x + d + 0.016, yc + dy - 0.016, yc + dy + 0.016)) graft("Body", [flat_quads("nails", N, 0.0016, IRON)], ang=35) return r def ladder(): """Rebuilt: flat sawn stringers with red caps, real treads on cleats, a rope handline, the same hook over the deck edge. Same 0.7 m width and reach, the grab rails still pass between the two fence rails onto the deck.""" P = [] Y0, Y1 = -0.225, -0.07 rng = random.Random(9) for s in (-1, 1): x = s * 0.27 pts = [(x - 0.05, -2.16), (x + 0.05, -2.16), (x + 0.05, 0.86), (x, 0.92), (x - 0.05, 0.86)] P.append(grain(prism("stringer", pts, "XZ", Y0, Y1, TIM), (0, 0, 1))) # the red cap, iron shoe at the foot, iron band at the deck edge P.append(plain(x - 0.054, x + 0.054, Y0 - 0.004, Y1 + 0.004, 0.62, 0.82, PRED, "paint")) P.append(plain(x - 0.057, x + 0.057, Y0 - 0.006, Y1 + 0.006, -2.16, -1.98, IRON, "shoe")) P.append(plain(x - 0.057, x + 0.057, Y0 - 0.006, Y1 + 0.006, -0.02, 0.05, IRON, "band")) nut(P, (x + s * 0.05, -0.15, 0.015), (s, 0, 0), r=0.018, h=0.01, m=STL) # the grab rail: a heavier timber, a raking strut under it, an iron foot on the deck P.append(beam((x, -0.2, 0.74), (x, 0.44, 0.74), 0.085, 0.095, bev=0, name="grab")) P.append(grain(plain(x - 0.045, x + 0.045, 0.37, 0.47, 0.02, 0.78, TIM, "grabpost"), (0, 0, 1))) P.append(beam((x, 0.1, 0.72), (x, 0.4, 0.2), 0.05, 0.06, bev=0, name="strut")) P.append(plain(x - 0.1, x + 0.1, 0.3, 0.54, 0.0, 0.03, IRON, "foot")) for dx in (-0.07, 0.07): nut(P, (x + dx, 0.42, 0.03), (0, 0, 1), r=0.016, h=0.01, m=STL) # iron hook over the deck edge, a stand-off against the fascia P.append(ptube("hook", rpath([(x, 0.16, 0.012), (x, -0.02, 0.012), (x, -0.02, -0.2), (x, -0.09, -0.2)], 0.04, 2), 0.022, IRON, segs=5)) P.append(plain(x - 0.04, x + 0.04, -0.1, 0.0, -0.36, -0.28, TIM, "stand")) # the treads: sawn boards on cleats, wider than the stringers so a boot lands on them. One was split and has been mended with a strip of tin z, k = -0.3, 0 while z > -1.95: m_ = PKW if k == 3 else rng.choice((PK, PK, PKD)) P.append(plank_x(-0.335, 0.335, -0.14, 0.15, z - 0.045, z, m_, rng, ch=0.01)) for s in (-1, 1): P.append(plain(s * 0.2, s * 0.222, Y0 + 0.012, Y1 - 0.012, z - 0.1, z - 0.045, IRON, "cleat")) if k == 3: P.append(plain(-0.08, 0.08, -0.218, -0.062, z - 0.002, z + 0.003, TIN, "mend")) k += 1 z -= 0.3 P.append(beam((-0.32, 0.14, 0.74), (0.32, 0.14, 0.74), 0.08, 0.08, bev=0, name="bar")) for x in (-0.14, -0.1, -0.06, -0.02, 0.02, 0.06, 0.1, 0.14): # rope wound round the bar where a hand lands P.append(cx("gripturn", 0.05, x - 0.016, x + 0.016, 0.14, 0.74, ROPE, v=6)) P.append(grain(bx(-0.32, 0.32, -0.09, -0.05, -0.08, 0.06, PKD, bev=0.0, name="backtie"), (1, 0, 0))) # a knotted rope handline down one side path = [(0.33, -0.19, 0.74), (0.345, -0.25, 0.3), (0.335, -0.26, -0.3), (0.35, -0.255, -0.9), (0.34, -0.26, -1.42)] P.append(ptube("handline", path, 0.015, ROPE, segs=4)) for t in (0.42, -0.1, -0.62, -1.14): P.append(cz("knot", 0.032, t - 0.028, t + 0.028, 0.34, -0.256, ROPE, v=6)) ffin(P, "Body", ang=35) return dict(elev=18, azim=-55, views=[("_close", dict(elev=10, azim=-30, dist_mul=0.5, target=(0, 0, 0.1)))]) def dock(): """Round 2 ramp, then: red plank skirts down both sides so it stands as one solid shape, steel wheel plates, cream chevrons up the middle, a hazard lip, lanterns.""" r = UB.ramp() L, W = 6.12, 3.0 th = math.asin(0.2) P, F = [], [] # steel wheel plates in lengths, bolted down for sx in (-0.74, 0.74): for (a, b) in ((-5.92, -4.5), (-4.46, -3.0), (-2.96, -1.5), (-1.46, -0.22)): F.append(plain(sx - 0.2, sx + 0.2, a, b, 0.003, 0.014, G2, "wheelplate")) for dy in (0.05, -0.05): y = (a if dy > 0 else b) + dy F.append(flat_quads("pbolts", [(sx + dx - 0.015, sx + dx + 0.015, y - 0.015, y + 0.015) for dx in (-0.15, 0.0, 0.15)], 0.0155, G3)) for yy in (-1.3, -2.5, -3.7, -4.9): chevron_flat(F, yy, 0.36, 0.26, 0.14, 0.002, 0.03, m="M_PaintCream") # hazard board over the bottom lip F.append(uv_wall(plain(-W / 2 + 0.12, W / 2 - 0.12, -L - 0.3, -L + 0.02, 0.0, 0.006, "M_Hazard", "hazlip"))) # lanterns on the lowest posts for sx in (-1, 1): xc = sx * (W / 2 - 0.06) F.append(cz("lpeg", 0.022, 0.6, 0.66, xc, -5.0, IRON, v=6)) F.append(lantern(F, xc, -5.0, 0.66, m="M_LightAmber", r=0.05)) for o in F: xg(o, rx=th) P += F z_at = lambda yy: yy * math.tan(th) for sx in (-1, 1): x0, x1 = sorted((sx * 1.455, sx * 1.495)) y = -5.62 k = 0 while y < -0.28: y1 = y + 0.42 pts = [(y, -1.3), (y1, -1.3), (y1, z_at(y1) - 0.3), (y, z_at(y) - 0.3)] P.append(grain(prism("skirt", pts, "YZ", x0, x1, RED if k % 5 != 3 else PRED), (0, 0, 1))) y += 0.44 k += 1 for (ya, yb) in ((-5.6, -3.2), (-2.9, -0.3)): P.append(grain(plain(x0 - 0.012 if sx < 0 else x1, x0 if sx < 0 else x1 + 0.012, ya, yb, -1.12, -1.03, CRM, "skirtrail"), (0, 1, 0))) graft("Body", P, ang=35, ms={CRM: 0.4}) return r # ======================================================================= the supply wall _stroke, _simplify = UB.stroke, UB.simplify def supply_wall(): UB.stroke, UB.simplify = (lambda name, loop, w, y, m: _stroke(name, loop, 0.01, y, m)), (lambda pts, tol=0.009: _simplify(pts, 0.012)) r = UB.supply_wall() UB.stroke, UB.simplify = _stroke, _simplify P = [] # a treadle grindstone at the far end, under the hammer: where every blade on the wall gets its edge gx, gy, gz, R = 2.0, -0.36, 0.42, 0.25 P.append(cx("stone", R, gx - 0.05, gx + 0.05, gy, gz, "M_Concrete", v=14)) P.append(cx("stonebore", 0.07, gx - 0.058, gx + 0.058, gy, gz, IRON, v=8)) P.append(cx("axle", 0.018, gx - 0.24, gx + 0.26, gy, gz, IRON, v=6)) for s in (-1, 1): for dy in (-1, 1): P.append(beam((gx + s * 0.16, gy, gz + 0.04), (gx + s * 0.2, gy + dy * 0.2, 0.0), 0.05, 0.06, bev=0, name="gleg")) P.append(grain(plain(gx + s * 0.16 - 0.03, gx + s * 0.16 + 0.03, gy - 0.2, gy + 0.2, 0.14, 0.19, TIM, "grail"), (0, 1, 0))) P.append(cx("bearing", 0.036, gx + s * 0.16 - 0.034, gx + s * 0.16 + 0.034, gy, gz, IRON, v=8)) P.append(ptube("crank", rpath([(gx + 0.26, gy, gz), (gx + 0.26, gy, gz + 0.16), (gx + 0.33, gy, gz + 0.16)], 0.02, 2), 0.012, IRON, segs=4)) P.append(cx("crankgrip", 0.022, gx + 0.3, gx + 0.38, gy, gz + 0.16, PRED, v=6)) # the trough under the stone P.append(grain(plain(gx - 0.13, gx + 0.13, gy - 0.16, gy + 0.16, 0.19, 0.27, TIM, "trough"), (1, 0, 0))) P.append(plain(gx - 0.1, gx + 0.1, gy - 0.13, gy + 0.13, 0.272, 0.274, "M_TroughWater", "water")) graft("Body", P, ang=35) return dict(elev=12, azim=-28, man=(0.15, -1.0, 0), views=[("_bare", dict(elev=6, azim=-4, dist_mul=0.72))]) # ======================================================================= the upgrade stand def terminal(): r = UB.terminal() P = [] # bunting along the front of the awning a, b = Vector((-0.52, -0.5, 1.755)), Vector((0.52, -0.5, 1.755)) n = 9 pts = [a.lerp(b, k / n) - Vector((0, 0, 0.03 * math.sin(PI * k / n))) for k in range(n + 1)] P.append(ptube("string", pts, 0.005, IRON, segs=3)) for k in range(n): c0, c1 = pts[k], pts[k + 1] tip = c0.lerp(c1, 0.5) - Vector((0, 0, 0.065)) p0, p1 = c0.lerp(c1, 0.08), c0.lerp(c1, 0.92) P.append(prism("flag", [(p0.x, p0.z), (tip.x, tip.z), (p1.x, p1.z)], "XZ", -0.504, -0.496, (PRED, CRM, GRN)[k % 3])) # plans in a barrel beside the stand bx_, by_ = 0.7, 0.22 P.append(grain(revm("pbarrel", [(0.13, 0.0), (0.155, 0.16), (0.16, 0.3), (0.15, 0.46), (0.128, 0.46), (0.128, 0.2), (0, 0.2)], TIM, segs=8, loc=(bx_, by_, 0)), (0, 0, 1))) for z, r_ in ((0.1, 0.149), (0.38, 0.156)): P.append(cz("phoop", r_, z - 0.016, z + 0.016, bx_, by_, IRON, v=8, cap=False)) for (dx, dy, h, m_) in ((-0.05, 0.03, 0.74, "M_PaintCream"), (0.05, -0.04, 0.82, "M_Canvas"), (0.01, 0.06, 0.66, "M_PaintCream"), (0.06, 0.05, 0.6, "M_Canvas")): P.append(cyl_between("plan", (bx_ + dx, by_ + dy, 0.22), (bx_ + dx * 1.7, by_ + dy * 1.7, h), 0.03, m_, v=6)) c = Vector((bx_ + dx * 1.5, by_ + dy * 1.5, h - 0.14)) P.append(cz("tie", 0.033, c.z - 0.012, c.z + 0.012, c.x, c.y, PRED, v=6)) # a pennant over the awning P.append(cz("fmast", 0.012, 1.88, 2.26, 0.5, 0.44, IRON, v=5)) P.append(prism("fpen", [(0.5, 2.25), (0.5, 2.09), (0.86, 2.18)], "XZ", 0.436, 0.444, GRN)) graft("Body", P, ang=35, ms={CRM: 0.45, RED: 0.5}) return r # ======================================================================= the Grass Depot def hopper(): """The eye of a 1.3 m crew member is at the rim. Round 2 had thin air down there: a board apron under the rim makes the base read as a bin, with the stencil big enough to read across the deck. The tower gets its iron straps.""" r = UW.hopper() P = [] Z0, Z1 = 0.62, 1.03 for rz, front in ((0.0, True), (PI, False), (-PI / 2, False)): G = [] n = 6 w = 1.5 / n for k in range(n): x0 = -0.75 + k * w + 0.008 G.append(grain(plain(x0, x0 + w - 0.016, -0.905, -0.875, Z0 + (0.02 if k % 2 else 0.0), Z1, RED, "apron"), (0, 0, 1))) G.append(grain(plain(-0.76, 0.76, -0.915, -0.905, Z0 + 0.03, Z0 + 0.1, CRM, "abatten"), (1, 0, 0))) if front: sign_text(G, "DROP HERE", 0.15, INK, (0, -0.908, 0.84)) else: G.append(prism("aarrow", [(-0.12, 0.92), (0.12, 0.92), (0.12, 0.8), (0.22, 0.8), (0.0, 0.72), (-0.22, 0.8), (-0.12, 0.8)][::-1], "XZ", -0.911, -0.905, INK)) P += xgs(G, rz=rz) # iron splice straps on the corner posts, bolted through hw = lambda z: 0.87 - 0.17 * z / 3.7 for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)): for z in (1.5, 2.56, 3.3): h = hw(z) P.append(plain(sx * h - 0.086, sx * h + 0.086, sy * h - 0.086, sy * h + 0.086, z - 0.03, z + 0.03, IRON, "pstrap")) nut(P, (sx * (h + 0.086), sy * h, z), (sx, 0, 0), r=0.016, h=0.008, m=STL) graft("Body", P, ang=35, ms={CRM: 0.45}) return r # ======================================================================= the crew cabin _wnd, _tin, _cz, _cb = UB.window, UB.tin_slope, UB.cz, UB.cyl_between def cabin_window(P, x, y, z, w=1.0, h=1.1, rz=0.0, shutters=True, flowers=False, curtains=True, rng=None, seed=3): return _wnd(P, x, y, z, w=w, h=h, rz=rz, shutters=shutters, flowers=flowers, curtains=curtains and rz != 180, rng=rng, seed=seed) def cabin_tin(P, x0, x1, ya, za, yb, zb, n=6, t=0.03, rusty=(), lift=0.008): return _tin(P, x0, x1, ya, za, yb, zb, n=n, t=t, rusty=(), lift=lift) def cabin_cz(name, *a, **k): return None if name in ("flash", "stove", "sband", "hatstem", "hat") else _cz(name, *a, **k) def cabin_cb(name, *a, **k): return None if name == "stay" else _cb(name, *a, **k) def uvbox3(o, s=0.5): uv_box(o, s) return uv_keep(o) def cloth(P, x, z, pts_, m_, y=-1.78): """A flat piece of washing on the line: two skins back to back.""" bm = bmesh.new() F_ = [bm.verts.new((x + u, y - 0.002, z + v)) for u, v in pts_] B_ = [bm.verts.new((x + u, y + 0.002, z + v)) for u, v in reversed(pts_)] f, g = bm.faces.new(F_), bm.faces.new(B_) bmesh.ops.triangulate(bm, faces=[f, g], ngon_method="EAR_CLIP") bm.normal_update() for q in bm.faces: want = 1 if q.calc_center_median().y > y else -1 if q.normal.y * want < 0: q.normal_flip() o = mesh_obj("cloth", bm) set_mats(o, m_) P.append(uv_wall(o)) def crew_cabin(): """Round 2 house. The stovepipe is now a fieldstone chimney, the whole rust-brown sheets are small bolted patches, and the porch has been lived on: washing on a line and two hanging baskets. Curtains on the two back windows paid for it.""" UB.window, UB.tin_slope, UB.cz, UB.cyl_between = cabin_window, cabin_tin, cabin_cz, cabin_cb r = UB.crew_cabin() UB.window, UB.tin_slope, UB.cz, UB.cyl_between = _wnd, _tin, _cz, _cb P = [] # chimney px_, py_, ZR, YR = 2.0, 0.05, 4.0, 0.55 zf = ZR - abs(py_ - YR) x0, x1, y0, y1 = px_ - 0.3, px_ + 0.3, py_ - 0.27, py_ + 0.27 P.append(uvbox3(plain(x0, x1, y0, y1, zf - 0.4, 4.42, "M_RockWet", "chimney"), 1.1)) P.append(uvbox3(plain(x0 - 0.05, x1 + 0.05, y0 - 0.05, y1 + 0.05, 4.42, 4.52, "M_RockWet", "chimcap"), 1.1)) P.append(plain(x0 - 0.03, x1 + 0.03, y0 - 0.03, y1 + 0.03, 4.52, 4.56, "M_Concrete", "chimtop")) P.append(plain(x0 - 0.06, x1 + 0.06, y0 - 0.16, y1, zf - 0.05, zf + 0.13, TIN, "flashing")) for (dx, h) in ((-0.13, 0.26), (0.13, 0.2)): P.append(cz("pot", 0.075, 4.56, 4.56 + h, px_ + dx, py_, PRED, v=8, r2=0.095)) P.append(cz("potrim", 0.11, 4.56 + h, 4.56 + h + 0.03, px_ + dx, py_, PRED, v=8)) # small patches on the roof, bolted for (x, ya, za, yb, zb) in ((-1.5, -0.45, 3.0, 0.1, 3.55), (0.55, -1.7, 2.37, -1.1, 2.7), (-0.7, 1.05, 3.5, 1.45, 3.1)): a, b, c, d = (x - 0.3, ya, za + 0.04), (x + 0.3, ya, za + 0.04), (x + 0.3, yb, zb + 0.04), (x - 0.3, yb, zb + 0.04) if ya > 1: a, b, c, d = d, c, b, a P.append(uv_keep_slope(board(a, b, c, d, 0.012, "M_TinOld", bev=0, along="ad", name="rpatch"), (a, d))) # washing on a line between two porch posts a, b = Vector((-2.62, -1.78, 1.92)), Vector((-0.34, -1.78, 1.92)) n = 8 pts = [a.lerp(b, k / n) - Vector((0, 0, 0.09 * math.sin(PI * k / n))) for k in range(n + 1)] P.append(ptube("line", pts, 0.008, ROPE, segs=3)) at = lambda t: a.lerp(b, t).z - 0.09 * math.sin(PI * t) w = 0.34 h = 0.5 cloth(P, a.x + (b.x - a.x) * 0.2, at(0.2) + 0.01, [(-w / 2, 0), (-w / 2 - 0.11, -0.2), (-w / 2 - 0.03, -0.24), (-w / 2 + 0.03, -0.16), (-w / 2 + 0.03, -h), (w / 2 - 0.03, -h), (w / 2 - 0.03, -0.16), (w / 2 + 0.03, -0.24), (w / 2 + 0.11, -0.2), (w / 2, 0)], PRED) w = 0.3 h = 0.56 cloth(P, a.x + (b.x - a.x) * 0.5, at(0.5) + 0.01, [(-w / 2, 0), (-w / 2, -h), (-0.03, -h), (0.0, -0.3), (0.03, -h), (w / 2, -h), (w / 2, 0)], "M_Denim") w = 0.26 h = 0.36 cloth(P, a.x + (b.x - a.x) * 0.78, at(0.78) + 0.01, [(-w / 2, 0), (-w / 2, -h), (0.0, -h + 0.03), (w / 2, -h), (w / 2, 0)], "M_PaintCream") # two hanging baskets for x in (-0.26, 1.36): c = Vector((x, -1.62, 1.72)) P.append(cyl_between("bcord", (x, -1.72, 2.1), c + Vector((0, 0, 0.06)), 0.006, ROPE, v=3)) P.append(cz("basket", 0.13, c.z - 0.12, c.z, x, c.y, TIM, v=7, r2=0.17)) for k in range(2): a_ = k * 3.1 P.append(rock(0.1, (x + 0.08 * math.cos(a_), c.y + 0.08 * math.sin(a_), c.z + 0.06), seed=k + 4, sc=(1, 1, 0.85), m=LEAF, amp=0.15, name="foliage")) P.append(rock(0.045, (x + 0.1 * math.cos(a_ + 0.6), c.y + 0.1 * math.sin(a_ + 0.6), c.z + 0.12), seed=k, m=(PRED, GOLD, INK)[k], amp=0.1, name="bloom")) graft("Body", P, ang=35, ms={CRM: 0.4}) return dict(r, views=[("_front", dict(elev=8, azim=-8, dist_mul=0.72)), ("_close", dict(elev=10, azim=-14, dist_mul=0.42, target=(-0.6, -1.6, 1.3))), ("_back", dict(elev=22, azim=150))]) # ======================================================================= yard lamp and radio mast def yard_lamp(): """Round 2 pole, then: a cream rim and a wire guard on the shade, a finger sign to the meadow at eye level, climbing pegs, a birdhouse.""" r = UW.yard_lamp() P = [] # the finger post, on the -Y face: seen from the deck fz = 1.42 P.append(grain(prism("finger", [(-0.42, fz - 0.1), (0.3, fz - 0.1), (0.46, fz), (0.3, fz + 0.1), (-0.42, fz + 0.1)], "XZ", -0.125, -0.085, RED), (1, 0, 0))) sign_text(P, "MEADOW", 0.105, INK, (-0.05, -0.129, fz - 0.002)) for x in (-0.37, 0.27): nut(P, (x, -0.125, fz), (0, -1, 0), r=0.012, h=0.006, m=IRON) # birdhouse on the back of the pole bz = 2.02 P.append(grain(prism("bhouse", [(-0.1, bz), (0.1, bz), (0.1, bz + 0.2), (0.0, bz + 0.29), (-0.1, bz + 0.2)], "XZ", 0.08, 0.26, PRED), (0, 0, 1))) P.append(cy("bhole", 0.036, 0.255, 0.263, 0.0, bz + 0.17, "M_Charcoal", v=8)) P.append(cy("bperch", 0.009, 0.25, 0.31, 0.0, bz + 0.08, IRON, v=4)) for s in (-1, 1): a, b, c, d = (s * 0.14, 0.05, bz + 0.18), (0.0, 0.05, bz + 0.33), (0.0, 0.3, bz + 0.33), (s * 0.14, 0.3, bz + 0.18) if s > 0: a, b, c, d = d, c, b, a P.append(board(a, b, c, d, 0.016, TIN, bev=0, along="ab", name="broof")) # staggered iron pegs up the pole z, s = 0.95, 1 while z < 2.3: P.append(cx("peg", 0.012, min(s * 0.075, s * 0.2), max(s * 0.075, s * 0.2), 0.0, z, IRON, v=4)) z += 0.33 s = -s # shade rim and wire guard yc, zc = -0.4, 2.43 P.append(cz("shaderim", 0.268, zc - 0.03, zc + 0.005, 0, yc, CRM, v=12, cap=False)) for k in range(4): a = k * PI / 2 + PI / 4 P.append(cyl_between("guard", (0.13 * math.cos(a), yc + 0.13 * math.sin(a), zc + 0.03), (0.0, yc, zc - 0.13), 0.005, IRON, v=3)) graft("Body", P, ang=35) return r _wcb = UW.cyl_between def mast_cb(name, a, b, r, m, **k): if name in ("leg", "girt", "diag"): r *= 1.35 return _wcb(name, a, b, r, m, **k) def radio_mast(): """The dish was a flat grey plate. Now it has bright red and cream gores, the mast has more body, and a little tin porch keeps the rain off the radio.""" UW.cyl_between = mast_cb r = UW.radio_mast() UW.cyl_between = _wcb # gores: the faces of the bowl's inner surface take turns o = bpy.data.objects["Dish"] me = o.data names = [m_.name if m_ else "" for m_ in me.materials] if TIN in names: ti = names.index(TIN) for nm in (PRED, CRM): me.materials.append(mat(nm)) ip, ic = len(names), len(names) + 1 R = Matrix.Rotation(-math.radians(58), 3, "X") for p in me.polygons: if p.material_index == ti: c = R @ Vector(p.center) k = int(math.floor((math.atan2(c.y, c.x) + TAU) / (TAU / 12))) p.material_index = ip if k % 2 == 0 else ic me.update() # the porch over the board P = [] MYF, ZE, YB, ZB = -0.74, 2.04, 0.12, 2.3 UB.tin_slope(P, -0.64, 0.64, MYF, ZE, YB, ZB, n=3, rusty=(1,)) P.append(grain(plain(-0.66, 0.66, MYF - 0.03, MYF, ZE - 0.07, ZE + 0.02, CRM, "pfascia"), (1, 0, 0))) k_ = (ZB - ZE) / (YB - MYF) for x in (-0.46, 0.46): P.append(beam((x, YB, ZB - 0.07), (x, MYF + 0.02, ZE - 0.05), 0.05, 0.08, bev=0, name="prafter")) P.append(beam((x, -0.13, 1.72), (x, -0.56, ZE + (-0.56 - MYF) * k_ - 0.08), 0.05, 0.06, bev=0, name="pknee")) P.append(cyl_between("lrod", (0, -0.42, 2.17), (0, -0.42, 1.98), 0.007, IRON, v=4)) P.append(lantern(P, 0.0, -0.42, 1.74, m="M_LightAmber", r=0.05)) graft("Body", P, ang=35, ms={CRM: 0.5}) return r # ======================================================================= the mowers def push_mower(): """Round 2 machine with a working life: a rake lashed to the hopper, a lunch pail on the chassis, clippings spilling over the rim.""" r = UM.push_mower() random.seed(77) P = [] Xh, Y1h = 0.44, 0.90 for k in range(6): t = k / 5 tuft(P, -Xh + 2 * Xh * t, Y1h + 0.01, 0.79, L=0.1, n=2, az=PI / 2, m="M_GrassFill") for y in (0.5, 0.74): tuft(P, Xh + 0.01, y, 0.79, L=0.1, n=2, az=0.0, m="M_GrassFill") # the rake a, b = Vector((0.5, 0.2, 0.36)), Vector((0.5, 1.0, 0.74)) P.append(grain(cyl_between("rakepole", a, b, 0.016, TIM, v=6), b - a)) c = b + (b - a).normalized() * 0.02 P.append(grain(plain(0.3, 0.7, c.y - 0.03, c.y + 0.03, c.z - 0.025, c.z + 0.025, TIM, "rakehead"), (1, 0, 0))) for k in range(7): x = 0.32 + k * 0.06 P.append(cyl_between("tine", (x, c.y + 0.03, c.z), (x, c.y + 0.11, c.z - 0.03), 0.006, "P_G2", v=3)) for y, z in ((0.5, 0.5), (0.82, 0.66)): P.append(torus("rlash", 0.03, 0.009, (0.5, y, z), "Y", seg=6, rseg=3, m=ROPE)) # the lunch pail x, y, z = -0.2, 0.3, 0.38 P.append(cz("pail", 0.085, z, z + 0.14, x, y, "P_G4", v=8)) P.append(cz("paillid", 0.092, z + 0.14, z + 0.17, x, y, "P_RED", v=8)) P.append(ptube("pailbail", [(x - 0.08, y, z + 0.15), (x - 0.04, y, z + 0.24), (x + 0.04, y, z + 0.24), (x + 0.08, y, z + 0.15)], 0.005, "P_G1", segs=3)) graft("Body", P, ang=34, wn=False) return r _wheel = UM.wheel def rider_wheel(name, hub, R, W, out=1, lugs=12, sides=18, rs=10, rim="P_WHITE", bolts=5): return _wheel(name, hub, R, W, out=out, lugs=lugs - (2 if lugs == 12 else 1), sides=sides, rs=rs, rim=rim, bolts=bolts - 1) def rider_mower(): """Round 2 machine, a red and cream sunshade on a tube frame over the driver. Fewer lugs on the tyres pay for it. The crew with his hat stands 2.25 m tall on this seat, so the shade sits at 2.3 m.""" UM.wheel = rider_wheel r = UM.rider_mower() UM.wheel = _wheel P = [] Z = 2.3 for s in (-1, 1): pts = rpath([(s * 0.42, 0.54, 0.62), (s * 0.42, 0.54, Z - 0.02), (s * 0.42, -0.34, Z - 0.02)], 0.12, 3) P.append(ptube("hoop", pts, 0.024, "P_G2", segs=6)) P.append(cz("hoopfoot", 0.042, 0.6, 0.66, s * 0.42, 0.54, "P_G1", v=6)) P.append(ptube("hoopbar", [(-0.42, 0.54, 1.42), (0.42, 0.54, 1.42)], 0.02, "P_G2", segs=6)) N = 6 arch = lambda x: Z + 0.075 * (1 - (x / 0.56) ** 2) for k in range(N): xa, xb = -0.56 + k * 1.12 / N, -0.56 + (k + 1) * 1.12 / N prof = [(-0.46, 0.0), (0.64, 0.0), (0.64, 0.022), (-0.46, 0.022)] rings = [[(xa, y, arch(xa) + z) for y, z in prof], [(xb, y, arch(xb) + z) for y, z in prof]] P.append(UM.loft(rings, "P_RED" if k % 2 == 0 else "P_WHITE", name="shade")) graft("Body", P, ang=34, wn=False) return r def mower_bar(): """Round 2 bar with a safety curtain of chain strips along the mouth, grass caught in it.""" r = UM.mower_bar() G0, HW = -0.55, 1.40 P = [] x = -HW + 0.07 k = 0 while x < HW - 0.04: z1 = G0 + 0.385 z0 = z1 - (0.2 if k % 2 == 0 else 0.17) P.append(plain(x - 0.022, x + 0.022, -1.31, -1.296, z0, z1, "P_G1", "chain")) P.append(plain(x - 0.028, x + 0.028, -1.312, -1.294, z1 - 0.1, z1 - 0.088, "P_G3", "chainlink")) x += 0.14 k += 1 random.seed(5) for x in (-1.1, -0.72, 0.3, 0.9): tuft(P, x, -1.3, G0 + 0.2, L=0.12, n=3, az=-PI / 2, m="M_GrassFill") graft("Body", P, ang=34, wn=False) return r # ======================================================================= the crew _done, _face, _sphere, _gear = UC.done, UC.face, UC.sphere, UC.crew_gear STATE = {} def crew_sphere(name, r, *a, **k): if name == "eye": k.update(seg=16, rings=9) elif name == "pupil": r = 0.046 return _sphere(name, r, *a, **k) def crew_face(sx, F): _face(sx, F) # a green iris, a little proud of the eye, behind the smaller pupil c = Vector((sx * UC.EYEZ.x, UC.EYEZ.y, UC.EYEZ.z)) pc = c + Vector((-sx * 0.019, -0.109, -0.006)) F.append(_sphere("iris", 0.068, tuple(pc), seg=12, rings=5, m="M_Teal", scale=(1.0, 0.36, 1.0))) def crew_done(P, name, uv=3.0, ang=45): if name == "Backpack": S = STATE["S"] FACET = UC.FACET # a leather belt over the overalls with a brass buckle, a pouch at the hip Z = 0.372 band = lambda u, v, off: S.p(-90 + 360 * u, Z - 0.02 + 0.04 * v, 0.03 + off) P.append(OC.grid_slab("belt", band, 14, 1, 0.006, -0.006, LEAT, smooth_ang=FACET)) bc = S.p(-90, Z, 0.042) n = (bc - Vector((0, S.cy, bc.z))).normalized() fr = OC.frame_on(bc, n, up=(0, 0, 1)) P.append(OC.ring_prism("buckle", OC.rrect_pts(0.084, 0.06, 0.008, 1), OC.rrect_pts(0.046, 0.034, 0.004, 1), 0.012, fr, BRASS)) pc = S.p(-90 + 58, Z - 0.062, 0.05) pn = (pc - Vector((0, S.cy, pc.z))).normalized() fr = OC.frame_on(pc, pn, up=(0, 0, 1)) P.append(OC.prism("pouch", OC.rrect_pts(0.1, 0.11, 0.02, 2), 0.04, fr, LEAT)) P.append(OC.prism("pflap", OC.rrect_pts(0.104, 0.05, 0.012, 2), 0.012, fr @ Matrix.Translation((0, 0.034, 0.04)), "M_Navy")) UT.stud(P, fr @ Vector((0, 0.03, 0.052)), pn, r=0.009, h=0.005, m=BRASS) return _done(P, name, uv=uv, ang=ang) def crew_gear_wrap(S): STATE["S"] = S return _gear(S) def crew(): UC.sphere, UC.face, UC.done, UC.crew_gear = crew_sphere, crew_face, crew_done, crew_gear_wrap r = UC.crew() UC.sphere, UC.face, UC.done, UC.crew_gear = _sphere, _face, _done, _gear return r # ======================================================================= rocket and launch pad: never upgraded, over budget, smooth where everything else is cut OFF = 11.25 # the hull's sixteen sides are turned so a flat faces -Y def ringed(name, prof, m, n=16): """Revolved, turned so a flat faces the front.""" return xf(revm(name, prof, m, segs=n), rz=math.radians(OFF)) def corrugate(o, R): """Ribs step up the hull like a grain bin: U up, V round.""" me = o.data bm = bmesh.new() bm.from_mesh(me) uvl = bm.loops.layers.uv.verify() mw = o.matrix_world for f in bm.faces: c = mw @ f.calc_center_median() ac = math.atan2(c.y, c.x) for l in f.loops: p = mw @ l.vert.co a = math.atan2(p.y, p.x) if a - ac > PI: a -= TAU elif ac - a > PI: a += TAU l[uvl].uv = (p.z * 1.6, a * R * 0.5) bm.to_mesh(me) bm.free() return uv_keep(o) def arc_decal(name, r, a0, a1, z0, z1, m, n): """A patch on the hull, angle a0..a1, UV 0..1.""" bm = bmesh.new() uvl = bm.loops.layers.uv.verify() V = [] for i in range(n + 1): a = math.radians(a0 + (a1 - a0) * i / n) V.append((bm.verts.new((r * math.cos(a), r * math.sin(a), z0)), bm.verts.new((r * math.cos(a), r * math.sin(a), z1)))) for i in range(n): f = bm.faces.new((V[i][0], V[i + 1][0], V[i + 1][1], V[i][1])) for l, (u, v) in zip(f.loops, (((i) / n, 0), ((i + 1) / n, 0), ((i + 1) / n, 1), (i / n, 1))): l[uvl].uv = (u, v) o = mesh_obj(name, bm) set_mats(o, m) return uv_keep(o) def clip_x(pts, x0, x1): """Sutherland-Hodgman on two vertical lines.""" def cut(P_, inside, isect): out = [] for i in range(len(P_)): a, b = P_[i - 1], P_[i] ia, ib = inside(a), inside(b) if ib: if not ia: out.append(isect(a, b)) out.append(b) elif ia: out.append(isect(a, b)) return out def at(x): return lambda a, b: (x, a[1] + (b[1] - a[1]) * (x - a[0]) / (b[0] - a[0])) return cut(cut(pts, lambda p: p[0] >= x0, at(x0)), lambda p: p[0] <= x1, at(x1)) def rocket(): """A galvanised silo with ambitions, cut in sixteen flat sides: lapped courses of tin, a red tin nose in shingled rows, board fins on skids, a barn window, a ladder and a side door, milk churns for attitude control.""" P = [] R = 1.18 A = R * math.cos(math.pi / 16) # tail cone P.append(ringed("tail", [(0.45, 1.0), (0.82, 1.03), (1.05, 1.1), (1.2, 1.24), (1.25, 1.42), (R + 0.015, 1.72), (R, 1.8)], IRON)) # the courses of tin, each lapping over the one below C = ((1.72, 2.76, TIN), (2.74, 3.76, "M_TinOld"), (3.74, 5.0, TIN), (4.98, 6.22, TIN)) for (z0, z1, m_) in C: o = ringed("course", [(R + 0.022, z0), (R + 0.022, z0 + 0.03), (R, z0 + 0.07), (R, z1)], m_) P.append(corrugate(o, R)) for z in (1.76, 2.74, 3.74, 4.98, 6.2): P.append(ringed("hoop", [(R + 0.015, z - 0.055), (R + 0.04, z - 0.04), (R + 0.04, z + 0.04), (R + 0.015, z + 0.055)], IRON)) for k in range(8): a = TAU * (k + 0.5) / 8 + math.radians(OFF) nut(P, ((R + 0.036) * math.cos(a), (R + 0.036) * math.sin(a), z), (math.cos(a), math.sin(a), 0), r=0.02, h=0.012, m=STL) # the nose: ogive rows of red tin, a cream band NZ0, NL = 6.2, 2.8 rho = (R * R + NL * NL) / (2 * R) og = lambda z: math.sqrt(max(0.0, rho * rho - (z - NZ0) ** 2)) + R - rho zs = [6.2, 6.62, 7.02, 7.4, 7.76, 8.08, 8.36, 8.6, 8.76] for i, (a, b) in enumerate(zip(zs, zs[1:])): m_ = "M_PaintCream" if i == 1 else (PRED if i % 2 == 0 else "M_Pontoon") P.append(ringed("nosepanel", [(og(a) + 0.025, a), (og(a) + 0.008, a + 0.03), (og(b), b)], m_)) P.append(ringed("tipcap", [(og(8.74) + 0.03, 8.72), (0.2, 8.84), (0.08, 8.98), (0, 9.0)], IRON)) P.append(cz("ant", 0.022, 8.98, 9.26, 0, 0, IRON, v=6)) P.append(sphere("antl", 0.06, (0, 0, 9.28), seg=8, rings=5, m="M_Brass")) # engine: an iron funnel P.append(ringed("bell", [(0.6, 0.32), (0.57, 0.45), (0.48, 0.65), (0.38, 0.84), (0.34, 1.0)], IRON, n=12)) P.append(ringed("bellin", [(0.545, 0.33), (0.3, 0.9)], "M_Soot", n=12)) P.append(ringed("lip", [(0.57, 0.3), (0.625, 0.31), (0.625, 0.35), (0.57, 0.36)], STL, n=12)) P.append(ringed("bellband", [(0.5, 0.58), (0.54, 0.59), (0.52, 0.65), (0.48, 0.66)], STL, n=12)) # four plank fins on skids out = [(0.98, 3.35), (0.98, 1.3), (1.42, 0.12), (1.92, 0.12), (1.98, 0.85), (1.84, 1.85), (1.36, 3.1)] xs = (0.96, 1.18, 1.4, 1.62, 1.84, 2.0) for k in range(4): G = [] for i, (x0, x1) in enumerate(zip(xs, xs[1:])): pts = clip_x(out, x0 + 0.006, x1 - 0.006) if len(pts) >= 3: G.append(grain(prism("fin", pts, "XZ", -0.13, 0.13, RED if (i + k) % 2 == 0 else PRED), (0, 0, 1))) G.append(grain(plain(1.38, 1.93, -0.165, 0.165, 0.0, 0.14, TIM, "foot"), (1, 0, 0))) G.append(plain(1.36, 1.95, -0.172, 0.172, 0.1, 0.15, IRON, "shoe")) G.append(prism("finstripe", [(1.5, 0.52), (1.97, 0.52), (1.97, 0.7), (1.46, 0.7)], "XZ", -0.136, 0.136, "M_PaintCream")) for z in (1.32, 2.22): x1 = 1.9 if z < 2 else 1.68 G.append(plain(1.0, x1, -0.142, 0.142, z - 0.04, z + 0.04, IRON, "fstrap")) nut(G, (x1 - 0.1, -0.142, z), (0, -1, 0), r=0.018, h=0.01, m=STL) nut(G, (x1 - 0.1, 0.142, z), (0, 1, 0), r=0.018, h=0.01, m=STL) P += xgs(G, rz=math.radians(45 + 90 * k)) # a real barn window on the front flat, curtains and all UB.window(P, 0.0, -A - 0.02, 5.55, w=0.42, h=0.78, shutters=False, curtains=False) # the GreenHaul sign panels on both sides for ac in (180.0, 0.0): P.append(arc_decal("dframe", R + 0.012, ac - 56.25, ac + 56.25, 2.15, 3.45, "M_PaintCream", 5)) P.append(arc_decal("decal", R + 0.02, ac - 50.625, ac + 50.625, 2.25, 3.35, "M_RocketDecal", 5)) # a side door in the back flat, cream frame, red boards G = [grain(plain(-0.21, 0.21, A, A + 0.03, 2.3, 3.5, CRM, "dfr"), (0, 0, 1))] for k in range(3): x = -0.17 + k * 0.115 G.append(grain(plain(x, x + 0.108, A + 0.03, A + 0.05, 2.34, 3.46, RED, "dbrd"), (0, 0, 1))) G.append(beam((-0.15, A + 0.052, 2.42), (0.15, A + 0.052, 3.38), 0.06, 0.012, CRM, bev=0, name="dbrace")) for z in (2.55, 3.25): G.append(plain(-0.2, 0.06, A + 0.05, A + 0.062, z - 0.02, z + 0.02, IRON, "dhinge")) P += G # a ladder up the flat at 135 degrees a = math.radians(135.0 + 11.25) d, t = Vector((math.cos(a), math.sin(a), 0)), Vector((-math.sin(a), math.cos(a), 0)) c = d * (R + 0.12) for s in (-1, 1): p = c + t * s * 0.17 P.append(cz("lrail", 0.02, 1.86, 6.1, p.x, p.y, IRON, v=5)) for z in (2.2, 4.0, 5.8): q = p - d * 0.13 P.append(cyl_between("lbr", q + Vector((0, 0, z)), p + Vector((0, 0, z)), 0.012, IRON, v=4)) z = 2.05 while z < 6.05: P.append(cyl_between("lrung", c - t * 0.17 + Vector((0, 0, z)), c + t * 0.17 + Vector((0, 0, z)), 0.013, IRON, v=4)) z += 0.32 # milk churns strapped on near the nose: attitude control, allegedly can = [(0.15, 0.0), (0.16, 0.02), (0.16, 0.4), (0.09, 0.48), (0.08, 0.6), (0.11, 0.62), (0.11, 0.66), (0.0, 0.67)] for k in range(4): G = [revm("churn", can, TIN, segs=8, loc=(R + 0.16, 0.0, 5.25), cap_bot=True), cz("chstrap", 0.168, 5.4, 5.44, R + 0.16, 0.0, IRON, v=8, cap=False), plain(R - 0.04, R + 0.33, -0.15, 0.15, 5.2, 5.25, TIM, "chshelf")] P += xgs(G, rz=math.radians(45 + 90 * k)) ffin(P, "Body", ang=20, ms={CRM: 0.4}) empty("Flame", (0.0, 0.0, 0.32)) return dict(elev=12, azim=-35, views=[("_back", dict(elev=20, azim=150)), ("_close", dict(elev=10, azim=-20, dist_mul=0.45, target=(0, 0, 5.2)))]) def launch_pad(): """Rebuilt on the same plan: plank crib, a ring of baulks with a pit, four cradle cheeks, the derrick at the back right, red diesel tanks, the gated cargo bay at the front. The derrick is half as wide again with planked floors and a tin hut on top. RocketMount and Bay stay where they were. Under 8 000 tris, it was 12 800.""" rng = random.Random(44) P = [] C = (0.0, 0.35) TOP, zt = 0.58, 0.25 # the crib: dark timber base, plank top with real gaps, two staggered courses of baulks round it P.append(plain(-2.86, 2.86, -1.74, 2.86, 0.0, 0.17, IRON, "fill")) n = 15 pitch = (2.82 + 1.67) / n for k in range(n): yc = -1.67 + pitch * (k + 0.5) cut = rng.uniform(-1.8, 1.8) for (a, b) in ((-2.82, cut), (cut, 2.82)): P.append(plank_x(a + 0.004, b - 0.004, yc, pitch - 0.014, 0.16, zt - rng.choice((0.0, 0.0, 0.006)), rng.choice((PK, PK, PKW, PKD)), rng)) for k, (z0, z1) in enumerate(((0.0, 0.125), (0.125, 0.25))): d = 0.05 * k for y0, y1 in ((-1.8 + d, -1.67 + d), (2.82 - d, 2.95 - d)): P.append(grain(bx(-2.95 + d, 2.95 - d, y0, y1, z0, z1, TIM, bev=0.018, name="crib"), (1, 0, 0))) for s in (-1, 1): x0, x1 = sorted((s * (2.95 - d), s * (2.82 - d))) P.append(grain(bx(x0, x1, -1.8 + d, 2.95 - d, z0, z1, TIM, bev=0.018, name="crib"), (0, 1, 0))) for (x, y) in ((-2.86, -1.72), (2.86, -1.72), (-2.86, 2.86), (2.86, 2.86)): P.append(plain(x - 0.09, x + 0.09, y - 0.09, y + 0.09, 0.25, 0.265, IRON, "spike")) nut(P, (x, y, 0.265), (0, 0, 1), r=0.03, h=0.016, m=STL) def ring(R0, R1, z0, z1, m_, seg=16, a_off=0.0, gap=0.5, name="baulk", grainit=True): out = [] for k in range(seg): a0 = math.radians(360.0 * k / seg + a_off + gap) a1 = math.radians(360.0 * (k + 1) / seg + a_off - gap) pts = [(C[0] + R0 * math.cos(a0), C[1] + R0 * math.sin(a0)), (C[0] + R1 * math.cos(a0), C[1] + R1 * math.sin(a0)), (C[0] + R1 * math.cos(a1), C[1] + R1 * math.sin(a1)), (C[0] + R0 * math.cos(a1), C[1] + R0 * math.sin(a1))] o = prism(name, pts, "XY", z0, z1, m_) am = (a0 + a1) / 2 out.append(grain(o, (-math.sin(am), math.cos(am), 0)) if grainit else o) return out # the cradle: two staggered tiers of baulks, iron hoops, strike plates under the rocket's feet P += ring(1.37, 2.12, zt, zt + 0.17, TIM) P += ring(1.4, 2.04, zt + 0.17, TOP - 0.004, TIM, a_off=11.25) P.append(cz("hoop", 2.135, zt + 0.05, zt + 0.11, C[0], C[1], IRON, v=16, cap=False)) P.append(cz("hoop", 2.055, zt + 0.22, zt + 0.28, C[0], C[1], IRON, v=16, cap=False)) # the pit: dark floor, a flame cone, a grate of iron bars P.append(cz("pit", 1.38, zt, zt + 0.04, C[0], C[1], "M_Soot", v=16)) P.append(revm("deflector", [(1.1, zt + 0.04), (0.7, zt + 0.07), (0.35, zt + 0.15), (0.12, zt + 0.21), (0.0, zt + 0.22)], STL, segs=12, loc=(C[0], C[1], 0))) for k in range(8): bar_ = plain(0.3, 1.39, -0.04, 0.04, zt + 0.19, zt + 0.25, IRON, "gbar") P.append(xg(bar_, rz=math.radians(45 * k + 22.5), t=(C[0], C[1], 0))) P.append(revm("gring", [(0.84, zt + 0.19), (0.9, zt + 0.19), (0.9, zt + 0.25), (0.84, zt + 0.25)], IRON, segs=16, closed=True, loc=(C[0], C[1], 0))) P.append(revm("gring2", [(0.24, zt + 0.19), (0.32, zt + 0.19), (0.32, zt + 0.25), (0.24, zt + 0.25)], IRON, segs=8, closed=True, loc=(C[0], C[1], 0))) # four cheeks on the cardinals: timber knees with an iron base, strap and a burlap pad against the hull chk = [(1.55, TOP - 0.02), (2.02, TOP - 0.02), (1.97, 1.2), (1.8, 2.0), (1.34, 2.0), (1.34, 1.78), (1.56, 1.62)] for k in range(4): G = [grain(prism("cheek", chk, "XZ", -0.14, 0.14, TIM), (0, 0, 1)), uv_wall(plain(1.28, 1.36, -0.13, 0.13, 1.74, 1.98, BUR, "cpad")), cy("cpin", 0.055, -0.17, 0.17, 1.68, 1.0, IRON, v=8), plain(1.5, 2.06, -0.18, 0.18, TOP - 0.03, TOP + 0.07, IRON, "cbase"), plain(1.46, 1.92, -0.155, 0.155, 1.54, 1.6, IRON, "cstrap")] P += xgs(G, rz=math.radians(90 * k), t=(C[0], C[1], 0)) # the derrick at the back right corner T = (2.27, 2.31) hw = 0.56 lv = [zt, 1.7, 3.15, 4.6, 6.05, 7.3] for sx in (-1, 1): for sy in (-1, 1): x, y = T[0] + sx * hw, T[1] + sy * hw P.append(grain(plain(x - 0.1, x + 0.1, y - 0.1, y + 0.1, zt, 7.32, TIM, "col"), (0, 0, 1))) P.append(plain(x - 0.13, x + 0.13, y - 0.13, y + 0.13, zt, zt + 0.1, IRON, "colfoot")) for i, z in enumerate(lv[1:]): for s in (-1, 1): P.append(grain(plain(T[0] - hw - 0.12, T[0] + hw + 0.12, T[1] + s * hw - 0.05, T[1] + s * hw + 0.05, z, z + 0.14, TIM, "girt"), (1, 0, 0))) P.append(grain(plain(T[0] + s * hw - 0.05, T[0] + s * hw + 0.05, T[1] - hw - 0.12, T[1] + hw + 0.12, z - 0.13, z + 0.0, TIM, "girt"), (0, 1, 0))) for i in range(1, len(lv) - 1): z0, z1 = lv[i] + 0.14, lv[i + 1] - 0.13 for s in (-1, 1): for flip in (-1, 1): d = 0.075 * flip P.append(beam((T[0] + s * hw + s * 0.06 + d * 0.3, T[1] + flip * hw, z0), (T[0] + s * hw + s * 0.06 + d * 0.3, T[1] - flip * hw, z1), 0.04, 0.09, bev=0, name="brace")) P.append(beam((T[0] + flip * hw, T[1] + s * hw + s * 0.06 + d * 0.3, z0), (T[0] - flip * hw, T[1] + s * hw + s * 0.06 + d * 0.3, z1), 0.09, 0.04, bev=0, name="brace")) # the red tool shed in the bottom bay, door to the front P.append(uvbox3(plain(T[0] - hw + 0.04, T[0] + hw - 0.04, T[1] - hw + 0.04, T[1] + hw - 0.04, zt, lv[1] - 0.05, RED, "tbay"), 0.5)) P.append(grain(plain(T[0] - 0.3, T[0] + 0.14, T[1] - hw, T[1] - hw + 0.05, zt + 0.02, zt + 1.22, CRM, "tdoor"), (0, 0, 1))) P.append(beam((T[0] - 0.24, T[1] - hw - 0.006, zt + 0.1), (T[0] + 0.08, T[1] - hw - 0.006, zt + 1.14), 0.07, 0.014, PRED, bev=0, name="tdz")) # plank floors, the top hut: red boards under a tin pyramid, a mast with a lantern and pennant for z in (4.6, 6.05): P.append(uv_wall(plain(T[0] - hw, T[0] + hw, T[1] - hw, T[1] + hw, z + 0.14, z + 0.18, "M_WoodDeck", "floor"))) P.append(uvbox3(plain(T[0] - hw - 0.02, T[0] + hw + 0.02, T[1] - hw - 0.02, T[1] + hw + 0.02, 6.5, 7.32, RED, "hut"), 0.5)) P.append(grain(plain(T[0] - 0.24, T[0] + 0.24, T[1] - hw - 0.05, T[1] - hw - 0.02, 6.72, 7.1, "M_LightAmber", "hutwin"), (1, 0, 0))) for z in (6.68, 7.12): P.append(grain(plain(T[0] - 0.3, T[0] + 0.3, T[1] - hw - 0.06, T[1] - hw - 0.02, z - 0.03, z + 0.03, CRM, "hutfr"), (1, 0, 0))) for x in (-0.27, 0.0, 0.27): P.append(plain(T[0] + x - 0.025, T[0] + x + 0.025, T[1] - hw - 0.06, T[1] - hw - 0.02, 6.7, 7.1, CRM, "hutfr")) rf = revm("troof", [(0.96, 7.32), (0.0, 7.86)], TIN, segs=4, cap_bot=True) P.append(grain(xf(rf, rz=PI / 4, t=(T[0], T[1], 0)), (0, 0, 1))) P.append(grain(plain(T[0] - 0.67, T[0] + 0.67, T[1] - 0.67, T[1] + 0.67, 7.3, 7.36, CRM, "troofrim"), (1, 0, 0))) P.append(cz("tmast", 0.024, 7.8, 8.44, T[0], T[1], IRON, v=6)) P.append(sphere("tball", 0.05, (T[0], T[1], 8.445), seg=8, rings=5, m="M_Brass")) P.append(prism("pennant", [(T[0] - 0.02, 8.32), (T[0] - 0.02, 8.04), (T[0] - 0.6, 8.18)], "XZ", T[1] - 0.006, T[1] + 0.006, PRED)) # the ladder up the front of the tower ly, lx = T[1] - hw - 0.17, T[0] + 0.3 for dx in (-0.17, 0.17): P.append(grain(plain(lx + dx - 0.03, lx + dx + 0.03, ly - 0.03, ly + 0.03, lv[1], 6.5, TIM, "lrail"), (0, 0, 1))) for z in (2.4, 4.0, 5.5): P.append(plain(lx + dx - 0.015, lx + dx + 0.015, ly, T[1] - hw, z - 0.02, z + 0.02, IRON, "lbrk")) z = lv[1] + 0.25 while z < 6.45: P.append(cx("lrung", 0.018, lx - 0.17, lx + 0.17, ly, z, IRON, v=4)) z += 0.34 # a service boom to the rocket with two hoses, a plank gangway on rope stays d = Vector((C[0] - T[0], C[1] - T[1], 0)) Ld = d.length phi = math.atan2(d.y, d.x) La = Ld - 1.3 A1 = [grain(plain(0.3, La - 0.15, -0.1, 0.1, 4.62, 4.84, TIM, "arm1"), (1, 0, 0)), plain(La - 0.22, La - 0.02, -0.17, 0.17, 4.52, 4.9, IRON, "head1"), uv_wall(plain(La - 0.04, La + 0.04, -0.14, 0.14, 4.56, 4.86, BUR, "pad1")), beam((0.25, 0.0, 3.9), (1.0, 0.0, 4.64), 0.08, 0.1, bev=0, name="kneeA"), ptube("hose", [(0.25, 0.16, 4.62), (La * 0.45, 0.16, 4.3), (La - 0.15, 0.16, 4.62)], 0.05, RUB, segs=6), ptube("hose2", [(0.25, -0.16, 4.66), (La * 0.5, -0.16, 4.42), (La - 0.15, -0.16, 4.66)], 0.035, GOLD, segs=5)] A2 = [uv_wall(plain(0.3, La - 0.12, -0.3, 0.3, 6.1, 6.17, "M_WoodDeck", "arm2")), plain(La - 0.16, La + 0.02, -0.33, 0.33, 6.03, 6.2, IRON, "head2"), uv_wall(plain(La - 0.02, La + 0.05, -0.28, 0.28, 6.05, 6.5, BUR, "pad2"))] for s in (-1, 1): A2.append(grain(plain(0.3, La - 0.1, s * 0.27 - 0.035, s * 0.27 + 0.035, 5.97, 6.09, TIM, "gstring"), (1, 0, 0))) for x in (0.42, La - 0.2): A2.append(grain(plain(x - 0.03, x + 0.03, s * 0.3 - 0.03, s * 0.3 + 0.03, 6.1, 6.68, TIM, "gpost"), (0, 0, 1))) A2.append(ptube("grope", [(0.42, s * 0.3, 6.62), (La * 0.5, s * 0.3, 6.52), (La - 0.2, s * 0.3, 6.62)], 0.014, ROPE, segs=4)) P += xgs(A1 + A2, rz=phi, t=(T[0], T[1], 0)) # the red diesel tanks on saddles, the back left for x in (-2.48, -1.86): P.append(xf(revm("tank", [(0.0, -0.62), (0.2, -0.62), (0.28, -0.52), (0.28, 0.52), (0.2, 0.62), (0.0, 0.62)], PRED, segs=10), rx=PI / 2, t=(x, 2.28, zt + 0.42))) for y in (1.95, 2.6): P.append(xf(cz("tband", 0.292, -0.04, 0.04, 0, 0, IRON, v=10, cap=False), rx=PI / 2, t=(x, y, zt + 0.42))) P.append(plain(x - 0.2, x + 0.2, y - 0.07, y + 0.07, zt, zt + 0.22, TIM, "cradle")) P.append(cz("valve", 0.05, zt + 0.68, zt + 0.78, x, 2.28, IRON, v=6)) P.append(cz("vwheel", 0.08, zt + 0.78, zt + 0.81, x, 2.28, "M_Brass", v=8)) P.append(ptube("fuel", [(-2.17, 1.7, zt + 0.42), (-2.17, 1.25, zt + 0.42), (-1.5, 0.9, zt + 0.12), (-1.2, 0.75, zt + 0.12)], 0.05, STL, segs=6)) # lanterns on posts at the front of the crib for s in (-1, 1): x, y = s * 2.62, -1.42 P.append(grain(plain(x - 0.09, x + 0.09, y - 0.09, y + 0.09, zt, zt + 0.5, TIM, "wpost"), (0, 0, 1))) P.append(plain(x - 0.11, x + 0.11, y - 0.11, y + 0.11, zt + 0.5, zt + 0.53, IRON, "wcap")) P.append(lantern(P, x, y, zt + 0.53, m="M_LightAmber", r=0.06)) # the cargo bay on the deck: hay-gold frame, cream chevrons, gate posts with green lanterns, the chute into the crib P.append(grain(plain(-1.6, 1.6, -2.88, -1.9, 0.0, 0.03, TIM, "bayfloor"), (1, 0, 0))) for (x0, x1, y0, y1) in ((-1.7, 1.7, -2.98, -2.88), (-1.7, 1.7, -1.9, -1.8), (-1.7, -1.6, -2.88, -1.9), (1.6, 1.7, -2.88, -1.9)): P.append(plain(x0, x1, y0, y1, 0.0, 0.04, GOLD, "bayframe")) for yb in (-2.14, -2.41, -2.68): chevron_flat(P, yb + 0.33, 0.6, 0.22, 0.11, 0.025, 0.036, m=INK) for s in (-1, 1): x, y = s * 1.78, -2.4 P.append(grain(plain(x - 0.12, x + 0.12, y - 0.12, y + 0.12, 0.0, 1.05, TIM, "pylon"), (0, 0, 1))) for z in (0.12, 0.74): P.append(plain(x - 0.13, x + 0.13, y - 0.13, y + 0.13, z, z + 0.06, IRON, "pyband")) P.append(plain(x - 0.15, x + 0.15, y - 0.15, y + 0.15, 1.04, 1.1, IRON, "pycap")) P.append(lantern(P, x, y, 1.1, m="M_LightGreen", r=0.06)) P.append(plain(-0.78, 0.78, -1.815, -1.77, 0.02, 0.215, TIM, "chutef")) P.append(uv_wall(plain(-0.64, 0.64, -1.84, -1.815, 0.05, 0.2, BUR, "chutefl"))) ffin(P, "Body", ang=35, ms={BUR: 2.0}) empty("RocketMount", (C[0], C[1], TOP)) empty("Bay", (0.0, -2.39, 0.0)) return dict(elev=24, azim=-38, views=[("_back", dict(elev=22, azim=150)), ("_close", dict(elev=12, azim=-30, dist_mul=0.5, target=(0.4, -0.8, 0.8)))]) # ======================================================================= main BUILDERS = { "SM_Tool_NailScissors": nail_scissors, "SM_Tool_GardenShears": garden_shears, "SM_Tool_Sickle": sickle, "SM_Tool_Scythe": scythe, "SM_Tool_LongScythe": long_scythe, "SM_Tool_WideScythe": wide_scythe, "SM_Tool_Hammer": hammer, "SM_DeckTile": deck_tile, "SM_Ladder": ladder, "SM_Dock": dock, "SM_SupplyWall": supply_wall, "SM_Terminal": terminal, "SM_Hopper": hopper, "SM_CrewCabin": crew_cabin, "SM_Decor_Lamp": yard_lamp, "SM_Decor_Dish": radio_mast, "SM_PushMower": push_mower, "SM_RiderMower": rider_mower, "SM_MowerBar": mower_bar, "SM_Rocket": rocket, "SM_LaunchPad": launch_pad, "SM_Crew": crew, } BUDGET = {"SM_Tool_NailScissors": 1400, "SM_Tool_GardenShears": 2000, "SM_Tool_Sickle": 1400, "SM_Tool_Scythe": 2000, "SM_Tool_LongScythe": 2200, "SM_Tool_WideScythe": 2200, "SM_Tool_Hammer": 1800, "SM_DeckTile": 5000, "SM_Ladder": 2000, "SM_Dock": 5000, "SM_SupplyWall": 6000, "SM_Terminal": 4500, "SM_Hopper": 8000, "SM_CrewCabin": 8000, "SM_Decor_Lamp": 2000, "SM_Decor_Dish": 8000, "SM_PushMower": 8000, "SM_RiderMower": 8000, "SM_MowerBar": 8000, "SM_Rocket": 8000, "SM_LaunchPad": 8000, "SM_Crew": 8000} def main(): args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] names = [a for a in args if a in BUILDERS] rest = [a for a in args if a not in BUILDERS] if "SM_Crew" in names: # rigged: it has its own export names.remove("SM_Crew") reset() random.seed(7) OC.finish_x("SM_Crew", crew()) sys.argv = sys.argv[:sys.argv.index("--") + 1] + names + rest if not names: return build_main({k: v for k, v in BUILDERS.items() if k != "SM_Crew"}, BUDGET) if __name__ == "__main__": main()