"""GRASS CUTTER - fifth round of the hand tools: a detail pass. Pilot: SM_Tool_WideScythe, SM_Tool_Scythe, SM_Tool_GardenShears; then the other blade tools: SM_Tool_NailScissors, SM_Tool_Sickle, SM_Tool_Hammer, SM_Tool_LongScythe, and SM_Tool_Shears (the old file name of the garden shears: the game's SM_Tool_Shears.fbx is still round 2's copy of them on the same frame and no tool uses it, so it is the round 5 garden shears again under that name). Round 4 (gc_up4_tools) gave the tools their real shapes, but up close in first person the parts still read as placeholders: rods for braces, a hex tube for a turnbuckle, a box with two bolts for the blade mount, plain bands for clamps. This round keeps round 4's frame exactly (pivots, axes, lengths, grip points, object names and origins, material slot names) and models the parts properly: blades a real section: a fine edge, a bright ground bevel, a flat hammered cheek (mottled pack greys plus a little dimpling), a rounded spine, a beard where the heel curves up into the mount, the heel thickening where it is forged into the tang backs the WideScythe's riveted back is a channel clasping the spine, domed rivet heads on top, peened tails under it mounts a forged shoe round the snath end: rounded edges, a lip round the entry, jaw plates riveted over the blade where it leaves, through-bolts with washers, hex heads, nuts and threads poking out, a driven timber wedge with a mushroomed head braces flat bars forged flat into bolt eyes, bolted into clevis lugs welded (with a bead) to a saddle strap and to the blade back; the turnbuckle is an open brass frame with two threaded rods and lock nuts clamps straps with rolled edges and pinch ears, a bolt through the ears wood turned nibs: brass ferrule, collars and grooves, a spiral leather wrap, a knob held by a nut; grain runs along every part shears a pivot bolt with a dished washer, a nut with the thread through it, riveted ferrules, rubber bumpers in steel cups, ridged rubber grips, a sharper branch notch Hammered steel: the cheek faces are triangulated and each takes one of five close greys (P_HMD 88, P_HM1 92, P_G1, P_HM2 99, P_HML 107, all from the pack atlas) from a smooth noise field, so a hammer mark shades through next-door steps instead of a face jumping a whole step. The ground bevel is the brightest grey (P_WHITE) behind a dark grind line (P_DGREY), the edge a honed line (P_G5). Every P_ slot becomes M_Pack, so the game sees no new material. Shoes (scythe mounts) are swept forged pillows that draw in towards the blade, with a swelled socket collar round the snath; the wedge is a tapered timber block with a mushroomed end-grain head; strap ears are half as big again as the pilot's. Output never goes to Assets: .blend, fbx/.fbx in ArtSource/Blender/remaster_v3_tools (export settings of common.py). Run (absolute paths): blender -b --factory-startup --python C:/Github/Grass-Cutters/ArtSource/Blender/scripts/gc_up5_tools.py -- [SM_Tool_WideScythe ...] Review renders and the review scene: gc_up5_check.py. """ import sys, os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import common import gc_up4_tools as U4 from gc_up4_tools import * # noqa: F401,F403 (round 4 helpers, gc_up3_base, kit, materials) import gc_up_kit as KIT import gc_up_tools as UT import gc_up_machines as UM import gc_farm_tools as FT from os_crew import lathe, catmull TAU = 2 * math.pi DEG = math.radians OUT = os.path.join(common.ROOT, "ArtSource", "Blender", "remaster_v3_tools") # hammered steel: two neutral greys either side of P_G1, from the grey ramp along the bottom of the pack atlas UM.SW["HMD"] = (.2021, .0107, "#585858") UM.SW["HML"] = (.2334, .0107, "#6B6B6B") for _k in ("HMD", "HML"): common.MATDEFS["P_" + _k] = {"name": "P_" + _k, "color": UM.SW[_k][2]} HMD, HML = "P_HMD", "P_HML" # two more steps between them, from the cool grey column of the atlas (u .1236): 88, 92, (G1 95-99), 99, 107. Five close greys let the # hammered mottle shade from one into the next instead of jumping a whole step face by face. UM.SW["HM1"] = (.1236, .2534, "#5C5D5E") UM.SW["HM2"] = (.1236, .278, "#636466") for _k in ("HM1", "HM2"): common.MATDEFS["P_" + _k] = {"name": "P_" + _k, "color": UM.SW[_k][2]} HM1, HM2 = "P_HM1", "P_HM2" # blade finish: the bright ground bevel, the honed edge line, the dark line where the grind meets the flat BEV, EDGE, GLINE = WHT, G5, DGY def _hash3(i, j, k, seed): n = (i * 73856093) ^ (j * 19349663) ^ (k * 83492791) ^ (seed * 2654435761) n &= 0xffffffff n = ((n ^ (n >> 13)) * 1274126177) & 0xffffffff n ^= n >> 16 return (n & 0xffff) / 32767.5 - 1.0 def vnoise(p, seed=0): """Smooth value noise in [-1, 1] at point p (lattice spacing 1).""" x, y, z = p i, j, k = math.floor(x), math.floor(y), math.floor(z) fx, fy, fz_ = x - i, y - j, z - k sx, sy, sz = (fx * fx * (3 - 2 * fx), fy * fy * (3 - 2 * fy), fz_ * fz_ * (3 - 2 * fz_)) acc = 0.0 for di in (0, 1): for dj in (0, 1): for dk in (0, 1): w = (sx if di else 1 - sx) * (sy if dj else 1 - sy) * (sz if dk else 1 - sz) acc += w * _hash3(i + di, j + dj, k + dk, seed) return acc def hammer_field(p, scale=0.02, seed=1): """Hammer marks: soft blotches about `scale` across, a finer layer over them. Roughly -1..1.""" p = Vector(p) / scale return (0.62 * vnoise(p, seed) + 0.28 * vnoise(p * 2.3 + Vector((7.1, 3.3, 1.7)), seed + 1) + 0.1 * vnoise(p * 5.1 + Vector((1.3, 9.2, 4.4)), seed + 2)) * 1.45 def hammer_mottle(o, slot, levels=None, scale=0.02, seed=1, bias=0.0, cuts=(-0.78, -0.26, 0.26, 0.78), frame=None, tri=True): """Hammered steel on the faces of material `slot` of o: those faces are triangulated (so a blotch's outline runs on diagonals, not in squares) and each takes one of five close greys (dark .. light; the middle one defaults to the slot's own material) from a smooth noise field at its centre. The five greys are next-door steps, so a blotch shades through them like a soft stain. frame: a matrix taking the mesh's coordinates to the space the noise lives in (the blade's own frame keeps the marks fixed to it).""" me = o.data names = [m.name if m else "" for m in me.materials] if levels is None: levels = (HMD, HM1, names[slot], HM2, HML) idx = [] for nm in levels: if nm not in names: me.materials.append(mat(nm)) names.append(nm) idx.append(names.index(nm)) bm = bmesh.new() bm.from_mesh(me) fs = [f for f in bm.faces if f.material_index == slot] if tri and fs: r = bmesh.ops.triangulate(bm, faces=fs, quad_method="BEAUTY", ngon_method="BEAUTY") fs = [f for f in r["faces"]] Fi = frame if frame is not None else Matrix.Identity(4) for f in fs: v = hammer_field(Fi @ f.calc_center_median(), scale, seed) + bias k = sum(1 for c in cuts if v > c) f.material_index = idx[k] bm.to_mesh(me) bm.free() me.update() return o # natural jute twine, from the atlas' rope column UM.SW["JUTE"] = (.0484, .3276, "#9B835A") common.MATDEFS["P_JUTE"] = {"name": "P_JUTE", "color": UM.SW["JUTE"][2]} JUTE = "P_JUTE" # Mottle by UV: the faces keep M_Pack and each vertex gets a UV along a ramp of the atlas, from a smooth noise field. The ramp is stepped, # but the steps now fall on smooth contour lines across the faces instead of on the faces' edges, so a hammer mark has a soft outline # however close the camera gets. (u, v) centre, (du, dv) per unit of the field, clamp on the moving axis. STEEL_RAMP = ((0.1236, 0.2656), (0.0, 0.028), (0.2215, 0.3110)) # the cool grey column: 87 | 92 | 99 | 109 FORGE_RAMP = ((0.1709, 0.0107), (0.017, 0.0), (0.1275, 0.2140)) # the bottom grey ramp: 52 | 69 | 88 (forge scale on dark iron) def hammer_uv(o, slot, ramp=STEEL_RAMP, scale=0.02, seed=1, frame=None, bias=0.0): """Hammered or forged steel on the faces of material `slot`: the slot becomes M_Pack and every vertex of those faces takes a UV on `ramp` from hammer_field at the vertex (in `frame`'s space). The other P_ slots get their swatches from pack_uv as usual; the object is marked uv_done so nothing box-maps over it.""" me = o.data me.materials[slot] = mat("M_Pack") (u0, v0), (du, dv), (lo, hi) = ramp Fi = frame if frame is not None else Matrix.Identity(4) bm = bmesh.new() bm.from_mesh(me) uvl = bm.loops.layers.uv.verify() vals = {} for f in bm.faces: if f.material_index != slot: continue for lp in f.loops: k = vals.get(lp.vert.index) if k is None: k = vals[lp.vert.index] = hammer_field(Fi @ lp.vert.co, scale, seed) + bias u, w = u0 + du * k, v0 + dv * k if du: u = max(lo, min(hi, u)) else: w = max(lo, min(hi, w)) lp[uvl].uv = (u, w) bm.to_mesh(me) bm.free() me.update() o["uv_done"] = True return o # Hardware level of detail: inside a builder wrapped by _lod, the small fixings (the hidden nut side of bolts, washers, threads, rivet # tails, weld beads, strap ears) are built with fewer segments. Builders not wrapped (the other scripts') get the full counts. HW_LOD = [0] def _lod(fn): def run(*a, **k): HW_LOD[0] = 1 try: return fn(*a, **k) finally: HW_LOD[0] = 0 run.__name__, run.__doc__ = fn.__name__, fn.__doc__ return run # ======================================================================= frames and sections def fz(c, n, ref=None): """Local +Z -> n at c, local +X towards ref (projected), so a hex can be turned on purpose.""" n = Vector(n).normalized() r = Vector(ref) if ref is not None else (Vector((1, 0, 0)) if abs(n.x) < 0.9 else Vector((0, 1, 0))) x = (r - n * r.dot(n)) if x.length < 1e-6: x = n.orthogonal() x.normalize() y = n.cross(x) M = Matrix((x, y, n)).transposed().to_4x4() M.translation = Vector(c) return M def circ(r, n=12, ph=None): ph = PI / n if ph is None else ph ra, rb = r if isinstance(r, tuple) else (r, r) return [(ra * math.cos(ph + TAU * k / n), rb * math.sin(ph + TAU * k / n)) for k in range(n)] def rrect(hw, hh, rc, nc=3): """Rounded rectangle, counter-clockwise from the +a +b corner; 4 * (nc + 1) points. Face j: j % (nc + 1) == nc is a flat.""" rc = min(rc, hw * 0.98, hh * 0.98) pts = [] for cx, cy, a0 in ((hw - rc, hh - rc, 0), (-(hw - rc), hh - rc, 90), (-(hw - rc), -(hh - rc), 180), (hw - rc, -(hh - rc), 270)): for j in range(nc + 1): a = DEG(a0 + 90 * j / nc) pts.append((cx + rc * math.cos(a), cy + rc * math.sin(a))) return pts def frames(C, ref=None): """Parallel-transport frames along a polyline: tangents, N (across, starts towards ref), B = T x N.""" n = len(C) T = [(C[min(i + 1, n - 1)] - C[max(i - 1, 0)]).normalized() for i in range(n)] r = Vector(ref) if ref is not None else (Vector((1, 0, 0)) if abs(T[0].x) < 0.9 else Vector((0, 0, 1))) N = (r - T[0] * r.dot(T[0])).normalized() Ns, Bs = [], [] for i in range(n): N = (N - T[i] * N.dot(T[i])).normalized() Ns.append(N) Bs.append(T[i].cross(N)) return T, Ns, Bs def arclen(C): L = [0.0] for a, b in zip(C, C[1:]): L.append(L[-1] + (b - a).length) return L def sweep(name, C, sec, mats, colfn=None, uv=None, cap0=True, cap1=True, ang=30, ref=None, frm=None): """A solid along polyline C. sec(s, i) -> [(a, b)] across N and along B (same count every ring). colfn(i, j) -> slot of the face from ring i to i + 1, point j to j + 1 (caps: colfn(-1, -1), colfn(n, -1)). uv = (u0, uw, scale): timber UVs, U round the section inside one board of the texture, V along the arc (grain along the part).""" C = [Vector(p) for p in C] T, N, B = frm or frames(C, ref) L = arclen(C) bm = bmesh.new() uvl = bm.loops.layers.uv.verify() R = [] for i, c in enumerate(C): s = L[i] / max(L[-1], 1e-9) R.append([bm.verts.new(tuple(c + N[i] * a + B[i] * b)) for a, b in sec(s, i)]) m = len(R[0]) for i in range(len(R) - 1): for j in range(m): k = (j + 1) % m f = bm.faces.new((R[i][j], R[i][k], R[i + 1][k], R[i + 1][j])) f.material_index = colfn(i, j) if colfn else 0 if uv: u0, uw, sc = uv ua, ub = u0 - uw + 2 * uw * j / m, u0 - uw + 2 * uw * (j + 1) / m for lp, (uu, vv) in zip(f.loops, ((ua, L[i]), (ub, L[i]), (ub, L[i + 1]), (ua, L[i + 1]))): lp[uvl].uv = (uu, vv * sc) caps = [] if cap0: caps.append(bm.faces.new(list(reversed(R[0])))) caps[-1].material_index = colfn(-1, -1) if colfn else 0 if cap1: caps.append(bm.faces.new(R[-1])) caps[-1].material_index = colfn(len(R), -1) if colfn else 0 if uv: for f in caps: for lp in f.loops: lp[uvl].uv = (uv[0] + (lp.vert.co.x - lp.vert.co.y) * 2.0, lp.vert.co.z * 2.0) if caps: bmesh.ops.triangulate(bm, faces=[f for f in caps if len(f.verts) > 4], ngon_method="EAR_CLIP") bmesh.ops.recalc_face_normals(bm, faces=bm.faces) idx = [f.material_index for f in bm.faces] o = mesh_obj(name, bm) set_mats(o, *mats) o.data.polygons.foreach_set("material_index", idx) o.data.update() smooth(o, ang) if uv: o["uv_done"] = True return o def bprism(name, outline, z0, z1, mats, bev=0.0, segs=2, frame=None, min_ang=25, bev_slot=None, ang=30): """An outline (x, y) extruded z0..z1 with every sharp edge bevelled (bmesh bevel, `segs` segments). bev_slot: slot of the bevel faces.""" bm = bmesh.new() lo = [bm.verts.new((x, y, z0)) for x, y in outline] hi = [bm.verts.new((x, y, z1)) for x, y in outline] n = len(outline) bm.faces.new(list(reversed(lo))) bm.faces.new(hi) for j in range(n): k = (j + 1) % n bm.faces.new((lo[j], lo[k], hi[k], hi[j])) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) if bev > 0: es = [e for e in bm.edges if e.is_manifold and e.calc_face_angle(0) > DEG(min_ang)] r = bmesh.ops.bevel(bm, geom=es, offset=bev, offset_type="OFFSET", segments=segs, profile=0.5, affect="EDGES", clamp_overlap=True) if bev_slot is not None: for f in r["faces"]: f.material_index = bev_slot bmesh.ops.triangulate(bm, faces=[f for f in bm.faces if len(f.verts) > 4], quad_method="BEAUTY", ngon_method="EAR_CLIP") if frame is not None: bmesh.ops.transform(bm, matrix=frame, verts=bm.verts) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) idx = [f.material_index for f in bm.faces] o = mesh_obj(name, bm) set_mats(o, *mats) o.data.polygons.foreach_set("material_index", idx) o.data.update() smooth(o, ang) return o def sellipse(a, b, p=4.0, n=24, ph=0.0): """A superellipse |x/a|^p + |y/b|^p = 1, n points counter-clockwise: p = 2 an ellipse, p ~ 4 a forged pillow (flats that swell, corners that round).""" out = [] for k in range(n): t = ph + TAU * k / n c, s = math.cos(t), math.sin(t) out.append((a * math.copysign(abs(c) ** (2 / p), c), b * math.copysign(abs(s) ** (2 / p), s))) return out def rounded_outline(pts, r, n=3): """Round every corner of a closed outline by r (n points per corner).""" out = [] m = len(pts) for i in range(m): p, a, b = Vector(pts[i]), Vector(pts[i - 1]), Vector(pts[(i + 1) % m]) da, db = (a - p).normalized(), (b - p).normalized() k = min(r, (a - p).length * 0.45, (b - p).length * 0.45) p0, p1 = p + da * k, p + db * k for j in range(n + 1): t = j / n q = (1 - t) ** 2 * p0 + 2 * (1 - t) * t * p + t ** 2 * p1 # quadratic Bezier through the corner out.append((q.x, q.y)) return out def lug_outline(w, h, r_end, n=5): """A lug: a base w wide at y = 0 rising to a round end of radius r_end centred at (0, h).""" r_ = max(r_end, 0.0) return [(-w / 2, 0.0), (w / 2, 0.0)] + [(r_ * math.cos(PI * k / n), h + r_ * math.sin(PI * k / n)) for k in range(n + 1)] # ======================================================================= hardware def washer(P, c, n, r, t, m=G4, segs=None, ref=None): segs = segs or (8 if r < 0.016 else 10) if HW_LOD[0]: segs = min(segs, 8 if r >= 0.012 else 6) ch = t * 0.4 P.append(lathe("washer", [(0.0, 0.0), (r, 0.0), (r, t - ch), (r - ch, t), (0.0, t)], segs=segs, m=m, frame=fz(c, n, ref), smooth_ang=30)) return Vector(c) + Vector(n).normalized() * t def hexnut(P, c, n, R, h, m=G4, ref=None, name="nut"): """Across corners 2R, h high on +n from c, both faces chamfered.""" ch = min(h * 0.22, R * 0.2) P.append(lathe(name, [(0.0, 0.0), (R - ch, 0.0), (R, ch), (R, h - ch), (R - ch, h), (0.0, h)], segs=6, m=m, frame=fz(c, n, ref), smooth_ang=20)) return Vector(c) + Vector(n).normalized() * h def thread(P, c, n, r, L, m=G3, pitch=None, segs=8, inside=0.004): """A threaded end poking out L past c along n: sawtooth grooves, a chamfered tip.""" pitch = pitch or max(r * 0.7, 0.0018) if HW_LOD[0]: pitch = max(pitch, (L - r * 0.25) / 3.2) segs = 6 prof = [(0.0, -inside), (r * 0.86, -inside)] z = 0.0 while z + pitch < L - r * 0.25: prof += [(r, z + pitch * 0.25), (r * 0.84, z + pitch * 0.75)] z += pitch prof += [(r * 0.92, L - r * 0.25), (r * 0.62, L), (0.0, L)] P.append(lathe("thread", prof, segs=segs if r > 0.0045 else 6, m=m, frame=fz(c, n), smooth_ang=25)) def head(P, c, n, r, kind="hex", m=G4, ref=None): """A bolt head sitting on c, facing n. r: shank radius.""" if kind == "hex": R, h = r * 1.85, r * 1.25 P.append(lathe("bolthead", [(0.0, 0.0), (R * 0.93, 0.0), (R, h * 0.12), (R, h * 0.7), (R * 0.84, h), (0.0, h * 1.04)], segs=6, m=m, frame=fz(c, n, ref), smooth_ang=20)) elif kind == "square": R, h = r * 1.9, r * 1.3 P.append(lathe("bolthead", [(0.0, 0.0), (R, 0.0), (R, h * 0.72), (R * 0.82, h), (0.0, h * 1.03)], segs=4, m=m, frame=fz(c, n, ref), smooth_ang=20)) else: # dome: a carriage bolt or a rivet R, h = r * 1.75, r * 1.05 P.append(lathe("bolthead", [(0.0, 0.0), (R, 0.0), (R * 0.97, h * 0.28), (R * 0.82, h * 0.66), (R * 0.5, h * 0.93), (0.0, h)], segs=8 if HW_LOD[0] else 10, m=m, frame=fz(c, n, ref), smooth_ang=40)) def bolt5(P, a, n, L, r, kind="hex", m=G4, m_nut=None, m_thr=G3, w_head=True, nut=True, thr=None, ref=None): """A through-bolt: the head side face at a (outward normal n), the far face at a - n L. Washers both sides, a nut, the thread poking out.""" a, n = Vector(a), Vector(n).normalized() p = washer(P, a - n * 0.0004, n, r * 2.2, r * 0.32, m=m, ref=ref) if w_head else a head(P, p, n, r, kind, m=m, ref=ref) if nut: b = a - n * L q = washer(P, b + n * 0.0004, -n, r * 2.2, r * 0.32, m=m, segs=6 if HW_LOD[0] else None) q = hexnut(P, q, -n, r * 1.85, r * 1.5, m=m_nut or m, ref=ref) thread(P, q - (-n) * 0.002, -n, r * 0.92, (thr if thr is not None else r * 1.4) + 0.002, m=m_thr) def rivet(P, c, n, r, m=BRASS, tail=None, L=0.0): """A domed rivet head at c facing n; tail: a peened tail on the far face c - n L.""" head(P, c, n, r, "dome", m=m) if tail: n = Vector(n).normalized() b = Vector(c) - n * L P.append(lathe("peen", [(0.0, 0.0), (r * 1.45, 0.0), (r * 1.25, r * 0.4), (r * 0.7, r * 0.62), (0.0, r * 0.66)], segs=6 if HW_LOD[0] else 8, m=tail, frame=fz(b, -n), smooth_ang=40)) def bead(P, pts, r, m=G3, segs=5): """A weld bead along pts: a rippled, slightly flattened bar.""" C = resample([Vector(p) for p in pts], max(4, int(arclen([Vector(p) for p in pts])[-1] / (r * 1.5))), per=4) nn = len(C) def rf(s): k = 0.82 + 0.18 * abs(math.sin(s * nn * 1.4)) tip = min(1.0, s * 6, (1 - s) * 6) return (r * k * (0.5 + 0.5 * tip), r * 0.75 * k * (0.5 + 0.5 * tip)) P.append(UT.tube("bead", C, rf, m, segs=4 if HW_LOD[0] else segs, per=1, ang=60)) def spiral_wrap(name, C, L0, L1, R, pitch, depth, m, segs=16, rows=5, ref=None, start=0.0): """Bands wound in a helix round polyline C between arc lengths L0 and L1: each turn a rounded band, a groove between turns. R(Lpos) -> radius of what is wrapped. The start and the end of the strip run on a slant, like a real wrap's cut ends.""" C = [Vector(p) for p in C] T, N, B = frames(C, ref) L = arclen(C) def at(x): x = max(0.0, min(L[-1], x)) i = next((q for q in range(len(L) - 1) if L[q + 1] >= x), len(L) - 2) f = (x - L[i]) / max(1e-9, L[i + 1] - L[i]) return C[i].lerp(C[i + 1], f), (N[i].lerp(N[i + 1], f)).normalized(), (B[i].lerp(B[i + 1], f)).normalized() turns = (L1 - L0) / pitch nph = int(math.ceil((turns + 1) * segs)) # a shingled strip: it rises from under the last turn to a thick edge lapped over by the next one prof = [0.1 + 0.9 * (q / rows) ** 0.8 for q in range(rows + 1)] nr = len(prof) bm = bmesh.new() G = [] for k in range(nph + 1): ph = TAU * k / segs + start base = L0 + pitch * (k / segs - 1.0) row = [] for q in range(nr): x = base + pitch * q / (nr - 1) c, n_, b_ = at(x) fade = 1.0 if L0 - 1e-6 <= x <= L1 + 1e-6 else 0.15 rr = R(x) + depth * prof[q] * fade row.append(bm.verts.new(tuple(c + (n_ * math.cos(ph) + b_ * math.sin(ph)) * rr))) G.append(row) for k in range(nph): for q in range(nr - 1): bm.faces.new((G[k][q], G[k + 1][q], G[k + 1][q + 1], G[k][q + 1])) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) # the strip is open: make sure it faces outwards (its first face against the radial direction) f0 = bm.faces[len(bm.faces) // 2] c0 = f0.calc_center_median() cc, _, _ = at(L0 + (L1 - L0) / 2) f0.normal_update() if f0.normal.dot(c0 - cc) < 0: bmesh.ops.reverse_faces(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) smooth(o, 50) return o def rope_coil(name, C, Lc, R, r, turns, m=ROPE, segs=16, lobes=3, ref=None): """A rope lashed round a part: `turns` turns round polyline C centred at arc length Lc, R(angle) the radius it lies at, a three strand twist.""" C = [Vector(p) for p in C] T, N, B = frames(C, ref) L = arclen(C) def at(x): x = max(0.0, min(L[-1], x)) i = next((q for q in range(len(L) - 1) if L[q + 1] >= x), len(L) - 2) f = (x - L[i]) / max(1e-9, L[i + 1] - L[i]) return C[i].lerp(C[i + 1], f), (N[i].lerp(N[i + 1], f)).normalized(), (B[i].lerp(B[i + 1], f)).normalized() adv = r * 2.15 n = int(turns * segs) path = [] for k in range(n + 1): ph = TAU * k / segs x = Lc + adv * (k / segs - turns / 2) c, n_, b_ = at(x) path.append(c + (n_ * math.cos(ph) + b_ * math.sin(ph)) * R(ph)) tw = 7.0 def sec(s, i): return [(r * (1 + 0.16 * math.cos(lobes * (q * TAU / 7) - tw * s * turns * TAU / lobes)) * math.cos(q * TAU / 7), r * (1 + 0.16 * math.cos(lobes * (q * TAU / 7) - tw * s * turns * TAU / lobes)) * math.sin(q * TAU / 7)) for q in range(7)] return sweep(name, path, sec, [m], ang=50) # ======================================================================= blades def blade_section(g, tt, f_hammer=None, nc=None): """(fraction across from the edge to the spine, height) round the section, and the slot of each face. Slots: 0 cheek, 1 edge, 2 bevel, 3 shoulder, 4 spine, 5 / 6 hammered cheek (chosen later). nc: points across each cheek between the shoulder and the spine (None: round 5's first three), for a finer hammered mottle.""" if nc is None: ch = [0.46, 0.63, 0.8] else: a = g + 0.08 ch = [a + (0.8 - a) * k / (nc - 1) for k in range(nc)] top = [(0.0, 0.0), (0.035, 0.12), (g, 0.40), (g + 0.035, 0.47)] + [(f, 0.5) for f in ch] + [(0.93, 0.48), (0.985, 0.36), (1.0, 0.15)] bot = [(1.0, -0.15), (0.985, -0.36), (0.93, -0.48)] + [(f, -0.5) for f in reversed(ch)] + [(g + 0.035, -0.465), (g, -0.40), (0.035, -0.12)] pts = [(f, h * tt) for f, h in top + bot] m = len(ch) slots = [1, 2, 3] + [0] * (m + 1) + [4] * 5 + [0] * (m + 1) + [3, 2, 1] return pts, slots def heel_twist(v, x, twist): """Turn an offset v (from the spine, blade-local) about the spine's line by the heel twist at x: (degrees at the heel, length). F tilts the scythe blades by TILT; turning the heel back by the same angle lets it run level into the mount.""" if not twist or x >= twist[1]: return v a = DEG(twist[0]) * (1 - max(0.0, x) / twist[1]) ** 1.5 c, s_ = math.cos(a), math.sin(a) return Vector((v.x, v.y * c - v.z * s_, v.y * s_ + v.z * c)) def blade5(name, S, E, z, t, frame=None, ground=0.3, seed=5, rust=(), P=None, dimple=0.0005, twist=None, mottle=(0.07, 0.07), sub=1, nc=None, mscale=None): """A blade from spine and edge outlines (x, y) in the plane z: a fine edge, a bright ground bevel behind a dark grind line, flat hammered cheeks (dimpled a little, mottled along the atlas' grey ramp by hammer_uv), a rounded spine. The last station closes to a point. twist: see heel_twist. sub: stations per outline step (finer mesh for the mottle), nc: points across each cheek (blade_section). mottle: falsy for a plain cheek; mscale: blotch size (default from the blade's width).""" rng = random.Random(seed) F = frame if frame is not None else Matrix.Identity(4) S0, E0 = S, E if sub > 1: S2, E2 = [], [] for i in range(len(S) - 1): for k in range(sub): f = k / sub S2.append(tuple(Vector(S[i]).lerp(Vector(S[i + 1]), f))) E2.append(tuple(Vector(E[i]).lerp(Vector(E[i + 1]), f))) S2.append(S[-1]) E2.append(E[-1]) S, E = S2, E2 n = len(S) rings = [] slots = None for i in range(n): s, e = Vector((S[i][0], S[i][1])), Vector((E[i][0], E[i][1])) u = i / (n - 1) tt = t * (1.0 - 0.6 * u ** 3) if i % sub == 0: g = ground + rng.uniform(-0.03, 0.03) pts, slots = blade_section(g, tt, nc=nc) ring = [] for q, (f, h) in enumerate(pts): p = e.lerp(s, f) if 0 < i < n - 2 and g + 0.06 < f < 0.85: h += rng.uniform(-dimple, dimple) * (1 if h > 0 else -1) v = heel_twist(Vector((0.0, p.y - s.y, h)), s.x, twist) ring.append(F @ Vector((p.x, s.y + v.y, z + v.z))) rings.append(ring) tip = sum(rings[-1], Vector()) / len(rings[-1]) rings[-1] = [tip] def col(i, j): if j < 0: return 4 return slots[j] o = rings_mesh(name, rings, [G1, EDGE, BEV, GLINE, DGY, HMD, HML], colfn=col, ang=26) if mottle: W = max((Vector(a) - Vector(b)).length for a, b in zip(S, E)) hammer_uv(o, 0, STEEL_RAMP, scale=mscale or max(0.025, min(0.06, W * 0.26)), seed=seed, frame=F.inverted()) S, E = S0, E0 n = len(S) if P is not None: for (i, j) in rust: i = min(i, n - 2) sm = (Vector(S[i]) + Vector(S[i + 1])) / 2 em = (Vector(E[i]) + Vector(E[i + 1])) / 2 c = em.lerp(sm, .7) Ls = (Vector(S[i + 1]) - Vector(S[i])).length W = (sm - em).length a = math.atan2(S[i + 1][1] - S[i][1], S[i + 1][0] - S[i][0]) up = 1 if j == 2 else -1 tt = t * (1.0 - 0.6 * (i / (n - 1)) ** 3) Fl = F @ Matrix.Translation((c.x, c.y, z)) @ Matrix.Rotation(a, 4, "Z") blot(P, Fl, (0, 0, up * (tt * .5 + .0012)), Ls * 1.8, W * .2, rng, flip=up < 0, key=RB) return o def scythe_outline(y0, L, w0, bow, curl, n, neck=None): """Round 4's scythe outline (spine S, edge E) at n + 1 stations. neck = (x_end, w_max, x_full): inside the mount (x < x_end) the blade is no wider than w_max, then the edge sweeps down in a curve (the beard) to its full width at x_full.""" S, E = [], [] for i in range(n + 1): u = i / n x = L * u y = y0 - bow * math.sin(u * 2.35) + curl * u ** 3 w = w0 * (1 - u) ** 0.62 * (0.8 + 0.2 * math.sin(min(1.0, u * 4) * 1.57)) + 0.007 if neck and x < neck[2]: f = max(0.0, (x - neck[0]) / (neck[2] - neck[0])) f = f * f * (3 - 2 * f) w = min(w, neck[1] + (w - neck[1]) * f) S.append((x, y)) E.append((x, y + w)) S[-1] = (S[-1][0] + 0.02, S[-1][1] + 0.01) E[-1] = (S[-1][0], S[-1][1] + 0.003) return S, E def tilt_frame(y0, hz): return Matrix.Translation((0, y0, hz)) @ Matrix.Rotation(DEG(-UT.TILT), 4, "X") @ Matrix.Translation((0, -y0, -hz)) def back_channel(P, S, E, z, t, F, i0, i1, wf=0.034, th=0.0055, m=G2, n_sub=1, rivets=(), r_riv=0.0085, nose=0.009, taper=0.7, twist=None): """A strip folded over the blade's spine and clasping it: a top flange on the cheek, a round nose past the spine, a shorter flange under. Built over stations i0..i1 of (S, E). rivets: station indices that get a domed head on top and a peened tail under.""" nS = len(S) ss = [] for i in range(i0, i1): for k in range(n_sub): ss.append(i + k / n_sub) ss.append(float(i1)) def st(x): i = min(int(x), nS - 2) f = x - i s = Vector(S[i]).lerp(Vector(S[i + 1]), f) e = Vector(E[i]).lerp(Vector(E[i + 1]), f) return s, e, (e - s).normalized(), i + f C, A, H = [], [], [] for x in ss: s, e, a, xf = st(x) C.append(Vector((s.x, s.y, z))) A.append(Vector((a.x, a.y, 0.0))) H.append(t * (1.0 - 0.6 * (xf / (nS - 1)) ** 3)) Lc = arclen(C) def sec(sf, i): tt = H[i] * 0.5 k = 1 - (1 - taper) * sf w1, w2, tk = wf * k, wf * 0.62 * k, th * (0.75 + 0.25 * k) nz = nose * k end = min(1.0, sf * 30, (1 - sf) * 30) # the strip's ends are hammered thin tk *= 0.35 + 0.65 * end pts = [(w1, tt + 0.0003), (w1 - 0.004, tt + tk * 0.85), (w1 * 0.5, tt + tk), (0.0, tt + tk)] for q in range(1, 6): an = PI / 2 + PI * q / 6 pts.append((nz * 0.9 * math.cos(an) - 0.0, (tt + tk) * math.sin(an))) pts += [(0.0, -tt - tk), (w2 * 0.6, -tt - tk), (w2 - 0.003, -tt - tk * 0.8), (w2, -tt - 0.0003)] return pts # N across towards the edge, B up: build rings by hand rings = [] for i, c in enumerate(C): sf = Lc[i] / Lc[-1] rings.append([c + heel_twist(A[i] * a + Vector((0, 0, b)), c.x, twist) for a, b in sec(sf, i)]) rings = [[F @ p for p in r] for r in rings] o = rings_mesh("back", rings, [m, G3, DGY], colfn=lambda i, j: 2 if j < 0 else (1 if j in (0, 11) else 2 if 3 <= j <= 8 else 0), ang=34) P.append(o) up = (F.to_3x3() @ Vector((0, 0, 1))).normalized() for i in rivets: s, e, a, xf = st(float(i)) tt = t * (1.0 - 0.6 * (xf / (nS - 1)) ** 3) * 0.5 k = 1 - (1 - taper) * (i - i0) / max(1, i1 - i0) c = Vector((s.x, s.y, z)) + Vector((a.x, a.y, 0)) * wf * k * 0.5 tk = th * (0.75 + 0.25 * k) rivet(P, F @ (c + Vector((0, 0, tt + tk - 0.0003))), up, r_riv, m=BRASS, tail=G3, L=2 * (tt + tk - 0.0003)) return o # ======================================================================= wood def turned(name, C, rf, m=TIM, segs=16, s=1.6, u0=0.125, ang=34, ref=None, cap0=True, cap1=True): """A turned part along a path: rf(s) -> radius.""" return sweep(name, C, lambda sf, i: circ(rf(sf), segs), [m], uv=(u0, 0.09, s), ang=ang, ref=ref, cap0=cap0, cap1=cap1) def nib5(P, x, y, z_top, m_knob=PRED, r=0.036, z_low=-0.105, wrap=LEAT, bolt_below=True, ferrule=BRASS, nut_drop=0.0): """A turned nib along Z where the fist closes: a ferrule where it meets the snath, a collar and grooves, a spiral leather wrap with a brass welt at each end, a painted knob held on by a nut on the through-bolt (nut_drop lower, past a strap eye).""" fr = Matrix.Translation((x, y, 0)) zt = z_top z0, z1 = -0.063, 0.02 # the timber: a bead and a groove under the wrap, a groove, a bead and a neck above it prof = [(r * 0.78, z_low + 0.012), (r * 0.86, z_low + 0.02), (r * 0.95, z_low + 0.026), (r * 0.9, z_low + 0.031), (r * 0.97, z_low + 0.035), (r * 0.98, z0 - 0.004), (r * 0.98, z1 + 0.005), (r * 0.93, z1 + 0.009), (r * 0.98, z1 + 0.014), (r * 0.96, z1 + 0.019), (r * 0.86, z1 + 0.025), (r * 0.84, z1 + 0.034), (r * 0.82, zt - 0.03)] # swept, not lathed, so the grain runs up the nib inside one board of the timber texture P.append(sweep("nib", [Vector((x, y, z_)) for r_, z_ in prof], lambda sf, i: circ(prof[i][0], 16), [TIM], uv=(0.125, 0.08, 1.6), ref=(1, 0, 0), ang=34)) # a brass ferrule with rolled rims where the nib goes into the snath P.append(lathe("ferrule", [(r * 0.8, zt - 0.031), (r * 0.86, zt - 0.03), (r * 0.88, zt - 0.026), (r * 0.84, zt - 0.022), (r * 0.84, zt - 0.006), (r * 0.88, zt - 0.003), (r * 0.86, zt + 0.002), (r * 0.7, zt + 0.004)], segs=16, m=ferrule, frame=fr, smooth_ang=40)) # the knob: a painted turned knob, a groove round it, a dished end P.append(lathe("knob", [(r * 0.8, z_low + 0.014), (r * 0.98, z_low + 0.01), (r * 1.2, z_low + 0.002), (r * 1.3, z_low - 0.006), (r * 1.24, z_low - 0.009), (r * 1.24, z_low - 0.013), (r * 1.3, z_low - 0.016), (r * 1.18, z_low - 0.022), (r * 0.6, z_low - 0.025), (0.0, z_low - 0.0235)], segs=14, m=m_knob, frame=fr, smooth_ang=40)) if bolt_below: b = Vector((x, y, z_low - 0.0242 - nut_drop)) q = washer(P, b, (0, 0, -1), r * 0.45, 0.0025, m=BRASS, segs=12) q = hexnut(P, q, (0, 0, -1), r * 0.34, 0.009, m=G4) thread(P, q + Vector((0, 0, 0.002)), (0, 0, -1), r * 0.2, 0.008, m=G3) if wrap: C = [Vector((x, y, z0 - 0.02)), Vector((x, y, z1 + 0.02))] P.append(spiral_wrap("wrap", C, 0.02, 0.02 + (z1 - z0), lambda q: r * 0.985, 0.0165, 0.0034, wrap, segs=13 if HW_LOD[0] else 16, rows=3, ref=(1, 0, 0))) for zz in (z0 - 0.002, z1 + 0.002): P.append(lathe("welt", [(r * 1.0, zz - 0.0045), (r * 1.1, zz - 0.003), (r * 1.13, zz), (r * 1.1, zz + 0.003), (r * 1.0, zz + 0.0045)], segs=12 if HW_LOD[0] else 16, m=BRASS if wrap == LEAT else IRON, frame=fr, smooth_ang=50)) # ======================================================================= clamps, lugs, braces def strap5(P, pth, t, hw, hh, rc, w=0.024, th=0.0045, m=IRON, ears=1, ear_len=0.034, bolt_m=G4, nc=3, phase_up=True, ear_scale=1.5): """A forged strap round a rounded-rect bar at path fraction t: rolled edges, the ends chamfered down onto the bar, two pinch ears on the +X (ears=1) or -X (ears=-1) side with a bolt down through them. hw, hh, rc: the bar's half section there. ear_scale: the ears' size over round 5's first pilot (they were too small to read in first person).""" Ltot = pth.L[-1] ss = [-0.5, -0.47, -0.4, -0.3, 0.3, 0.4, 0.47, 0.5] tk = [0.0006, th * 0.9, th * 1.25, th, th, th * 1.25, th * 0.9, 0.0006] C = [pth.at(t + q * w / Ltot) for q in ss] T, N, B = frames(C, ref=(1, 0, 0)) def sec(sf, i): d = tk[i] return rrect(hw + d, hh + d, rc + d, nc) P.append(sweep("strap", C, sec, [m], cap0=False, cap1=False, ang=40, frm=(T, N, B))) if ears: c = pth.at(t) i = len(C) // 2 Nx, Bz, Tt = N[i] * (1 if N[i].x >= 0 else -1), B[i], T[i] side = Nx * ears es = ear_scale gap = 0.007 * es ** 0.5 el, ew, et = ear_len * es, w * min(0.5, 0.42 * es), th * min(1.35, es) for sz in (-1, 1): zc = sz * (gap / 2 + et / 2) org = c + side * (hw - 0.004) + Bz * zc Fm = Matrix((side, Tt, Bz)).transposed().to_4x4() Fm.translation = org # the ear widens a little where it leaves the strap (a forged fillet), a round end out = rounded_outline([(0.0, -ew), (el * 0.35, -ew * 0.97), (el, -ew * 0.84), (el, ew * 0.84), (el * 0.35, ew * 0.97), (0.0, ew)], 0.009 * es, n=2 if HW_LOD[0] else 3) P.append(bprism("ear", out, -et / 2, et / 2, [m, G3], bev=0.0012 * es, segs=1, frame=Fm, bev_slot=1)) bc = c + side * (hw - 0.004 + el * 0.62) bolt5(P, bc + Bz * (gap / 2 + et), Bz, gap + 2 * et, 0.0065 * min(1.25, es), m=bolt_m, ref=Tt, thr=0.008 * es) def clevis(P, c, d, n, w, t, base, r_eye, gap, m=G2, bead_m=G3, bead_at=None): """Two lug plates either side of an eye at c, normal to the bolt axis n, rising along d from their bases (`base` back along -d, buried in what they are welded to); a weld bead where each meets that surface, bead_at back from c. Returns the bolt's head point and length.""" n = Vector(n).normalized() d = (Vector(d) - n * Vector(d).dot(n)).normalized() u = d.cross(n) for sz in (-1, 1): off = n * sz * (gap / 2 + t / 2) Fm = Matrix((u, d, n)).transposed().to_4x4() Fm.translation = c - d * base + off P.append(bprism("lug", lug_outline(w, base, r_eye), -t / 2, t / 2, [m, G3], bev=min(0.0014, t * 0.3), segs=1, frame=Fm, bev_slot=1)) if bead_at is not None: b0 = c - d * bead_at + n * sz * (gap / 2 + t + 0.0008) bead(P, [b0 - u * w * 0.5, b0, b0 + u * w * 0.5], 0.0024, m=bead_m) return c + n * (gap / 2 + t), gap + 2 * t def flat_brace(P, a, b, n, w, t, r_eye, m=IRON, segs_mid=6): """A forged flat bar from eye a to eye b: rounded section, flattened wider into an eye round each bolt, the bolt axis n.""" a, b = Vector(a), Vector(b) d = (b - a).normalized() n = (Vector(n) - d * Vector(n).dot(d)).normalized() u = n.cross(d) Lb = (b - a).length ns = 18 C = [a.lerp(b, k / ns) for k in range(ns + 1)] T = [d] * len(C) N = [u] * len(C) Bv = [n] * len(C) def sec(sf, i): x = sf * Lb e = min(x, Lb - x) k = max(0.0, 1 - e / (r_eye * 2.6)) # 1 at the eye, 0 along the bar hw = w / 2 + (r_eye - w / 2) * k ** 1.5 hh = t / 2 * (1 - 0.25 * k) return rrect(hw, hh, min(hw, hh) * (0.8 - 0.4 * k), 2 if HW_LOD[0] else 3) P.append(sweep("brace", C, sec, [m], frm=(T, N, Bv), ang=34)) for c in (a, b): Fm = Matrix((u, d, n)).transposed().to_4x4() Fm.translation = c P.append(bprism("eye", circ(r_eye, 14), -t * 0.37, t * 0.37, [m, G3], bev=t * 0.18, segs=1, frame=Fm, bev_slot=0, ang=40)) def rod_eye(P, c, d, n, r_rod, R, m=G3): """A forged eye on the end of a rod: a ring round the bolt (axis n) at c, the rod coming in along -d.""" d = Vector(d).normalized() n = (Vector(n) - d * Vector(n).dot(d)).normalized() u = n.cross(d) ring = [] for k in range(14): a = TAU * k / 14 ring.append(c + (u * math.cos(a) + d * math.sin(a)) * R) P.append(UT.tube("eye", ring + [ring[0], ring[1]], lambda s: (r_rod * 1.05, r_rod * 0.85), m, segs=6, per=1, cap=False, ang=50)) def turnbuckle(P, a, b, n, r_rod, m_body=BRASS, m_rod=G3, m_nut=G4, Lb=0.13, Rb=0.0175): """An open-frame turnbuckle in the middle of a rod from a to b: two hex end bosses joined by two side bars, threaded rods screwed in from each end, a lock nut against each boss, the rod ends showing in the frame.""" a, b = Vector(a), Vector(b) d = (b - a).normalized() n = (Vector(n) - d * Vector(n).dot(d)).normalized() u = n.cross(d) mid = (a + b) / 2 hb = 0.02 # boss length for sg in (-1, 1): c0 = mid + d * sg * (Lb / 2 - hb) prof = [(0.0, 0.0), (Rb * 0.82, 0.0), (Rb, 0.0025), (Rb, hb - 0.004), (Rb * 0.8, hb), (r_rod * 1.3, hb + 0.002), (0.0, hb + 0.002)] P.append(lathe("tbboss", prof, segs=6, m=m_body, frame=fz(c0, d * sg, n), smooth_ang=20)) # lock nut and the threaded rod going in q = hexnut(P, c0 + d * sg * (hb + 0.0025), d * sg, r_rod * 1.95, r_rod * 1.55, m=m_nut, ref=u) P.append(lathe("rodthread", thread_prof(r_rod, Lb / 2 - 0.006 - hb + 0.016), segs=6 if HW_LOD[0] else 8, m=m_rod, frame=fz(mid + d * sg * 0.006, d * sg), smooth_ang=25)) # the side bars: flat, swelling a little in the middle for sg in (-1, 1): C = [mid + d * (Lb / 2 - hb * 0.6) * k + u * sg * (Rb * 0.78 + 0.004 * (1 - k * k)) for k in (-1, -0.6, -0.2, 0.2, 0.6, 1)] P.append(sweep("tbbar", resample(C, 8), lambda sf, i: rrect(0.0042, 0.0068, 0.003, 1), [m_body], ref=u, ang=40)) def thread_prof(r, L, pitch=None): pitch = pitch or max(r * 0.75, 0.0018) prof = [(0.0, 0.0), (r * 0.84, 0.0)] z = 0.0 while z + pitch < L - r * 0.25: prof += [(r, z + pitch * 0.25), (r * 0.84, z + pitch * 0.75)] z += pitch prof += [(r * 0.92, L - r * 0.25), (r * 0.62, L), (0.0, L)] return prof def path_at_y(pth, y): """The point of a Path where it crosses y (the paths here run down -Y).""" C = pth.C for a, b in zip(C, C[1:]): if (a.y - y) * (b.y - y) <= 0 and a.y != b.y: return a.lerp(b, (y - a.y) / (b.y - a.y)) return C[0] if abs(C[0].y - y) < abs(C[-1].y - y) else C[-1] # ======================================================================= the mount ("shoe") at the heel of a scythe def shoe(P, x0, x1, y0, y1, z0, z1, bev, bolts, wedge, entry, m=DGY, blade_z=None, taper=(0.56, 0.48)): """A forged shoe round the end of the snath, swept along X: a forged pillow section (a superellipse, flats that swell and corners that round, worn bright) that rounds over at the back, keeps its size over the snath, then draws in towards the blade where the heel leaves it (narrower, and its top coming down towards the blade's plane blade_z), on a flat underside with crisp edges, forge scale mottled along the atlas' dark ramp. A swelled socket collar where the snath goes in (the +Y face), forged bosses under the bolt heads, through-bolts from the top with washers, nuts and threads under, and a timber wedge driven down the +X end under an iron keeper: a tapered block with long grain up its sides and a mushroomed end-grain head. bolts: [(x, y)]. wedge: (y0, y1, depth). entry: (pth, section fn (d, k) -> [(x, z)] where k = 1 / cos(slope)). bev: unused (kept for the callers).""" cy = (y0 + y1) / 2 A0 = (y1 - y0) / 2 bz = blade_z if blade_z is not None else z0 + (z1 - z0) * 0.25 xs0 = x0 + (x1 - x0) * 0.42 rb = min(0.024, (z1 - z0) * 0.36) re = 0.01 zt_end = bz + (z1 - bz) * taper[1] PB = 9.0 # the underside: flat, with crisp rounded edges def prof(x): """(half width in Y, top, bottom, exponent of the top half) at x. The bottom stays flat at z0 (it only rounds up at the very ends); the top comes down towards the blade.""" d = max(0.0, min(1.0, (x - xs0) / (x1 - xs0))) d = d * d * (3 - 2 * d) e0 = min(1.0, max(0.0, (x - x0) / rb)) e1 = min(1.0, max(0.0, (x1 - x) / re)) kb = 0.5 + 0.5 * math.sqrt(max(0.0, 1 - (1 - e0) ** 2)) ke = 0.8 + 0.2 * math.sqrt(max(0.0, 1 - (1 - e1) ** 2)) A = A0 * (1 - (1 - taper[0]) * d) * kb * ke top = z1 + (zt_end - z1) * d bot = z0 + (top - z0) * (1 - kb * ke) * 0.45 top = bot + (top - bot) * kb * ke return A, top, bot, 4.6 - 1.2 * d def ssec(A, top, bot, pt, n): """The shoe's section round its waist line: a superellipse with a fuller top half and a flat underside.""" H = top - bot Bt, Bb = H * 0.6, H * 0.4 out = [] for k in range(n): t = PI / n + TAU * k / n c_, s_ = math.cos(t), math.sin(t) p_ = pt if s_ >= 0 else PB out.append((A * math.copysign(abs(c_) ** (2 / p_), c_), (Bt if s_ >= 0 else Bb) * math.copysign(abs(s_) ** (2 / p_), s_))) return out, bot + Bb xs = [x0 + rb * (1 - math.cos(k / 4 * PI / 2)) for k in range(4)] xs += [x0 + rb + (x1 - re - x0 - rb) * k / 9 for k in range(10)] xs += [x1 - re + re * math.sin(k / 3 * PI / 2) for k in range(1, 4)] NP = 24 C, secs = [], [] for x in xs: A, top, bot, p = prof(x) sec_, mid = ssec(A, top, bot, p, NP) C.append(Vector((x, cy, mid))) secs.append(sec_) X, Y, Z = Vector((1, 0, 0)), Vector((0, 1, 0)), Vector((0, 0, 1)) nn = len(C) def wornf(i, j): if j < 0: return 0 t = PI / NP + TAU * (j + 0.5) / NP return 1 if abs(math.cos(t)) > 0.58 and abs(math.sin(t)) > 0.58 else 0 so = sweep("shoe", C, lambda sf, i: secs[i], [m, G1], colfn=wornf, ang=32, frm=([X] * nn, [Y] * nn, [Z] * nn)) if m == DGY: hammer_uv(so, 0, FORGE_RAMP, scale=0.016, seed=int(abs(x1 * 997)) % 97) P.append(so) def surf_top(x, y, up=True): A, top, bot, p = prof(x) H = top - bot q = min(0.98, abs(y - cy) / A) if up: return bot + H * 0.4 + H * 0.6 * (1 - q ** p) ** (1 / p) return bot + H * 0.4 - H * 0.4 * (1 - q ** PB) ** (1 / PB) # the socket collar where the snath goes in: swept along the snath itself, it swells out of the shoe, then draws down to a rolled # lip hugging the snath. Capped, so it is a solid ring (the cap discs lie inside the snath). pth, secf = entry tf_ = pth.nearest_y(y1) Lp = pth.L[-1] offs = [0.01, 0.0, -0.007, -0.014, -0.021, -0.026, -0.029, -0.031] # metres along the snath from the +Y face, + = into the shoe dd = [0.013, 0.0148, 0.0152, 0.0132, 0.0094, 0.0074, 0.005, 0.001] cs = [pth.at(tf_ + o_ / Lp) for o_ in offs] P.append(sweep("lip", cs, lambda sf, i: secf(dd[i], 1.0), [m, G1], colfn=lambda i, j: 1 if i in (4, 5) else 0, ang=40, ref=(1, 0, 0))) # through-bolts on forged bosses for bx_, by_ in bolts: zt = surf_top(bx_, by_) zb = surf_top(bx_, by_, up=False) r = 0.0085 P.append(lathe("boss", [(0.0, zt - 0.006), (r * 2.75, zt - 0.006), (r * 2.65, zt - 0.0015), (r * 2.45, zt + 0.0012), (r * 2.25, zt + 0.0022), (0.0, zt + 0.0022)], segs=16, m=m, frame=Matrix.Translation((bx_, by_, 0)), smooth_ang=40)) bolt5(P, (bx_, by_, zt + 0.0022), (0, 0, 1), zt + 0.0022 - zb, r, m=G4, ref=(1, 0, 0), thr=0.012) if wedge: wy0, wy1, wd = wedge wd = max(wd, 0.024) A, top_e, bot_e, _ = prof(x1 - re) zb_w = max(bot_e + 0.004, bz + 0.012) zh = z1 + 0.012 # where the head starts to spread yc_, hy = (wy0 + wy1) / 2, (wy1 - wy0) / 2 rng = random.Random(int(abs(x1 * 1000 + wy0 * 100))) # the block, from the bottom of the slot up to the head: thin at the foot, thick at the top zs = [zb_w + (zh - zb_w) * q / 6 for q in range(7)] # the mushroom: (spread) per ring, the lip rolling out and down over the block, then the bruised rim and the dome hd = [(0.0042, 0.0), (0.0092, 0.0), (0.0122, 0.0), (0.0128, 0.0), (0.0112, 0.0), (0.0082, 0.0), (0.0048, 0.0)] zs_h = [zh + 0.0010, zh + 0.0024, zh + 0.0020, zh + 0.0036, zh + 0.006, zh + 0.0078, zh + 0.009] rings_z = zs + zs_h jit = [rng.uniform(-1, 1) for _ in range(20)] def wsec(sf, i): z = rings_z[i] if i < len(zs): f = (z - zb_w) / (zh - zb_w) tx = wd * (0.42 + 0.58 * f) hyy = hy * (0.9 + 0.1 * f) sp = 0.0 else: tx, hyy = wd, hy sp = hd[i - len(zs)][0] pts = rrect(tx / 2 + sp, hyy + sp, 0.003 + sp * 0.5, 3) if i >= len(zs): # the bruised rim of the head: uneven kj = min(1.0, sp / 0.006) pts = [(a * (1 + 0.06 * jit[q % 20] * kj), b * (1 + 0.035 * jit[(q + 7) % 20] * kj)) for q, (a, b) in enumerate(pts)] return pts Cw = [] for i, z in enumerate(rings_z): if i < len(zs): f = (z - zb_w) / (zh - zb_w) tx = wd * (0.42 + 0.58 * f) else: tx = wd Cw.append(Vector((x1 - 0.006 + tx / 2, yc_, z))) nw = len(Cw) o = sweep("wedge", Cw, wsec, [TIM], uv=(0.375, 0.08, 1.8), cap0=True, cap1=False, ang=40, frm=([Z] * nw, [X] * nw, [Y] * nw)) P.append(o) # the end-grain head: a low dome, the growth rings as arcs round a pith off one corner (the timber texture laid radially across # all four of its boards: the dark lines between them become rings) top_ring = [Cw[-1] + X * a + Y * b for a, b in wsec(1.0, nw - 1)] cc = Cw[-1] + Z * 0.0024 pith = cc + X * (wd * 1.6) + Y * (hy * 1.2) bm = bmesh.new() uvl = bm.loops.layers.uv.verify() rows = [top_ring] + [[cc.lerp(p, f) + Z * (0.0024 * (1 - f * f)) for p in top_ring] for f in (0.7, 0.4)] V = [[bm.verts.new(p) for p in r] for r in rows] vc = bm.verts.new(cc + Z * 0.0024) dmax = max((p - pith).length for p in top_ring) dmin = (cc - pith).length - max(wd, hy * 2) uvf = lambda p: (0.06 + 0.88 * max(0.0, min(1.0, ((p - pith).length - dmin) / (dmax - dmin))), math.atan2((p - pith).y, (p - pith).x) * 0.02) nr = len(top_ring) for a in range(len(V) - 1): for j in range(nr): q = (j + 1) % nr f = bm.faces.new((V[a][j], V[a][q], V[a + 1][q], V[a + 1][j])) for lp in f.loops: lp[uvl].uv = uvf(lp.vert.co) for j in range(nr): f = bm.faces.new((V[-1][j], V[-1][(j + 1) % nr], vc)) for lp in f.loops: lp[uvl].uv = uvf(lp.vert.co) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) for f in bm.faces: f.normal_update() if sum(f.normal.z for f in bm.faces) < 0: bmesh.ops.reverse_faces(bm, faces=bm.faces) eg = mesh_obj("endgrain", bm) set_mats(eg, TIM) smooth(eg, 50) eg["uv_done"] = True P.append(eg) # the iron keeper: a strap round the wedge and the shoe's end, riveted to the shoe's sides kz = zb_w + (zh - zb_w) * 0.45 txk = wd * (0.42 + 0.58 * 0.45) xo = x1 - 0.006 + txk + 0.0025 xb = x1 - re - 0.018 A_b = prof(xb)[0] ya, yb_ = min(wy0, cy - A_b) - 0.0025, max(wy1, cy + A_b) + 0.0025 Ab = prof(xb)[0] kp = [Vector((xb, cy - Ab - 0.0022, kz)), Vector((x1 - 0.004, ya, kz)), Vector((xo - 0.004, ya, kz)), Vector((xo, ya + 0.005, kz)), Vector((xo, yb_ - 0.005, kz)), Vector((xo - 0.004, yb_, kz)), Vector((x1 - 0.004, yb_, kz)), Vector((xb, cy + Ab + 0.0022, kz))] kc = resample(kp, 18, per=4) P.append(sweep("keeper", kc, lambda sf, i: rrect(0.0075, 0.0022, 0.0012, 1), [IRON, G2], colfn=lambda i, j: 1 if j % 4 == 3 else 0, ref=(0, 0, 1), ang=40)) for sg in (-1, 1): rivet(P, Vector((xb + 0.006, cy + sg * (prof(xb + 0.006)[0] + 0.0044), kz)), (0, sg, 0), 0.0032, m=G4) ny = (y1 - y0) return [(y0 + ny * 0.1, z0), (y1, z0), (y1, z1), (y0 + ny * 0.22, z1), (y0, z1 - (z1 - z0) * 0.24), (y0, z0 + (z1 - z0) * 0.18)] def jaws(P, S, E, z, t, F, x0, x1, width, th=0.006, rivets=2, m=DGY): """Jaw plates over and under the blade where it leaves the mount, from the spine out by `width` (fraction of the blade's width), rounded and chamfered, riveted through the blade.""" s0, e0 = Vector(S[0]), Vector(E[0]) n = 10 pts_top = [] xs = [x0 + (x1 - x0) * k / n for k in range(n + 1)] def at(x): # interpolate spine and edge at x along the outline stations for i in range(len(S) - 1): if S[i][0] <= x <= S[i + 1][0] or i == len(S) - 2: f = (x - S[i][0]) / max(1e-9, S[i + 1][0] - S[i][0]) return Vector(S[i]).lerp(Vector(S[i + 1]), f), Vector(E[i]).lerp(Vector(E[i + 1]), f) return Vector(S[0]), Vector(E[0]) lo, hi = [], [] for x in xs: s, e = at(x) k = 1 - 0.35 * ((x - x0) / (x1 - x0)) ** 2 lo.append(s + (s - e).normalized() * 0.006) hi.append(s.lerp(e, width * k)) outline = [(p.x, p.y) for p in lo] + [(p.x, p.y) for p in reversed(hi)] up = (F.to_3x3() @ Vector((0, 0, 1))).normalized() for sz in (-1, 1): zt = t * 0.5 * sz z0_, z1_ = (z + zt, z + zt + th) if sz > 0 else (z + zt - th, z + zt) P.append(bprism("jaw", outline, z0_, z1_, [m, G2], bev=0.0018, segs=1, frame=F, bev_slot=1, min_ang=35)) for k in range(rivets): x = x0 + (x1 - x0) * (0.45 + 0.4 * k / max(1, rivets - 1)) s, e = at(x) c = s.lerp(e, width * 0.5) rivet(P, F @ Vector((c.x, c.y, z + t * 0.5 + th)), up, 0.0075, m=G4, tail=G4, L=t + 2 * th) # ======================================================================= the tools def wide_scythe(): P = [] nibs = ((0.03, -0.04), (-0.03, -0.62)) pts = [(0.0, 0.13, 0.136), (0.0, 0.05, 0.145), (0.0, -0.3, 0.15), (0.0, -0.8, 0.135), (0.0, -1.3, 0.07), (0.0, -1.62, -0.02), (0.0, -1.74, -0.06)] pth = UT.Path(pts, per=6) Ltot = pth.L[-1] # ---- the beam: an eased square section (round 4's chamfered octagon, same size), green paint worn to the timber on the corners # where the hands and the shoulder rub C = resample(pts, 32) hwf = lambda s: 0.0425 - 0.0092 * s hhf = lambda s: 0.0495 - 0.011 * s rcf = lambda s: 0.36 * hwf(s) rng = random.Random(11) wear = [lambda s: 0.0 <= s <= 0.14, lambda s: 0.03 <= s <= 0.12, lambda s: 0.34 <= s <= 0.43] worn = {} for i in range(len(C) - 1): s = i / (len(C) - 1) for j in range(16): corner = j % 4 != 3 if corner and any(w(s) for w in wear) and (j % 4 == 1 or rng.random() < 0.35) and j // 4 in (0, 1): worn[(i, j)] = 1 P.append(sweep("snath", C, lambda sf, i: rrect(hwf(sf), hhf(sf), rcf(sf), 3), [TEAL, TIM], colfn=lambda i, j: worn.get((i, j), 0), ref=(1, 0, 0), uv=(0.625, 0.09, 1.2), ang=34)) sat = lambda t: (hwf(t), hhf(t), rcf(t)) for t0 in (0.13, 0.48): strap5(P, pth, t0 + 0.011, *sat(t0 + 0.011), w=0.026, ears=1 if t0 < 0.3 else -1) # ---- a stuffed sacking shoulder pad, quilted in three pillows, roped on with two coils of three-strand rope Cp = [pth.at(0.0) + (pth.at(0.0) - pth.at(0.01)).normalized() * 0.014] + [pth.at(k * 0.125 / 12) for k in range(13)] def padsec(sf, i): puff = 0.0045 * abs(math.sin(sf * PI * 3)) ** 0.6 + 0.0015 end = math.sin(min(1.0, sf * 9, (1 - sf) * 9) * PI / 2) ** 0.5 k_ = (0.8 if sf < 0.5 else 0.86) + (0.2 if sf < 0.5 else 0.14) * end hw, hh = (hwf(0.0) + 0.014 + puff) * k_, (hhf(0.0) + 0.013 + puff) * k_ return rrect(hw, hh, min(hw, hh) * 0.62, 3) P.append(sweep("pad", Cp, padsec, ["M_Burlap"], ref=(1, 0, 0), uv=(0.5, 0.5, 5.0), ang=40)) Lcp = arclen(Cp)[-1] for q in (1, 2): # in the quilting seams hw, hh = hwf(0.0) + 0.0155 + 0.0032, hhf(0.0) + 0.0145 + 0.0032 def Rr(ph, hw=hw, hh=hh): c, s = math.cos(ph), math.sin(ph) return 1.0 / ((abs(c) / hw) ** 3.2 + (abs(s) / hh) ** 3.2) ** (1 / 3.2) P.append(rope_coil("lash", Cp, Lcp * q / 3, Rr, 0.0058, 1.75, segs=13, ref=(1, 0, 0))) # ---- D-handles: a turned nib, a forged strap from an eye bolted through the beam's side round under the knob for k, (x, y) in enumerate(nibs): t = pth.nearest_y(y + 0.05) cb = pth.at(t) hw, hh = hwf(t), hhf(t) Bp = Vector((x, y, -0.1325)) nib5(P, x, y, 0.1, m_knob=GOLD, r=0.038, wrap=LEAT, nut_drop=0.0075) A = Vector((-hw - 0.0034, y + 0.05, cb.z + 0.008)) xo = min(A.x, x - 0.074) sp = [A, Vector((A.x, A.y, cb.z - hh + 0.004)), Vector((xo, y + 0.05, 0.03)), Vector((xo, y + 0.05, -0.1)), Vector((x - 0.03, y + 0.02, Bp.z)), Bp] sp = resample(sp, 16, per=6) P.append(sweep("stirrup", sp, lambda sf, i: rrect(0.0105, 0.0032, 0.0022, 1), [IRON, G2], colfn=lambda i, j: 1 if j % 2 == 0 else 0, ref=(0, 1, 0), ang=36)) Fm = fz(A, (-1, 0, 0), (0, 0, 1)) P.append(bprism("eye", circ(0.0145, 12), -0.0032, 0.0032, [IRON, G2], bev=0.0012, segs=1, frame=Fm, bev_slot=1)) bolt5(P, A + Vector((-0.0032, 0, 0)), (-1, 0, 0), 2 * hw + 0.0068, 0.0062, kind="dome", m=G4, ref=(0, 0, 1), thr=0.007) P.append(lathe("eye2", [(0.0, -0.0034), (0.0165, -0.0034), (0.0178, -0.0018), (0.0178, 0.0018), (0.0165, 0.0034), (0.0, 0.0034)], segs=12, m=IRON, frame=Matrix.Translation(Bp), smooth_ang=40)) # ---- the blade: round 4's outline, finer, with a beard at the heel hz, y0 = -0.11, -1.78 F = tilt_frame(y0, hz) S, E = scythe_outline(y0, 1.42, 0.3, 0.17, 0.42, 44, neck=(0.088, 0.09, 0.24)) S36, E36 = scythe_outline(y0, 1.42, 0.3, 0.17, 0.42, 36, neck=(0.088, 0.09, 0.24)) S20, _ = scythe_outline(y0, 1.42, 0.3, 0.17, 0.42, 20) tw = (UT.TILT, 0.09) P.append(blade5("blade", S, E, hz, 0.036, frame=F, ground=0.3, seed=9, rust={(11, 2), (28, 2)}, P=P, twist=tw, sub=1, nc=4)) on = lambda i, dy=0.012, dz=0.019: F @ Vector((S20[i][0], S20[i][1] + dy, hz + dz)) up = (F.to_3x3() @ Vector((0, 0, 1))).normalized() # the riveted back: a channel clasping the spine back_channel(P, S36, E36, hz, 0.036, F, 0, 34, wf=0.03, th=0.0055, m=G2, rivets=(4, 11, 20, 27), r_riv=0.0085, nose=0.009, taper=0.6, twist=tw) # ---- the mount: a forged shoe round the beam's end, jaws over the blade where it leaves end = pth.at(1.0) dv = (pth.at(1.0) - pth.at(0.97)).normalized() hwe, hhe, rce = sat(1.0) shoe(P, -0.062, 0.095, -1.82, -1.68, hz - 0.016, -0.012, 0.009, bolts=[(-0.03, -1.75), (0.05, -1.75)], wedge=(-1.795, -1.712, 0.02), entry=(pth, lambda d, k: [(a, b * k) for a, b in rrect(hwe + d, hhe + d, rce + d, 3)]), blade_z=hz) jaws(P, S, E, hz, 0.036, F, 0.09, 0.2, 0.62, th=0.0055, rivets=2) # ---- the braces. A saddle strap where round 4's braces met the beam, clevis lugs welded on it and on the blade's back tb = pth.nearest_y(-1.36) b1 = pth.at(tb) hwb, hhb, rcb = sat(tb) sth = 0.0045 strap5(P, pth, tb, hwb, hhb, rcb, w=0.06, th=sth, ears=0) ch_top = lambda i: 0.036 * (1.0 - 0.6 * (i / 20) ** 3) * 0.5 + 0.0055 # the back channel's top over the blade plane # strut A: a flat bar from a clevis on the saddle's +X side down to one on the back at round 4's station 6 pA = on(6, dz=0.045) dA = (pA - b1).normalized() nA = dA.cross((Vector((0, 0, 1)) + up).normalized()).normalized() sideX = Vector((1, 0, 0)) kA = (hwb + sth + 0.026) / max(1e-6, dA.x) eA0 = b1 + dA * kA eA1 = pA gapA = 0.0105 flat_brace(P, eA0, eA1, nA, 0.026, gapA - 0.001, 0.0155, m=IRON) hp, Lb = clevis(P, eA0, sideX, nA, 0.036, 0.0055, (eA0.x - hwb) + 0.004, 0.0165, gapA, bead_at=eA0.x - hwb - sth) bolt5(P, hp, nA, Lb, 0.0058, m=G4, ref=dA, thr=0.0065) hp, Lb = clevis(P, eA1, up, nA, 0.036, 0.0055, 0.045 - ch_top(6) + 0.004, 0.0165, gapA, bead_at=0.045 - ch_top(6)) bolt5(P, hp, nA, Lb, 0.0058, m=G4, ref=dA, thr=0.0065) # strut B: rods with forged eyes, a turnbuckle in the middle r0 = b1 + Vector((0, 0.02, hhb + sth + 0.022)) pB = on(12, dz=0.045) dB = (pB - r0).normalized() nB = dB.cross(Vector((0, 0, 1))).normalized() r_rod = 0.0078 for c, dl, base, ba in ((r0, Vector((0, 0, 1)), 0.022 + 0.004, 0.022), (pB, up, 0.045 - ch_top(12) + 0.004, 0.045 - ch_top(12))): dd = dB if c is r0 else -dB rod_eye(P, c, -dd, nB, 0.0062, 0.0135, m=G3) hp, Lb = clevis(P, c, dl, nB, 0.032, 0.005, base, 0.0145, 0.0098, bead_at=ba) bolt5(P, hp, nB, Lb, 0.0052, m=G4, ref=dd, thr=0.006) Lt = 0.13 mid = (r0 + pB) / 2 for sg, c in ((-1, r0), (1, pB)): a_ = c - sg * dB * 0.0135 b_ = mid + sg * dB * (Lt / 2 + 0.008) P.append(UT.tube("rod", [a_, b_], lambda s: r_rod * 0.92, G3, segs=10, ang=40)) turnbuckle(P, mid - dB * 0.5, mid + dB * 0.5, nB, r_rod, Lb=Lt) tfin4(P, "Body", uv=2.4, ang=30) return dict(elev=38, azim=-30, dist_mul=.7) def scythe(): P = [] nibs = ((0.03, -0.04), (-0.03, -0.66)) 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=6) rf = lambda s: 0.0295 - 0.0075 * s # the snath runs on into the shoe ext = pts[:-1] + [(0.0, -1.27, -0.05), (-0.002, -1.31, -0.062)] C = resample(ext, 64) P.append(turned("snath", C, lambda s: 0.0295 - 0.0075 * min(1.0, s * 1.03), segs=16, s=0.9, u0=0.125, ang=34)) for k, (x, y) in enumerate(nibs): nib5(P, x, y, 0.12, m_knob=PRED, r=0.036, wrap=LEAT) t = pth.nearest_y(y) r = rf(t) ring_clamp5(P, pth, t, r, boltside=1 if y > -0.3 else -1) # the butt: a spiral leather wrap between brass rings, a domed iron cap with a rivet Lt = pth.L[-1] Cb = [pth.at(k * 0.12 / 12) for k in range(13)] P.append(spiral_wrap("buttwrap", Cb, 0.006 * Lt, 0.094 * Lt, lambda q: rf(q / Lt) + 0.0008, 0.0165, 0.003, LEAT, segs=16, rows=4, ref=(1, 0, 0))) for t in (0.006, 0.096): c, d = pth.at(t), (pth.at(t + 0.004) - pth.at(t - 0.004)).normalized() r = rf(t) P.append(lathe("ring", [(r + 0.0005, -0.0045), (r + 0.0048, -0.003), (r + 0.0058, 0.0), (r + 0.0048, 0.003), (r + 0.0005, 0.0045)], segs=16, m=BRASS, frame=fz(c, d), smooth_ang=50)) c0, d0 = pth.at(0.0), (pth.at(0.0) - pth.at(0.02)).normalized() P.append(lathe("buttcap", [(0.031, -0.012), (0.0335, -0.006), (0.0335, -0.002), (0.031, 0.003), (0.024, 0.0075), (0.012, 0.0098), (0.0, 0.0102)], segs=16, m=G2, frame=fz(c0, d0), smooth_ang=40)) P.append(lathe("capring", [(0.0335, -0.012), (0.0352, -0.0105), (0.0352, -0.0075), (0.0335, -0.006)], segs=16, m=G3, frame=fz(c0, d0), smooth_ang=40)) head(P, c0 + d0 * 0.0095, d0, 0.005, "dome", m=BRASS) # painted bands by the fore grip for t0, m in ((.47, PRED), (.495, CRM), (.52, PRED)): a, b = pth.at(t0 + 0.001), pth.at(t0 + 0.015) P.append(UT.tube("band", [a, b], lambda s: rf(t0) + 0.0012, m, segs=16, ang=30, cap=False)) # a whetstone in a cow horn, hung off the snath on a leather strap with a buckle hk = pth.at(pth.nearest_y(-.26)) P.append(UT.tube("hstrap", [hk + Vector((0, -.012, 0)), hk + Vector((0, .012, 0))], lambda s: (.0335, .0335), LEAT, segs=16, ang=30, cap=False)) P.append(bprism("buckle", rounded_outline([(-0.009, -0.011), (0.009, -0.011), (0.009, 0.011), (-0.009, 0.011)], 0.003, 2), 0.0, 0.003, [BRASS], bev=0.001, segs=1, frame=fz(hk + Vector((0, 0, 0.0335)), (0, 0, 1), (0, 1, 0)))) a = hk + Vector((.03, 0, -.02)) hn = [a, a + Vector((.012, 0, -.05)), a + Vector((.03, .004, -.11)), a + Vector((.05, .01, -.19))] P.append(turned("horn", resample(hn, 14), lambda s: .03 * (1 - s) ** .7 + .005, m="M_PaintCream", segs=14, s=1.0)) for s0 in (0.08, 0.32): cc = resample(hn, 20) q = int(s0 * 20) dd = (cc[q + 1] - cc[q]).normalized() P.append(lathe("hornring", [(0.0, -0.004), (.03 * (1 - s0) ** .7 + .0065, -0.004), (.03 * (1 - s0) ** .7 + .0075, 0.0), (.03 * (1 - s0) ** .7 + .0065, 0.004), (0.0, 0.004)], segs=14, m=BRASS, frame=fz(cc[q], dd), smooth_ang=50)) P.append(bprism("hone", rounded_outline([(-0.015, -0.015), (0.015, -0.015), (0.015, 0.015), (-0.015, 0.015)], 0.006, 2), -0.025, 0.028, [G3], bev=0.003, segs=2, frame=Matrix.Translation(a + Vector((-.003, 0, .03))))) # ---- the blade end = Vector((0, -1.3, -0.055)) hz, y0 = -0.095, -1.3 F = tilt_frame(y0, hz) S, E = scythe_outline(y0, 0.8, 0.19, 0.13, 0.17, 48, neck=(0.046, 0.022, 0.15)) S18, _ = scythe_outline(y0, 0.8, 0.19, 0.13, 0.17, 18) tw = (UT.TILT, 0.05) P.append(blade5("blade", S, E, hz, 0.026, frame=F, ground=0.3, seed=4, rust={(24, 2)}, P=P, twist=tw, sub=1, nc=4)) back_channel(P, S, E, hz, 0.026, F, 0, 37, wf=0.02, th=0.0045, m=DGY, rivets=(), nose=0.008, taper=0.55, twist=tw) UM.star_badge(P, F @ Vector((0.1, -1.255, hz + 0.0135)), .05, F.to_3x3() @ Vector((0, 0, 1))) # ---- the mount dv = (pth.at(1.0) - pth.at(0.97)).normalized() shoe(P, -0.036, 0.05, -1.35, -1.27, hz - 0.012, -0.027, 0.007, bolts=[(0.007, -1.31)], wedge=(-1.335, -1.292, 0.018), entry=(pth, lambda d, k: [(a, b * k) for a, b in circ(0.022 + d, 16)]), blade_z=hz) # a side bolt through the shoe, nut on the far side bolt5(P, (-0.036, -1.31, -0.075), (-1, 0, 0), 0.086, 0.0072, m=G4, ref=(0, 0, 1), thr=0.0) jaws(P, S, E, hz, 0.026, F, 0.045, 0.13, 0.6, th=0.0045, rivets=2) # ---- the grass nail: a flat stay from a lug under a little strap on the snath to a lug on the blade's back tn = pth.nearest_y(-1.08) a = pth.at(tn) ring_clamp5(P, pth, tn, rf(tn), boltside=0, w=0.02, saddle=True) sd = rf(tn) + 0.0045 * 0.6 + 0.006 # the saddle's underside below the snath's centre p0 = a + Vector((0.0, 0, -sd - 0.011)) up = (F.to_3x3() @ Vector((0, 0, 1))).normalized() ch3 = 0.026 * 0.5 + 0.0045 p1 = F @ Vector((S18[3][0], S18[3][1] + 0.008, hz + 0.03)) d = (p1 - p0).normalized() nn = d.cross((Vector((0, 0, 1)) + up).normalized()).normalized() flat_brace(P, p0, p1, nn, 0.013, 0.0046, 0.0085, m=IRON) hp, Lb = clevis(P, p0, Vector((0, 0, -1)), nn, 0.02, 0.0035, 0.011 + 0.004, 0.009, 0.0052, bead_at=0.011) bolt5(P, hp, nn, Lb, 0.0034, m=G4, ref=d, thr=0.004) hp, Lb = clevis(P, p1, up, nn, 0.02, 0.0035, 0.03 - ch3 + 0.003, 0.009, 0.0052, bead_at=0.03 - ch3) bolt5(P, hp, nn, Lb, 0.0034, m=G4, ref=d, thr=0.004) tfin4(P, "Body", uv=2.4, ang=30) return dict(elev=38, azim=-30, dist_mul=.7) def ring_clamp5(P, pth, t, r, boltside=1, w=0.028, th=0.0045, m=IRON, saddle=False, ear_scale=1.5, bolt_m=G2): """A round strap round the snath at t: rolled edges, the ends chamfered down, pinch ears on the bolt side, a saddle under it.""" Ltot = pth.L[-1] ss = [-0.5, -0.47, -0.4, -0.3, 0.3, 0.4, 0.47, 0.5] tk = [0.0006, th * 0.9, th * 1.25, th, th, th * 1.25, th * 0.9, 0.0006] C = [pth.at(t + q * w / Ltot) for q in ss] T, N, B = frames(C, ref=(1, 0, 0)) P.append(sweep("clamp", C, lambda sf, i: circ(r + tk[i], 16), [m], cap0=False, cap1=False, ang=40, frm=(T, N, B))) c = pth.at(t) i = len(C) // 2 Tt = T[i] if boltside: side = Vector((boltside, 0, 0)) side = (side - Tt * side.dot(Tt)).normalized() Bz = Tt.cross(side) * boltside Bz = Bz if Bz.z > 0 else -Bz es = ear_scale gap = 0.0065 * es ** 0.5 ear_len, ew, et = 0.024 * es, w * min(0.48, 0.4 * es), th * min(1.35, es) for sz in (-1, 1): org = c + side * (r - 0.004) + Bz * sz * (gap / 2 + et / 2) Fm = Matrix((side, Tt, Bz)).transposed().to_4x4() Fm.translation = org out = rounded_outline([(0.0, -ew), (ear_len * 0.35, -ew * 0.97), (ear_len, -ew * 0.84), (ear_len, ew * 0.84), (ear_len * 0.35, ew * 0.97), (0.0, ew)], 0.008 * es, n=2 if HW_LOD[0] else 3) P.append(bprism("ear", out, -et / 2, et / 2, [m, G3], bev=0.0011 * es, segs=1, frame=Fm, bev_slot=1)) bc = c + side * (r - 0.004 + ear_len * 0.6) bolt5(P, bc + Bz * (gap / 2 + et), Bz, gap + 2 * et, 0.005 * min(1.3, es), m=bolt_m, ref=Tt, thr=0.006 * es) # the saddle under the strap that the stay hangs from if not saddle: return Fm = fz(c - Vector((0, 0, r + th * 0.6)), (0, 0, -1), Tt) P.append(bprism("saddle", rounded_outline([(-0.017, -w * 0.45), (0.017, -w * 0.45), (0.017, w * 0.45), (-0.017, w * 0.45)], 0.006, 2), -0.004, 0.006, [m, G3], bev=0.0015, segs=1, frame=Fm, bev_slot=1)) def garden_shears(): py, ty = PV_Y, -0.62 z_in = 0.0008 tf = lambda u: 0.0145 * (1 - 0.45 * u) + 0.002 def hw(u): # the spine: straight, then rounding over into the tip k = 0.78 base = 0.041 - 0.009 * min(u, k) return base * math.sqrt(max(0.0, 1 - ((u - k) / (1 - k)) ** 2)) + 0.002 if u > k else base he = lambda u: 0.011 * (1 - 0.5 * u) # a crisper branch notch: a round hollow with a short flat run-in notch = lambda u: 0.0135 * math.sin(PI * (u - 0.05) / 0.12) ** 0.7 if 0.05 < u < 0.17 else 0.0 cfn = lambda u: 0.0 t0 = tf(0.0) for nm, sx, sz in (("BladeA", 1, 1), ("BladeB", -1, -1)): P = [shear_blade5(sx, sz, py, ty, hw, he, cfn, tf, z_in=z_in, n=40, notch=notch if sx > 0 else None, seed=3 if sx > 0 else 8)] zc = sz * (z_in + t0 * 0.5) hz = sz * 0.0105 # the boss round the pivot: a chamfered disc with a raised rim and a seat for the washer zA, zB = sz * z_in, sz * (z_in + t0) lo, hi = min(zA, zB), max(zA, zB) if sz > 0: prof = [(0.0, lo), (0.0315, lo), (0.034, lo + 0.002), (0.034, hi - 0.003), (0.031, hi), (0.0225, hi), (0.0215, hi - 0.0012), (0.0, hi - 0.0012)] else: prof = [(0.0, lo + 0.0012), (0.0215, lo + 0.0012), (0.0225, lo), (0.031, lo), (0.034, lo + 0.003), (0.034, hi - 0.002), (0.0315, hi), (0.0, hi)] P.append(lathe("boss", prof, segs=24, m=G2, frame=Matrix.Translation((0, py, 0)), smooth_ang=30)) # the forged tang: a flat bar from the boss to the ferrule, rounded edges fr0 = Vector((sx * 0.031, -0.05, hz)) tg = [Vector((sx * 0.004, py + 0.012, zc)), Vector((sx * 0.012, -0.095, zc)), Vector((sx * 0.024, -0.066, hz)), fr0 + Vector((0, 0.012, 0))] tgc = resample(tg, 14, per=6) P.append(sweep("tang", tgc, lambda sf, i: rrect(0.0145 - 0.0025 * sf, 0.0068 + 0.0035 * sf, 0.0045 + 0.002 * sf, 2), [G2, G3], colfn=lambda i, j: 1 if j % 3 != 2 else 0, ref=(1, 0, 0), ang=36)) # the ash handle: turned, a bead and a groove behind the ferrule hp = [fr0, Vector((sx * 0.038, 0.0, hz)), Vector((sx * 0.044, 0.08, hz)), Vector((sx * 0.046, 0.168, hz))] hc = resample(hp, 30, per=6) def hrf(s): r = 0.0175 + 0.003 * math.sin(s * PI) - 0.0025 * max(0.0, 1 - s / 0.14) if 0.2 < s < 0.24: r += 0.0018 * math.sin((s - 0.2) / 0.04 * PI) if 0.27 < s < 0.3: r -= 0.0012 * math.sin((s - 0.27) / 0.03 * PI) return r P.append(turned("handle", hc, hrf, segs=16, s=1.6, u0=0.125, ref=(0, 0, 1))) # the steel ferrule: rolled rims, two rivets through it and the tang, a brass head on top and a peened tail under fa, fb = fr0 + Vector((-sx * 0.0015, -0.012, 0)), fr0 + Vector((sx * 0.0012, 0.022, 0)) fd = (fb - fa).normalized() P.append(lathe("ferrule", [(0.0, -0.002), (0.0195, -0.002), (0.0212, 0.0), (0.0212, 0.0035), (0.02, 0.005), (0.02, 0.029), (0.0218, 0.0305), (0.0218, 0.034), (0.0202, 0.0355), (0.0, 0.0355)], segs=16, m=G3, frame=fz(fa, fd, (0, 0, 1)), smooth_ang=40)) for k_ in (0.35, 0.7): rc = fa.lerp(fb, k_) rivet(P, rc + Vector((0, 0, 0.0201)), (0, 0, 1), 0.0036, m=BRASS, tail=BRASS, L=0.0402) # the red rubber grip: a lip at the front, finger swells, rings to hold it, a flared end gp = Path4([Vector((sx * 0.0405, 0.05, hz)), Vector((sx * 0.044, 0.1, hz)), Vector((sx * 0.046, 0.165, hz))]) gq = resample(gp.pts, 40) def grf(s): r = 0.0218 + 0.0042 * max(0.0, 1 - s / 0.06) ** 1.5 + 0.0018 * abs(math.sin(s * PI * 3.0)) ** 2 * (1 if s < 0.84 else 0) + 0.004 * max(0.0, (s - 0.88) / 0.12) if 0.08 < s < 0.86: r += 0.0011 * (1 if math.sin((s - 0.08) / 0.78 * PI * 11) > 0.35 else 0) # moulded grip rings return r P.append(sweep("grip", gq, lambda sf, i: circ(grf(sf), 16), [PRED], ref=(0, 0, 1), ang=40)) end = gp.pts[-1] P.append(lathe("knob", [(0.0, -0.002), (0.0245, -0.002), (0.0262, 0.003), (0.0262, 0.007), (0.024, 0.0105), (0.021, 0.0125), (0.0185, 0.0155), (0.0, 0.017)], segs=16, m=RUB, frame=Matrix.Translation(end) @ Matrix.Rotation(DEG(-90), 4, "X"), smooth_ang=40)) # the bumper: a rubber dome in a steel cup on the inside of each tang, the handles stop on these bc = Vector((sx * 0.02, -0.062, hz)) bn = Vector((-sx, 0, 0)) P.append(lathe("bumpcup", [(0.0, -0.002), (0.0098, -0.002), (0.0105, 0.0), (0.0105, 0.0045), (0.0092, 0.0055), (0.0, 0.0055)], segs=12, m=G4, frame=fz(bc - bn * 0.002, bn), smooth_ang=40)) P.append(lathe("bump", [(0.0, 0.004), (0.0078, 0.004), (0.0078, 0.0085), (0.0068, 0.0092), (0.0072, 0.0104), (0.0055, 0.0128), (0.003, 0.0138), (0.0, 0.014)], segs=12, m=RUB, frame=fz(bc - bn * 0.002, bn), smooth_ang=50)) if sx < 0: # a leather hanging loop through a brass eyelet in the end of one handle e = end + Vector((0, 0.012, 0)) P.append(lathe("eyelet", [(0.0045, -0.0035), (0.0068, -0.0035), (0.0075, -0.002), (0.0075, 0.002), (0.0068, 0.0035), (0.0045, 0.0035)], segs=12, m=BRASS, frame=fz(e + Vector((0, -0.004, 0)), (0, 0, 1)), smooth_ang=50)) pts = [e, e + Vector((-0.02, 0.022, 0)), e + Vector((-0.012, 0.056, 0)), e + Vector((0.016, 0.064, 0)), e + Vector((0.026, 0.034, 0)), e + Vector((0.006, 0.006, 0))] P.append(UT.tube("lanyard", pts, lambda s: (0.0055, 0.0028), LEAT, segs=8, per=5, ang=40, cap=False)) o = tfin4(P, nm, uv=5.0, ang=30) set_origin(o, (0, py, 0)) # ---- the pivot bolt (static Body): a domed brass head with a slot over a dished steel washer, a hex nut under a washer, # the thread poking through the nut zt = z_in + t0 c = Vector((0, py, 0)) B = [] B.append(lathe("dish", [(0.0, zt - 0.0012), (0.0205, zt - 0.0012), (0.0215, zt + 0.0004), (0.016, zt + 0.0022), (0.0, zt + 0.0022)], segs=24, m=G4, smooth_ang=30, frame=Matrix.Translation(c))) z1 = zt + 0.0022 B.append(lathe("head", [(0.0, z1 - 0.0005), (0.0172, z1 - 0.0005), (0.0175, z1 + 0.0018), (0.0155, z1 + 0.0048), (0.011, z1 + 0.0068), (0.005, z1 + 0.0078), (0.0, z1 + 0.008)], segs=20, m=BRASS, frame=Matrix.Translation(c), smooth_ang=40)) B.append(bprism("slot", [(-0.0115, -0.0014), (0.0115, -0.0014), (0.0115, 0.0014), (-0.0115, 0.0014)], z1 + 0.0055, z1 + 0.0082, [DGY], frame=Matrix.Translation(c))) q = washer(B, c + Vector((0, 0, -zt + 0.0006)), (0, 0, -1), 0.0185, 0.0018, m=G4, segs=20) q = hexnut(B, q, (0, 0, -1), 0.0165, 0.0085, m=G4, ref=(1, 0, 0)) thread(B, q + Vector((0, 0, 0.002)), (0, 0, -1), 0.0072, 0.0075, m=G3, segs=12) B.append(UT.disc("shaft", 0.008, 2 * zt, (0, py, 0), G3, n=12)) tfin4(B, "Body", uv=5.0, ang=30) return dict(elev=60, azim=-12, dist_mul=.72) def shear_blade5(sx, sz, py, ty, hw, he, cfn, tf, z_in=0.0008, n=30, heel=0.03, notch=None, seed=3, nc=6, mscale=0.03, mottle=True, spine=G2, inner=G3, cheek=G1): """One shear blade from the pivot to the tip: a flat inner face, a rounded spine, a hammered outer cheek, a dark grind line, a bright ground bevel and a fine edge. sx = +1: spine on -X, edge on +X (BladeA). sz: the layer. nc: points across the cheek.""" rng = random.Random(seed) rings, slots = [], None ys = [] for i in range(n + 1): f = i / n ys.append((py + heel) + (ty + 0.004 - (py + heel)) * f ** 0.92) # more stations through the notch if notch: ux = [0.05 + 0.12 * k / 10 for k in range(1, 10)] ys += [py - u * (py - ty) for u in ux] ys = sorted(set(round(y, 5) for y in ys), reverse=True) cf = [0.74 - (0.74 - 0.47) * q / (nc - 1) for q in range(nc)] for i, y in enumerate(ys): u = max(0.0, (py - y) / (py - ty)) c = cfn(u) k = 1.0 - 0.5 * (max(0.0, y - py) / heel) ** 2 h_e = he(u) * k - (notch(u) if notch else 0.0) S, E = c - sx * hw(u) * k, c + sx * h_e t = tf(u) W = abs(S - E) ch = min(0.0035, W * 0.18) X = lambda f: E + (S - E) * f # f: 0 at the edge, 1 at the spine dim = 0.00025 if 0 < i < len(ys) - 1 else 0.0 pts = ([(S, z_in), (S, z_in + t * 0.62), (S + sx * ch * 0.35, z_in + t * 0.9), (S + sx * ch, z_in + t)] + [(X(f), z_in + t + (rng.uniform(-dim, dim) if 0 < q < nc - 1 else 0.0)) for q, f in enumerate(cf)] + [(X(0.44), z_in + t * 0.95), (X(0.06), z_in + t * 0.2), (E, z_in + t * 0.08), (E, z_in)]) slots = [0, 0, 0] + [1] * nc + [2, 3, 4, 4, 5] rings.append([Vector((x, y, sz * z)) for x, z in pts]) tipc = cfn(1.0) + sx * he(1.0) * 0.4 rings.append([Vector((tipc, ty, sz * (z_in + tf(1.0) * 0.35)))]) mats = [spine, cheek, GLINE, BEV, EDGE, inner, HMD, HML] def col(i, j): if j < 0: return 0 return slots[j] o = rings_mesh("blade", rings, mats, colfn=col, ang=32) if mottle: hammer_uv(o, 1, STEEL_RAMP, scale=mscale * 0.6, seed=seed) return o # ======================================================================= round 5, second batch: the other blade tools def bump(s, c, w): """A smooth bump of half-width w centred on c (1 at c, 0 beyond).""" x = abs(s - c) / w return 0.0 if x >= 1 else 0.5 + 0.5 * math.cos(PI * x) def feature_ss(n, feats, lo=0.0, hi=1.0): """n even path fractions lo..hi plus a few around each feature (c, w), so grooves and beads get the stations they need.""" ss = [lo + (hi - lo) * k / n for k in range(n + 1)] for c, w in feats: ss += [c + w * q for q in (-1.3, -1.0, -0.7, -0.4, 0.0, 0.4, 0.7, 1.0, 1.3)] return sorted(set(round(min(hi, max(lo, s)), 6) for s in ss)) def rope_sec(r, lobes=3, n=7, tw=7.0, turns=1.0): """A three-strand rope section that twists along the rope: sec(s, i).""" return lambda s, i: [(r * (1 + 0.16 * math.cos(lobes * (q * TAU / n) - tw * s * turns * TAU / lobes)) * math.cos(q * TAU / n), r * (1 + 0.16 * math.cos(lobes * (q * TAU / n) - tw * s * turns * TAU / lobes)) * math.sin(q * TAU / n)) for q in range(n)] def endgrain_cap(name, ring, centre, nrm, rise, pith, u0=0.5, uw=0.44, m=TIM): """A low dome closing a ring of points (the cut end of a timber part): the timber texture laid radially round `pith` (a point off to one side) across all four of its boards, so the dark lines between the boards and the grain stripes become arcs: growth rings.""" nrm = Vector(nrm).normalized() centre = Vector(centre) pith = Vector(pith) bm = bmesh.new() uvl = bm.loops.layers.uv.verify() rows = [list(ring)] + [[centre.lerp(Vector(p), f) + nrm * (rise * (1 - f * f)) for p in ring] for f in (0.7, 0.4)] V = [[bm.verts.new(p) for p in r] for r in rows] vc = bm.verts.new(centre + nrm * rise) ds = [(Vector(p) - pith).length for p in ring] dmax, dmin = max(ds), max(0.0, min(ds) - (max(ds) - min(ds)) * 0.2) ax = (Vector(ring[0]) - centre).normalized() ay = nrm.cross(ax) def uvf(p): d = p - pith return (u0 - uw + 2 * uw * max(0.0, min(1.0, (d.length - dmin) / max(1e-6, dmax - dmin))), math.atan2(d.dot(ay), d.dot(ax)) * 0.02) nr = len(ring) for a in range(len(V) - 1): for j in range(nr): q = (j + 1) % nr f = bm.faces.new((V[a][j], V[a][q], V[a + 1][q], V[a + 1][j])) for lp in f.loops: lp[uvl].uv = uvf(lp.vert.co) for j in range(nr): f = bm.faces.new((V[-1][j], V[-1][(j + 1) % nr], vc)) for lp in f.loops: lp[uvl].uv = uvf(lp.vert.co) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) for f in bm.faces: f.normal_update() if sum(f.normal.dot(nrm) for f in bm.faces) < 0: bmesh.ops.reverse_faces(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) smooth(o, 50) o["uv_done"] = True return o def bow_ring(name, c, rx, ry, a_in, a_z, z, m_out=PRED, m_in=G4, seg=40, ns=14, p=2.4): """A finger bow: a closed ring round an oval centre line in the XY plane (rx, ry), its section a superellipse a_in across, a_z up. The enamel (m_out) stops short of the inside of the loop, where the steel (m_in) shows, worn by the finger.""" bm = bmesh.new() R = [] sec = sellipse(a_in, a_z, p, ns, ph=PI / ns) for i in range(seg): a = TAU * i / seg q = Vector((c[0] + rx * math.cos(a), c[1] + ry * math.sin(a), z)) nrm = Vector((math.cos(a) / rx, math.sin(a) / ry, 0)).normalized() R.append([bm.verts.new(q + nrm * u + Vector((0, 0, v))) for u, v in sec]) idx = [] for i in range(seg): A, B_ = R[i], R[(i + 1) % seg] for j in range(ns): k = (j + 1) % ns bm.faces.new((A[j], B_[j], B_[k], A[k])) t = PI / ns + TAU * (j + 0.5) / ns idx.append(1 if math.cos(t) < -0.55 else 0) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m_out, m_in) o.data.polygons.foreach_set("material_index", idx) o.data.update() smooth(o, 45) return o # ----------------------------------------------------------------------- nail scissors def nail_scissors(): """Round 4's frame (screw at PV_Y, tips at -0.455, the bows where they were). Polished blades with the real section (flat inner face, a rounded spine, a satin cheek, a dark grind line, a bright bevel, a fine edge) curving to the tips; a chamfered boss with a seat for the screw; shanks forged oval with a knuckle by the boss and a bead where they meet the bows; the bows enamelled over steel, the steel showing round the inside; a finger rest curling off the big bow to a polished ball; a slotted domed brass screw over a washer, a domed cap nut under.""" py, ty = PV_Y, -0.455 z_in = 0.0006 tf = lambda u: 0.0105 * (1 - 0.62 * u) + 0.0018 hw = lambda u: 0.0275 * (1 - u) ** 0.85 + 0.0016 he = lambda u: 0.0205 * (1 - u) ** 0.95 + 0.0010 cfn = lambda u: -0.02 * u ** 2.2 # curved nail scissors: the tips sweep a little to -X t0 = tf(0.0) for nm, sx, sz in (("BladeA", 1, 1), ("BladeB", -1, -1)): P = [shear_blade5(sx, sz, py, ty, hw, he, cfn, tf, z_in=z_in, n=44, heel=0.022, seed=5 if sx > 0 else 6, nc=5, mottle=False, cheek=G3, spine=G2, inner=G2)] zc = sz * (z_in + t0 * 0.5) # the boss round the screw: chamfered, a seat for the screw head (top) or the cap nut (under) zA, zB = sz * z_in, sz * (z_in + t0) lo, hi = min(zA, zB), max(zA, zB) if sz > 0: prof = [(0.0, lo), (0.0215, lo), (0.023, lo + 0.0015), (0.023, hi - 0.0022), (0.0208, hi), (0.0146, hi), (0.0139, hi - 0.0008), (0.0, hi - 0.0008)] else: prof = [(0.0, lo + 0.0008), (0.0139, lo + 0.0008), (0.0146, lo), (0.0208, lo), (0.023, lo + 0.0022), (0.023, hi - 0.0015), (0.0215, hi), (0.0, hi)] P.append(lathe("boss", prof, segs=24, m=G4, frame=Matrix.Translation((0, py, 0)), smooth_ang=30)) # the shank: forged oval, a knuckle by the boss, drawn thinner towards the bow big = sx < 0 cb = Vector((sx * (0.061 if big else 0.056), 0.064 if big else 0.06, zc)) rx, ry = (0.036, 0.046) if big else (0.031, 0.04) d = (Vector((0, py, zc)) - cb) a_in = math.atan2(d.y / ry, d.x / rx) entry = cb + Vector((rx * math.cos(a_in), ry * math.sin(a_in), 0)) sh = [Vector((0, py + 0.006, zc)), Vector((sx * 0.011, py + 0.05, zc)), Vector((sx * 0.03, -0.045, zc)), entry + Vector((0, -0.012, 0)), entry] C = resample(sh, 26, per=5) def shsec(s, i): k = 1 + 0.16 * bump(s, 0.16, 0.12) + 0.1 * bump(s, 0.86, 0.08) return sellipse(0.0066 * k * (1 - 0.12 * s), (0.0108 - 0.0024 * s) * k, 2.6, 14) P.append(sweep("shank", C, shsec, [G4, G5], colfn=lambda i, j: 1 if j in (0, 13, 6, 7) else 0, ref=(0, 0, 1), ang=40)) dd = (C[-3] - C[-1]).normalized() P.append(lathe("bead", [(0.0, -0.002), (0.0098, -0.002), (0.0122, 0.0), (0.0128, 0.0022), (0.0118, 0.0045), (0.0098, 0.0058), (0.0, 0.0058)], segs=14, m=G5, frame=fz(entry + dd * 0.004, dd), smooth_ang=50)) # the bow: red enamel over an oval steel loop, the steel showing round the inside P.append(bow_ring("bow", cb, rx, ry, 0.0118, 0.0082, zc, seg=40, ns=14)) if big: # the finger rest: a tapering spur curling back off the outside of the big bow, a polished ball on its end a0 = DEG(150) p0 = cb + Vector((rx * math.cos(a0), ry * math.sin(a0), 0)) spur = [p0 + Vector((0.004, -0.004, 0)), p0 + Vector((-0.012, 0.022, 0)), p0 + Vector((-0.014, 0.055, 0)), p0 + Vector((0.004, 0.075, 0))] Cs = resample(spur, 18, per=5) P.append(sweep("spur", Cs, lambda s, i: sellipse(0.0055 * (1 - 0.3 * s), 0.0072 * (1 - 0.45 * s), 2.3, 12), [G4, G5], colfn=lambda i, j: 1 if j in (2, 3) else 0, ref=(0, 0, 1), ang=40)) de = (Cs[-1] - Cs[-2]).normalized() P.append(lathe("spurtip", [(0.0, -0.003), (0.0042, -0.0025), (0.0062, 0.0), (0.0068, 0.0035), (0.0058, 0.0068), (0.0032, 0.0088), (0.0, 0.0092)], segs=14, m=G5, frame=fz(Cs[-1] - de * 0.002, de), smooth_ang=50)) P.append(lathe("spurcol", [(0.0, -0.0025), (0.0068, -0.0025), (0.0082, 0.0), (0.0068, 0.0025), (0.0, 0.0025)], segs=12, m=G5, frame=fz(Cs[2], (Cs[3] - Cs[1]).normalized()), smooth_ang=50)) o = tfin4(P, nm, uv=5.0, ang=30) set_origin(o, (0, py, 0)) # ---- the screw (static Body): a slotted domed brass head on a thin washer, a domed cap nut under, the shaft between zt = z_in + t0 c = Vector((0, py, 0)) B = [lathe("washer", [(0.0, zt - 0.0009), (0.0136, zt - 0.0009), (0.0139, zt - 0.0002), (0.0131, zt + 0.0004), (0.0, zt + 0.0004)], segs=24, m=G4, frame=Matrix.Translation(c), smooth_ang=30)] z1 = zt + 0.0004 B.append(lathe("head", [(0.0, z1 - 0.0004), (0.0124, z1 - 0.0004), (0.0127, z1 + 0.0009), (0.0118, z1 + 0.0026), (0.0094, z1 + 0.0041), (0.0055, z1 + 0.005), (0.0, z1 + 0.0053)], segs=24, m=BRASS, frame=Matrix.Translation(c), smooth_ang=40)) B.append(bprism("slot", [(-0.0082, -0.0009), (0.0082, -0.0009), (0.0082, 0.0009), (-0.0082, 0.0009)], z1 + 0.0032, z1 + 0.0056, [DGY], frame=Matrix.Translation(c))) B.append(lathe("capnut", [(0.0, -zt + 0.0008), (0.0112, -zt + 0.0008), (0.0114, -zt - 0.0006), (0.0108, -zt - 0.0022), (0.0088, -zt - 0.0036), (0.0052, -zt - 0.0043), (0.0, -zt - 0.0045)], segs=20, m=G4, frame=Matrix.Translation(c), smooth_ang=40)) B.append(UT.disc("shaft", 0.006, 2 * zt, (0, py, 0), G3, n=12)) tfin4(B, "Body", uv=5.0, ang=30) return dict(elev=60, azim=-12, dist_mul=.72) # ----------------------------------------------------------------------- sickle def sickle(): """Round 4's frame: the same pistol-handle path, reach and crescent. A turned handle (swell, waist, incised rings, a bead behind the ferrule, grain along it) with a spiral leather grip between brass welts; a turned red pommel with a brass ring and a screw eye at its end, a three-strand rope loop through it, the ends whipped with jute; a rolled brass ferrule riveted through; one forged iron bolster where the tang goes in; the crescent with the real section (edge, bevel, grind line, hammered cheek, a thickened forged spine).""" P = [] 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)] pth = UT.Path(hp, per=5) Lh = pth.L[-1] def rf(s): r = 0.04 + 0.009 * math.exp(-((s - 0.2) / 0.13) ** 2) + 0.004 * math.exp(-((s - 0.47) / 0.08) ** 2) - 0.004 * max(0.0, (s - 0.62) / 0.38) r -= 0.0016 * (bump(s, 0.575, 0.007) + bump(s, 0.6, 0.007)) # two incised rings ahead of the grip r += 0.0024 * bump(s, 0.925, 0.014) - 0.0012 * bump(s, 0.95, 0.008) # a bead and a cove behind the ferrule return r ss = feature_ss(70, [(0.575, 0.007), (0.6, 0.007), (0.925, 0.014), (0.95, 0.008)], 0.0, 0.985) C = [pth.at(s) for s in ss] P.append(sweep("handle", C, lambda sf, i: circ(rf(ss[i]), 18), [TIM], uv=(0.125, 0.09, 1.0), ref=(1, 0, 0), ang=34)) # the leather grip: a spiral wrap between two brass welts where the fingers close g0, g1 = 0.255, 0.5 P.append(spiral_wrap("wrap", C, g0 * Lh, g1 * Lh, lambda q: rf(q / Lh) + 0.0004, 0.021, 0.0033, LEAT, segs=18, rows=3, ref=(1, 0, 0))) for t in (g0 - 0.006, g1 + 0.006): c, d = pth.at(t), (pth.at(t + 0.004) - pth.at(t - 0.004)).normalized() r = rf(t) + 0.0035 P.append(lathe("welt", [(r - 0.004, -0.0048), (r - 0.0008, -0.0042), (r + 0.0012, -0.002), (r + 0.0016, 0.0), (r + 0.0012, 0.002), (r - 0.0008, 0.0042), (r - 0.004, 0.0048)], segs=18, m=BRASS, frame=fz(c, d), smooth_ang=50)) # the pommel: turned, red, a cove and a bead, a brass ring where it meets the handle, a screw eye in its end FP = Matrix.Translation((0, 0.031, 0)) P.append(lathe("pommel", [(0.037, -0.288), (0.0445, -0.2915), (0.0466, -0.2965), (0.0446, -0.3005), (0.0458, -0.3035), (0.0492, -0.3095), (0.0512, -0.317), (0.0514, -0.3245), (0.0494, -0.332), (0.0446, -0.3385), (0.0362, -0.3428), (0.022, -0.3452), (0.0, -0.346)], segs=20, m=PRED, frame=FP, smooth_ang=40)) P.append(lathe("pring", [(0.0405, -0.2925), (0.0436, -0.2912), (0.0458, -0.2895), (0.0462, -0.2862), (0.0452, -0.2826), (0.0428, -0.281), (0.0405, -0.2805)], segs=20, m=BRASS, frame=Matrix.Translation((0, 0.03, 0)), smooth_ang=50)) ey = Vector((0, 0.031, -0.3605)) P.append(lathe("eyeplate", [(0.0, -0.3448), (0.011, -0.3448), (0.0118, -0.3462), (0.0104, -0.3478), (0.004, -0.3484), (0.0, -0.3484)], segs=14, m=BRASS, frame=Matrix.Translation((0, 0.031, 0)), smooth_ang=40)) P.append(UT.tube("eyeshank", [Vector((0, 0.031, -0.347)), ey + Vector((0, 0, 0.0082))], lambda s: 0.0028, BRASS, segs=8, ang=40)) ring = [ey + Vector((0, 0.0085 * math.sin(TAU * k / 16), 0.0085 * math.cos(TAU * k / 16))) for k in range(16)] P.append(UT.tube("eye", ring + ring[:2], lambda s: 0.0026, BRASS, segs=8, per=1, cap=False, ang=50)) # a three-strand rope loop through the eye, the two ends laid together and whipped with twine lp = [ey + Vector((0.0, -0.002, 0.0)), ey + Vector((0.009, 0.005, -0.008)), ey + Vector((0.0055, 0.022, -0.018)), Vector((0.036, 0.085, -0.39)), Vector((0.0, 0.14, -0.414)), Vector((-0.036, 0.085, -0.39)), ey + Vector((-0.0055, 0.022, -0.018)), ey + Vector((-0.009, 0.005, -0.008)), ey + Vector((0.0, -0.002, 0.0))] Cl = resample(lp, 44, per=5) P.append(sweep("loop", Cl, rope_sec(0.0062, turns=4.5), [ROPE], ref=(0, 1, 0), ang=50)) wa, wb = ey + Vector((0, 0.019, -0.016)), ey + Vector((0, 0.034, -0.024)) wd_ = (wb - wa).normalized() P.append(lathe("whipcore", [(0.0, -0.0085), (0.0098, -0.008), (0.0128, -0.003), (0.0128, 0.003), (0.0098, 0.008), (0.0, 0.0085)], segs=12, m=ROPE, frame=fz((wa + wb) / 2, wd_, (1, 0, 0)), smooth_ang=50)) P.append(rope_coil("whip", [wa - wd_ * 0.01, wb + wd_ * 0.01], 0.01 + (wb - wa).length / 2, lambda ph: 0.0132, 0.0019, 3.2, m=JUTE, segs=12, ref=(1, 0, 0))) # the ferrule: rolled brass, a bead round its middle, a rivet through it and the tang (heads both sides) FY = Matrix.Translation((0, 0, z)) @ Matrix.Rotation(DEG(90), 4, "X") # local +Z -> world -Y P.append(lathe("ferrule", [(0.0372, 0.289), (0.0402, 0.2898), (0.0418, 0.2925), (0.0412, 0.296), (0.0404, 0.299), (0.0404, 0.3225), (0.0418, 0.325), (0.0424, 0.3295), (0.0418, 0.334), (0.0404, 0.3365), (0.0404, 0.3595), (0.0416, 0.3625), (0.0408, 0.3665), (0.0382, 0.3684), (0.0336, 0.369)], segs=22, m=BRASS, frame=FY, smooth_ang=40)) for sx in (-1, 1): rivet(P, Vector((sx * 0.0404, -0.31, z)), (sx, 0, 0), 0.0052, m=BRASS) # the bolster: forged iron where the tang goes in, a chamfered collar, a groove, a washer face against the blade's neck # one forged piece: an octagon swelling out of the ferrule, its shoulder rounding over into a domed front face round the neck pb_ = [(-0.3605, 0.0302), (-0.3625, 0.0336), (-0.3655, 0.0355), (-0.3695, 0.0359), (-0.3735, 0.035), (-0.3772, 0.0328), (-0.3805, 0.0296), (-0.3829, 0.0258), (-0.3845, 0.0214), (-0.3854, 0.0158)] nb_ = len(pb_) Xv, Yv, Zv = Vector((1, 0, 0)), Vector((0, 1, 0)), Vector((0, 0, 1)) bo = sweep("bolster", [Vector((0.0, y, z)) for y, r in pb_], lambda sf, i: oct_sec(pb_[i][1], pb_[i][1], pb_[i][1] * 0.92, pb_[i][1] * 0.5, pb_[i][1] * 0.16), [DGY, G3], colfn=lambda i, j: 1 if (j >= 0 and j % 3 == 2 and (j // 3) % 2 == 1) else 0, frm=([-Yv] * nb_, [Xv] * nb_, [Zv] * nb_), ang=36) hammer_uv(bo, 0, FORGE_RAMP, scale=0.01, seed=5) P.append(bo) # ---- the crescent: same outer circle and widths as round 4, a narrow neck from the bolster c = Vector((0.335, -0.79, 0)) S, E = [], [] n = 26 for i in range(n + 1): ad = 150 + (378 - 150) * i / n u = (ad - 142) / 236 a = DEG(ad) r_o = 0.455 - 0.05 * u + 0.012 * math.sin(u * math.pi) w = 0.128 * (1 - u) ** 0.62 * (0.86 + 0.14 * math.sin(min(1.0, u * 2.2) * 1.57)) + 0.005 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))) E[-1] = (S[-1][0] - 0.002, S[-1][1] - 0.006) s0, e0 = Vector((-0.015, -0.372)), Vector((0.015, -0.372)) s1, e1 = Vector(S[0]), Vector(E[0]) neck = [(s0.lerp(s1, k / 4), e0.lerp(e1, (k / 4) ** 1.4)) for k in range(4)] S = [tuple(a_) for a_, b_ in neck] + S E = [tuple(b_) for a_, b_ in neck] + E j = 4 + next(i for i in range(n + 1) if 150 + 228 * i / n >= 178) L = [0.0] for q in range(1, j + 1): L.append(L[-1] + (Vector(S[q]) - Vector(S[q - 1])).length) for q in range(1, j): E[q] = tuple(e0.lerp(Vector(E[j]), (L[q] / L[j]) ** 1.15)) t = 0.03 P.append(blade5("blade", S, E, z, t, ground=0.36, seed=12, rust={(15, 2)}, P=P, sub=2, nc=6)) # the forged spine: the back thickened into a rounded rib on both faces, swelling out of the neck and dying away towards the tip ns = len(S) rib = [] for i in range(2, 24): sp, ed = Vector(S[i]), Vector(E[i]) rib.append(Vector((*(sp + (ed - sp).normalized() * 0.012), z))) nr = len(rib) def ribsec(sf, i): u = (i + 2) / (ns - 1) tt = t * (1.0 - 0.6 * u ** 3) * 0.5 k = math.sin(min(1.0, sf * 5) * PI / 2) * (1 - sf ** 3) return [((tt + 0.0055 * k) * math.sin(TAU * q / 14), (0.0035 + 0.0075 * k) * math.cos(TAU * q / 14)) for q in range(14)] P.append(sweep("rib", rib, ribsec, [DGY, G2], colfn=lambda i, j: 1 if j in (3, 4, 10, 11) else 0, ref=(0, 0, 1), ang=50)) UM.star_badge(P, Vector((-0.004, -0.455, z + 0.0158)), .052, (0, 0, 1)) tfin4(P, "Body", uv=2.4, ang=30) return dict(elev=62, azim=-10, dist_mul=.72) # ----------------------------------------------------------------------- hammer def oct_sec(A1, A2, B, ch, fil, n=2): """An octagon round (a, b): a from -A1 to A2, b from -B to B, corners cut by ch, every corner rounded by fil. 8 (n + 1) points. Face 3k + 2 (n = 2) is the straight side k: even k a flat, odd k a chamfer.""" ch = min(ch, (A1 + A2) * 0.45, B * 0.9) pts = [(A2, -B + ch), (A2, B - ch), (A2 - ch, B), (-A1 + ch, B), (-A1, B - ch), (-A1, -B + ch), (-A1 + ch, -B), (A2 - ch, -B)] return rounded_outline(pts, fil, n=n) def claw_half(T, Wd, g, ch, cv, fil, sz): """One prong's section in (a along the claw's inward normal from its back, b across): the back and the side chamfered like the head's root (so the outline runs on unbroken), the face into the V ground to a bevel at its inner edge. sz: which half.""" pts = [(0.0, g), (T - cv, g), (T, g + cv), (T, Wd - ch), (T - ch, Wd), (ch, Wd), (0.0, Wd - ch)] pts = rounded_outline(pts, fil, n=2) if sz < 0: pts = [(a, -b) for a, b in reversed(pts)] return pts def hammer(): """Round 4's frame: the handle along -Y from the butt at +0.2, the head across it at y = -0.56, the round face on +X, the split claw on -X curling back towards the handle. The head and the claw's root are one forged solid swept from the face round the claw: chamfered cheeks (forge scale mottled on the flats, the chamfers worn bright) drawing into a chamfered octagonal neck that waists and swells into the round poll, a raised band round the poll, a bevelled striking face. The claw curves smoothly (64 stations), rounded with chamfered edges, split by a V that opens towards two sharp tips flaring a little apart, the V's edges ground and the tips polished. The neck's chamfers run out on a small shoulder before the poll. Under the head an eye boss grows out of it as a tapered octagonal skirt round the handle, chamfered at its rim. Through the top of the eye: end grain, a dark walnut wedge along the head, a steel wedge across it, two round wedges. A hickory handle; a moulded rubber grip with a flared butt, finger swells and ridges, a red stop band, a leather thong through brass grommets.""" P = [] 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)] pth = UT.Path(hp, per=5) HT, HB, HW = 0.058, 0.056, 0.044 # half height up (-Y), down (+Y), half width (Z) swell = lambda s: math.exp(-((s - 0.18) / 0.22) ** 2) flare = lambda s: max(0.0, (s - .86) / .14) ** 2 hrad = lambda s: (0.0305 + 0.007 * swell(s) + 0.012 * flare(s), 0.0215 + 0.005 * swell(s) + 0.0045 * flare(s)) X_, Y_, Z_ = Vector((1, 0, 0)), Vector((0, 1, 0)), Vector((0, 0, 1)) # ---- the handle, from under the grip up through the eye: inside the head it narrows to the eye g1 = 0.34 sy = [pth.at(g1 - 0.03 + (1 - g1 + 0.03) * k / 46) for k in range(47)] top = Vector((0.0, hy - HT - 0.0012, 0.0)) sy = sy + [top] y_in = hy + HB - 0.004 def hsec(sf, i): p = sy[i] s = g1 - 0.03 + (1 - g1 + 0.03) * min(1.0, i / 46) ra, rb = hrad(s) if p.y < y_in: f = min(1.0, (y_in - p.y) / 0.012) ra, rb = ra + (0.0298 - ra) * f, rb + (0.0188 - rb) * f return circ((ra, rb), 18) P.append(sweep("handle", sy, hsec, [TIM], uv=(0.875, 0.09, 0.9), ref=(1, 0, 0), ang=34, cap0=False)) # the end of the handle through the top of the eye: end grain, a walnut wedge along the head, a steel wedge across, two round wedges ytop = hy - HT er = [Vector((0.0298 * math.cos(PI / 18 + TAU * k / 18), top.y, 0.0188 * math.sin(PI / 18 + TAU * k / 18))) for k in range(18)] P.append(endgrain_cap("endgrain", er, top, (0, -1, 0), 0.0012, top + Vector((0.05, 0, 0.03)))) Fw = fz(top + Vector((0, 0.0014, 0)), (0, -1, 0), (1, 0, 0)) P.append(bprism("wwedge", rounded_outline([(-0.027, -0.0034), (0.027, -0.0034), (0.027, 0.0034), (-0.027, 0.0034)], 0.0018, 2), 0.0, 0.0034, ["P_BROWN", "P_BROWN"], bev=0.0012, segs=1, bev_slot=1, frame=Fw)) P.append(bprism("swedge", rounded_outline([(-0.0034, -0.0172), (0.0034, -0.0172), (0.0034, 0.0172), (-0.0034, 0.0172)], 0.0012, 1), 0.0, 0.0032, [G4, G5], bev=0.0009, segs=1, bev_slot=1, frame=Fw)) for x in (-0.017, 0.017): P.append(lathe("pin", [(0.0, -0.002), (0.0042, -0.002), (0.0046, 0.0004), (0.0036, 0.0022), (0.0, 0.0028)], segs=10, m=G5, frame=fz(top + Vector((x, 0.0006, 0)), (0, -1, 0)), smooth_ang=50)) lipr = [Vector((0.0332 * math.cos(TAU * k / 20), ytop - 0.0004, 0.0222 * math.sin(TAU * k / 20))) for k in range(20)] P.append(UT.tube("eyelip", lipr + lipr[:2], lambda s: (0.0026, 0.0016), G1, segs=6, per=1, cap=False, ang=50)) # ---- the head and the claw's root: one forged solid, swept from the face end back along -X and round the claw to the V # stations (x, half height, half width, chamfer, fillet); the cheeks are centred 1 mm above hy, the neck and the poll on hy Ah, cyh = (HT + HB) / 2, hy + (HB - HT) / 2 # towards the poll the neck's chamfers run out at 0.172 on a small forged shoulder (0.178), the section rounding over into a # short round neck below the poll band hs = [(0.213, 0.0486, 0.0486, 0.0285, 0.02), (0.204, 0.0486, 0.0486, 0.0285, 0.02), (0.193, 0.0478, 0.0478, 0.028, 0.016), (0.185, 0.0458, 0.0458, 0.027, 0.0145), (0.178, 0.0453, 0.0453, 0.0258, 0.0118), (0.172, 0.0432, 0.0432, 0.0236, 0.0048), (0.166, 0.0418, 0.0418, 0.0228, 0.0042), (0.148, 0.0378, 0.0378, 0.0205, 0.0035), (0.13, 0.0342, 0.0342, 0.0185, 0.003), (0.113, 0.0318, 0.0318, 0.0172, 0.003), (0.098, 0.0322, 0.0322, 0.0174, 0.003), (0.086, 0.0352, 0.0345, 0.0172, 0.003), (0.076, 0.0405, 0.0375, 0.017, 0.0032), (0.067, 0.0468, 0.0405, 0.0158, 0.0034), (0.059, 0.0526, 0.0428, 0.0135, 0.0035), (0.052, 0.0558, 0.0437, 0.0118, 0.0035), (0.046, Ah, HW, 0.011, 0.0035), (0.03, Ah, HW, 0.011, 0.0035), (0.0, Ah, HW, 0.011, 0.0035)] rings, kinds = [], [] for x, A, B, ch, fil in hs: f = min(1.0, max(0.0, (0.076 - x) / 0.03)) c = Vector((x, hy + (cyh - hy) * f, 0.0)) rings.append([c + Y_ * a + Z_ * b for a, b in oct_sec(A, A, B, ch, fil)]) kinds.append("head") # the claw: an outer curve continuing the top line, 64 stations; thickness inward and half width fall away towards the tips O = resample([(-0.03, hy - HT, 0), (-0.05, hy - HT, 0), (-0.12, hy - 0.053, 0), (-0.185, hy - 0.032, 0), (-0.238, hy + 0.008, 0), (-0.276, hy + 0.066, 0), (-0.296, hy + 0.128, 0)], 64, per=8) m_ = len(O) - 1 TN = [] for i in range(len(O)): T = (O[min(i + 1, m_)] - O[max(i - 1, 0)]).normalized() TN.append(Vector((T.y, -T.x, 0))) th = lambda t: 0.1105 * (1 - t) ** 1.2 + 0.0035 Wf = lambda t: HW - 0.011 * t tv = 0.36 iv = int(round(tv * m_)) for i in range(1, iv + 1): t = i / m_ T_ = th(t) c = O[i] + TN[i] * (T_ / 2) rings.append([c + TN[i] * a + Z_ * b for a, b in oct_sec(T_ / 2, T_ / 2, Wf(t), min(0.011, T_ * 0.2), 0.0035)]) kinds.append("root") nh = len(rings) i_run = next(k for k, h in enumerate(hs) if h[0] <= 0.1725) def hcol(i, j): if j < 0 or i < i_run: # the poll and its neck: no chamfer stripe past the shoulder return 0 if j % 3 == 2 and (j // 3) % 2 == 1: # the chamfers, worn bright return 1 return 0 head = rings_mesh("head", rings, [DGY, G3], colfn=hcol, ang=34) hammer_uv(head, 0, FORGE_RAMP, scale=0.014, seed=17) P.append(head) FX = M_axis("X", (0, hy, 0)) # the striking face: a wide bevel worn bright, the face polished, a little crowned P.append(lathe("face", [(0.0486, 0.2128), (0.0486, 0.2142), (0.0476, 0.2186), (0.0452, 0.2232), (0.0418, 0.2276), (0.0398, 0.2298), (0.0392, 0.2306)], segs=24, m=G4, frame=FX, smooth_ang=30)) P.append(lathe("facec", [(0.0394, 0.2304), (0.03, 0.2314), (0.016, 0.232), (0.0, 0.2322)], segs=24, m=G5, frame=FX, smooth_ang=30)) # a forged band round the poll, standing proud, a groove turned in its middle P.append(lathe("pollband", [(0.0478, 0.1952), (0.0499, 0.1962), (0.0506, 0.1978), (0.05, 0.1992), (0.0493, 0.2), (0.05, 0.2008), (0.0506, 0.2022), (0.0499, 0.2038), (0.0478, 0.2048)], segs=24, m=G4, frame=FX, smooth_ang=40)) # ---- the prongs: from the V's root to the tips, the V opening, the tips narrowing and flaring a little apart gap = lambda t: 0.0032 + 0.017 * max(0.0, (t - tv) / (1 - tv)) ** 0.85 for sz in (1, -1): R = [] for i in range(iv, m_ + 1): t = i / m_ T_, g = th(t), gap(t) / 2 narrow = 1 - 0.55 * max(0.0, (t - 0.78) / 0.22) ** 1.6 Wd = g + (Wf(t) - g) * narrow fl = 0.006 * max(0.0, (t - 0.7) / 0.3) ** 2 ch = min(0.011, T_ * 0.2, (Wd - g) * 0.3) cv = min(0.0055, T_ * 0.35, (Wd - g) * 0.3) fil = min(0.0035, T_ * 0.15, (Wd - g) * 0.12) sec = claw_half(T_, Wd + fl, g + fl, ch, cv, fil, sz) R.append([O[i] + TN[i] * a + Z_ * b for a, b in sec]) nseg = len(R[0]) bright = int((m_ - iv) * 0.7) def cf(i, j, sz=sz, bright=bright, nseg=nseg): if j < 0: return 2 jo = j if sz > 0 else (nseg - 2 - j) % nseg # the face's index on the +Z half's section if jo in (2, 3, 4, 5): # the V and its ground bevel return 2 if i >= bright else 1 if jo in (6, 7, 8): # the concave side, polished towards the tips return 2 if i >= bright else 0 return 1 if jo in (11, 17) else 0 pr = rings_mesh("prong", R, [DGY, G3, G5], colfn=cf, ang=34) hammer_uv(pr, 0, FORGE_RAMP, scale=0.014, seed=17) P.append(pr) for sz in (-1, 1): UM.star_badge(P, Vector((-0.004, hy, sz * (HW + 0.0005))), .064, (0, 0, sz)) # ---- the eye boss: grown out of the head's underside, filleted into it on every side (its walls leave the flat just inside the # cheeks' chamfers, so nothing steps out), an octagonal skirt tapering a little round the handle with an even wall, 18 mm long, # a small chamfer round its bottom rim, a narrow end face closing onto the wood # Its sides carry the cheeks' faces straight on down (covering the head's lower chamfers there), its ends grow out of the # underside and the claw's root, then the whole skirt draws in a little to a chamfered rim and a coned end face onto the wood. yb = hy + HB L_b = 0.0172 # the skirt below the head dys = [-0.0135, -0.0112, 0.0, 0.004, 0.0085, 0.013, L_b, L_b + 0.0017, L_b + 0.0025, L_b + 0.003, L_b + 0.0034] na = len(dys) i_rim = 7 Ca = [Vector((0.0, yb + d, 0.0)) for d in dys] A0, B0, A1, B1 = 0.0495, HW - 0.0002, 0.0445, 0.0375 def boss_oct(d, inset=0.0): t = min(1.0, max(0.0, d / L_b)) ** 1.25 A, B = A0 + (A1 - A0) * t - inset, B0 + (B1 - B0) * t - inset return oct_sec(A, A, B, min(A, B) * 0.3, 0.0028) def asec(sf, i): d = dys[i] if i <= i_rim: return boss_oct(d, 0.0018 if i == i_rim else 0.0) ra, rb = hrad(pth.nearest_y(yb + L_b)) e = (0.0062, 0.0012, -0.0006)[i - i_rim - 1] # the coned end face, then tucked into the wood out = [] for a, b in boss_oct(L_b, 0.0018): t = 1.0 / math.sqrt((a / (ra + e)) ** 2 + (b / (rb + e)) ** 2) out.append((a * t, b * t)) return out def acol(i, j): if j < 0: return 0 if i == i_rim - 1: # the rim chamfer, worn bright return 1 return 1 if (i < i_rim - 1 and j % 3 == 2 and (j // 3) % 2 == 1) else 0 ad = sweep("eyeboss", Ca, asec, [DGY, G3], colfn=acol, ang=34, frm=([Y_] * na, [X_] * na, [Z_] * na), cap0=False, cap1=False) hammer_uv(ad, 0, FORGE_RAMP, scale=0.014, seed=17) P.append(ad) # ---- the grip: moulded rubber, a flared butt, four finger swells, fine ridges between them, a lip and a red stop band gp = [pth.at(g1 * k / 8) for k in range(9)] gp[0] = gp[0] + (gp[0] - gp[1]).normalized() * 0.012 gC = resample(gp, 110, per=5) def gr(s): k = (1.0 + 0.22 * max(0.0, 1 - s / 0.11) ** 2 + 0.05 * max(0.0, math.sin((s - 0.2) / 0.62 * 4 * PI)) * (0.2 < s < 0.82) + 0.06 * max(0.0, (s - 0.93) / 0.07)) if 0.13 < s < 0.9: k += 0.026 * max(0.0, math.cos((s - 0.13) / 0.77 * 26 * PI)) ** 6 # moulded ridges return k P.append(sweep("grip", gC, lambda sf, i: circ((0.0405 * gr(sf), 0.0295 * gr(sf)), 20), [RUB], ref=(1, 0, 0), ang=40)) c0, d0 = gC[0], (gC[0] - gC[2]).normalized() P.append(lathe("buttend", [(0.0, 0.0034), (0.022, 0.0028), (0.034, 0.0006), (0.0405, -0.003), (0.0, -0.003)], segs=20, m=RUB, frame=fz(c0, d0, (1, 0, 0)) @ Matrix(((1.2, 0, 0, 0), (0, 0.87, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))), smooth_ang=40)) a, b = pth.at(g1 + 0.002), pth.at(g1 + 0.02) P.append(sweep("gband", [a.lerp(b, k / 5) for k in range(6)], lambda sf, i: circ((0.0412 - 0.004 * sf + 0.0008 * bump(sf, 0.5, 0.5), 0.0302 - 0.003 * sf + 0.0008 * bump(sf, 0.5, 0.5)), 20), [PRED], ref=(1, 0, 0), ang=40)) gy = gC[4] for sx in (-1, 1): rr = 0.0405 * gr(4 / 110) * 0.99 P.append(lathe("grommet", [(0.0042, -0.0025), (0.0068, -0.0022), (0.0076, 0.0), (0.0068, 0.0022), (0.0042, 0.0025)], segs=12, m=BRASS, frame=fz(gy + Vector((sx * rr, 0, 0)), (sx, 0, 0)), smooth_ang=50)) th_ = [gy + Vector((0.034, 0.0, 0)), gy + Vector((0.052, 0.028, 0)), Vector((0.04, 0.29, 0)), Vector((0.0, 0.306, 0)), Vector((-0.036, 0.28, 0)), gy + Vector((-0.05, 0.03, 0)), gy + Vector((-0.034, 0.0, 0))] P.append(UT.tube("thong", resample(th_, 30, per=5), lambda s: (0.0068, 0.0026), LEAT, segs=8, per=1, ang=40, cap=False)) tfin4(P, "Body", uv=4.0, ang=30) return dict(elev=64, azim=-14, dist_mul=.72) # ----------------------------------------------------------------------- long scythe def long_scythe(): """Round 4's frame: the longer barn-red snath on the same line, nibs at the same grips, the blade on the same outline, the grain cradle in the same place. The snath painted barn red with cream bands, worn through to the timber where the hands and the ground rub; a brass butt cap; turned nibs with yellow knobs held by brass straps; the blade with the real section, a folded back, a forged shoe with a driven wedge, jaw plates; the paint worn away in soft patches; the cradle: a turned post in an iron socket strapped to the snath, three bent ash fingers mortised into it with iron ferrules, an iron stay bolted to the blade's back and lashed to each finger with twine, an iron bow from the post.""" P = [] nibs = ((0.03, -0.04), (-0.03, -0.64)) pts = [(0.02, 0.15, 0.108), (0.02, 0.07, 0.125), (0.0, -0.2, 0.12), (-0.022, -0.6, 0.12), (-0.012, -1.02, 0.09), (0.008, -1.34, 0.01), (0.0, -1.5, -0.055)] pth = UT.Path(pts, per=6) Lt = pth.L[-1] rxf = lambda s: 0.0295 - 0.0065 * min(1.0, s) rzf = lambda s: 0.0325 - 0.0075 * min(1.0, s) # ---- the snath, run on into the shoe. Paint worn through on the top where the hands go and all round the butt ext = pts + [(-0.002, -1.54, -0.066)] pe = UT.Path(ext, per=6) kx = Lt / pe.L[-1] # stations: every 3 cm, every 7 mm through the worn zones (the butt, the fore grip, under the heel) ss = [q / 30 for q in range(31)] for a_, b_ in ((0.0, 0.1), (0.33, 0.47), (0.93, 1.0)): ss += [(a_ + (b_ - a_) * q / 13) * kx for q in range(14)] ss = sorted(set(round(min(1.0, q), 5) for q in ss)) C = [pe.at(q) for q in ss] Le = arclen(C) sf_of = lambda i: min(1.0, Le[i] / Lt) worn = {} def wearw(s, up): """How worn the paint is here: all round the butt, on top where the fore hand slides, underneath at the heel.""" w = 1.0 if s < 0.045 else max(0.0, 1 - (s - 0.045) / 0.05) w = max(w, bump(s, 0.395, 0.06) * max(0.0, up) ** 0.6) w = max(w, max(0.0, (s - 0.95) / 0.05) * max(0.0, -up) ** 0.6) return w for i in range(len(C) - 1): s = (sf_of(i) + sf_of(i + 1)) / 2 for j in range(16): ang = PI / 16 + TAU * (j + 0.5) / 16 up = math.sin(ang) # B is roughly up w = wearw(s, up) if w <= 0: continue cpt = (C[i] + C[i + 1]) / 2 + Vector((rxf(s) * math.cos(ang), 0, rzf(s) * math.sin(ang))) n_ = hammer_field(cpt, 0.028, 21) * 0.5 + 0.5 if n_ < w * 0.78: worn[(i, j)] = 1 P.append(sweep("snath", C, lambda sf, i: circ((rxf(sf_of(i)), rzf(sf_of(i))), 16), [PRED, TIM], colfn=lambda i, j: worn.get((i, j), 0), ref=(1, 0, 0), uv=(0.125, 0.09, 0.9), ang=34)) # cream bands, painted a hair proud for t0 in (0.33, 0.37, 0.72, 0.76): cs = [pth.at(t0 + 0.011 * k) for k in range(2)] P.append(sweep("stripe", cs, lambda sf, i, t0=t0: circ((rxf(t0) + 0.0007, rzf(t0) + 0.0007), 18), [CRM], ref=(1, 0, 0), cap0=False, cap1=False, ang=40)) # the brass butt cap: a rim, a dome, a rivet c0, d0 = pth.at(0.0), (pth.at(0.0) - pth.at(0.02)).normalized() Fb = fz(c0, d0, (1, 0, 0)) P.append(lathe("buttcap", [(0.031, -0.014), (0.0338, -0.0128), (0.0352, -0.0098), (0.0352, -0.0062), (0.0336, -0.004), (0.0338, -0.0015), (0.031, 0.003), (0.024, 0.0072), (0.013, 0.0094), (0.0, 0.0098)], segs=18, m=BRASS, frame=Fb, smooth_ang=40)) head(P, c0 + d0 * 0.0092, d0, 0.0048, "dome", m=G4) # ---- nibs and their brass straps for x, y in nibs: nib5(P, x, y, 0.125, m_knob=GOLD, r=0.036, wrap=LEAT) t = pth.nearest_y(y) ring_clamp5(P, pth, t, max(rxf(t), rzf(t)) + 0.0006, boltside=1 if y > -0.3 else -1, m=BRASS, bolt_m=G4) # ---- the blade hz, y0 = -0.098, -1.52 F = tilt_frame(y0, hz) S, E = scythe_outline(y0, 1.1, 0.17, 0.15, 0.27, 44, neck=(0.046, 0.022, 0.15)) S36, E36 = scythe_outline(y0, 1.1, 0.17, 0.15, 0.27, 36, neck=(0.046, 0.022, 0.15)) S20, _ = scythe_outline(y0, 1.1, 0.17, 0.15, 0.27, 20) tw = (UT.TILT, 0.05) P.append(blade5("blade", S, E, hz, 0.024, frame=F, ground=0.3, seed=7, rust={(26, 2)}, P=P, twist=tw, sub=1, nc=4)) back_channel(P, S36, E36, hz, 0.024, F, 0, 28, wf=0.02, th=0.0045, m=G2, rivets=(4, 12, 20), r_riv=0.0062, nose=0.008, taper=0.55, twist=tw) # ---- the mount rxe, rze = rxf(1.0), rzf(1.0) shoe(P, -0.036, 0.05, -1.57, -1.49, hz - 0.012, -0.032, 0.007, bolts=[(0.007, -1.53)], wedge=(-1.555, -1.512, 0.018), entry=(pth, lambda d, k: [(a, b * k) for a, b in circ((rxe + d, rze + d), 18)]), blade_z=hz) bolt5(P, (-0.036, -1.53, -0.076), (-1, 0, 0), 0.086, 0.0072, m=G4, ref=(0, 0, 1), thr=0.0) jaws(P, S, E, hz, 0.024, F, 0.045, 0.13, 0.6, th=0.0045, rivets=2) # ---- the grain cradle tc = pth.nearest_y(-1.22) base = pth.at(tc) topp = Vector((0.05, -1.26, 0.27)) rc = max(rxf(tc), rzf(tc)) + 0.0006 ring_clamp5(P, pth, tc, rc, boltside=-1, w=0.034, m=IRON, bolt_m=G4) # the socket: an iron cup welded on the strap, the post standing in it, a bolt across dpost = (topp - base).normalized() sb = base + Vector((0, 0, rc - 0.004)) P.append(lathe("socket", [(0.0, -0.002), (0.0262, -0.002), (0.0282, 0.004), (0.0282, 0.03), (0.0296, 0.0325), (0.0296, 0.037), (0.0268, 0.039), (0.0, 0.039)], segs=18, m=IRON, frame=fz(sb, dpost, (1, 0, 0)), smooth_ang=40)) bead(P, [sb + Vector((-0.024, 0.006, 0.002)), sb + Vector((0.0, 0.009, 0.003)), sb + Vector((0.024, 0.006, 0.002))], 0.0026, m=G3) bolt5(P, sb + dpost * 0.02 + Vector((0.0296, 0, 0)), (1, 0, 0), 0.0592, 0.0048, m=G4, ref=(0, 0, 1), thr=0.005) # the post: turned, a bead under its head, an iron cap Cp = [sb.lerp(topp, q) for q in feature_ss(5, [(0.86, 0.035), (0.9, 0.02)])] def prf(s): return 0.0235 - 0.004 * s + 0.0022 * bump(s, 0.86, 0.035) - 0.0012 * bump(s, 0.9, 0.02) P.append(turned("post", Cp, prf, segs=14, s=1.6, u0=0.375, ref=(1, 0, 0))) P.append(lathe("postcap", [(0.0182, -0.012), (0.0212, -0.0108), (0.0222, -0.008), (0.0222, -0.001), (0.0205, 0.0022), (0.016, 0.0048), (0.008, 0.0062), (0.0, 0.0065)], segs=16, m=IRON, frame=fz(topp, dpost, (1, 0, 0)), smooth_ang=40)) # the fingers: round 4's lines, bent ash, tapering, a rounded tip; an iron ferrule where each goes into the post ns_ = len(S20) - 1 fingers = [] for k, (lift, frac) in enumerate(((0.3, 0.84), (0.205, 0.92), (0.105, 0.98))): Fp = [] for i in range(6): u = i / 5 q = S20[int(round(u * (ns_ - 2) * frac))] Fp.append(F @ Vector((0.03 + q[0] * 0.98, q[1] + 0.03, hz + lift + (0.03 - 0.02 * k) * math.sin(u * 1.6)))) root = base.lerp(topp, (1.0, 0.68, 0.36)[k]) Fp = [root] + Fp[2:] Cf = resample(Fp, 16, per=5) P.append(turned("finger", Cf, lambda s: (0.0155 - 0.008 * s) * (1 - 0.6 * max(0.0, (s - 0.95) / 0.05) ** 2) + 0.0006, segs=10, s=1.4, u0=0.375, ref=(0, 0, 1))) df = (Cf[2] - Cf[0]).normalized() P.append(lathe("fferrule", [(0.0, -0.002), (0.0168, -0.002), (0.0178, 0.0005), (0.0178, 0.0098), (0.0166, 0.012), (0.0, 0.012)], segs=10, m=IRON, frame=fz(Cf[0] + df * 0.018, df), smooth_ang=40)) fingers.append((Fp, Cf)) # the stay: a forged flat bar through each finger's lashing, down to a lug riveted on the blade's back pS = F @ Vector((S20[10][0], S20[10][1] + 0.01, hz + 0.024)) stay = [fingers[0][0][3], fingers[1][0][3], fingers[2][0][3], pS] Cs = resample(stay, 16, per=5) P.append(sweep("stay", Cs, lambda sf, i: rrect(0.0068, 0.0034, 0.0022, 2), [IRON, G2], colfn=lambda i, j: 1 if j % 3 == 1 else 0, ref=(0, 0, 1), ang=40)) for k in range(3): Fp, Cf = fingers[k] Lf = arclen(Cf) j = min(range(len(Cf)), key=lambda q: (Cf[q] - Fp[3]).length) rr = (0.0155 - 0.008 * Lf[j] / Lf[-1]) + 0.0006 P.append(rope_coil("lash", Cf, Lf[j], lambda ph, rr=rr: rr + 0.0024, 0.0024, 2.5, m=TWINE, segs=7, ref=(0, 0, 1))) up = (F.to_3x3() @ Vector((0, 0, 1))).normalized() nS = (Cs[-1] - Cs[-3]).normalized().cross(up).normalized() Fe = Matrix(((Cs[-1] - Cs[-3]).normalized(), nS.cross((Cs[-1] - Cs[-3]).normalized()), nS)).transposed().to_4x4() Fe.translation = pS P.append(bprism("stayeye", circ(0.0092, 14), -0.0034, 0.0034, [IRON, G2], bev=0.0012, segs=1, frame=Fe, bev_slot=1)) hp_, Lb = clevis(P, pS, up, nS, 0.022, 0.0035, 0.024 - (0.012 + 0.0045) + 0.003, 0.0095, 0.0075, bead_at=0.024 - (0.012 + 0.0045)) bolt5(P, hp_, nS, Lb, 0.0036, m=G4, ref=up, thr=0.004) # the bow: an iron rod from the post's head round to the top finger, forged eyes, a bolt through the post f0 = fingers[0][0] bw = [topp + dpost * -0.03, f0[2], f0[3]] Cb = resample(bw, 20, per=5) P.append(UT.tube("cbow", Cb, lambda s: 0.0064, IRON, segs=8, per=1, ang=40)) rope_c = fingers[0][1] P.append(rope_coil("lash", rope_c, arclen(rope_c)[min(range(len(rope_c)), key=lambda q: (rope_c[q] - f0[2]).length)], lambda ph: 0.0155 * 0.85 + 0.0036, 0.0022, 2.0, m=TWINE, segs=10, ref=(0, 0, 1))) tfin4(P, "Body", uv=2.4, ang=30) return dict(elev=38, azim=-30, dist_mul=.7) # ======================================================================= main BUILDERS = {"SM_Tool_WideScythe": _lod(wide_scythe), "SM_Tool_Scythe": _lod(scythe), "SM_Tool_GardenShears": garden_shears, "SM_Tool_NailScissors": nail_scissors, "SM_Tool_Shears": garden_shears, "SM_Tool_Sickle": sickle, "SM_Tool_Hammer": hammer, "SM_Tool_LongScythe": _lod(long_scythe)} BUDGET = {n: 20000 for n in BUILDERS} def main(): common.MODELS = os.path.join(OUT, "fbx") common.BLENDS = OUT common.PREVIEWS = os.path.join(OUT, "previews") KIT.SHOTS = os.path.join(OUT, "previews") for d in (common.MODELS, common.PREVIEWS): os.makedirs(d, exist_ok=True) if "--" in sys.argv and "--quick" not in sys.argv: sys.argv.append("--quick") # the review renders are gc_up5_check.py's job elif "--" not in sys.argv: sys.argv += ["--", "--quick"] KIT.build_main(BUILDERS, BUDGET) if __name__ == "__main__": main()