Grass Cutters Together: the project as of moon-sweepers f3666f0

A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-06 18:44:40 +06:00
parent 0f0467cd0c
commit d1c3761e58
4190 changed files with 270757 additions and 1 deletions

View File

@ -0,0 +1,527 @@
"""GRASS CUTTER - one model per hand tool, in the style of the POLYGON Farm pack: chunky facets, forged two-tone blades.
SM_Tool_NailScissors tiny folding scissors, red enamel bows on brass hinges Body, BladeA, BladeB
SM_Tool_GardenShears forged grass shears on timber handles Body, BladeA, BladeB
SM_Tool_Shears copy of SM_Tool_GardenShears (the old file name)
SM_Tool_Sickle crescent blade on a pistol handle Body
SM_Tool_Scythe the classic: timber S-snath, two nibs Body
SM_Tool_LongScythe longer, barn-red snath, a grain cradle over the blade Body
SM_Tool_WideScythe huge two-handed: squared green beam, braced broad blade Body
SM_Tool_Hammer claw hammer Body
Hold convention (the same as the tools these replace, see Assets/Scripts/Player/ViewModel.cs):
Blender axes, grip at the origin, the tool runs forward along -Y, up = +Z. The first-person fist closes around an axis
parallel to Z (its centre lands within 2 cm of the origin), so what the hand holds runs along Z: the scythes hang a nib
from the snath at the origin and a second one at ViewModel's rear grip distance, the sickle has a pistol handle.
The blade lies in the XY plane and sweeps out to +X. The supply wall hangs a tool with -Y up and +Z into the board, so
everything stays flat in XY and nothing reaches far along +Z.
BladeA / BladeB pivot on the screw at their origin, about local Z. Positive angles in Unity turn BladeA's tip to Blender
-X, so BladeA's blade lies on the -X side and its handle on the +X side, like real scissors. Closed at rest in the file.
The sizes are the old ones: ViewModel's scales (0.42, 0.75, 0.2, 0.46, 0.5, 0.54) and the wall's stay valid.
Run (from project root):
blender -b --factory-startup --python ArtSource/Blender/scripts/gc_up_tools.py -- [SM_Tool_Scythe ...]
Check with gc_up_check.py.
"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import gc_farm_tools as FT
from gc_farm_tools import * # noqa: F401,F403 (common + os_crew helpers, done, bar, grain, around, ptube, bez, bx ...)
TIM, IRON, STL, BLD, RUST = "M_Timber", "M_Navy", "M_Steel", "M_Blade", "M_Rust"
LEA, ROPE, TWINE, BRASS = "M_Leather", "M_Rope", "M_Twine", "M_Brass"
PRED, GRN, CRM, GOLD = "M_PaintRed", "M_Teal", "M_PaintWhite", "M_PaintYellow"
PV_Y = -0.145 # the scissor screw, where the old shears had it
# ======================================================================= geometry
class Path:
"""Catmull-Rom path with arc-length lookup."""
def __init__(self, pts, per=4):
self.C = catmull(pts, per)
self.L = [0.0]
for a, b in zip(self.C, self.C[1:]):
self.L.append(self.L[-1] + (b - a).length)
def at(self, t):
s = self.L[-1] * max(0.0, min(1.0, t))
i = next((k for k in range(len(self.L) - 1) if self.L[k + 1] >= s), len(self.L) - 2)
f = (s - self.L[i]) / max(1e-9, self.L[i + 1] - self.L[i])
return self.C[i].lerp(self.C[i + 1], f)
def nearest_y(self, y):
return min((k / 200 for k in range(201)), key=lambda t: abs(self.at(t).y - y))
def tube(name, pts, rf, m, segs=8, per=3, s=1.0, u0=0.125, uw=0.09, cap=True, ang=30, phase=None, spin=0.0):
"""Faceted bar along a path. rf(t) -> r or (across, up). UV: V runs along the bar, U stays on one board of the timber
texture. spin: extra roll of the section."""
C = catmull(pts, per) if len(pts) > 2 else [Vector(p) for p in pts]
L = [0.0]
for a, b in zip(C, C[1:]):
L.append(L[-1] + (b - a).length)
tot = L[-1]
Tn = [(C[min(i + 1, len(C) - 1)] - C[max(i - 1, 0)]).normalized() for i in range(len(C))]
ref = Vector((1, 0, 0)) if abs(Tn[0].x) < 0.9 else Vector((0, 0, 1))
N = (ref - Tn[0] * ref.dot(Tn[0])).normalized()
a0 = math.pi / segs if phase is None else phase
bm = bmesh.new()
uvl = bm.loops.layers.uv.verify()
R = []
for i, c in enumerate(C):
N = (N - Tn[i] * N.dot(Tn[i])).normalized()
B = Tn[i].cross(N)
r = rf(L[i] / tot)
ra, rb = r if isinstance(r, tuple) else (r, r)
ring = []
for k in range(segs):
q = a0 + spin + TAU * k / segs
ring.append(bm.verts.new(c + N * (ra * math.cos(q)) + B * (rb * math.sin(q))))
R.append(ring)
for i in range(len(R) - 1):
for k in range(segs):
j = (k + 1) % segs
f = bm.faces.new((R[i][k], R[i][j], R[i + 1][j], R[i + 1][k]))
ua, ub = u0 - uw + 2 * uw * k / segs, u0 - uw + 2 * uw * (k + 1) / segs
for lp, (u, v) in zip(f.loops, ((ua, L[i]), (ub, L[i]), (ub, L[i + 1]), (ua, L[i + 1]))):
lp[uvl].uv = (u, v * s)
if cap:
bm.faces.new(list(reversed(R[0])))
bm.faces.new(R[-1])
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
o = mesh_obj(name, bm)
set_mats(o, m)
smooth(o, ang)
o["uv_done"] = True
return o
def forged(spine, edge, z, t, body=STL, frame=None, rust=(), name="blade", ground=0.34, m_edge=BLD):
"""A blade from two outlines (x, y): flat cheeks, a bright ground bevel down to a sharp edge, thickest along the spine.
rust: (station, 1 or 2 or 4 or 5) quads of the cheek that turn to rust."""
n = len(spine)
bm = bmesh.new()
R = []
for i in range(n):
s = Vector((spine[i][0], spine[i][1], 0.0))
e = Vector((edge[i][0], edge[i][1], 0.0))
b, m = e.lerp(s, ground), e.lerp(s, 0.68)
tt = t * (1.0 - 0.6 * (i / (n - 1)) ** 3)
R.append([bm.verts.new(p + Vector((0, 0, z + dz))) for p, dz in ((e, 0.0), (b, tt * 0.42), (m, tt * 0.5), (s, tt * 0.5), (s, -tt * 0.5), (m, -tt * 0.5), (b, -tt * 0.42))])
idx = []
for i in range(n - 1):
for j in range(7):
k = (j + 1) % 7
bm.faces.new((R[i][j], R[i][k], R[i + 1][k], R[i + 1][j]))
idx.append(1 if j in (0, 6) else (2 if (i, j) in rust else 0))
bm.faces.new(list(reversed(R[0])))
bm.faces.new(R[-1])
idx += [0, 0]
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
if frame is not None:
bmesh.ops.transform(bm, matrix=frame, verts=bm.verts)
o = mesh_obj(name, bm)
set_mats(o, body, m_edge, RUST)
# to_mesh clamps material indices on a mesh with no slots yet, so they go on after set_mats
o.data.polygons.foreach_set("material_index", idx)
o.data.update()
smooth(o, 28)
return o
def plate(name, pts, z0, z1, m, bevel=0.0, frame=None):
"""A flat cut-out: outline (x, y), z0..z1."""
fr = Matrix.Translation((0, 0, z0))
if frame is not None:
fr = frame @ fr
return prism(name, pts, z1 - z0, fr, m, bevel=bevel, segs=1)
def disc(name, r, h, loc, m, n=8, axis="Z", bevel=0.0):
return cyl(name, r, h, loc, axis=axis, verts=n, m=m, bevel=bevel, segs=1)
def stud(P, loc, normal, r=0.012, m=IRON, hexa=True, h=0.009):
return bolt(P, loc, normal, r=r, h=h, m=m, hexa=hexa)
def nib(P, x, y, z_top, m_knob=PRED, tilt=0.0, r=0.036, z_low=-0.105, wrap=LEA):
"""A turned handle running along Z where the fist closes, with a painted knob and a wrap under the fingers."""
fr = Matrix.Translation((x, y, 0)) @ Matrix.Rotation(DEG(tilt), 4, "X")
g = lathe("nib", [(r * 0.8, z_low + 0.012), (r * 0.92, -0.07), (r * 1.0, -0.03), (r * 1.02, 0.02), (r * 0.9, 0.06), (r * 0.74, z_top)], segs=8, m=TIM, frame=fr, smooth_ang=34)
grain(g, fr.to_3x3() @ Vector((0, 0, 1)), 1.6, off=(0.03, 0.2))
P.append(g)
P.append(lathe("knob", [(0.0, z_low - 0.02), (r * 0.8, z_low - 0.02), (r * 1.28, z_low - 0.002), (r * 1.3, z_low + 0.012), (r * 0.92, z_low + 0.026)], segs=8, m=m_knob, frame=fr, smooth_ang=34))
if wrap:
P.append(lathe("wrap", [(r * 1.03, -0.056), (r * 1.1, -0.05), (r * 1.13, 0.016), (r * 1.04, 0.024)], segs=8, m=wrap, frame=fr, smooth_ang=34))
def ring_clamp(P, path, t, r, w=0.03, m=IRON, boltside=1):
"""Iron band round a bar, with a square bolt on one side."""
a, b = path.at(t - w / path.L[-1]), path.at(t + w / path.L[-1])
P.append(tube("clamp", [a, b], lambda s: r, m, segs=8, ang=30))
c = path.at(t)
stud(P, c + Vector((boltside * r, 0, 0)), (boltside, 0, 0), r=r * 0.48, m=IRON, h=r * 0.5)
def whetstone(P, c):
"""A whetstone in a leather holster, what a mower carries."""
P.append(rbox("hone", (0.034, 0.05, 0.11), c, bevel=0.009, segs=1, m=STL))
# ======================================================================= scissors
def scissor_blade(sx, py, ty, w0, curve, dz, t, body, rust, n=7, heel=0.03):
"""sx=+1: BladeA, spine on -X. Outline stations from the heel behind the screw to the tip."""
S, E = [], []
for i in range(n + 1):
u = i / n
y = (py + heel) + (ty - (py + heel)) * u
c = curve * ((py - y) / (py - ty)) ** 2 if y < py else 0.0
w = (w0 * (1.0 - u) ** 0.62 + 0.006) * (0.42 + 0.58 * min(1.0, u * 3.2) ** 0.7)
E.append((c + sx * 0.003 * (1 - u), y))
S.append((c - sx * w, y))
return forged(S, E, dz, t, body=body, rust=rust)
def nail_scissors():
py, ty = PV_Y, -0.455
for nm, sx, dz in (("BladeA", 1, 0.0075), ("BladeB", -1, -0.0075)):
P = [scissor_blade(sx, py, ty, 0.074, 0.075, dz, 0.0135, STL, {(3, 2)} if sx > 0 else set(), n=6)]
# the boss round the screw and the first half of the arm
P.append(disc("boss", 0.044, 0.0135, (0, py, dz), STL, n=10))
hp = Vector((sx * 0.046, -0.04, dz)) # the folding hinge
P.append(tube("arm", [(0, py, dz), (sx * 0.026, -0.098, dz), hp], lambda s: (0.0125, 0.0068), STL, segs=6, per=2, ang=28, spin=math.pi / 2))
# the brass hinge knuckle: this is what makes them folding scissors
P.append(disc("knuckle", 0.022, 0.024, hp, BRASS, n=10))
P.append(disc("pin", 0.0095, 0.03, hp, IRON, n=6))
P.append(rbox("hingeleaf", (0.03, 0.04, 0.008), hp + Vector((sx * 0.002, 0.02, 0.0)), bevel=0.003, segs=1, m=BRASS))
# the bow: red enamel over a wire loop, a flat spot where it meets the hinge
c = Vector((sx * 0.062, 0.058, dz))
lp = torus("bow", 0.05, 0.0155, loc=(0, 0, 0), seg=10, rseg=5, m=PRED)
lp.data.transform(Matrix.Translation(c) @ Matrix.Scale(0.82, 4, (1, 0, 0)) @ Matrix.Scale(1.14, 4, (0, 1, 0)))
P.append(lp)
P.append(tube("neck", [hp + Vector((0, 0.012, 0)), c + Vector((-sx * 0.012, -0.056, 0))], lambda s: 0.0135, PRED, segs=6, ang=28))
if sx > 0: # the little finger rest
P.append(tube("tang", [c + Vector((sx * 0.03, 0.04, 0)), c + Vector((sx * 0.052, 0.078, 0)), c + Vector((sx * 0.036, 0.108, 0))], lambda s: 0.0082 * (1 - 0.5 * s), STL, segs=5, per=2, ang=28))
else: # a keyring eye
P.append(torus("eye", 0.0145, 0.0048, loc=tuple(c + Vector((sx * 0.02, 0.07, 0))), axis="X", seg=8, rseg=3, m=BRASS))
o = done(P, nm, uv=5.0, ang=30)
set_origin(o, (0, py, 0))
B = [disc("screw", 0.022, 0.03, (0, py, 0), BRASS, n=8, bevel=0.003), disc("slot", 0.0052, 0.034, (0, py, 0), IRON, n=6)]
B.append(rbox("slot2", (0.03, 0.0052, 0.0016), (0, py, 0.0156), bevel=0.0, m=IRON))
done(B, "Body", uv=5.0, ang=30)
return dict(elev=60, azim=-12, dist_mul=0.72, extra=[("under", dict(elev=-55, azim=-12, dist_mul=0.72), None)])
def garden_shears():
py, ty = PV_Y, -0.62
for nm, sx, dz in (("BladeA", 1, 0.0105), ("BladeB", -1, -0.0105)):
rust = {(2, 2), (3, 2), (5, 2)} if sx > 0 else {(3, 2), (4, 2)}
P = [scissor_blade(sx, py, ty, 0.098, 0.0, dz, 0.018, IRON, rust, n=7)]
P.append(disc("boss", 0.064, 0.018, (0, py, dz), IRON, n=10))
# the forged tang, then a timber handle in an iron ferrule
t0 = Vector((sx * 0.012, py + 0.062, dz))
fr = Vector((sx * 0.03, -0.022, dz))
P.append(tube("tang", [(0, py, dz), t0, fr], lambda s: (0.018, 0.0088), IRON, segs=6, per=2, ang=28, spin=math.pi / 2))
hp = [fr, (sx * 0.038, 0.035, dz), (sx * 0.05, 0.095, dz), (sx * 0.046, 0.15, dz)]
P.append(tube("handle", hp, lambda s: (0.0235 + 0.006 * math.sin(s * 3.1), 0.018 + 0.004 * math.sin(s * 3.1)), TIM, segs=8, per=3, s=1.6, u0=0.125 + 0.25 * (0 if sx > 0 else 2), ang=30, spin=math.pi / 2))
P.append(tube("ferrule", [fr + Vector((-sx * 0.003, -0.018, 0)), fr + Vector((sx * 0.002, 0.02, 0))], lambda s: (0.0255, 0.021), IRON, segs=8, ang=30, spin=math.pi / 2))
stud(P, fr + Vector((0, 0.002, 0.021)), (0, 0, 1), r=0.0072, m=BRASS, hexa=False, h=0.005)
P.append(tube("endcap", [(sx * 0.0465, 0.142, dz), (sx * 0.046, 0.164, dz), (sx * 0.044, 0.174, dz)], lambda s: (0.0255 * (1 - 0.32 * s * s), 0.02 * (1 - 0.32 * s * s)), PRED, segs=8, per=2, ang=30, spin=math.pi / 2))
if sx > 0: # the bow spring between the handles, riveted to this one
P.append(tube("spring", [(0.024, -0.03, dz), (0.002, 0.01, dz - 0.0105), (-0.012, 0.05, dz - 0.0105)], lambda s: (0.0048, 0.0125), STL, segs=4, per=2, ang=20))
# a catch that hooks over the other handle
P.append(tube("catch", [(0.04, 0.11, dz), (0.0, 0.125, dz + 0.012), (-0.03, 0.11, dz + 0.016)], lambda s: 0.0052, IRON, segs=5, per=2, ang=28))
else: # a rope lanyard
pts = [(-0.045, 0.177, dz), (-0.066, 0.2, dz), (-0.056, 0.235, dz), (-0.028, 0.24, dz), (-0.018, 0.206, dz), (-0.036, 0.178, dz)]
P.append(tube("lanyard", pts, lambda s: 0.0052, ROPE, segs=5, per=2, ang=40, cap=False))
o = done(P, nm, uv=5.0, ang=30)
set_origin(o, (0, py, 0))
B = [disc("screw", 0.03, 0.05, (0, py, 0), BRASS, n=8, bevel=0.004)]
stud(B, (0, py, 0.024), (0, 0, 1), r=0.016, m=IRON, h=0.008)
done(B, "Body", uv=5.0, ang=30)
return dict(elev=60, azim=-12, dist_mul=0.72, extra=[("under", dict(elev=-55, azim=-12, dist_mul=0.72), None)])
# ======================================================================= sickle
def sickle():
P = []
z = 0.26
# the pistol handle: down through the fist, curving forward over it
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)]
P.append(tube("handle", hp, lambda s: (0.056 + 0.015 * math.sin(min(1, s * 1.5) * 3.1), 0.05 + 0.015 * math.sin(min(1, s * 1.5) * 3.1)), TIM, segs=8, per=3, s=1.0, ang=30))
pth = Path(hp, per=3)
P.append(tube("cap", [(0, 0.033, -0.325), (0, 0.03, -0.3), (0, 0.027, -0.27)], lambda s: 0.067 - 0.012 * abs(2 * s - 1), PRED, segs=8, per=1, ang=30))
for a, b in ((0.26, 0.36), (0.42, 0.52)): # rawhide lashings where the fingers go
P.append(tube("thong", [pth.at(a), pth.at((a + b) / 2), pth.at(b)], lambda s: 0.071, LEA, segs=8, per=2, ang=30, cap=False))
# ferrule and the tang into the blade
P.append(tube("ferrule", [(0, -0.3, z), (0, -0.37, z)], lambda s: 0.058 - 0.008 * s, IRON, segs=8, ang=30))
stud(P, (0.05, -0.335, z), (1, 0, 0), r=0.018, m=BRASS, hexa=False, h=0.01)
stud(P, (-0.05, -0.335, z), (-1, 0, 0), r=0.018, m=BRASS, hexa=False, h=0.01)
# a loop of rope through the butt to hang it by
P.append(tube("loop", [(0, 0.03, -0.33), (0.06, 0.085, -0.38), (0.0, 0.17, -0.41), (-0.06, 0.085, -0.38), (0, 0.03, -0.33)], lambda s: 0.014, ROPE, segs=5, per=2, ang=40))
# crescent: spine on the outside, edge inside, a C that opens towards +X and hooks back at the tip
c = Vector((0.335, -0.79, 0))
S, E = [], []
n = 15
rust = set()
for i in range(n + 1):
u = i / n
a = DEG(142 + 236 * u)
r_o = 0.455 - 0.05 * u + 0.012 * math.sin(u * math.pi)
w = 0.135 * (1 - u) ** 0.55 * (0.72 + 0.28 * math.sin(min(1.0, u * 2.4) * 1.57)) + 0.008
S.append((c.x + r_o * math.cos(a), c.y + r_o * math.sin(a)))
E.append((c.x + (r_o - w) * math.cos(a), c.y + (r_o - w) * math.sin(a)))
S[0], E[0] = (-0.04, -0.33), (0.045, -0.33)
for i in (5, 10):
E[i] = (E[i][0] + (S[i][0] - E[i][0]) * 0.2, E[i][1] + (S[i][1] - E[i][1]) * 0.2)
rust = {(3, 2), (4, 2), (9, 2), (10, 2), (11, 2), (4, 5)}
P.append(forged(S, E, z, 0.034, body=IRON, rust=rust, ground=0.52))
# the spine rib, standing proud
rib = [(p[0], p[1], z + 0.012) for p in S[1:12]]
P.append(tube("rib", rib, lambda s: (0.0105 * (1 - 0.6 * s), 0.0085), STL, segs=4, per=1, ang=30))
done(P, "Body", uv=2.4, ang=30)
return dict(elev=62, azim=-10, dist_mul=0.72, extra=[("side", dict(elev=10, azim=-78, dist_mul=0.72), None), ("heel", dict(elev=30, azim=150, dist_mul=0.74), None)])
# ======================================================================= scythes
TILT = 38.0 # the far side of a scythe blade lifts, or first person only ever sees its edge
def scythe_blade(P, hz, y0, L, w0, bow, curl, t, body=IRON, rust=(), n=11, chips=()):
"""Heel at (0, y0), runs out to +X. Spine on the far side (-Y), the edge on the concave side towards the mower.
Turned TILT degrees about X through the heel. Returns the spine outline and F, the matrix for parts that sit on it."""
F = Matrix.Translation((0, y0, hz)) @ Matrix.Rotation(DEG(-TILT), 4, "X") @ Matrix.Translation((0, -y0, -hz))
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.008
S.append((x, y))
E.append((x, y + w - (0.016 if i in chips else 0.0)))
S[-1] = (S[-1][0] + 0.02, S[-1][1] + 0.01)
E[-1] = (S[-1][0], S[-1][1] + 0.003)
P.append(forged(S, E, hz, t, body=body, rust=rust, frame=F, ground=0.46))
return S, F
def heel(P, end, r, hz, m=IRON):
"""The iron socket, its wedge and the tang that joins the blade."""
c = Vector(end)
P.append(bx(-0.036, 0.05, c.y - 0.05, c.y + 0.03, hz - 0.012, c.z + 0.028, m, bevel=0.006, segs=1, name="socket"))
P.append(rbox("wedge", (0.022, 0.05, 0.03), (0.052, c.y - 0.01, c.z - 0.006), bevel=0.004, segs=1, m=TIM))
stud(P, (0.0, c.y - 0.01, c.z + 0.028), (0, 0, 1), r=0.013, m=STL, h=0.008)
stud(P, (-0.036, c.y - 0.01, c.z - 0.01), (-1, 0, 0), r=0.012, m=STL, h=0.008)
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 = Path(pts, per=4)
P.append(tube("snath", pts, lambda s: 0.03 - 0.008 * s, TIM, segs=8, per=3, s=0.9, ang=30))
# hands: two turned nibs hanging from iron clamps
for (x, y), mk in zip(nibs, (PRED, PRED)):
nib(P, x, y, 0.12, m_knob=mk)
ring_clamp(P, pth, pth.nearest_y(y), 0.037, boltside=1 if y > -0.3 else -1)
# a leather wrap at the butt, an iron cap
P.append(tube("buttwrap", [pth.at(0.0), pth.at(0.05), pth.at(0.1)], lambda s: 0.0345, LEA, segs=8, per=2, ang=30, cap=False))
P.append(tube("buttcap", [pth.at(-0.0) + Vector((0, 0.012, 0)), pth.at(0.0), pth.at(0.012)], lambda s: 0.0375 - 0.008 * (1 - s), IRON, segs=8, per=1, ang=30))
# a rag tied round the snath, a whetstone holster
tn = pth.nearest_y(-0.94)
P.append(tube("rag", [pth.at(tn - 0.02), pth.at(tn), pth.at(tn + 0.02)], lambda s: 0.0335, "M_Burlap", segs=6, per=2, ang=40, cap=False, s=5.0, u0=0.5, uw=0.3))
FT.tie(P, tuple(pth.at(tn)), (0, 1, 0.3), 0.034, m=TWINE, tails=[[tuple(pth.at(tn) + Vector((0.03, 0, 0))), tuple(pth.at(tn) + Vector((0.06, 0.012, -0.04))), tuple(pth.at(tn) + Vector((0.052, 0.02, -0.09)))]])
# the blade
end = Vector((0, -1.3, -0.055))
hz = -0.095
rust = {(2, 2), (3, 2), (7, 2), (3, 5)}
S, F = scythe_blade(P, hz, -1.3, 0.8, 0.19, 0.13, 0.17, 0.026, rust=rust, chips=(4,))
heel(P, end, 0.034, hz)
P.append(tube("rib", [F @ Vector((p[0], p[1] + 0.008, hz + 0.0135)) for p in S[:10]], lambda s: (0.011 * (1 - 0.5 * s), 0.0075), STL, segs=4, per=1, ang=30))
# the grass nail: a thin stay from snath to the back of the blade
a = pth.at(pth.nearest_y(-1.08))
P.append(tube("nail", [a + Vector((0.0, 0, -0.01)), F @ Vector((S[2][0], S[2][1] + 0.008, hz + 0.014))], lambda s: 0.0082, IRON, segs=5, ang=28))
done(P, "Body", uv=2.4, ang=30)
return dict(elev=38, azim=-30, dist_mul=0.7, extra=[("heel", dict(elev=30, azim=-20, target=(0.15, -1.25, -0.05), radius=0.34), None), ("grip", dict(elev=18, azim=120, target=(0, -0.05, 0.05), radius=0.3), None)])
def long_scythe():
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 = Path(pts, per=4)
P.append(tube("snath", pts, lambda s: (0.03 - 0.007 * s, 0.033 - 0.008 * s), PRED, segs=8, per=3, ang=30))
# cream bands on the barn-red paint, bare timber where the paint has worn through at the rear
for t0 in (0.33, 0.37, 0.72, 0.76):
P.append(tube("stripe", [pth.at(t0), pth.at(t0 + 0.011)], lambda s: (0.0322, 0.0352), CRM, segs=8, ang=30, cap=False))
P.append(tube("worn", [pth.at(0.0), pth.at(0.05), pth.at(0.1)], lambda s: 0.034, TIM, segs=8, per=2, s=0.9, ang=30))
P.append(tube("buttcap", [pth.at(0.0) + Vector((0, 0.012, 0)), pth.at(0.0), pth.at(0.012)], lambda s: 0.0375, BRASS, segs=8, per=1, ang=30))
for x, y in nibs:
nib(P, x, y, 0.125, m_knob=GOLD)
ring_clamp(P, pth, pth.nearest_y(y), 0.0375, m=BRASS, boltside=1 if y > -0.3 else -1)
end = Vector((0, -1.52, -0.06))
hz = -0.098
rust = {(3, 2), (4, 2), (8, 2)}
S, F = scythe_blade(P, hz, -1.52, 1.1, 0.17, 0.15, 0.27, 0.024, body=STL, rust=rust, n=12, chips=(6,))
heel(P, end, 0.034, hz, m=IRON)
P.append(tube("rib", [F @ Vector((p[0], p[1] + 0.008, hz + 0.0125)) for p in S[:11]], lambda s: (0.011 * (1 - 0.5 * s), 0.0075), IRON, segs=4, per=1, ang=30))
# the grain cradle: a post on the snath, three bent timber fingers over the blade, an iron stay tying them to its back
py = pth.nearest_y(-1.22)
base = pth.at(py)
top = Vector((0.05, -1.26, 0.27))
P.append(tube("cpost", [base + Vector((0.0, 0, 0.02)), top], lambda s: 0.024, TIM, segs=6, ang=28, s=1.6))
ring_clamp(P, pth, py, 0.0345, boltside=-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 = S[int(round(u * 10 * 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))))
Fp = [base.lerp(top, (1.0, 0.68, 0.36)[k])] + Fp[2:]
P.append(tube("finger", Fp, lambda s: 0.0165 - 0.0085 * s, TIM, segs=5, per=2, ang=28, s=1.4, u0=0.375))
fingers.append(Fp)
stay = [fingers[0][3], fingers[1][3], fingers[2][3], F @ Vector((S[6][0], S[6][1] + 0.01, hz + 0.012))]
P.append(tube("cstay", stay, lambda s: 0.0092, IRON, segs=5, per=1, ang=28))
P.append(tube("cbow", [top, fingers[0][2], fingers[0][3]], lambda s: 0.0092, IRON, segs=5, per=2, ang=28))
for k in range(3):
c = fingers[k][3]
P.append(tube("lash", [c + Vector((0, 0, -0.016)), c + Vector((0, 0, 0.016))], lambda s: 0.0175 - 0.002 * k, TWINE, segs=5, ang=30))
done(P, "Body", uv=2.4, ang=30)
return dict(elev=38, azim=-30, dist_mul=0.7, extra=[("heel", dict(elev=30, azim=-20, target=(0.25, -1.4, 0.05), radius=0.46), None), ("grip", dict(elev=18, azim=120, target=(0, -0.05, 0.05), radius=0.3), None)])
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 = Path(pts, per=4)
# a squared green beam, chamfered, with a cream line down it
P.append(tube("snath", pts, lambda s: (0.046 - 0.01 * s, 0.054 - 0.012 * s), GRN, segs=8, per=3, ang=30, phase=math.pi / 8))
for t0 in (0.13, 0.48, 0.82):
a, b, c = pth.at(t0), pth.at(t0 + 0.011), pth.at(t0 + 0.022)
k = 1 - 0.2 * t0
P.append(tube("strap", [a, b, c], lambda s: (0.05 * k, 0.058 * k), IRON, segs=8, per=1, ang=30, phase=math.pi / 8, cap=False))
for sx in (-1, 1):
stud(P, b + Vector((sx * 0.05 * k, 0, 0)), (sx, 0, 0), r=0.0115, m=STL, h=0.008)
# sacking and rope round the butt, a shoulder pad of stuffed leather
P.append(tube("pad", [pth.at(0.0), pth.at(0.06), pth.at(0.12)], lambda s: 0.06, "M_Burlap", segs=8, per=2, ang=38, phase=math.pi / 8, s=5.0, u0=0.5, uw=0.5))
for t0 in (0.02, 0.1):
P.append(tube("lash", [pth.at(t0), pth.at(t0 + 0.006)], lambda s: 0.0635, ROPE, segs=8, ang=30, phase=math.pi / 8, cap=False))
# D-handles: an iron stirrup from the beam round a vertical timber grip
for (x, y), bs in zip(nibs, (1, -1)):
nib(P, x, y, 0.1, m_knob=GOLD, r=0.038, wrap=LEA)
P.append(tube("stirrup", [(x - 0.052, y + 0.05, 0.13), (x - 0.074, y + 0.05, 0.03), (x - 0.074, y + 0.05, -0.1), (x - 0.03, y + 0.02, -0.135), (x, y, -0.135)], lambda s: 0.0092, IRON, segs=5, per=2, ang=28))
# the blade: a metre and a third of it, broad, with a riveted back
hz = -0.11
end = Vector((0, -1.76, -0.065))
rust = {(2, 2), (3, 2), (4, 2), (8, 2), (9, 2), (2, 5)}
S, F = scythe_blade(P, hz, -1.78, 1.42, 0.3, 0.17, 0.42, 0.036, body=IRON, rust=rust, n=13, chips=(4, 9))
on = lambda i, dy=0.012, dz=0.019: F @ Vector((S[i][0], S[i][1] + dy, hz + dz))
P.append(tube("back", [on(i) for i in range(13)], lambda s: (0.024 * (1 - 0.72 * s), 0.0105), STL, segs=4, per=1, ang=30))
nrm = (F.to_3x3() @ Vector((0, 0, 1))).normalized()
for i in (1, 4, 7, 10):
stud(P, on(i, dz=0.028), nrm, r=0.0135, m=BRASS, h=0.006)
# a broad socket, and a brace triangulating the blade off the beam
P.append(bx(-0.062, 0.095, -1.82, -1.68, hz - 0.016, -0.012, IRON, bevel=0.008, segs=1, name="socket"))
P.append(rbox("wedge", (0.03, 0.09, 0.048), (0.1, -1.75, -0.05), bevel=0.005, segs=1, m=TIM))
for x in (-0.03, 0.05):
stud(P, (x, -1.75, -0.012), (0, 0, 1), r=0.016, m=STL, h=0.01)
b1 = pth.at(pth.nearest_y(-1.36))
P.append(tube("strutA", [b1, on(4, dz=0.03)], lambda s: (0.0185, 0.0125), IRON, segs=6, ang=28))
r0, r1 = b1 + Vector((0, 0.02, 0.05)), on(8, dz=0.03)
P.append(tube("strutB", [r0, r1], lambda s: 0.0125, STL, segs=6, ang=28))
P.append(tube("buckle", [r0.lerp(r1, 0.44), r0.lerp(r1, 0.56)], lambda s: 0.0235, BRASS, segs=6, ang=28))
# hazard paint on the blade root, as a warning to anyone behind you
for k in range(3):
x0 = 0.12 + k * 0.065
P.append(plate("hazard", [(x0, -1.885), (x0 + 0.032, -1.885), (x0 + 0.056, -1.79), (x0 + 0.024, -1.79)], hz + 0.0172, hz + 0.0196, GOLD, frame=F))
done(P, "Body", uv=2.4, ang=30)
return dict(elev=38, azim=-30, dist_mul=0.7, extra=[("heel", dict(elev=30, azim=-20, target=(0.3, -1.65, 0.0), radius=0.55), None), ("grip", dict(elev=18, azim=120, target=(0, -0.05, 0.05), radius=0.34), None)])
# ======================================================================= hammer
def hammer():
"""Handle along -Y, grip at the origin, the head across it: the face on +X (screen left in the hand), the claw on -X."""
P = []
hy = -0.56 # centre of the head
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.058, 0.0)]
# hickory, oval in section, swelling into the palm
P.append(tube("handle", hp, lambda s: (0.039 + 0.012 * math.exp(-((s - 0.2) / 0.2) ** 2), 0.0265 + 0.009 * math.exp(-((s - 0.2) / 0.2) ** 2)), TIM, segs=8, per=3, s=0.9, ang=30, spin=0.0))
pth = Path(hp, per=3)
# a leather grip with a welted edge, a thong through the butt
for a, b in ((0.03, 0.34),):
P.append(tube("hgrip", [pth.at(a), pth.at((a + b) / 2), pth.at(b)], lambda s: (0.0545, 0.0395), LEA, segs=8, per=2, ang=30, cap=False))
for t0 in (a, b - 0.012):
P.append(tube("welt", [pth.at(t0), pth.at(t0 + 0.012)], lambda s: (0.0575, 0.0425), IRON, segs=8, ang=30, cap=False))
P.append(tube("buttcap", [(0.0, 0.214, 0.0), (0.0, 0.2, 0.0), (0.003, 0.18, 0.0)], lambda s: (0.0435, 0.0305), PRED, segs=8, per=1, ang=30))
P.append(tube("thong", [(0, 0.212, 0), (0.05, 0.25, 0), (0.05, 0.31, 0), (0.0, 0.33, 0), (-0.04, 0.29, 0), (-0.034, 0.24, 0), (0, 0.212, 0)], lambda s: 0.0078, LEA, segs=5, per=2, ang=40))
# the steel strap down the neck of the handle
for sz in (-1, 1):
P.append(bx(-0.016, 0.016, hy + 0.05, hy + 0.2, sz * 0.03 - 0.004, sz * 0.03 + 0.004, STL, bevel=0.002, segs=1, name="langet"))
for k in range(2):
stud(P, (0, hy + 0.09 + k * 0.08, sz * 0.033), (0, 0, sz), r=0.008, m=BRASS, hexa=False, h=0.004)
# the head. v = up the handle, u = +X. Cheeks: a chamfered block round the eye
W = 0.05
cheek = [(-0.08, -0.042), (-0.06, -0.066), (0.07, -0.066), (0.098, -0.046), (0.098, 0.046), (0.07, 0.062), (-0.06, 0.062), (-0.08, 0.05)]
P.append(plate("cheek", [(u, hy - v) for u, v in cheek], -W, W, IRON))
# chamfer strips on the top edges of the cheeks, painted barn red
for sz in (-1, 1):
P.append(plate("paint", [(u * 0.84, hy - v * 0.76) for u, v in cheek], sz * W, sz * (W + 0.0034), PRED) if sz > 0 else
plate("paint", [(u * 0.84, hy - v * 0.76) for u, v in cheek], sz * (W + 0.0034), sz * W, PRED))
# the neck and the round poll, bright where it has been striking
FX = M_axis("X", (0.09, hy, 0))
P.append(lathe("neck", [(0.052, 0.0), (0.045, 0.03), (0.05, 0.05), (0.064, 0.08), (0.066, 0.1)], segs=10, m=IRON, frame=FX, smooth_ang=30))
P.append(lathe("poll", [(0.066, 0.1), (0.0665, 0.128), (0.058, 0.141)], segs=10, m=STL, frame=FX, smooth_ang=30))
P.append(lathe("face", [(0.058, 0.141), (0.03, 0.147), (0.0, 0.149)], segs=10, m=BLD, frame=FX, smooth_ang=30))
# the handle's end through the eye: timber, an iron wedge across it
P.append(bx(-0.036, 0.036, hy - 0.076, hy - 0.056, -0.027, 0.027, TIM, bevel=0.003, segs=1, name="eyetop"))
P.append(bx(-0.03, 0.03, hy - 0.08, hy - 0.072, -0.005, 0.005, STL, bevel=0.0015, segs=1, name="wedge"))
for x in (-0.018, 0.018):
P.append(disc("wedgedot", 0.0072, 0.006, (x, hy - 0.08, 0), IRON, n=6, axis="Y"))
# the claw: two prongs curving back towards the hand, split by a V
prof = [(-0.07, 0.056), (-0.125, 0.05), (-0.185, 0.03), (-0.24, -0.015), (-0.285, -0.082), (-0.298, -0.122), (-0.27, -0.102), (-0.222, -0.058), (-0.175, -0.03), (-0.125, -0.022), (-0.07, -0.042)]
pts = [(u, hy - v) for u, v in prof]
P.append(plate("clawroot", [(u, hy - v) for u, v in prof[:2] + [(-0.14, 0.0), (-0.125, -0.022)] + prof[-1:]], -W * 0.92, W * 0.92, IRON))
for sz in (-1, 1):
gap, thick = 0.0085, W * 0.92 - 0.0085
o = plate("prong", pts, sz * gap if sz > 0 else -W * 0.92, W * 0.92 if sz > 0 else -gap, IRON)
# taper the prongs in to their tips
for v in o.data.vertices:
k = max(0.0, min(1.0, (-v.co.x - 0.12) / 0.18))
mid = sz * (gap + thick * 0.5)
v.co.z = mid + (v.co.z - mid) * (1 - 0.62 * k) + sz * 0.007 * k
P.append(o)
# bright claw tips, worn from pulling nails
P.append(lathe("rim", [(0.0485, -0.02), (0.0525, -0.016), (0.0525, -0.006), (0.0485, -0.002)], segs=10, m=STL, frame=FX, smooth_ang=30))
# a maker's rust bloom on the cheek
P.append(plate("bloom", [(-0.06, hy + 0.04), (-0.022, hy + 0.05), (-0.008, hy + 0.024), (-0.044, hy + 0.014)], W + 0.0002, W + 0.0024, RUST))
done(P, "Body", uv=4.0, ang=30)
return dict(elev=64, azim=-14, dist_mul=0.72, extra=[("head", dict(elev=30, azim=-120, target=(0, -0.56, 0), radius=0.3), None), ("back", dict(elev=20, azim=150, dist_mul=0.72), None)])
BUILDERS = {
"SM_Tool_NailScissors": nail_scissors,
"SM_Tool_GardenShears": garden_shears,
"SM_Tool_Shears": garden_shears,
"SM_Tool_Sickle": sickle,
"SM_Tool_Scythe": scythe,
"SM_Tool_LongScythe": long_scythe,
"SM_Tool_WideScythe": wide_scythe,
"SM_Tool_Hammer": hammer,
}
if __name__ == "__main__":
args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
for nm in (args or list(BUILDERS)):
reset()
random.seed(7)
r = BUILDERS[nm]() or {}
OC.finish_x(nm, r)