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>
185 lines
10 KiB
Python
185 lines
10 KiB
Python
"""GRASS CUTTER - base machines, re-themed from os_machines.py (same footprints, pivots and named parts).
|
|
|
|
Overrides: water drops become leaves, the barrel pictogram becomes a hay bale, the cryo snowflake becomes a hemp leaf,
|
|
icicles become hanging grass tufts, and the edge pump becomes an edge mower (a cutting arm reaching down into the
|
|
meadow with a spinning blade disc as its Rotor).
|
|
Run (from project root):
|
|
blender -b --factory-startup --python ArtSource/Blender/scripts/gc_machines.py -- [SM_Hopper SM_Filler ...]
|
|
"""
|
|
import sys, os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import os_machines as OM
|
|
from os_machines import * # noqa: F401,F403 (helpers + material names)
|
|
|
|
LEAF, LEAFD = "M_Leaf", "M_LeafDark"
|
|
|
|
|
|
# ======================================================================= icon overrides
|
|
|
|
def leaf_pts(R, cx_=0.0, cy_=0.0, h=1.75, n=14):
|
|
"""Pointed leaf outline (CCW) in the box a water drop used to fill: width 2R, from cy-R up to cy+h*R."""
|
|
y0, y1 = cy_ - R, cy_ + h * R
|
|
pts = []
|
|
for i in range(n + 1):
|
|
t = i / n
|
|
pts.append((cx_ + R * 1.05 * math.sin(math.pi * t) ** 0.8, y0 + (y1 - y0) * t))
|
|
for i in range(n - 1, 0, -1):
|
|
t = i / n
|
|
pts.append((cx_ - R * 1.05 * math.sin(math.pi * t) ** 0.8, y0 + (y1 - y0) * t))
|
|
return pts
|
|
|
|
|
|
def leaflet(L, w, n=7):
|
|
"""One slim leaflet from the origin along +Y (XY plane)."""
|
|
pts = []
|
|
for i in range(n + 1):
|
|
t = i / n
|
|
pts.append((w * math.sin(math.pi * t) ** 0.9 * (1 - 0.25 * t), L * t))
|
|
for i in range(n - 1, 0, -1):
|
|
t = i / n
|
|
pts.append((-w * math.sin(math.pi * t) ** 0.9 * (1 - 0.25 * t), L * t))
|
|
return pts
|
|
|
|
|
|
def hemp_icon(P, c, facing, s=1.0, m=OM.TE, t=0.012):
|
|
"""Seven-leaflet hemp leaf pictogram (replaces the cryo snowflake)."""
|
|
G = []
|
|
for ang, L in ((0, 0.17), (24, 0.15), (-24, 0.15), (52, 0.12), (-52, 0.12), (82, 0.075), (-82, 0.075)):
|
|
o = prism("leaflet", leaflet(L * s, 0.022 * s), "XY", 0, t, m)
|
|
xf(o, rz=math.radians(ang))
|
|
G.append(o)
|
|
G.append(box("stem", -0.007 * s, 0.007 * s, -0.07 * s, 0.0, 0, t, m, bev=0))
|
|
for o in G:
|
|
xf(o, t=(0, -0.03 * s, 0))
|
|
P.append(orient(o, facing, c))
|
|
|
|
|
|
def bale_icon(P, c, facing, s=1.0, base=OM.TE, ink="M_PaintWhite"):
|
|
"""Stencilled hay-bale pictogram on a rounded plate (replaces the barrel)."""
|
|
G = [plate("ibase", 0.4 * s, 0.4 * s, 0.012, base, r=0.05 * s)]
|
|
G[-1] = xf(G[-1], rx=PI / 2)
|
|
G.append(decal(rrect(0, -0.03 * s, 0.3 * s, 0.2 * s, 0.03 * s), 0.012, 0.018, ink))
|
|
for xx in (-0.07, 0.07):
|
|
G.append(decal(rrect(xx * s, -0.03 * s, 0.025 * s, 0.22 * s, 0.008 * s, n=1), 0.012, 0.022, base))
|
|
G.append(decal(leaf_pts(0.03 * s, 0, 0.11 * s, n=8), 0.012, 0.02, ink))
|
|
for o in G:
|
|
rx, rz = (0, 0) if facing == "-Y" else (0, {"+X": PI / 2, "-X": -PI / 2, "+Y": PI}[facing] if isinstance(facing, str) else math.radians(facing) + PI / 2)
|
|
P.append(xf(o, rz=rz, t=c))
|
|
|
|
|
|
def grass_tuft(P, x, y, z, L, r=0.022):
|
|
"""A tuft of clippings hanging off a ledge (replaces icicles)."""
|
|
for k, (dx, dy, k_l) in enumerate(((0, 0, 1.0), (r * 1.2, 0.004, 0.75), (-r * 1.1, -0.004, 0.85))):
|
|
o = cyl("tuft", r * 0.55, L * k_l, (0, 0, -L * k_l / 2), "Z", verts=5, m=LEAF if k != 1 else LEAFD, r2=0.002)
|
|
xf(o, rx=math.radians(6 * (k - 1)), ry=math.radians(8 * (1 - k)), t=(x + dx, y + dy, z))
|
|
P.append(o)
|
|
|
|
|
|
OM.drop_pts = leaf_pts
|
|
OM.snowflake = hemp_icon
|
|
OM.barrel_icon = bale_icon
|
|
OM.icicle = grass_tuft
|
|
|
|
|
|
# ======================================================================= edge mower (SM_Pump)
|
|
|
|
def edge_mower():
|
|
P = []
|
|
W, OR, TE, DG, RB, ST, GL, HZ = OM.W, OM.OR, OM.TE, OM.DG, OM.RB, OM.ST, OM.GL, OM.HZ
|
|
NV, BR = OM.NV, OM.BR
|
|
# skid (1 x 2) + deck-edge clamp hooking over the front edge
|
|
P.append(box("skid", -0.47, 0.47, -0.97, 0.95, 0.0, 0.1, DG, bev=0.03, segs=2))
|
|
P.append(box("skidhaz", -0.4, 0.4, -0.976, -0.95, 0.02, 0.08, HZ, bev=0))
|
|
for s in (-1, 1):
|
|
P.append(box("skidhaz", s * 0.47 - 0.006, s * 0.47 + 0.006, -0.9, -0.5, 0.02, 0.08, HZ, bev=0))
|
|
P.append(box("clamp", -0.32, 0.32, -1.04, -0.97, -0.34, 0.1, DG, bev=0.02, segs=1))
|
|
P.append(box("clamppad", -0.28, 0.28, -1.045, -1.03, -0.3, -0.14, RB, bev=0.006, segs=1))
|
|
for x in (-0.22, 0.22):
|
|
bolt(P, (x, -1.04, 0.0), "-Y", r=0.022, h=0.014)
|
|
for (x, y) in ((-0.4, -0.9), (0.4, -0.9), (-0.4, 0.88), (0.4, 0.88)):
|
|
bolt(P, (x, y, 0.1), "+Z", r=0.02)
|
|
C = (0.0, 0.42)
|
|
# collector drum (where the clippings go) at the bottom, motor stack on top
|
|
P.append(cz("drum", 0.36, 0.1, 0.48, C[0], C[1], OR, v=28, bev=0.03, segs=2))
|
|
P.append(cz("drumwin", 0.362, 0.2, 0.4, C[0], C[1], GL, v=28))
|
|
P.append(cz("drumfill", 0.34, 0.12, 0.33, C[0], C[1], "M_GrassFill", v=20))
|
|
P.append(cz("volcap", 0.22, 0.48, 0.53, C[0], C[1], W, v=24, bev=0.015, segs=1))
|
|
bolt_ring(P, 8, 0.3, 0.48, c=C, a0=22.5)
|
|
# outlet down into the deck (to the silo)
|
|
pipe(P, [(0.31, C[1] - 0.1, 0.27), (0.31, C[1] - 0.32, 0.27), (0.31, C[1] - 0.32, 0.05)], 0.065, ST, rad=0.1, segs=12, n=4)
|
|
deck_flange(P, 0.31, C[1] - 0.32, 0.1, nb=5)
|
|
ZM = 1.18
|
|
P.append(revm("motor", [(0.3, 0.53), (0.34, 0.56), (0.35, 0.6), (0.35, ZM - 0.06), (0.34, ZM - 0.03)], W, segs=28, loc=(C[0], C[1], 0)))
|
|
for k in range(14):
|
|
a = 2 * PI * k / 14
|
|
fn = box("fin", 0.34, 0.395, -0.011, 0.011, 0.62, ZM - 0.12, W, bev=0.008, segs=1)
|
|
xf(fn, rz=a, t=(C[0], C[1], 0))
|
|
P.append(fn)
|
|
P.append(revm("fband", [(0.39, 0.74), (0.398, 0.745), (0.398, 0.805), (0.39, 0.81)], TE, segs=28, loc=(C[0], C[1], 0)))
|
|
P.append(revm("shroud", [(0.33, ZM - 0.04), (0.38, ZM - 0.03), (0.41, ZM), (0.41, ZM + 0.12), (0.39, ZM + 0.14), (0.34, ZM + 0.14), (0.33, ZM + 0.11), (0.33, ZM)],
|
|
OR, segs=28, loc=(C[0], C[1], 0), closed=True))
|
|
P.append(cz("fancap", 0.33, ZM + 0.1, ZM + 0.13, C[0], C[1], DG, v=28))
|
|
for rr in (0.31, 0.22, 0.13):
|
|
P.append(torus("grille", rr, 0.011, (C[0], C[1], ZM + 0.135), "Z", seg=24, rseg=4, m=ST))
|
|
pl = decal(rrect(0, 0.97, 0.32, 0.12, 0.03), 0.0, 0.008, NV)
|
|
P.append(wrap_cyl(pl, 0.397, -90, c=C, step=0.05))
|
|
t = text("label", "GREENHAUL", 0.055, "M_PaintWhite")
|
|
orient(t, "-Y", (0, -0.011, 0.97))
|
|
P.append(wrap_cyl(t, 0.397, -90, c=C))
|
|
P.append(box("tbox", -0.42, -0.3, C[1] - 0.13, C[1] + 0.13, 0.66, 1.0, DG, bev=0.025, segs=2))
|
|
P.append(box("tlid", -0.43, -0.39, C[1] - 0.11, C[1] + 0.11, 0.68, 0.98, OR, bev=0.015, segs=1))
|
|
lever = [cyl("lpivot", 0.025, 0.03, (0, 0, 0.015), "Z", verts=10, m=ST),
|
|
box("lbar", -0.012, 0.012, 0.0, 0.14, 0.02, 0.04, "M_PaintRed", bev=0.006, segs=1),
|
|
sphere("lknob", 0.03, (0, 0.14, 0.03), seg=10, rings=5, m="M_PaintRed")]
|
|
for o in lever:
|
|
P.append(orient(o, "-X", (-0.43, C[1], 0.76), spin=-0.6))
|
|
P.append(ptube("cable", rpath([(-0.36, C[1] + 0.13, 0.74), (-0.36, C[1] + 0.32, 0.5), (-0.2, C[1] + 0.42, 0.12)], 0.12), 0.022, RB, segs=6))
|
|
# mowing boom: a hinge block, two orange arms over the deck edge, then a strut down to the cutter deck
|
|
ZH = 0.42
|
|
P.append(box("hinge", -0.2, 0.2, -0.3, 0.0, 0.1, ZH + 0.14, DG, bev=0.03, segs=2))
|
|
P.append(cx("pivot", 0.07, -0.24, 0.24, -0.15, ZH, ST, v=16, bev=0.01))
|
|
YC, ZC = -1.62, -0.96 # cutter centre (over the meadow, the deck edge is at y = -1)
|
|
for s in (-1, 1):
|
|
x = s * 0.13
|
|
P.append(ptube("boom", rpath([(x, -0.15, ZH), (x, -0.95, ZH + 0.22), (x, YC + 0.08, -0.2), (x, YC + 0.02, ZC + 0.16)], 0.16, 6), 0.045, OR, segs=10))
|
|
for y, z in ((-0.55, ZH + 0.12), (-1.25, ZH - 0.05)):
|
|
P.append(cx("crossbar", 0.03, -0.13, 0.13, y, z, DG, v=10))
|
|
P.append(box("boomhaz", -0.17, 0.17, -0.8, -0.7, ZH + 0.1, ZH + 0.22, HZ, bev=0.01, segs=1))
|
|
# hydraulic ram from the hinge block to the boom
|
|
P.append(cyl_between("ram", (0, -0.25, 0.22), (0, -0.7, ZH + 0.12), 0.035, ST, v=12))
|
|
P.append(cyl_between("ramsleeve", (0, -0.25, 0.22), (0, -0.48, 0.32), 0.05, DG, v=12))
|
|
# cutter deck: an orange dome guard with a skirt, the blade disc spins underneath
|
|
P.append(revm("guard", [(0.0, ZC + 0.24), (0.2, ZC + 0.23), (0.4, ZC + 0.17), (0.5, ZC + 0.08), (0.53, ZC + 0.02), (0.53, ZC - 0.02)],
|
|
[OR, OR, OR, W, W], segs=32, loc=(0, YC, 0)))
|
|
P.append(revm("guardin", [(0.52, ZC - 0.02), (0.48, ZC + 0.06), (0.36, ZC + 0.14), (0.1, ZC + 0.19), (0.0, ZC + 0.195)], DG, segs=24, loc=(0, YC, 0)))
|
|
P.append(torus("skirt", 0.53, 0.03, (0, YC, ZC - 0.02), "Z", seg=32, rseg=5, m=RB))
|
|
P.append(cz("gmotor", 0.12, ZC + 0.22, ZC + 0.38, 0, YC, W, v=18, bev=0.02))
|
|
P.append(cz("gmotorcap", 0.13, ZC + 0.36, ZC + 0.42, 0, YC, OR, v=18, bev=0.015))
|
|
for k in range(10):
|
|
a = 2 * PI * k / 10
|
|
P.append(arc_band("gdash", 0.42, 0.47, ZC + 0.135, ZC + 0.155, math.degrees(a) + 4, math.degrees(a) + 20, "M_PaintWhite", segs=2, c=(0, YC)))
|
|
# suction hose from the guard back up to the collector drum
|
|
P.append(hose("hose", [(0.32, YC + 0.1, ZC + 0.2), (0.4, YC + 0.4, 0.1), (0.36, -0.9, 0.55), (0.3, 0.1, 0.62), (0.2, C[1] - 0.2, 0.52)], 0.06, step=0.05, segs=10, rad=0.2))
|
|
gauge(P, (0.0, -0.32, ZH + 0.3), "-Y", r=0.07, stem=0.06)
|
|
fin(P, "Body", uv=1.0, haz=3.0)
|
|
# Rotor: the blade disc (spins about its vertical axis), origin at its hub
|
|
Q = [cz("hub", 0.07, ZC - 0.01, ZC + 0.06, 0, YC, DG, v=14, bev=0.01, segs=1),
|
|
cz("disc", 0.3, ZC - 0.005, ZC + 0.015, 0, YC, ST, v=24)]
|
|
for k in range(3):
|
|
bl = prism("blade", [(0.08, -0.05), (0.46, -0.05), (0.49, -0.02), (0.49, 0.03), (0.44, 0.045), (0.08, 0.05)], "XY", -0.008, 0.008, "M_Blade")
|
|
xf(bl, rx=0.06)
|
|
xf(bl, rz=k * 2 * PI / 3, t=(0, YC, ZC + 0.005))
|
|
Q.append(bl)
|
|
tip = prism("btip", [(0.4, -0.05), (0.49, -0.02), (0.49, 0.03), (0.4, 0.045)], "XY", -0.009, 0.009, OR)
|
|
xf(tip, rz=k * 2 * PI / 3, t=(0, YC, ZC + 0.005))
|
|
Q.append(tip)
|
|
part(Q, "Rotor", (0, YC, ZC))
|
|
return dict(elev=14, azim=-60)
|
|
|
|
|
|
BUILDERS = dict(OM.BUILDERS)
|
|
BUILDERS["SM_Pump"] = edge_mower
|
|
|
|
if __name__ == "__main__":
|
|
run(BUILDERS)
|