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>
93 lines
3.6 KiB
Python
93 lines
3.6 KiB
Python
"""GRASS CUTTER - the four mowing tools, re-themed from os_crew.py (same pivots, Nozzle / Fan / Fill / Plunger parts).
|
|
|
|
Each intake gets a serrated steel cutter ring with an orange trimmer-line band behind it, and the fan blades become
|
|
steel cutting blades, so the suction tools read as handheld vacuum mowers:
|
|
SM_Tool_HandPump = Clip-Vac, SM_Tool_SlurpGun = Weed Whacker, SM_Tool_HydroCannon = Mulch Cannon,
|
|
SM_Tool_MegaSiphon = Tornado Mower.
|
|
Run (from project root):
|
|
blender -b --factory-startup --python ArtSource/Blender/scripts/gc_crew.py -- [SM_Tool_HandPump ...]
|
|
"""
|
|
import sys, os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import os_crew as OC
|
|
from os_crew import * # noqa: F401,F403
|
|
|
|
|
|
def cutter_ring(nozzle, radius, teeth, depth):
|
|
"""Saw-tooth ring facing -Y at the nozzle: triangular teeth pointing forward, plus a trim-line band."""
|
|
P = []
|
|
c = Vector(nozzle)
|
|
for k in range(teeth):
|
|
a0 = 2 * math.pi * k / teeth
|
|
a1 = 2 * math.pi * (k + 1) / teeth
|
|
am = (a0 + a1) / 2
|
|
ring = lambda a, r: Vector((math.cos(a) * r, 0, math.sin(a) * r))
|
|
bm = bmesh.new()
|
|
t = radius * 0.08
|
|
vs = []
|
|
for rr in (radius - t, radius + t):
|
|
vs.append([bm.verts.new(c + ring(a0, rr)), bm.verts.new(c + ring(a1, rr)),
|
|
bm.verts.new(c + ring(am, rr) + Vector((0, -depth, 0)))])
|
|
bm.faces.new(vs[0]); bm.faces.new(list(reversed(vs[1])))
|
|
for i in range(3):
|
|
j = (i + 1) % 3
|
|
bm.faces.new((vs[0][i], vs[1][i], vs[1][j], vs[0][j]))
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
o = mesh_obj("tooth", bm)
|
|
set_mats(o, "M_Blade")
|
|
P.append(o)
|
|
band = torus("trim", radius * 1.02, max(0.004, radius * 0.07), loc=(0, 0, 0), axis="Y", seg=28, rseg=6, m="M_TrimLine")
|
|
band.location = c + Vector((0, depth * 0.35, 0))
|
|
P.append(band)
|
|
return P
|
|
|
|
|
|
def mower(builder, teeth=18, depth_k=0.32, radius=None):
|
|
def build():
|
|
res = builder()
|
|
sc = bpy.context.scene
|
|
body = sc.objects.get("Body")
|
|
noz = sc.objects.get("Nozzle")
|
|
bpy.context.view_layer.update()
|
|
n = noz.matrix_world.translation.copy()
|
|
r = radius
|
|
if r is None:
|
|
# radius of the intake lip: widest Body ring within 2 cm behind the nozzle
|
|
mw = body.matrix_world
|
|
r = 0.0
|
|
for v in body.data.vertices:
|
|
p = mw @ v.co
|
|
if 0.0 <= p.y - n.y < 0.02:
|
|
r = max(r, math.hypot(p.x - n.x, p.z - n.z))
|
|
r = max(r, 0.02)
|
|
P = cutter_ring(n, r * 0.98, teeth, max(0.012, r * depth_k))
|
|
for o in P:
|
|
OC.uv_box(o, 4.0)
|
|
cut = join(P, "Cutter")
|
|
smooth(cut, 30)
|
|
merged = join([body, cut], "Body")
|
|
fan = sc.objects.get("Fan")
|
|
if fan:
|
|
for i, m_ in enumerate(fan.data.materials):
|
|
if m_ and m_.name not in ("M_DarkGrey", "M_Steel"):
|
|
fan.data.materials[i] = mat("M_Blade")
|
|
print(f" cutter ring r={r:.3f} at {tuple(round(x, 3) for x in n)}")
|
|
return res
|
|
return build
|
|
|
|
|
|
BUILDERS = {
|
|
"SM_Tool_HandPump": mower(OC.tool_handpump, teeth=10, depth_k=0.6),
|
|
"SM_Tool_SlurpGun": mower(OC.tool_slurpgun, teeth=20),
|
|
"SM_Tool_HydroCannon": mower(OC.tool_hydrocannon, teeth=22),
|
|
"SM_Tool_MegaSiphon": mower(OC.tool_megasiphon, teeth=28),
|
|
}
|
|
|
|
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(hash(nm) & 0xffff)
|
|
r = BUILDERS[nm]() or {}
|
|
OC.finish_x(nm, r)
|