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,193 @@
"""GRASS CUTTER - the small machines on the pack's own tractor: SM_RiderMower and SM_PushMower.
The Garden Rider is the POLYGON Farm vintage tractor (SM_Veh_TractorOld_01) brought down to garden size, with a mower deck
slung under its belly between the axles, a chute off the right side and a slatted grass box on the hitch. The push mower
keeps its reel, hopper and handles from gc_up3_base, and runs on the pack tractor's own wheels.
The pack's parts keep their UVs and go out on M_Pack, the atlas the pack uses in the game; only what is new is ours.
Names Vehicle looks for: Wheel_* (spun, the front ones steered), Seat, Fill (scaled on local Z), Bars, Reel.
Run: blender -b --factory-startup --python ArtSource/Blender/scripts/gc_pack_vehicles.py -- [SM_RiderMower SM_PushMower]
"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import common
import gc_up3_base as U3
from gc_up_machines import * # noqa: F401,F403
from mathutils import Matrix, Vector
from mathutils.bvhtree import BVHTree
PACK = r"D:\PROJECTS\ASSETS\_extract_POLYGON_Farm\flat"
RIDER = 0.62 # the vintage tractor at this size is a garden tractor the crew sit on with their knees up
def atlas():
"""M_Pack: in the game the pack's atlas; here the same texture, so the pictures look like the game."""
m = bpy.data.materials.get("M_Pack")
if m:
return m
m = bpy.data.materials.new("M_Pack")
m.use_nodes = True
nt = m.node_tree
b = next(n for n in nt.nodes if n.type == "BSDF_PRINCIPLED")
t = nt.nodes.new("ShaderNodeTexImage")
t.image = bpy.data.images.load(os.path.join(PACK, "Textures", "PolygonFarm_Texture_01_A.png"))
nt.links.new(t.outputs["Color"], b.inputs["Base Color"])
b.inputs["Roughness"].default_value = 0.8
return m
def pack(name, M):
"""The pack model's meshes, each baked through M into plain objects on M_Pack. Returns them by their pack names."""
before = set(bpy.context.scene.objects)
bpy.ops.import_scene.fbx(filepath=os.path.join(PACK, "Models", name + ".fbx"))
new = [o for o in bpy.context.scene.objects if o not in before]
out = {}
for o in new:
if o.type != "MESH":
continue
o.data = o.data.copy()
o.data.transform(M @ o.matrix_world)
o.parent = None
o.matrix_world = Matrix.Identity(4)
mat = atlas()
o.data.materials.clear()
o.data.materials.append(mat)
out[o.name.split(".")[0]] = o
for o in new:
if o.type != "MESH":
bpy.data.objects.remove(o)
return out
def centre_origin(o):
"""A wheel spins about its own origin: put it on the hub."""
lo = Vector(map(min, *[v.co for v in o.data.vertices]))
hi = Vector(map(max, *[v.co for v in o.data.vertices]))
c = (lo + hi) / 2
o.data.transform(Matrix.Translation(-c))
o.location = c
return c, hi - lo
def rider_mower():
random.seed(5)
parts = pack("SM_Veh_TractorOld_01", Matrix.Scale(RIDER, 4))
for n, o in parts.items():
if "Wheel_" in n:
o.name = "Wheel_" + n.split("Wheel_")[1].upper()
centre_origin(o)
elif n.endswith("SteeringW"):
o.name = "SteeringW"
else:
o.name = "Tractor"
body = bpy.data.objects["Tractor"]
# the seat: straight down onto the cushion behind the wheel
bvh = BVHTree.FromObject(body, bpy.context.evaluated_depsgraph_get())
hit = bvh.ray_cast(Vector((0, 0.36, 3.0)), Vector((0, 0, -1)))[0]
seat = common.empty("Seat", (0, 0.34, (hit.z if hit else 0.78) + 0.03))
P = []
# the deck: a wide flat shell under the belly, wider than the tractor, skirted, striped, with castors at its front corners
Y0, Y1, Z0, Z1, HW = -0.47, 0.05, 0.07, 0.25, 1.0
shell = [(Y0 - 0.02, Z0 + 0.04), (Y0, Z1 - 0.03), (Y0 + 0.06, Z1), (Y1 - 0.05, Z1), (Y1, Z1 - 0.04), (Y1 + 0.01, Z0 + 0.03), (Y1 - 0.01, Z0), (Y0 + 0.01, Z0)]
P.append(px(shell, -HW, HW, "P_RED", bev=0.01, name="deck"))
for xm in (-0.62, -0.5, 0.5, 0.62):
P.append(px([(Y0 + 0.06, Z1 + 0.004), (Y1 - 0.05, Z1 + 0.004), (Y1 - 0.05, Z1 + 0.012), (Y0 + 0.06, Z1 + 0.012)], xm - 0.035, xm + 0.035, "P_WHITE", name="stripe"))
P.append(bx(-HW - 0.01, HW + 0.01, Y0 - 0.035, Y0 - 0.005, Z0 - 0.04, Z0 + 0.03, "P_BLACK", name="skirt"))
P.append(bx(-HW - 0.01, HW + 0.01, Y1 - 0.005, Y1 + 0.025, Z0 - 0.04, Z0 + 0.03, "P_BLACK", name="skirt"))
for s in (-1, 1):
a, b = sorted((s * HW, s * (HW + 0.02)))
P.append(px(shell, a, b, "P_G1", name="endplate"))
# castors keep the deck off the bumps
P.append(cz("castorpost", 0.018, Z1 - 0.02, Z1 + 0.04, s * (HW - 0.08), Y0 - 0.06, "P_G2", v=6))
P.append(cx("castor", 0.05, min(s * (HW - 0.105), s * (HW - 0.055)), max(s * (HW - 0.105), s * (HW - 0.055)), Y0 - 0.1, 0.05, "P_BLACK", v=10))
# spindle domes over the three blades
for x in (-0.6, 0.0, 0.6):
P.append(cz("spindle", 0.1, Z1, Z1 + 0.05, x, (Y0 + Y1) / 2, "P_G3", v=10, r2=0.06))
P.append(cz("spindlecap", 0.035, Z1 + 0.05, Z1 + 0.075, x, (Y0 + Y1) / 2, "P_G1", v=8))
# the belt guard along the top and the hangers up to the frame
P.append(bx(-0.66, 0.66, (Y0 + Y1) / 2 - 0.06, (Y0 + Y1) / 2 + 0.06, Z1 + 0.05, Z1 + 0.07, "P_G2", name="beltguard"))
for x in (-0.25, 0.25):
for y in (Y0 + 0.08, Y1 - 0.08):
P.append(bx(x - 0.015, x + 0.015, y - 0.015, y + 0.015, Z1, 0.42, "P_G1", name="hanger"))
# the chute off the right side, and the duct from it up and back into the box
P.append(loft([[(-HW, -0.32, Z0 + 0.03), (-HW, -0.06, Z0 + 0.03), (-HW, -0.06, Z1 - 0.01), (-HW, -0.32, Z1 - 0.01)],
[(-HW - 0.16, -0.26, Z0 + 0.05), (-HW - 0.16, -0.1, Z0 + 0.05), (-HW - 0.16, -0.1, Z1 + 0.04), (-HW - 0.16, -0.26, Z1 + 0.04)]], "P_G3", name="chute"))
duct = [(-HW - 0.12, -0.18, Z1), (-0.72, 0.2, 0.42), (-0.5, 0.8, 0.72), (-0.34, 1.05, 0.88)]
P.append(ptube("duct", duct, 0.065, "P_G4", segs=8))
for t in (1, 2):
P.append(ptube("ductband", [Vector(duct[t]) - Vector((0, 0.025, 0)), Vector(duct[t]) + Vector((0, 0.025, 0))], 0.072, "P_G1", segs=8))
# the grass box on the hitch: a red tub with slatted sides, the level showing between the slats
Xh, Ya, Yb, Zf, Zt = 0.42, 0.98, 1.62, 0.36, 0.98
P.append(bx(-Xh, Xh, Ya, Yb, Zf, Zf + 0.03, "P_G1", name="floor"))
for s in (-1, 1):
P.append(sb(s, Xh - 0.03, Xh, Ya, Yb, Zf + 0.03, 0.6, "P_RED", name="tub"))
for z in (0.67, 0.75, 0.83, 0.91):
P.append(sb(s, Xh - 0.025, Xh, Ya, Yb, z - 0.02, z + 0.02, "P_G2", name="slat"))
for y0, y1 in ((Yb - 0.03, Yb), (Ya, Ya + 0.03)):
P.append(bx(-Xh, Xh, y0, y1, Zf + 0.03, 0.6, "P_RED", name="tub"))
for z in (0.67, 0.75, 0.83, 0.91):
P.append(bx(-Xh, Xh, y0, y1, z - 0.02, z + 0.02, "P_G2", name="slat"))
for sx in (-1, 1):
for y in (Ya, Yb):
P.append(bx(sx * Xh - 0.025, sx * Xh + 0.025, y - 0.025, y + 0.025, Zf, Zt + 0.03, "P_G1", name="post"))
P.append(sb(sx, Xh - 0.02, Xh + 0.015, Ya - 0.015, Yb + 0.015, Zt, Zt + 0.04, "P_WHITE", name="rim"))
for y in (Ya, Yb):
P.append(bx(-Xh - 0.015, Xh + 0.015, y - 0.015, y + 0.02, Zt, Zt + 0.04, "P_WHITE", name="rim"))
P.append(bx(-0.3, 0.3, Yb, Yb + 0.012, 0.42, 0.56, "P_WHITE", name="backstripe"))
decal(P, (0, Yb + 0.014, 0.49), 0.24, 0.09, (0, 1, 0), R_52)
# the drawbar and the hitch pin, the box's two little wheels
P.append(bx(-0.05, 0.05, 0.78, Ya + 0.05, 0.3, 0.36, "P_G1", name="drawbar"))
P.append(cz("pin", 0.02, 0.28, 0.42, 0, 0.84, "P_G4", v=6))
rust(P, (Xh + 0.002, 1.4, 0.48), 0.14, 0.09, (1, 0, 0))
pfin(P, "Kit")
fill(-Xh + 0.035, Xh - 0.035, Ya + 0.035, Yb - 0.035, Zf + 0.03, Zt - 0.01, lump=0.05)
for s, nm in ((1, "Wheel_BoxL"), (-1, "Wheel_BoxR")):
G = [cx("tyre", 0.17, -0.05, 0.05, 0, 0, "P_BLACK", v=14), cx("rim", 0.1, -0.055, 0.055, 0, 0, "P_WHITE", v=10)]
o = pfin(G, nm)
o.location = (s * (Xh + 0.07), (Ya + Yb) / 2, 0.17)
return dict(elev=18, azim=-42, dist_mul=0.8, seat=seat)
def push_mower():
"""Round 3's reel mower, on the pack tractor's wheels: its little front ones at the corners of the reel, its big rear ones
under the hopper."""
U3.push_mower()
for o in [o for o in bpy.context.scene.objects if o.name.startswith("Wheel_")]:
for c in o.children_recursive:
bpy.data.objects.remove(c)
bpy.data.objects.remove(o)
# where round 2 hung its own wheels, and how big they were
hubs = {"Wheel_FL": (Vector((0.815, -0.65, 0.15)), 0.15), "Wheel_FR": (Vector((-0.815, -0.65, 0.15)), 0.15),
"Wheel_RL": (Vector((0.5, 0.12, 0.3)), 0.3), "Wheel_RR": (Vector((-0.5, 0.12, 0.3)), 0.3)}
old = pack("SM_Veh_TractorOld_01", Matrix.Identity(4))
src = {"F": old["SM_Veh_TractorOld_Wheel_fl"], "R": old["SM_Veh_TractorOld_Wheel_rl"]}
size = {k: centre_origin(o)[1].z / 2 for k, o in src.items()}
for n, (hub, r) in hubs.items():
w = src["F" if n[-2] == "F" else "R"]
size_ = size["F" if n[-2] == "F" else "R"]
o = bpy.data.objects.new(n, w.data.copy())
bpy.context.scene.collection.objects.link(o)
o.data.transform(Matrix.Scale(r / size_, 4))
o.location = hub
# the pack's wheels are dished outward on +X: the ones on the other side face the other way
if hub.x < 0:
o.data.transform(Matrix.Scale(-1, 4, (1, 0, 0)))
o.data.flip_normals()
for o in list(old.values()):
bpy.data.objects.remove(o)
return dict(elev=18, azim=-42, dist_mul=0.8)
BUILDERS = {"SM_RiderMower": rider_mower, "SM_PushMower": push_mower}
if __name__ == "__main__":
args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
common.PREVIEWS = os.environ.get("GC_PREVIEWS", common.PREVIEWS)
for name in (args or list(BUILDERS)):
common.reset()
pv = BUILDERS[name]()
pv.pop("seat", None)
print(f"[{name}] tris={common.tri_count()}", flush=True)
common.export(name)
common.preview(name, **pv)
common.preview(name + "_back", **dict(pv, azim=150))