"""GRASS CUTTER - the basic scythe (SM_Tool_Scythe) in the stylized, hand-painted set. Built from gc_style_kit; the other hand tools of the set are in gc_style_tools.py, which also uses the snath and blade helpers here. Game frame (round 4, gc_up4_tools.scythe; ViewModel / CrewAvatar hold data depends on it): one object "Body", no parent, origin at the world origin, identity transform; Blender -Y = Unity forward, blade out on +X; the snath runs y +0.15 .. -1.27, the blade heel at (0, -1.3, -0.095) tilted 38 degrees, tip at x ~0.82; nibs (grips) hang along Z at (0.03, -0.04) and (-0.03, -0.66). Run (absolute paths): blender -b --factory-startup --python C:/Github/Grass-Cutters/ArtSource/Blender/scripts/gc_style_scythe.py -- [--res 2048] [--samples 128] [--no-bake (reuse textures/T_Scythe_Painted.png)] [--no-render] [--shots full,mount,...] Writes ArtSource/Blender/stylized/{SM_Tool_Scythe.blend, fbx/, textures/T_Scythe_Painted.png, previews/SM_Tool_Scythe_*.png}. """ import os, sys, math sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import gc_style_kit as K from mathutils import Vector, Matrix DEG = math.radians TILT = 38.0 def tilt_frame(y0, hz): return Matrix.Translation((0, y0, hz)) @ Matrix.Rotation(DEG(-TILT), 4, "X") @ Matrix.Translation((0, -y0, -hz)) def scythe_outline(y0, L, w0, bow, curl, n=28): """Round 4's outline: spine points S and widths W at n + 1 stations, the tip point.""" S, W = [], [] for i in range(n + 1): u = i / n S.append(Vector((L * u, y0 - bow * math.sin(u * 2.35) + curl * u ** 3))) W.append(w0 * (1 - u) ** 0.62 * (0.8 + 0.2 * math.sin(min(1.0, u * 4) * 1.57)) + 0.007) tip = Vector((S[-1].x + 0.02, S[-1].y + 0.01)) return S, W, tip def scythe_blade(y0, hz, L, w0, bow, curl, n=28, thick=1.0, name="blade"): """The crescent in the round 4 plane: a fat rounded spine, a thick body, a broad ground bevel to a bright edge. Returns (S, W, F).""" S, W, tip = scythe_outline(y0, L, w0, bow, curl, n) F = tilt_frame(y0, hz) E = [] for i in range(n): t = (S[min(i + 1, n)] - S[max(i - 1, 0)]).normalized() nrm = Vector((-t.y, t.x)) if nrm.y < 0: nrm = -nrm E.append(S[i] + nrm * W[i]) K.blade(name, [(p.x, p.y) for p in S[:n]], [(p.x, p.y) for p in E], F, z0=hz, rw=lambda u: 0.042 * thick * (1 - 0.35 * u), rh=lambda u: 0.024 * thick * (1.0 - 0.55 * u ** 1.2), hb=lambda u: (0.0052 * (1 - 0.4 * u) + 0.001) * thick, bev=lambda w, u: min(0.042, 0.36 * w), tip=(tip.x, tip.y), cuts=(n // 2,)) return S, W, F def snath(pts, r0, r1, key="wood", cuts=None, sides=8, sq=1.0, n=30): """The snath: a chunky chamfered octagon along pts, r0 at the butt to r1 at the blade.""" pth = K.Path(pts) K.pole("snath", pth, lambda t: r0 + (r1 - r0) * t, key, n=n, cap0=False, cap1=True, cuts=cuts, sides=sides, sq=sq) return pth def butt(pth, r0, key_band="brass", key_cap="iron"): """A brass band near the butt and a domed dark iron cap.""" K.band("buttband", pth, 0.05, 0.03, r0, 0.0065, key_band) c0 = pth.at(0.0) d0 = (pth.at(0.0) - pth.at(0.03)).normalized() K.lathe("buttcap", [(r0 * 0.96, -0.02), (r0 + 0.0055, -0.016), (r0 + 0.006, -0.004), (r0 + 0.002, 0.004), (r0 * 0.7, 0.013), (r0 * 0.32, 0.0175), (0.0, 0.019)], key_cap, segs=16, frame=K.frame_z(c0, d0), phase=math.pi / 16) def nibs_and_clamps(pth, rfun, nibs, z_top=0.12, r=0.036, side_split=-0.3): for k, (x, y) in enumerate(nibs): s = pth.nearest_y(y) ctr = pth.at(s) K.nib(k, x, y, z_top, r=r, stem_to=ctr.z - 0.015) K.clamp(k, pth, s, rfun(s), 1 if y > side_split else -1, saddle_xy=(x, y)) def mount(pth, y0, hz, x0=0.007, top_z=-0.0155): """The blade mount: a brass collar on the snath end, a dark iron socket with a brass strap and big bolts.""" Ls = pth.len r = 0.027 K.band("collar", pth, Ls - 0.036, 0.054, r, 0.0095, "brass", ch=0.006) K.band("collar_lip", pth, Ls - 0.071, 0.012, r, 0.005, "iron", ch=0.003) yc, zc = y0 - 0.01, (hz + top_z) / 2 - 0.006 sz = top_z - hz + 0.017 K.rbox("socket", (x0, yc, zc), (0.1, 0.098, sz), "iron", bev=0.013, segs=2) K.rbox("strap", (x0, yc - 0.002, zc), (0.11, 0.036, sz + 0.01), "brass", bev=0.008, segs=2) K.hexbolt("bolt_top", (x0, yc - 0.002, zc + sz / 2 + 0.005), (0, 0, 1), r=0.017, h=0.012, washer=0.022) K.hexbolt("bolt_side", (x0 - 0.055, yc - 0.002, zc), (-1, 0, 0), r=0.016, h=0.011, washer=0.021) SNATH_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)] def scythe(): r0, r1 = 0.0355, 0.027 pth = snath(SNATH_PTS, r0, r1, cuts=(10, 20)) rfun = lambda s: r0 + (r1 - r0) * s / pth.len butt(pth, r0) nibs_and_clamps(pth, rfun, ((0.03, -0.04), (-0.03, -0.66))) mount(pth, -1.3, -0.095) scythe_blade(-1.3, -0.095, 0.8, 0.19, 0.13, 0.17) return dict(res=2048, ps=1.0, full={"full": (38, 150), "full_front": (34, -38)}, views=[("mount", (0.03, -1.28, -0.05), 0.16, 30, 215), ("clamps", (0.0, -0.06, 0.03), 0.17, 16, -55), ("blade_edge", (0.55, -1.25, -0.13), 0.3, 45, 165)]) BUILDERS = {"SM_Tool_Scythe": scythe} if __name__ == "__main__": K.run(BUILDERS)