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>
1289 lines
71 KiB
Python
1289 lines
71 KiB
Python
"""GRASS CUTTER - model upgrade: the mowers and the robots, built to stand next to Synty's POLYGON Farm tractor and combine.
|
|
|
|
SM_PushMower big walk-behind cylinder mower, 1.35 m cut. Crew walks behind it. Body Fill Reel Bars Seat Intake Wake Wheel_*
|
|
SM_RiderMower ride-on garden tractor, 2 m cut, rear collector. Body Fill Reel Bars Seat Intake Wake Wheel_*
|
|
SM_MowerBar 2.8 m front mower for the pack tractor, final size, origin at the middle of the mounting frame. Body Reel
|
|
SM_RobotMower the little friendly dock robot, under 2 500 tris. Body Lamp
|
|
SM_Reaper the big autonomous harvester, 3 x 4 x 2.2 m, final size (no ReaperScale). Body Reel Muzzle Lamp
|
|
SM_RobotDock 3 x 3 m plank pad, lean-to shed, charging post. Body Lamp
|
|
|
|
Paint comes straight from the pack's atlas so the colours are the tractor's own. A material called P_<key> is a stand-in: pfin()
|
|
writes the UVs of that swatch or atlas region on its faces and swaps the slot for M_Pack, so a machine is nearly one draw call.
|
|
|
|
Authored in Blender space: metres, Z up, front = -Y (Unity +Z), Unity +X = Blender -X. Parts that move are loose objects with
|
|
their origin on their axle, Bars keeps its rotation so its local Z is the steering axis.
|
|
|
|
Run (absolute paths, the shell starts in another project):
|
|
blender -b --factory-startup --python D:/PROJECTS/LOCAL/GrassCutter/ArtSource/Blender/scripts/gc_up_machines.py -- [names]
|
|
Set GC_VIEWS=<dir> to also render review angles there with back faces culled, as Unity shows them.
|
|
"""
|
|
import sys, os, zlib
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import common
|
|
from gc_farm_machines import * # noqa: F401,F403 (helpers + material names)
|
|
|
|
TAU = 2 * math.pi
|
|
|
|
# flat atlas swatches: UV of a uniform patch, and the colour it shows (only used in the viewport before the swap)
|
|
SW = {
|
|
"RED": (.015, .046, "#944741"), "REDD": (.015, .036, "#793A35"), "DRED": (.0125, .067, "#772323"),
|
|
"WHITE": (.036, .045, "#DBDBDB"), "LGREY": (.036, .036, "#B8B8B8"), "CREAM": (.30, .38, "#BAB4AC"),
|
|
"CAB": (.0525, .041, "#495347"), "BLACK": (.0825, .041, "#25272A"), "DGREY": (.075, .067, "#454545"),
|
|
"G1": (.0125, .0275, "#5F6361"), "G2": (.03, .0275, "#7C817D"), "G3": (.0475, .0275, "#929993"),
|
|
"G4": (.0675, .0275, "#ABB2AC"), "G5": (.084, .0275, "#CCD1CE"),
|
|
"ORANGE": (.115, .191, "#EA7501"), "GOLD": (.215, .48, "#D1A44C"), "TERRA": (.051, .067, "#C6794E"),
|
|
"BROWN": (.455, .42, "#41261B"), "GRN": (.2575, .44, "#5B9853"), "GRND": (.2575, .41, "#456E3B"),
|
|
"CLIP": (.2575, .48, "#71AE5F"),
|
|
"RUSTA": (.4497, .49, "#8A5240"), "RUSTB": (.4497, .441, "#5A3226"),
|
|
}
|
|
# atlas regions: u0, v0, u1, v1
|
|
REG = {
|
|
"MUD": (.01, .505, .53, .745), # tractor red, dirt along the bottom edge: z = 0 lands in the dirt
|
|
"WORN": (.285, .03, .47, .385), # scratched pale paint
|
|
"PEEL": (.725, .51, .99, .98), # old red paint coming off in strips
|
|
"RUST": (.85, .08, .93, .19),
|
|
}
|
|
for k, v in SW.items():
|
|
common.MATDEFS["P_" + k] = {"name": "P_" + k, "color": v[2]}
|
|
for k in tuple(REG) + ("TYRE",):
|
|
common.MATDEFS["P_" + k] = {"name": "P_" + k, "color": "#944741"}
|
|
|
|
R_535 = (.474, .868, .528, .894)
|
|
R_3749 = (.461, .833, .529, .859)
|
|
R_52 = (.487, .797, .521, .821)
|
|
R_80 = (.487, .757, .521, .781)
|
|
R_VENT = (.450, .9136, .537, .986)
|
|
R_DEAD = (.1543, .867, .2728, .988)
|
|
|
|
|
|
# ======================================================================= paint
|
|
|
|
MUD_Z0 = [0.0] # where the ground is for the MUD paint
|
|
|
|
|
|
def pack_uv(o):
|
|
me = o.data
|
|
names = [m.name if m else "" for m in me.materials]
|
|
if not any(n.startswith("P_") for n in names):
|
|
return
|
|
bm = bmesh.new()
|
|
bm.from_mesh(me)
|
|
bm.normal_update()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
hw = o.get("hw", 0.1)
|
|
Ro = o.get("Ro", 0.4)
|
|
for f in bm.faces:
|
|
nm = names[f.material_index]
|
|
if not nm.startswith("P_"):
|
|
continue
|
|
key = nm[2:]
|
|
if key in SW:
|
|
for l in f.loops:
|
|
l[uvl].uv = SW[key][:2]
|
|
continue
|
|
if key == "TYRE":
|
|
# across the tyre the strip goes black, mud, black; around the tyre it wanders
|
|
ac = math.atan2(f.calc_center_median().z, f.calc_center_median().y)
|
|
for l in f.loops:
|
|
p = l.vert.co
|
|
a = math.atan2(p.z, p.y)
|
|
if a - ac > PI:
|
|
a -= TAU
|
|
elif ac - a > PI:
|
|
a += TAU
|
|
l[uvl].uv = (.071 + max(-1.0, min(1.0, p.x / hw)) * .068, .785 + (a + PI) / TAU * .19)
|
|
continue
|
|
u0, v0, u1, v1 = REG[key]
|
|
n = f.normal
|
|
ps = [l.vert.co for l in f.loops]
|
|
S = 0.25
|
|
if abs(n.z) > max(abs(n.x), abs(n.y)):
|
|
if key == "MUD": # upward faces stay clean red
|
|
for l in f.loops:
|
|
l[uvl].uv = SW["RED"][:2]
|
|
continue
|
|
aa, bb = [p.x for p in ps], [p.y for p in ps]
|
|
else:
|
|
aa = [p.y if abs(n.x) > abs(n.y) else p.x for p in ps]
|
|
bb = [p.z for p in ps]
|
|
spa = (max(aa) - min(aa)) * S
|
|
spb = (max(bb) - min(bb)) * S
|
|
k = min(1.0, (u1 - u0) / max(spa, 1e-6))
|
|
du = u0 + random.random() * max(0.0, (u1 - u0) - spa * k) - min(aa) * S * k
|
|
if key == "MUD":
|
|
for l, a, b in zip(f.loops, aa, bb):
|
|
l[uvl].uv = (a * S * k + du, min(v1, v0 + max(0.0, b - MUD_Z0[0]) * S))
|
|
else:
|
|
kb = min(1.0, (v1 - v0) / max(spb, 1e-6))
|
|
dv = v0 + random.random() * max(0.0, (v1 - v0) - spb * kb) - min(bb) * S * kb
|
|
for l, a, b in zip(f.loops, aa, bb):
|
|
l[uvl].uv = (a * S * k + du, b * S * kb + dv)
|
|
bm.to_mesh(me)
|
|
bm.free()
|
|
for i, n in enumerate(names):
|
|
if n.startswith("P_"):
|
|
me.materials[i] = mat("M_Pack")
|
|
|
|
|
|
def one_uv(o):
|
|
"""Blender 5 calls a layer made through bmesh "Float2": left alone, a join ends up with two UV sets and Unity reads the wrong one."""
|
|
me = o.data
|
|
if not me.uv_layers:
|
|
me.uv_layers.new(name="UVMap")
|
|
keep = me.uv_layers.active or me.uv_layers[0]
|
|
for l in [l for l in me.uv_layers if l.name != keep.name]:
|
|
me.uv_layers.remove(l)
|
|
me.uv_layers[0].name = "UVMap"
|
|
|
|
|
|
def pfin(P, name, ang=34, origin=None):
|
|
P = [o for o in P if o is not None]
|
|
for o in P:
|
|
uv_part(o)
|
|
pack_uv(o)
|
|
one_uv(o)
|
|
o = join(P, name)
|
|
smooth(o, ang)
|
|
if origin is not None:
|
|
set_origin(o, origin)
|
|
return o
|
|
|
|
|
|
# ======================================================================= shapes
|
|
|
|
def loft(rings, m, bev=0.0, name="loft"):
|
|
"""Closed solid through rings of points, all rings the same length."""
|
|
bm = bmesh.new()
|
|
R = [[bm.verts.new(p) for p in r] for r in rings]
|
|
n = len(R[0])
|
|
for a, b in zip(R, R[1:]):
|
|
for i in range(n):
|
|
j = (i + 1) % n
|
|
bm.faces.new((a[i], a[j], b[j], b[i]))
|
|
bm.faces.new(R[0])
|
|
bm.faces.new(list(reversed(R[-1])))
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
if bev <= 0:
|
|
bmesh.ops.triangulate(bm, faces=[f for f in bm.faces if len(f.verts) > 4], ngon_method="EAR_CLIP")
|
|
o = mesh_obj(name, bm)
|
|
set_mats(o, m)
|
|
if bev > 0:
|
|
be = o.modifiers.new("bev", "BEVEL")
|
|
be.width = bev
|
|
be.segments = 1
|
|
be.limit_method = "ANGLE"
|
|
be.angle_limit = math.radians(28)
|
|
bake(o)
|
|
return o
|
|
|
|
|
|
def px(prof, x0, x1, m, bev=0.0, name="px"):
|
|
"""(y, z) outline extruded along X."""
|
|
return loft([[(x0, y, z) for (y, z) in prof], [(x1, y, z) for (y, z) in prof]], m, bev, name)
|
|
|
|
|
|
def py(prof, y0, y1, m, bev=0.0, name="py"):
|
|
"""(x, z) outline extruded along Y."""
|
|
return loft([[(x, y0, z) for (x, z) in prof], [(x, y1, z) for (x, z) in prof]], m, bev, name)
|
|
|
|
|
|
def pz(prof, z0, z1, m, bev=0.0, name="pz"):
|
|
"""(x, y) outline extruded along Z."""
|
|
return loft([[(x, y, z0) for (x, y) in prof], [(x, y, z1) for (x, y) in prof]], m, bev, name)
|
|
|
|
|
|
def sec(y, hw, z0, z1, ch=0.06, cb=None, xo=0.0):
|
|
"""Eight-sided body section at y. ch top corner chamfer, cb bottom."""
|
|
cb = ch if cb is None else cb
|
|
return [(xo - hw + cb, y, z0), (xo + hw - cb, y, z0), (xo + hw, y, z0 + cb), (xo + hw, y, z1 - ch),
|
|
(xo + hw - ch, y, z1), (xo - hw + ch, y, z1), (xo - hw, y, z1 - ch), (xo - hw, y, z0 + cb)]
|
|
|
|
|
|
def arc(cy_, cz_, R, a0, a1, n):
|
|
return [(cy_ + R * math.cos(math.radians(a0 + (a1 - a0) * i / n)), cz_ + R * math.sin(math.radians(a0 + (a1 - a0) * i / n))) for i in range(n + 1)]
|
|
|
|
|
|
def fender(P, s, cy_, cz_, R, x0, x1, a0=170, a1=8, n=9, t=0.035, m="P_RED", band="P_WHITE"):
|
|
"""The pack's fender: a red arc over the tyre with a white band down the middle of it."""
|
|
xa, xb = sorted((s * x0, s * x1))
|
|
P.append(px(arc(cy_, cz_, R + t, a0, a1, n) + arc(cy_, cz_, R, a1, a0, n), xa, xb, m, name="fender"))
|
|
if band:
|
|
w = (x1 - x0) * 0.2
|
|
xm = (x0 + x1) / 2
|
|
xa, xb = sorted((s * (xm - w), s * (xm + w)))
|
|
P.append(px(arc(cy_, cz_, R + t + 0.006, a0, a1, n) + arc(cy_, cz_, R + t - 0.01, a1, a0, n), xa, xb, band, name="fenderband"))
|
|
|
|
|
|
def sb(s, x0, x1, y0, y1, z0, z1, m, bev=0.0, name="sb"):
|
|
"""Box mirrored by s = +-1."""
|
|
return bx(min(s * x0, s * x1), max(s * x0, s * x1), y0, y1, z0, z1, m, bev=bev, name=name)
|
|
|
|
|
|
def soft(pts, n=2):
|
|
"""Round a polyline off (Chaikin), for hoses and cables."""
|
|
pts = [Vector(p) for p in pts]
|
|
for _ in range(n):
|
|
out = [pts[0]]
|
|
for a, b in zip(pts, pts[1:]):
|
|
out += [a.lerp(b, .25), a.lerp(b, .75)]
|
|
out.append(pts[-1])
|
|
pts = out
|
|
return [tuple(p) for p in pts]
|
|
|
|
|
|
def bolt(P, p, n, r=0.016, m="P_G4"):
|
|
p, n = Vector(p), Vector(n).normalized()
|
|
P.append(cyl_between("bolt", p - n * 0.004, p + n * 0.012, r, m, v=6))
|
|
|
|
|
|
def decal(P, c, w, h, n, rect, flip=False):
|
|
"""A one-sided atlas sticker, a hair off the surface."""
|
|
c, n = Vector(c), Vector(n).normalized()
|
|
up = Vector((0, 0, 1)) if abs(n.z) < 0.9 else Vector((0, 1, 0))
|
|
r = up.cross(n).normalized()
|
|
up = n.cross(r)
|
|
vs = [c - r * w / 2 - up * h / 2, c + r * w / 2 - up * h / 2, c + r * w / 2 + up * h / 2, c - r * w / 2 + up * h / 2]
|
|
o = mesh_obj("decal", verts=[tuple(v) for v in vs], faces=[(0, 1, 2, 3)])
|
|
set_mats(o, "M_Pack")
|
|
uv = o.data.uv_layers.new(name="UVMap")
|
|
a, b = (rect[2], rect[0]) if flip else (rect[0], rect[2])
|
|
for i, q in enumerate(((a, rect[1]), (b, rect[1]), (b, rect[3]), (a, rect[3]))):
|
|
uv.data[i].uv = q
|
|
uv_keep(o)
|
|
P.append(o)
|
|
|
|
|
|
def star_badge(P, c, h, n):
|
|
"""The firm's badge: a white star on a dark red disc."""
|
|
c, n = Vector(c), Vector(n).normalized()
|
|
q = n.to_track_quat("Z", "Y")
|
|
disc = cz("badge", h * .5, -.004, .006, m="P_DRED", v=10)
|
|
pts = []
|
|
for k in range(10):
|
|
a = PI / 2 + k * PI / 5
|
|
r_ = h * (.40 if k % 2 == 0 else .165)
|
|
pts.append((r_ * math.cos(a), r_ * math.sin(a)))
|
|
star = pz(pts, .004, .010, "P_WHITE", name="star")
|
|
for o in (disc, star):
|
|
o.rotation_mode = "QUATERNION"
|
|
o.rotation_quaternion = q
|
|
o.location = c
|
|
apply_xform(o)
|
|
o.rotation_mode = "XYZ"
|
|
o.rotation_euler = (0, 0, 0)
|
|
P.append(o)
|
|
|
|
|
|
def rust(P, c, w, h, n, heart=True):
|
|
"""A jagged stain: a flat rusty blot, its darker heart pushed off centre so it never reads as an eye."""
|
|
c, n = Vector(c), Vector(n).normalized()
|
|
up = Vector((0, 0, 1)) if abs(n.z) < 0.9 else Vector((0, 1, 0))
|
|
r = up.cross(n).normalized()
|
|
up = n.cross(r)
|
|
N = 9
|
|
for key, sc, lift in (("P_RUSTA", 1.0, .002), ("P_RUSTB", .42, .004))[:2 if heart else 1]:
|
|
vs = []
|
|
o0 = (0.0, 0.0) if sc == 1.0 else (random.choice((-1, 1)) * random.uniform(.2, .4) * w / 2, -random.uniform(.15, .35) * h / 2)
|
|
for k in range(N):
|
|
a = TAU * k / N
|
|
q = random.uniform(.55, 1.0) * sc
|
|
vs.append(tuple(c + n * lift + r * (o0[0] + math.cos(a) * q * w / 2) + up * (o0[1] + math.sin(a) * q * h / 2)))
|
|
o = mesh_obj("rust", verts=vs, faces=[tuple(range(N))])
|
|
set_mats(o, key)
|
|
P.append(o)
|
|
|
|
|
|
def wheel(name, hub, R, W, out=1, lugs=12, sides=18, rs=10, rim="P_WHITE", bolts=5):
|
|
"""Pack-style tyre: black sidewall, chevron lugs, mud in the tread, white dished rim. Origin on the axle."""
|
|
hw = W / 2
|
|
Rc = R * 0.9 if lugs else R
|
|
t = revm("tyre", [(R * 0.62, -hw * 0.78), (R * 0.8, -hw), (Rc, -hw * 0.88), (Rc, hw * 0.88), (R * 0.8, hw), (R * 0.62, hw * 0.78)],
|
|
["P_BLACK", "P_BLACK", "P_TYRE", "P_BLACK", "P_BLACK"], segs=sides)
|
|
xf(t, ry=PI / 2)
|
|
t["hw"], t["Ro"] = hw, R
|
|
G = [t]
|
|
if lugs:
|
|
d = 0.42 * PI / lugs
|
|
slant = 1.3 * PI / lugs
|
|
for k in range(lugs):
|
|
for s in (-1, 1):
|
|
a = TAU * k / lugs + (PI / lugs if s > 0 else 0.0)
|
|
|
|
def ring(x, ao):
|
|
return [(x, r_ * math.cos(ao + da), r_ * math.sin(ao + da)) for (r_, da) in ((Rc * 0.985, -d), (Rc * 0.985, d), (R, d), (R, -d))]
|
|
lug = loft([ring(s * hw * 0.12, a), ring(s * hw * 1.03, a + slant)], "P_TYRE", name="lug")
|
|
lug["hw"], lug["Ro"] = hw, R
|
|
G.append(lug)
|
|
o_ = out
|
|
r = revm("rim", [(0, o_ * hw * 0.52), (R * 0.15, o_ * hw * 0.52), (R * 0.2, o_ * hw * 0.34), (R * 0.46, o_ * hw * 0.34), (R * 0.56, o_ * hw * 0.68),
|
|
(R * 0.64, o_ * hw * 0.8), (R * 0.64, -o_ * hw * 0.8), (0, -o_ * hw * 0.5)],
|
|
["P_G1", "P_G1", rim, rim, rim, "P_BLACK", "P_BLACK"], segs=rs)
|
|
G.append(xf(r, ry=PI / 2))
|
|
for k in range(bolts):
|
|
a = TAU * k / bolts
|
|
G.append(cx("nut", R * 0.035, o_ * hw * 0.32 - 0.01, o_ * hw * 0.32 + 0.012, R * 0.33 * math.cos(a), R * 0.33 * math.sin(a), "P_G2", v=4))
|
|
o = pfin(G, name, ang=38)
|
|
o.location = hub
|
|
return o
|
|
|
|
|
|
def reel(name, ctr, half, R, bats=5, twist=1.1, end="P_RED", blade="P_G5", n=6, mids=0, hooks=0, hook_m="P_G5"):
|
|
"""Cylinder mower reel across X, origin on its shaft. Helical bats, so it reads as turning."""
|
|
G = []
|
|
for k in range(bats):
|
|
a0 = TAU * k / bats
|
|
rings = []
|
|
for i in range(n + 1):
|
|
t = i / n
|
|
x = -half + 2 * half * t
|
|
a = a0 + twist * (t - 0.5)
|
|
|
|
def pt(r_, da):
|
|
return (x, r_ * math.cos(a + da), r_ * math.sin(a + da))
|
|
rings.append([pt(R, -0.03), pt(R, 0.05), pt(R * 0.7, 0.13), pt(R * 0.7, 0.03)])
|
|
G.append(loft(rings, blade, name="bat"))
|
|
for h in range(hooks):
|
|
t = (h + .5) / hooks
|
|
x = -half + 2 * half * t
|
|
a = a0 + twist * (t - .5)
|
|
w = half / hooks * .1
|
|
|
|
def hp(r_, da):
|
|
return (r_ * math.cos(a + da), r_ * math.sin(a + da))
|
|
G.append(px([hp(R * .9, -.14), hp(R * .9, .12), hp(R * 1.18, -.26)], x - w, x + w, hook_m, name="hook"))
|
|
G.append(cx("core", R * .5, -half, half, 0, 0, "P_BLACK", v=8))
|
|
st = [-half, half] + [(-half + 2 * half * (j + 1) / (mids + 1)) for j in range(mids)]
|
|
for x in st:
|
|
G.append(cx("spider", R * 0.82, x - 0.012, x + 0.012, 0, 0, end, v=bats * 2))
|
|
G.append(cx("shaft", R * 0.14, -half - 0.05, half + 0.05, 0, 0, "P_G2", v=8))
|
|
o = pfin(G, name, ang=30)
|
|
o.location = ctr
|
|
return o
|
|
|
|
|
|
def fill(x0, x1, y0, y1, z0, z1, lump=0.06, nx=5, ny=4, name="Fill"):
|
|
"""Heaped clippings. Origin at the bottom: Vehicle scales it on local Z."""
|
|
bm = bmesh.new()
|
|
T = []
|
|
for i in range(nx):
|
|
row = []
|
|
for j in range(ny):
|
|
edge = i in (0, nx - 1) or j in (0, ny - 1)
|
|
z = z1 - (0.5 * lump if edge else -random.uniform(0.1, 1.0) * lump)
|
|
row.append(bm.verts.new((x0 + (x1 - x0) * i / (nx - 1), y0 + (y1 - y0) * j / (ny - 1), z)))
|
|
T.append(row)
|
|
for i in range(nx - 1):
|
|
for j in range(ny - 1):
|
|
bm.faces.new((T[i][j], T[i + 1][j], T[i + 1][j + 1], T[i][j + 1]))
|
|
rim = [T[i][0] for i in range(nx)] + [T[nx - 1][j] for j in range(1, ny)] + [T[i][ny - 1] for i in range(nx - 2, -1, -1)] + [T[0][j] for j in range(ny - 2, 0, -1)]
|
|
low = [bm.verts.new((v.co.x, v.co.y, z0)) for v in rim]
|
|
for k in range(len(rim)):
|
|
j = (k + 1) % len(rim)
|
|
bm.faces.new((rim[k], rim[j], low[j], low[k]))
|
|
bm.faces.new(list(reversed(low)))
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
bmesh.ops.triangulate(bm, faces=[f for f in bm.faces if len(f.verts) > 4], ngon_method="EAR_CLIP")
|
|
o = mesh_obj(name, bm)
|
|
set_mats(o, "M_Clippings")
|
|
uv_box(o, 1.0)
|
|
one_uv(o)
|
|
flat(o)
|
|
set_origin(o, ((x0 + x1) / 2, (y0 + y1) / 2, z0))
|
|
return o
|
|
|
|
|
|
def shift_y(dy):
|
|
"""Slide the finished machine along Y so its footprint is centred on the origin."""
|
|
for o in bpy.context.scene.objects:
|
|
if o.type == "MESH" and o.location.length < 1e-6:
|
|
o.data.transform(Matrix.Translation((0, dy, 0)))
|
|
else:
|
|
o.location.y += dy
|
|
|
|
|
|
def beacon(P, x, y, z):
|
|
P.append(cz("beaconbase", 0.05, z, z + 0.03, x, y, "P_BLACK", v=8))
|
|
P.append(cz("beacon", 0.038, z + 0.03, z + 0.1, x, y, "P_ORANGE", v=8, r2=0.03))
|
|
|
|
|
|
def lamp_y(P, x, y, z, r, d=-1, glass="M_LightAmber", bez="P_BLACK"):
|
|
"""Round lamp looking along d * Y."""
|
|
a, b = sorted((y, y - d * 0.05))
|
|
P.append(cy("lampbez", r * 1.25, a, b, x, z, bez, v=10))
|
|
a, b = sorted((y + d * 0.008, y - d * 0.02))
|
|
P.append(cy("lamp", r, a, b, x, z, glass, v=10))
|
|
|
|
|
|
def jerrycan(P, x, y, z, m="P_RED", rz=0.0):
|
|
G = [bx(-0.09, 0.09, -0.05, 0.05, 0, 0.24, m, bev=0.01, name="can"), bx(-0.045, 0.045, -0.03, 0.03, 0.24, 0.27, m, name="canhandle"),
|
|
cz("cancap", 0.02, 0.24, 0.285, 0.06, 0, "P_G3", v=6)]
|
|
for o in G:
|
|
P.append(xf(o, rz=rz, t=(x, y, z)))
|
|
|
|
|
|
# ======================================================================= walk-behind mower
|
|
|
|
def push_mower():
|
|
P = []
|
|
Y0 = -0.70 # reel line
|
|
# the cutter unit: a wide arched hood open at the front and underneath, the reel shows through
|
|
hood = [(-.90, .365), (-.88, .405), (-.82, .45), (-.70, .48), (-.46, .48), (-.34, .40), (-.34, .12), (-.40, .12), (-.40, .38), (-.50, .425), (-.70, .425), (-.78, .40), (-.835, .365), (-.85, .345)]
|
|
P.append(px(hood, -.70, .70, "P_RED"))
|
|
arcs = hood[:6]
|
|
for xm in (-.47, -.36, .36, .47):
|
|
P.append(px([(y, z + .007) for (y, z) in arcs] + [(y, z - .02) for (y, z) in reversed(arcs)], xm - .04, xm + .04, "P_WHITE", name="stripe"))
|
|
# a lip of rubber along the mouth, and the bottom blade the reel shears against
|
|
P.append(bx(-.70, .70, -.915, -.865, .33, .375, "P_BLACK", name="lip"))
|
|
P.append(bx(-.70, .70, -.56, -.44, .055, .085, "P_G3", name="bedknife"))
|
|
plate = [(-.95, .05), (-.36, .05), (-.33, .42), (-.46, .50), (-.70, .50), (-.86, .46), (-.95, .34)]
|
|
for s in (-1, 1):
|
|
a, b = sorted((s * .70, s * .735))
|
|
P.append(px(plate, a, b, "P_MUD", name="sideplate"))
|
|
P.append(cx("bearing", .07, min(s * .735, s * .75), max(s * .735, s * .75), Y0, .20, "P_G1", v=10))
|
|
P.append(cx("bearingcap", .035, min(s * .75, s * .765), max(s * .75, s * .765), Y0, .20, "P_G4", v=6))
|
|
for k in range(4):
|
|
a_ = PI / 4 + k * PI / 2
|
|
bolt(P, (s * .75, Y0 + .05 * math.cos(a_), .20 + .05 * math.sin(a_)), (s, 0, 0), r=.009)
|
|
bolt(P, (s * .735, -.5, .40), (s, 0, 0))
|
|
bolt(P, (s * .735, -.42, .15), (s, 0, 0))
|
|
# bracket for the gauge wheel
|
|
P.append(sb(s, .735, .79, -.70, -.60, .29, .34, "P_G1", name="gaugearm"))
|
|
P.append(sb(s, .775, .805, -.68, -.62, .17, .33, "P_G1", name="gaugepost"))
|
|
P.append(cx("roller", .065, -.68, .68, -.42, .07, "P_G1", v=10))
|
|
star_badge(P, (0, -.80, .462), .15, (0, -.42, .91))
|
|
lamp_y(P, .24, -.885, .425, .032)
|
|
lamp_y(P, -.24, -.885, .425, .032)
|
|
|
|
# chassis
|
|
for s in (-1, 1):
|
|
P.append(px([(-.42, .22), (.52, .22), (.52, .34), (-.42, .34)], min(s * .30, s * .36), max(s * .30, s * .36), "P_G1", name="rail"))
|
|
P.append(bx(-.40, .40, -.40, .46, .34, .38, "P_DGREY", bev=.01, name="engineplate"))
|
|
P.append(cx("axle", .035, -.46, .46, .12, .30, "P_G1", v=8))
|
|
# chain case on one side, with a small rust stain
|
|
P.append(px([(-.2, .24), (.08, .22), (.17, .30), (.08, .38), (-.2, .34)], .37, .40, "P_CREAM", name="chaincase"))
|
|
for y in (-.14, 0.02):
|
|
bolt(P, (.40, y, .30), (1, 0, 0), r=.011)
|
|
rust(P, (.402, -.08, .27), .12, .07, (1, 0, 0))
|
|
# mudguards over the drive wheels: the pack's own fender
|
|
for s in (-1, 1):
|
|
fender(P, s, .12, .30, .335, .405, .60, a0=165, a1=10, n=7, t=.025)
|
|
P.append(sb(s, .385, .405, .02, .22, .34, .50, "P_G1", name="guardbracket"))
|
|
|
|
# the petrol engine
|
|
P.append(py([(-.2, .38), (.2, .38), (.24, .46), (.2, .60), (-.2, .60), (-.24, .46)], -.24, .12, "P_G1", name="crankcase"))
|
|
P.append(cz("blower", .23, .60, .72, 0, -.06, "P_REDD", v=14, bev=.012))
|
|
P.append(cz("blowerrim", .24, .625, .645, 0, -.06, "P_BLACK", v=14))
|
|
P.append(cz("startdome", .13, .72, .77, 0, -.06, "P_G4", v=10, r2=.10))
|
|
# pull-start handle and cord lying over the dome
|
|
P.append(ptube("cord", [(.0, -.06, .775), (.05, .02, .79), (.05, .10, .76)], .004, "P_BLACK", segs=4))
|
|
P.append(bx(.0, .10, .095, .125, .745, .775, "P_BLACK", name="pullgrip"))
|
|
# fuel tank, like the tractor's bonnet in small
|
|
P.append(loft([sec(-.40, .17, .60, .74, .04), sec(-.30, .19, .58, .78, .05), sec(-.18, .19, .58, .78, .05)], "P_RED", name="tank"))
|
|
P.append(bx(-.195, .195, -.31, -.27, .584, .784, "P_WHITE", name="tankband"))
|
|
P.append(cz("fuelcap", .04, .78, .815, .08, -.24, "P_WHITE", v=8))
|
|
P.append(bx(.07, .09, -.28, -.2, .815, .826, "P_BLACK", name="capbail"))
|
|
# the finned cylinder sticking out to the left, the plug lead and the silencer
|
|
for k in range(5):
|
|
x = -.25 - k * .036
|
|
P.append(bx(x - .012, x + .012, -.17, .09, .39, .59, "P_G2", name="fin"))
|
|
P.append(cx("head", .06, -.455, -.39, -.04, .49, "P_G1", v=8))
|
|
P.append(ptube("plug", soft([(-.455, -.04, .49), (-.47, .03, .62), (-.3, -.1, .72), (-.14, -.18, .73)]), .007, "P_RED", segs=4))
|
|
P.append(cy("silencer", .075, -.42, -.06, -.33, .30, "P_G3", v=8))
|
|
P.append(ptube("tail", [(-.33, -.42, .30), (-.33, -.5, .32), (-.4, -.54, .4)], .022, "P_G1", segs=6))
|
|
P.append(cx("airfilter", .08, .24, .32, -.1, .52, "P_BLACK", v=8))
|
|
P.append(cx("airfiltercap", .055, .32, .335, -.1, .52, "P_G3", v=8))
|
|
P.append(ptube("airhose", [(.24, -.1, .52), (.19, -.2, .57)], .022, "P_BLACK", segs=6))
|
|
|
|
# the throw duct: galvanised, from the hood over the wheel into the hopper
|
|
rings = []
|
|
for (y, z, x) in ((-.36, .46, .30), (-.20, .56, .30), (.04, .68, .30), (.28, .76, .28), (.50, .79, .24)):
|
|
rings.append([(x - .085, y, z - .07), (x + .085, y, z - .07), (x + .085, y, z + .07), (x - .085, y, z + .07)])
|
|
P.append(loft(rings, "P_G3", name="duct"))
|
|
for (y, z) in ((-.2, .56), (.28, .76)):
|
|
P.append(bx(.20, .40, y - .02, y + .02, z - .085, z + .085, "P_G1", name="ductband"))
|
|
|
|
# the hopper: red below, open slats above so the level shows
|
|
Xh, Y0h, Y1h, Zf, Zt = .44, .50, 1.02, .30, .76
|
|
P.append(bx(-Xh, Xh, Y0h, Y1h, Zf, Zf + .03, "P_G1", name="floor"))
|
|
for s in (-1, 1):
|
|
P.append(sb(s, Xh - .03, Xh, Y0h, Y1h, Zf + .03, .50, "P_MUD", name="panel"))
|
|
for z in (.565, .635, .705):
|
|
P.append(sb(s, Xh - .025, Xh, Y0h, Y1h, z - .018, z + .018, "P_G2", name="slat"))
|
|
P.append(bx(-Xh, Xh, Y1h - .03, Y1h, Zf + .03, .50, "P_MUD", name="panel"))
|
|
P.append(bx(-Xh, Xh, Y0h, Y0h + .03, Zf + .03, .50, "P_RED", name="panel"))
|
|
for z in (.565, .635, .705):
|
|
P.append(bx(-Xh, Xh, Y1h - .025, Y1h, z - .018, z + .018, "P_G2", name="slat"))
|
|
P.append(bx(-Xh, Xh, Y0h, Y0h + .025, z - .018, z + .018, "P_G2", name="slat"))
|
|
for sx in (-1, 1):
|
|
for y in (Y0h, Y1h):
|
|
P.append(bx(sx * (Xh + .005) - .025, sx * (Xh + .005) + .025, y - .025, y + .025, Zf, Zt + .03, "P_G1", name="post"))
|
|
for s in (-1, 1):
|
|
P.append(sb(s, Xh - .02, Xh + .015, Y0h - .015, Y1h + .015, Zt, Zt + .04, "P_WHITE", name="rimside"))
|
|
for y in (Y0h, Y1h):
|
|
P.append(bx(-Xh - .015, Xh + .015, y - .015, y + .02, Zt, Zt + .04, "P_WHITE", name="rimend"))
|
|
P.append(bx(-.30, .30, Y1h, Y1h + .012, .36, .47, "P_WHITE", name="backstripe"))
|
|
decal(P, (0, Y1h + .014, .415), .24, .09, (0, 1, 0), R_52)
|
|
# a dent, a rust stain, latches on the tailboard and a sack thrown over one side
|
|
rust(P, (Xh + .002, .9, .39), .18, .12, (1, 0, 0))
|
|
rust(P, (-Xh - .002, .62, .42), .1, .09, (-1, 0, 0))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * .33 - .03, s * .33 + .03, Y1h + .012, Y1h + .03, .28, .44, "P_G1", name="latch"))
|
|
for o in (px([(.70, .80), (.92, .80), (.94, .79), (.93, .58), (.86, .54), (.74, .57), (.68, .78)], -Xh - .024, -Xh - .008, "M_Burlap", name="sackside"),
|
|
px([(.70, .805), (.92, .805), (.92, .79), (.70, .79)], -Xh - .02, -Xh + .08, "M_Burlap", name="sacktop")):
|
|
uv_box(o, 3.5)
|
|
P.append(uv_keep(o))
|
|
|
|
# the long handles: two tubes up out of the chassis, over the hopper, drawing together at the stem
|
|
for s in (-1, 1):
|
|
P.append(ptube("handle", [(s * .33, .32, .36), (s * .33, .40, .62), (s * .31, .46, .84), (s * .24, .72, .88), (s * .05, 1.10, .92)], .024, "P_G2", segs=6))
|
|
P.append(ptube("handlebrace", [(-.27, .66, .87), (.27, .66, .87)], .016, "P_G2", segs=6))
|
|
P.append(cy("stemsock", .034, 1.06, 1.14, 0, .925, "P_BLACK", v=8))
|
|
# a coil of rope hung on the handle and a little jerrycan clamped to it
|
|
P.append(torus("hanky", .075, .012, (.29, .55, .78), "X", seg=10, rseg=4, m=ROPE))
|
|
jerrycan(P, -.33, .36, .42, m="P_RED", rz=PI / 2)
|
|
P.append(bx(-.33 - .09, -.33 + .09, .31, .41, .39, .42, "P_G1", name="canstand"))
|
|
pfin(P, "Body")
|
|
|
|
fill(-Xh + .035, Xh - .035, Y0h + .035, Y1h - .035, Zf + .03, Zt - .01, lump=.05)
|
|
reel("Reel", (0, Y0, .20), .675, .17, bats=5)
|
|
|
|
# Bars: a T on a stem, local Z runs up the stem and it swivels like a bicycle's
|
|
G = [cz("stem", .024, 0.0, .14, m="P_G2", v=8)]
|
|
G.append(ptube("crossbar", [(-.40, .05, .17), (-.30, .02, .16), (-.08, .0, .14), (.08, .0, .14), (.30, .02, .16), (.40, .05, .17)], .019, "P_G2", segs=6))
|
|
for s in (-1, 1):
|
|
G.append(ptube("grip", [(s * .29, .018, .158), (s * .405, .052, .172)], .027, "P_BLACK", segs=6))
|
|
G.append(ptube("lever", [(s * .1, -.03, .14), (s * .2, -.075, .135), (s * .32, -.05, .155)], .008, "P_G5", segs=4))
|
|
G.append(bx(-.06, .06, -.04, .04, .115, .17, "P_RED", name="throttlebox"))
|
|
G.append(cy("throttledial", .018, -.052, -.04, .0, .145, "M_GaugeFace", v=8))
|
|
G.append(ptube("cable", [(.05, .03, .12), (.1, .08, .02), (.08, .0, -.2)], .006, "P_BLACK", segs=4))
|
|
o = pfin(G, "Bars", ang=45)
|
|
o.rotation_euler = (math.radians(-28), 0, 0)
|
|
o.location = (0, 1.14, .925)
|
|
|
|
wheel("Wheel_FL", (.815, -.65, .15), .15, .09, out=1, lugs=0, sides=14, rs=10, bolts=3)
|
|
wheel("Wheel_FR", (-.815, -.65, .15), .15, .09, out=-1, lugs=0, sides=14, rs=10, bolts=3)
|
|
wheel("Wheel_RL", (.50, .12, .30), .30, .17, out=1, lugs=10, sides=16, rs=12)
|
|
wheel("Wheel_RR", (-.50, .12, .30), .30, .17, out=-1, lugs=10, sides=16, rs=12)
|
|
empty("Intake", (0, Y0, 0))
|
|
empty("Wake", (0, 1.08, .1))
|
|
empty("Seat", (0, 1.62, .15)) # feet = seat - 0.15: the crew stand on the ground behind the handles
|
|
shift_y(-.12)
|
|
return dict(elev=24, azim=-40)
|
|
|
|
|
|
# ======================================================================= garden tractor
|
|
|
|
def rider_mower():
|
|
P = []
|
|
RY, RZ, RR = -.60, .19, .165 # reel
|
|
# chassis: two pressed rails that step up over the cutter
|
|
rail = [(-1.60, .30), (-.98, .30), (-.86, .44), (.30, .44), (.40, .34), (1.40, .34), (1.40, .46), (.45, .46), (.34, .54), (-.82, .54), (-.94, .44), (-1.60, .44)]
|
|
for s in (-1, 1):
|
|
P.append(px(rail, min(s * .22, s * .30), max(s * .22, s * .30), "P_G1", name="rail"))
|
|
# the bonnet: the tractor's in small, tapered, with a flat top and big chamfers
|
|
P.append(loft([sec(-1.66, .27, .54, .86, .07), sec(-1.58, .30, .52, .92, .08), sec(-.86, .35, .52, 1.0, .10), sec(-.44, .37, .52, 1.02, .10)], "P_RED", name="bonnet"))
|
|
# white band round the waist of the bonnet, like the combine's
|
|
P.append(loft([sec(-1.585, .305, .615, .695, .0), sec(-.44, .376, .615, .695, .0)], "P_WHITE", name="waist"))
|
|
# engine bay below the bonnet, the grey lump the pack tractor shows
|
|
P.append(bx(-.24, .24, -1.42, -.5, .38, .54, "P_G4", bev=.012, name="block"))
|
|
# the nose: dark grille, slats, a radiator cap, lamps, a badge
|
|
P.append(py([(-.24, .58), (.24, .58), (.21, .82), (-.21, .82)], -1.69, -1.655, "P_BLACK", name="grille"))
|
|
for k in range(5):
|
|
z = .60 + k * .045
|
|
P.append(bx(-.215 + k * .004, .215 - k * .004, -1.70, -1.685, z, z + .02, "P_G3", name="slat"))
|
|
star_badge(P, (0, -1.70, .855), .09, (0, -.12, 1))
|
|
for s in (-1, 1):
|
|
lamp_y(P, s * .225, -1.67, .47, .04)
|
|
P.append(sb(s, .20, .25, -1.66, -1.5, .44, .50, "P_BLACK", name="lamparm"))
|
|
# side vents on the bonnet
|
|
for s in (-1, 1):
|
|
for k in range(4):
|
|
y = -1.28 + k * .1
|
|
P.append(sb(s, .335, .362, y, y + .055, .735, .905, "P_BLACK", name="vent"))
|
|
decal(P, (s * .378, -.72, .655), .17, .065, (s, 0, 0), R_535)
|
|
P.append(cz("radcap", .035, .985, 1.02, 0, -.92, "P_G4", v=8))
|
|
# exhaust stack with a flap, and its heat wrap
|
|
P.append(cz("stackfoot", .05, .96, 1.04, -.2, -1.0, "P_BLACK", v=8))
|
|
P.append(cz("stack", .032, 1.02, 1.48, -.2, -1.0, "P_G3", v=8))
|
|
P.append(cz("stackwrap", .042, 1.08, 1.24, -.2, -1.0, "P_DGREY", v=8))
|
|
P.append(xf(cz("flap", .04, -.006, .006, 0, 0, "P_BLACK", v=8), ry=-.35, t=(-.205, -1.0, 1.49)))
|
|
# front axle, bumper bar and a tow eye
|
|
P.append(cx("frontaxle", .04, -.46, .46, -1.22, .30, "P_G1", v=8))
|
|
P.append(ptube("bumper", [(-.34, -1.60, .40), (-.34, -1.76, .40), (.34, -1.76, .40), (.34, -1.60, .40)], .03, "P_G1", segs=6))
|
|
P.append(bx(-.34, .34, -1.79, -1.72, .34, .46, "P_DGREY", bev=.012, name="noseweight"))
|
|
# the operator's floor, ribbed, with a step each side
|
|
P.append(bx(-.44, .44, -.46, .22, .54, .58, "P_BLACK", bev=.008, name="floor"))
|
|
for k in range(5):
|
|
y = -.4 + k * .13
|
|
P.append(bx(-.40, .40, y, y + .03, .58, .59, "P_DGREY", name="floorrib"))
|
|
for s in (-1, 1):
|
|
P.append(sb(s, .42, .54, -.3, .1, .36, .385, "P_G1", name="step"))
|
|
P.append(sb(s, .42, .445, -.28, -.24, .385, .56, "P_G1", name="stepstrut"))
|
|
P.append(sb(s, .42, .445, .04, .08, .385, .56, "P_G1", name="stepstrut"))
|
|
# dash and steering
|
|
P.append(loft([sec(-.46, .25, .60, 1.04, .06), sec(-.34, .19, .62, 1.0, .05)], "P_CAB", name="dash"))
|
|
P.append(cyl_between("column", (0, -.42, .90), (0, -.29, 1.08), .03, "P_BLACK", v=8))
|
|
for x, r_ in ((-.1, .036), (.1, .036)):
|
|
P.append(cyl_between("gauge", (x, -.338, .94), (x, -.33, .955), r_, "P_BLACK", v=10))
|
|
P.append(cyl_between("gaugeface", (x, -.33, .955), (x, -.326, .962), r_ * .8, "M_GaugeFace", v=10))
|
|
P.append(ptube("lever", [(.28, .02, .58), (.32, .0, .78)], .012, "P_BLACK", segs=4))
|
|
P.append(cz("leverknob", .022, .78, .82, .325, 0, "P_RED", v=6))
|
|
|
|
# the seat on a red box, with a sprung post
|
|
P.append(bx(-.26, .26, .02, .50, .54, .68, "P_RED", bev=.02, name="seatbox"))
|
|
P.append(cz("seatpost", .1, .68, .74, 0, .24, "P_BLACK", v=8))
|
|
P.append(px([(.02, .74), (.44, .74), (.46, .80), (.42, .84), (.06, .84), (.0, .80)], -.25, .25, "P_DGREY", bev=.012, name="cushion"))
|
|
P.append(loft([sec(.42, .24, .80, 1.14, .05), sec(.50, .24, .84, 1.18, .05)], "P_DGREY", name="backrest"))
|
|
P.append(bx(-.2, .2, .39, .405, .86, 1.10, "P_BLACK", name="seatpanel"))
|
|
# rear fenders with the white band
|
|
for s in (-1, 1):
|
|
fender(P, s, .72, .44, .50, .38, .76, a0=178, a1=-6, n=10)
|
|
P.append(sb(s, .36, .395, .1, .46, .56, .97, "P_G1", name="fenderstay"))
|
|
P.append(cx("rearaxle", .05, -.42, .42, .72, .44, "P_G1", v=8))
|
|
P.append(bx(-.2, .2, .55, .9, .34, .56, "P_G4", bev=.012, name="transaxle"))
|
|
|
|
# the cutter under the belly: wide arched hood, the reel in its mouth, 2 m of cut
|
|
hood = [(-.78, .345), (-.76, .385), (-.70, .42), (-.60, .43), (.10, .43), (.22, .36), (.22, .10), (.15, .10), (.15, .35), (.05, .385), (-.60, .385), (-.66, .375), (-.715, .335), (-.73, .325)]
|
|
P.append(px(hood, -1.04, 1.04, "P_RED"))
|
|
arcs = hood[:6]
|
|
for xm in (-.74, .74):
|
|
P.append(px([(y, z + .007) for (y, z) in arcs] + [(y, z - .02) for (y, z) in reversed(arcs)], xm - .13, xm + .13, "P_WHITE", name="stripe"))
|
|
P.append(bx(-1.04, 1.04, -.795, -.745, .31, .35, "P_BLACK", name="lip"))
|
|
P.append(bx(-1.04, 1.04, -.46, -.34, .055, .085, "P_G3", name="bedknife"))
|
|
plate = [(-.84, .05), (.24, .05), (.26, .36), (.10, .45), (-.60, .45), (-.74, .42), (-.84, .32)]
|
|
for s in (-1, 1):
|
|
a, b = sorted((s * 1.04, s * 1.08))
|
|
P.append(px(plate, a, b, "P_MUD", name="deckend"))
|
|
P.append(cx("bearing", .075, min(s * 1.08, s * 1.095), max(s * 1.08, s * 1.095), RY, RZ, "P_G1", v=10))
|
|
for y, z in ((-.2, .36), (.1, .3), (.0, .12), (-.74, .33)):
|
|
bolt(P, (s * 1.08, y, z), (s, 0, 0))
|
|
P.append(px([(-.1, .0), (.14, .0), (.2, .06), (-.16, .06)], min(s * 1.0, s * 1.06), max(s * 1.0, s * 1.06), "P_G3", name="skid"))
|
|
# hangers from the frame to the deck
|
|
P.append(ptube("hanger", [(s * .34, -.72, .40), (s * .34, -.72, .50)], .022, "P_G3", segs=6))
|
|
P.append(ptube("hanger", [(s * .34, .04, .40), (s * .34, .04, .52)], .022, "P_G3", segs=6))
|
|
# drive housing on the deck, a warning stripe at the end and a stain
|
|
P.append(bx(.40, .94, -.42, .02, .42, .455, "P_CREAM", bev=.012, name="beltguard"))
|
|
for x in (.48, .86):
|
|
P.append(cz("beltboss", .05, .455, .475, x, -.2, "P_G2", v=8))
|
|
P.append(cz("drivebox", .10, .42, .50, -.52, -.2, "P_G1", v=8))
|
|
rust(P, (-.82, -.38, .422), .22, .14, (0, 0, 1))
|
|
|
|
# the blower tube from the deck end up round the fender into the hopper: the thing that says collector
|
|
tube_pts = [(.86, .06, .42), (.88, .12, .62), (.88, .22, .90), (.82, .40, 1.14), (.74, .62, 1.30), (.60, .86, 1.40)]
|
|
P.append(ptube("blowtube", tube_pts, .10, "P_G4", segs=8))
|
|
P.append(bx(.76, .96, -.04, .16, .40, .46, "P_G1", name="blowfoot"))
|
|
for t in (1, 3, 4):
|
|
d = Vector(tube_pts[t + 1 if t < 5 else t]) - Vector(tube_pts[t - 1])
|
|
P.append(cyl_between("tubeband", Vector(tube_pts[t]) - d.normalized() * .018, Vector(tube_pts[t]) + d.normalized() * .018, .112, "P_G1", v=8))
|
|
|
|
# the collector: a big steel bin on two hoops above the rear axle, open slats up top so the load shows
|
|
X, Y0, Y1, Zf, Zt = .66, .62, 1.72, .98, 1.70
|
|
P.append(bx(-X, X, Y0, Y1, Zf - .05, Zf, "P_G1", name="binfloor"))
|
|
for s in (-1, 1):
|
|
P.append(sb(s, X - .04, X, Y0, Y1, Zf, 1.32, "P_RED", name="binwall"))
|
|
P.append(sb(s, X, X + .008, Y0 + .04, Y1 - .04, 1.15, 1.21, "P_WHITE", name="binband"))
|
|
for z in (1.40, 1.50, 1.60):
|
|
P.append(sb(s, X - .03, X, Y0, Y1, z - .022, z + .022, "P_G2", name="binslat"))
|
|
P.append(sb(s, X - .05, X + .02, Y0 - .02, Y1 + .02, Zt - .01, Zt + .05, "P_WHITE", bev=.008, name="binrim"))
|
|
for y in (Y0, (Y0 + Y1) / 2, Y1):
|
|
P.append(bx(s * (X + .006) - .03, s * (X + .006) + .03, y - .03, y + .03, Zf - .05, Zt, "P_G1", name="binpost"))
|
|
# hoops down to the chassis behind the wheels
|
|
P.append(beam((s * .36, 1.30, .46), (s * .55, 1.30, Zf - .05), .06, .06, m="P_G1", bev=0, name="binleg"))
|
|
P.append(beam((s * .34, .50, .50), (s * .40, .66, Zf - .05), .06, .06, m="P_G1", bev=0, name="binleg"))
|
|
# tip rams at the back
|
|
P.append(cyl_between("ram", (s * .28, 1.36, .44), (s * .34, 1.5, .72), .04, "P_BLACK", v=8))
|
|
P.append(cyl_between("ramrod", (s * .34, 1.5, .72), (s * .38, 1.6, .93), .02, "P_G5", v=6))
|
|
for y0, y1 in ((Y0, Y0 + .04), (Y1 - .04, Y1)):
|
|
P.append(bx(-X, X, y0, y1, Zf, 1.32, "P_RED", name="binend"))
|
|
for z in (1.40, 1.50, 1.60):
|
|
P.append(bx(-X, X, y0 + .005, y1 - .005, z - .022, z + .022, "P_G2", name="binslat"))
|
|
P.append(bx(-X - .02, X + .02, y0 - .02, y1 + .02, Zt - .01, Zt + .05, "P_WHITE", bev=.008, name="binrim"))
|
|
# tailgate furniture
|
|
P.append(bx(-.56, .56, Y1, Y1 + .012, 1.03, 1.28, "P_WHITE", name="tailplate"))
|
|
decal(P, (0, Y1 + .014, 1.155), .42, .165, (0, 1, 0), R_3749)
|
|
for s in (-1, 1):
|
|
P.append(bx(s * .46 - .04, s * .46 + .04, Y1 + .012, Y1 + .04, 1.28, 1.42, "P_G1", name="gatelatch"))
|
|
P.append(bx(s * .6 - .05, s * .6 + .05, Y1, Y1 + .02, 1.02, 1.1, "M_LightRed", name="taillamp"))
|
|
P.append(cy("hinge", .03, Y1, Y1 + .05, s * .3, 1.66, "P_G1", v=6))
|
|
rust(P, (X + .002, 1.42, 1.08), .32, .15, (1, 0, 0))
|
|
rust(P, (-X - .002, .86, 1.24), .2, .12, (-1, 0, 0))
|
|
beacon(P, .54, .68, Zt + .05)
|
|
P.append(cyl_between("aerial", (-.58, .66, Zt + .05), (-.62, .70, Zt + .58), .006, "P_BLACK", v=4))
|
|
# spare jerrycan on the fender and a coil of rope on the step, a little of the crew's life
|
|
jerrycan(P, -.60, .28, .385, m="P_G1")
|
|
P.append(torus("coil", .1, .016, (.48, -.16, .405), "Z", seg=12, rseg=4, m=ROPE))
|
|
pfin(P, "Body")
|
|
|
|
fill(-X + .045, X - .045, Y0 + .045, Y1 - .045, Zf, Zt - .03, lump=.07, nx=6, ny=5)
|
|
reel("Reel", (0, RY, RZ), 1.01, RR, bats=5, mids=1)
|
|
|
|
# steering wheel, local Z = the column
|
|
G = [torus("rim", .16, .017, (0, 0, 0), "Z", seg=14, rseg=4, m="P_BLACK")]
|
|
for k in range(3):
|
|
a = TAU * k / 3 + PI / 2
|
|
G.append(cyl_between("spoke", (0, 0, 0), (.16 * math.cos(a), .16 * math.sin(a), 0), .012, "P_G3", v=4))
|
|
G.append(cz("boss", .04, -.02, .025, m="P_RED", v=8))
|
|
o = pfin(G, "Bars", ang=50)
|
|
o.rotation_euler = (math.radians(-36), 0, 0)
|
|
o.location = (0, -.285, 1.09)
|
|
|
|
wheel("Wheel_FL", (.50, -1.22, .30), .30, .20, out=1, lugs=9, sides=14)
|
|
wheel("Wheel_FR", (-.50, -1.22, .30), .30, .20, out=-1, lugs=9, sides=14)
|
|
wheel("Wheel_RL", (.58, .72, .44), .44, .30, out=1, lugs=12, sides=16, rs=10, bolts=5)
|
|
wheel("Wheel_RR", (-.58, .72, .44), .44, .30, out=-1, lugs=12, sides=16, rs=10, bolts=5)
|
|
empty("Intake", (0, RY, 0))
|
|
empty("Wake", (0, 1.82, .1))
|
|
empty("Seat", (0, .22, .98)) # same habit as the old rider: seat surface + 0.14
|
|
return dict(elev=24, azim=-40)
|
|
|
|
|
|
# ======================================================================= front mower for the pack tractor
|
|
|
|
def mower_bar():
|
|
"""The origin is the mounting frame: the tractor's nose (y -1.90, z 0.55 on the 0.75 scale tractor). Ground is at z = -0.55."""
|
|
G0 = -.55
|
|
MUD_Z0[0] = G0
|
|
P = []
|
|
RY, RZ, RR = -1.02, G0 + .22, .20
|
|
HW = 1.40
|
|
# the mounting frame on the tractor's nose: plate, top link lugs, lower hooks
|
|
P.append(py([(-.42, -.30), (.42, -.30), (.46, -.24), (.46, .22), (.36, .32), (-.36, .32), (-.46, .22), (-.46, -.24)], -.07, .03, "P_DGREY", name="mountplate"))
|
|
P.append(py([(-.34, -.20), (.34, -.20), (.34, .22), (-.34, .22)], -.085, -.07, "P_RED", name="mountface"))
|
|
for s in (-1, 1):
|
|
for z in (-.2, .0, .2):
|
|
bolt(P, (s * .40, -.07, z), (0, -1, 0), r=.016)
|
|
P.append(sb(s, .22, .30, -.26, -.07, -.31, -.19, "P_G1", name="lowerhook"))
|
|
P.append(cx("hookpin", .03, min(s * .20, s * .32), max(s * .20, s * .32), -.2, -.25, "P_G4", v=6))
|
|
P.append(sb(s, .07, .11, -.24, -.07, .17, .31, "P_G1", name="toplug"))
|
|
# the two lift arms, box section, out to the main beam
|
|
P.append(loft([sec(-.08, .05, -.17, .05, .012, xo=s * .30), sec(-.66, .06, -.33, -.09, .012, xo=s * .52)], "P_RED", name="liftarm"))
|
|
# hydraulic ram with a bright rod and a hose
|
|
P.append(cyl_between("ram", (s * .16, -.10, .22), (s * .30, -.40, .06), .045, "P_BLACK", v=8))
|
|
P.append(cyl_between("ramrod", (s * .30, -.40, .06), (s * .42, -.62, -.09), .022, "P_G5", v=6))
|
|
P.append(ptube("hose", soft([(s * .17, -.12, .27), (s * .24, -.2, .36), (s * .3, -.34, .20), (s * .30, -.38, .10)]), .011, "P_BLACK", segs=4))
|
|
P.append(cyl_between("toplink", (0, -.2, .24), (0, -.68, -.02), .035, "P_G2", v=8))
|
|
# the main beam across the back of the hood
|
|
P.append(loft([sec(-.72, HW - .06, G0 + .30, G0 + .50, .03)[:], sec(-.56, HW - .06, G0 + .30, G0 + .50, .03)], "P_DGREY", name="mainbeam"))
|
|
|
|
# the hood: one long arch, wider than the cut
|
|
hood = [(-1.30, G0 + .425), (-1.28, G0 + .47), (-1.20, G0 + .53), (-1.03, G0 + .56), (-.72, G0 + .56), (-.60, G0 + .47), (-.60, G0 + .10), (-.67, G0 + .10),
|
|
(-.67, G0 + .45), (-.74, G0 + .50), (-1.03, G0 + .50), (-1.14, G0 + .475), (-1.22, G0 + .42), (-1.24, G0 + .40)]
|
|
P.append(px(hood, -HW, HW, "P_RED"))
|
|
arcs = hood[:6]
|
|
for xm in (-.95, .95):
|
|
P.append(px([(y, z + .007) for (y, z) in arcs] + [(y, z - .02) for (y, z) in reversed(arcs)], xm - .16, xm + .16, "P_WHITE", name="stripe"))
|
|
# rubber flap along the front edge
|
|
P.append(bx(-HW, HW, -1.315, -1.26, G0 + .385, G0 + .44, "P_BLACK", name="lip"))
|
|
P.append(bx(-HW, HW, -.86, -.74, G0 + .055, G0 + .085, "P_G3", name="bedknife"))
|
|
# the ground roller behind the reel, and the skids
|
|
P.append(cx("groundroller", .10, -HW + .04, HW - .04, -.62, G0 + .10, "P_G2", v=12))
|
|
P.append(cx("rollerband", .104, -.02, .02, -.62, G0 + .10, "P_G1", v=12))
|
|
plate = [(-1.34, G0 + .05), (-.56, G0 + .05), (-.52, G0 + .50), (-.70, G0 + .58), (-1.03, G0 + .58), (-1.24, G0 + .53), (-1.34, G0 + .41)]
|
|
for s in (-1, 1):
|
|
a, b = sorted((s * HW, s * (HW + .05)))
|
|
P.append(px(plate, a, b, "P_MUD", name="endplate"))
|
|
P.append(cx("bearing", .09, min(s * (HW + .05), s * (HW + .07)), max(s * (HW + .05), s * (HW + .07)), RY, RZ, "P_G1", v=10))
|
|
P.append(cx("bearingcap", .05, min(s * (HW + .07), s * (HW + .085)), max(s * (HW + .07), s * (HW + .085)), RY, RZ, "P_G4", v=6))
|
|
for k in range(4):
|
|
a_ = PI / 4 + k * PI / 2
|
|
bolt(P, (s * (HW + .07), RY + .065 * math.cos(a_), RZ + .065 * math.sin(a_)), (s, 0, 0), r=.011)
|
|
P.append(px([(-1.38, G0 + .0), (-.62, G0 + .0), (-.56, G0 + .05), (-1.34, G0 + .07)], min(s * (HW - .02), s * (HW + .06)), max(s * (HW - .02), s * (HW + .06)), "P_G3", name="skid"))
|
|
# striped warning board and a whip so the driver can see the bar's ends
|
|
y0, y1 = -1.30, -.72
|
|
tb = bx(min(s * (HW + .05), s * (HW + .06)), max(s * (HW + .05), s * (HW + .06)), y0, y1, G0 + .30, G0 + .50, "M_Hazard", name="warnboard")
|
|
P.append(uv_wall(tb))
|
|
P.append(cyl_between("whip", (s * (HW + .02), -.70, G0 + .56), (s * (HW + .08), -.70, G0 + 1.34), .009, "P_BLACK", v=4))
|
|
P.append(cz("whiptip", .03, G0 + 1.34, G0 + 1.40, s * (HW + .08), -.70, "P_ORANGE", v=6))
|
|
lamp_y(P, s * (HW - .14), -1.30, G0 + .49, .036, glass="M_LightAmber")
|
|
|
|
# stiffening ribs over the hood and lifting eyes: the long roof needs breaking up
|
|
for x in (-1.32, -.62, .62, 1.32):
|
|
P.append(px([(y, z + .022) for (y, z) in arcs[1:5]] + [(y, z - .004) for (y, z) in reversed(arcs[1:5])], x - .022, x + .022, "P_DGREY", name="rib"))
|
|
for k in range(7):
|
|
x = -.54 + k * .06
|
|
P.append(bx(x, x + .03, -1.17, -1.0, G0 + .562, G0 + .57, "P_BLACK", name="louvre"))
|
|
P.append(ptube("hoodhose", soft([(-.18, -.82, G0 + .66), (-.46, -.8, G0 + .62), (-.9, -.76, G0 + .585), (-1.3, -.74, G0 + .585)], 1), .012, "P_BLACK", segs=4))
|
|
# the drive: gearbox on the hood, guarded shaft from the frame, long belt case down one end
|
|
P.append(bx(-.20, .20, -1.04, -.70, G0 + .55, G0 + .72, "P_G1", bev=.015, name="gearbox"))
|
|
P.append(cz("gearboxcap", .05, G0 + .72, G0 + .76, .09, -.86, "P_G4", v=8))
|
|
for s in (-1, 1):
|
|
for y in (-.98, -.76):
|
|
bolt(P, (s * .205, y, G0 + .64), (s, 0, 0))
|
|
P.append(cyl_between("ptoguard", (.0, -.34, .02), (.0, -.70, G0 + .65), .055, "P_ORANGE", v=8))
|
|
for t in (.15, .5, .85):
|
|
c = Vector((0, -.34, .02)).lerp(Vector((0, -.70, G0 + .65)), t)
|
|
d = (Vector((0, -.70, G0 + .65)) - Vector((0, -.34, .02))).normalized()
|
|
P.append(cyl_between("ptoband", c - d * .012, c + d * .012, .063, "P_BLACK", v=8))
|
|
P.append(bx(.28, HW - .02, -1.0, -.76, G0 + .55, G0 + .635, "P_CREAM", bev=.012, name="beltcase"))
|
|
for x in (.42, .85, 1.26):
|
|
bolt(P, (x, -.88, G0 + .635), (0, 0, 1), r=.018)
|
|
decal(P, (-.7, -.86, G0 + .553), .30, .115, (0, 0, 1), R_80)
|
|
star_badge(P, (0, -1.235, G0 + .535), .17, (0, -.4, .92))
|
|
# stains, a tuft of hay caught on the bracket
|
|
rust(P, (-.46, -.86, G0 + .563), .22, .1, (0, 0, 1))
|
|
rust(P, (HW + .051, -.84, G0 + .17), .24, .1, (1, 0, 0))
|
|
tuft(P, -.46, -.62, G0 + .50, L=.14, n=4)
|
|
tuft(P, .78, -1.29, G0 + .47, L=.12, n=3, az=-PI / 2)
|
|
pfin(P, "Body")
|
|
reel("Reel", (0, RY, RZ), HW - .03, RR, bats=6, n=8, mids=2)
|
|
MUD_Z0[0] = 0.0
|
|
return dict(elev=24, azim=-40)
|
|
|
|
|
|
# ======================================================================= the little robot
|
|
|
|
def gear_wheel(P, x, y, R, W, teeth=8, rim="P_WHITE"):
|
|
"""Cheap chunky tyre for a machine whose wheels don't turn in code: a toothed outline, a rim, a hub."""
|
|
pts = []
|
|
for k in range(teeth * 2):
|
|
a = PI * k / teeth
|
|
r_ = R if k % 2 == 0 else R * 0.9
|
|
pts.append((y + r_ * math.cos(a - .1), R + r_ * math.sin(a - .1)))
|
|
pts.append((y + r_ * math.cos(a + .1), R + r_ * math.sin(a + .1)))
|
|
P.append(px(pts, x - W / 2, x + W / 2, "P_BLACK", name="tyre"))
|
|
sx = 1 if x > 0 else -1
|
|
a, b = sorted((x + sx * W * .4, x + sx * W * .56))
|
|
P.append(cx("rim", R * .58, a, b, y, R, rim, v=8))
|
|
a, b = sorted((x + sx * W * .56, x + sx * W * .64))
|
|
P.append(cx("hub", R * .2, a, b, y, R, "P_G1", v=6))
|
|
|
|
|
|
def robot_mower():
|
|
P = []
|
|
# chassis and the cutter skirt under the nose
|
|
P.append(bx(-.38, .38, -.62, .62, .13, .26, "P_DGREY", bev=0, name="chassis"))
|
|
P.append(cz("skirt", .47, .05, .13, 0, -.22, "P_G3", v=12))
|
|
P.append(cz("skirtlip", .49, .05, .075, 0, -.22, "P_G1", v=12))
|
|
# a chubby green shell, the nose wide enough to carry a face
|
|
P.append(loft([sec(-.72, .37, .20, .60, .10), sec(-.62, .44, .17, .68, .13), sec(-.28, .49, .15, .76, .15), sec(.12, .46, .15, .72, .13)], "P_GRN", name="shell"))
|
|
# the cream stripe over the top, like a tractor's
|
|
top = [(-.72, .60), (-.62, .68), (-.28, .76), (.12, .72)]
|
|
P.append(px([(y, z + .008) for (y, z) in top] + [(y, z - .02) for (y, z) in reversed(top)], -.09, .09, "P_WHITE", name="stripe"))
|
|
# face: two headlamp eyes in white bezels, dark pupils looking slightly inward, little brows, a wide smile
|
|
Eyes = []
|
|
for s in (-1, 1):
|
|
ex = s * .185
|
|
P.append(cy("bezel", .122, -.752, -.70, ex, .435, "P_WHITE", v=12))
|
|
P.append(cy("bezelrim", .135, -.72, -.70, ex, .435, "P_G1", v=12))
|
|
Eyes.append(cy("eye", .098, -.766, -.74, ex, .435, "M_Emissive", v=12))
|
|
P.append(cy("pupil", .04, -.776, -.76, ex - s * .018, .425, "P_BLACK", v=8))
|
|
P.append(cy("glint", .012, -.781, -.774, ex + .012, .44, "P_WHITE", v=4))
|
|
P.append(beam((s * .07, -.73, .585), (s * .30, -.73, .565), .022, .03, m="P_GRND", bev=0, name="brow"))
|
|
up = [(-.205 + .41 * k / 8, .285 - .05 * (1 - (2 * k / 8 - 1) ** 2)) for k in range(9)]
|
|
lo = [(x, z - .045 - .03 * (1 - abs(x) / .205)) for (x, z) in reversed(up)]
|
|
P.append(py(up + lo, -.735, -.71, "P_BLACK", name="smile"))
|
|
P.append(py([(-.045, .232), (.045, .232), (.045, .206), (-.045, .206)], -.74, -.73, "P_TERRA", name="tongue"))
|
|
for s in (-1, 1):
|
|
P.append(cy("dimple", .017, -.732, -.72, s * .235, .305, "P_G4", v=6))
|
|
# cream bumper, a pair of bolts
|
|
P.append(py([(-.36, .10), (.36, .10), (.40, .15), (.36, .19), (-.36, .19), (-.40, .15)], -.776, -.70, "P_WHITE", name="bumper"))
|
|
P.append(bx(-.40, .40, -.74, -.60, .12, .16, "P_G1", bev=0, name="bumpermount"))
|
|
for s in (-1, 1):
|
|
P.append(cy("boltb", .016, -.782, -.774, s * .30, .145, "P_G1", v=4))
|
|
# flanks: a stain and a fleet number
|
|
for s in (-1, 1):
|
|
decal(P, (s * .493, -.32, .50), .2, .08, (s, 0, 0), R_52)
|
|
rust(P, (.466, .03, .30), .14, .09, (1, .05, 0))
|
|
# the bin of clippings on the back
|
|
Xb, Y0b, Y1b = .38, .12, .62
|
|
P.append(bx(-Xb, Xb, Y0b, Y1b, .26, .29, "P_G1", bev=0, name="binfloor"))
|
|
for s in (-1, 1):
|
|
P.append(sb(s, Xb - .03, Xb, Y0b, Y1b, .29, .62, "P_MUD", name="binside"))
|
|
P.append(sb(s, Xb - .04, Xb + .012, Y0b - .01, Y1b + .012, .60, .64, "P_WHITE", name="binrim"))
|
|
P.append(bx(-Xb, Xb, Y1b - .03, Y1b, .29, .62, "P_RED", bev=0, name="binback"))
|
|
P.append(bx(-Xb - .01, Xb + .01, Y1b - .035, Y1b + .012, .60, .64, "P_WHITE", bev=0, name="binrim"))
|
|
P.append(bx(-Xb, Xb, Y0b, Y0b + .03, .29, .62, "P_RED", bev=0, name="binfront"))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * .24 - .03, s * .24 + .03, Y1b, Y1b + .016, .30, .58, "P_G1", bev=0, name="binstrap"))
|
|
h = sphere("heap", 1.0, (0, 0, 0), seg=8, rings=4, m="M_Clippings", scale=(.34, .24, .16))
|
|
for v in h.data.vertices:
|
|
v.co *= 1.0 + random.uniform(-.1, .1)
|
|
P.append(uv_wall(xf(h, t=(0, .37, .58))))
|
|
for (x, y, z, rz) in ((.14, .30, .72, .4), (-.12, .42, .715, 1.1), (.02, .46, .73, 2.0), (-.2, .3, .68, .2)):
|
|
c = bx(-.04, .04, -.015, .015, -.01, .012, "P_GOLD", bev=0, name="clip")
|
|
P.append(xf(c, rz=rz, t=(x, y, z)))
|
|
# a cream waistband round the shell like the combine's, a hatch and vent on the back of it, rivets along the hatch
|
|
W_ = [(-.62, .446), (-.28, .496), (.12, .466)]
|
|
P.append(loft([[(-hw_, y_, .30), (hw_, y_, .30), (hw_, y_, .37), (-hw_, y_, .37)] for (y_, hw_) in W_], "P_WHITE", name="waistband"))
|
|
P.append(loft([[(-.20, y_, z_ - .03), (.20, y_, z_ - .03), (.20, y_, z_ + .012), (-.20, y_, z_ + .012)] for (y_, z_) in ((-.14, .755), (.08, .74))], "P_GRND", name="hatch"))
|
|
for k in range(4):
|
|
y_ = -.11 + k * .05
|
|
P.append(bx(-.14, .14, y_, y_ + .024, .76 - k * .004, .768 - k * .004, "P_BLACK", bev=0, name="louvre"))
|
|
for s in (-1, 1):
|
|
for y_ in (-.10, .05):
|
|
bolt(P, (s * .18, y_, .763), (0, 0, 1), r=.009, m="P_G1")
|
|
# wheels
|
|
for s in (-1, 1):
|
|
gear_wheel(P, s * .485, -.40, .15, .09, teeth=7)
|
|
gear_wheel(P, s * .485, .42, .20, .12, teeth=8)
|
|
# the antenna and its little flag, so you can find it in tall grass
|
|
P.append(cz("aerialfoot", .03, .62, .67, .30, .56, "P_G1", v=6))
|
|
P.append(cz("aerial", .010, .66, 1.12, .30, .56, "P_G3", v=4))
|
|
P.append(cz("aerialball", .022, 1.11, 1.15, .30, .56, "P_ORANGE", v=6))
|
|
P.append(py([(.30, 1.11), (.42, 1.07), (.54, 1.025), (.42, 1.0), (.30, .955)], .553, .567, "P_RED", name="flag"))
|
|
P.append(py([(.30, 1.05), (.40, 1.035), (.44, 1.03), (.40, 1.01), (.30, 1.0)], .549, .571, "P_WHITE", name="flagband"))
|
|
pfin(P, "Body", ang=38)
|
|
pfin(Eyes, "Lamp", ang=50)
|
|
return dict(elev=20, azim=-35)
|
|
|
|
|
|
# ======================================================================= the Reaper
|
|
|
|
def haz(a0, a1, b0, b1, n, emit, cols=("P_GOLD", "P_BLACK")):
|
|
"""Diagonal hazard stripes over a rectangle in a,b. emit(outline, colour) makes one stripe."""
|
|
w = (a1 - a0) / n
|
|
sl = (b1 - b0) * .9
|
|
extra = int(math.ceil(sl / w))
|
|
for i in range(-extra, n):
|
|
p0, p1 = a0 + i * w, a0 + (i + 1) * w
|
|
q = [(max(a0, min(a1, p0)), b0), (max(a0, min(a1, p1)), b0), (max(a0, min(a1, p1 + sl)), b1), (max(a0, min(a1, p0 + sl)), b1)]
|
|
out = []
|
|
for v in q:
|
|
if not out or (abs(out[-1][0] - v[0]) + abs(out[-1][1] - v[1])) > 1e-5:
|
|
out.append(v)
|
|
if len(out) >= 3 and abs(out[0][0] - out[-1][0]) + abs(out[0][1] - out[-1][1]) < 1e-5:
|
|
out.pop()
|
|
if len(out) >= 3:
|
|
emit(out, cols[i % 2])
|
|
|
|
|
|
def sign_oct(P, c, h, n):
|
|
"""The pack's own DEAD STOP END sign, cut to its octagon."""
|
|
c, n = Vector(c), Vector(n).normalized()
|
|
up = Vector((0, 0, 1))
|
|
r = up.cross(n).normalized()
|
|
up = n.cross(r)
|
|
pts = [(-.41, -1), (.41, -1), (1, -.41), (1, .41), (.41, 1), (-.41, 1), (-1, .41), (-1, -.41)]
|
|
vs = [tuple(c + r * (a * h / 2) + up * (b * h / 2)) for (a, b) in pts]
|
|
o = mesh_obj("sign", verts=vs, faces=[tuple(range(8))])
|
|
set_mats(o, "M_Pack")
|
|
uv = o.data.uv_layers.new(name="UVMap")
|
|
u0, v0, u1, v1 = R_DEAD
|
|
for i, (a, b) in enumerate(pts):
|
|
uv.data[i].uv = ((u0 + u1) / 2 + a * (u1 - u0) / 2 * .97, (v0 + v1) / 2 + b * (v1 - v0) / 2 * .97)
|
|
uv_keep(o)
|
|
P.append(o)
|
|
|
|
|
|
def reaper():
|
|
P = []
|
|
# --------------------------------------------------- crawler tracks: nothing on it needs to turn, and they weigh it down
|
|
outline = arc(1.48, .52, .47, -90, 90, 6) + arc(-.90, .47, .42, 90, 270, 6)
|
|
for s in (-1, 1):
|
|
x0, x1 = sorted((s * .98, s * 1.44))
|
|
P.append(px(outline, x0, x1, "P_BLACK", name="track"))
|
|
# grousers, spaced round the outline
|
|
L = [0.0]
|
|
for a, b in zip(outline, outline[1:] + outline[:1]):
|
|
L.append(L[-1] + math.hypot(b[0] - a[0], b[1] - a[1]))
|
|
N = 22
|
|
c = (sum(p[0] for p in outline) / len(outline), sum(p[1] for p in outline) / len(outline))
|
|
for k in range(N):
|
|
d = L[-1] * k / N
|
|
i = max(j for j in range(len(outline)) if L[j] <= d)
|
|
a, b = outline[i], outline[(i + 1) % len(outline)]
|
|
t = (d - L[i]) / max(1e-6, L[i + 1] - L[i])
|
|
p = (a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t)
|
|
tg = Vector((b[0] - a[0], b[1] - a[1])).normalized()
|
|
nr = Vector((-tg.y, tg.x))
|
|
if nr.dot(Vector((p[0] - c[0], p[1] - c[1]))) < 0:
|
|
nr = -nr
|
|
q = Vector(p)
|
|
P.append(px([tuple(q - tg * .05), tuple(q + tg * .05), tuple(q + tg * .035 + nr * .05), tuple(q - tg * .035 + nr * .05)], min(s * .965, s * 1.455), max(s * .965, s * 1.455), "P_DGREY", name="grouser"))
|
|
# road wheels, drive sprocket, idler
|
|
for y, r_, zc in ((-.90, .34, .47), (-.30, .20, .32), (.18, .20, .32), (.66, .20, .32), (1.48, .38, .52)):
|
|
a, b = sorted((s * 1.44, s * 1.47))
|
|
P.append(cx("roadwheel", r_, a, b, y, zc, "P_G1", v=10))
|
|
a, b = sorted((s * 1.47, s * 1.485))
|
|
P.append(cx("roadhub", r_ * .45, a, b, y, zc, "P_RED", v=6))
|
|
# the skirt over the top run, striped down its whole length
|
|
P.append(px([(-1.10, .62), (1.84, .62), (1.84, 1.00), (-.92, 1.00)], min(s * .94, s * 1.47), max(s * .94, s * 1.47), "P_DGREY", name="skirt"))
|
|
|
|
def side(out, col, s_=s):
|
|
P.append(px(out, min(s_ * 1.47, s_ * 1.48), max(s_ * 1.47, s_ * 1.48), col, name="hazside"))
|
|
haz(-.90, 1.80, .68, .96, 10, side)
|
|
for y in (-.8, -.1, .6, 1.4):
|
|
bolt(P, (s * 1.48, y, .645), (s, 0, 0), r=.018)
|
|
# a tool locker with a hasp, and a strapped can, on top of the skirt
|
|
P.append(sb(s, 1.04, 1.40, .10, .86, 1.0, 1.2, "P_G1", bev=.012, name="locker"))
|
|
P.append(sb(s, 1.03, 1.41, .08, .88, 1.2, 1.235, "P_REDD", bev=.008, name="lockerlid"))
|
|
for y in (.3, .66):
|
|
P.append(sb(s, 1.40, 1.415, y - .03, y + .03, 1.12, 1.24, "P_G3", name="hasp"))
|
|
jerrycan(P, s * 1.22, 1.32, 1.0, m="P_RED" if s > 0 else "P_G1", rz=PI / 2)
|
|
P.append(sb(s, 1.20, 1.24, 1.2, 1.44, 1.0, 1.262, "P_BLACK", name="canstrap"))
|
|
|
|
# --------------------------------------------------- the hull, a low wedge
|
|
P.append(loft([sec(-1.28, .86, .50, 1.18, .12), sec(-.62, .94, .46, 1.36, .16), sec(1.10, .96, .46, 1.44, .14), sec(1.92, .88, .56, 1.36, .14)], "P_REDD", name="hull"))
|
|
# angry eyes: two slits raked inward, set in a black visor across the brow
|
|
P.append(loft([sec(-1.30, .70, .99, 1.16, .05), sec(-1.26, .74, .97, 1.175, .05)], "P_BLACK", name="visor"))
|
|
Eyes = []
|
|
for s in (-1, 1):
|
|
Eyes.append(py([(s * .16, 1.04), (s * .60, 1.13), (s * .62, 1.07), (s * .22, 1.00)], -1.315, -1.30, "M_LightRed", name="eye"))
|
|
star_badge(P, (0, -1.0, 1.262), .22, (0, -.3, .95))
|
|
# the engine deck behind the gun: louvres, two stacks, a filler
|
|
for k in range(6):
|
|
y = 1.26 + k * .1
|
|
P.append(bx(-.54, .54, y, y + .055, 1.44 - .06 * (k > 3), 1.47 - .06 * (k > 3), "P_BLACK", bev=0, name="louvre"))
|
|
# an orange warning vent on each flank, stacks with heat guards
|
|
for s in (-1, 1):
|
|
decal(P, (s * 1.0, .62, 1.22), .36, .3, (s, 0, 0), R_VENT)
|
|
P.append(cz("stack", .075, 1.2, 1.98, s * .74, 1.62, "P_BLACK", v=8))
|
|
P.append(cz("stackrim", .09, 1.98, 2.02, s * .74, 1.62, "P_G1", v=8))
|
|
P.append(cz("stackguard", .095, 1.46, 1.72, s * .74, 1.62, "P_G3", v=8))
|
|
decal(P, (-1.0, 1.42, 1.22), .32, .125, (-1, 0, 0), R_80)
|
|
decal(P, (1.0, 1.42, 1.22), .32, .125, (1, 0, 0), R_80)
|
|
rust(P, (.965, -.16, 1.14), .5, .2, (1, .0, 0))
|
|
rust(P, (-.965, .2, 1.12), .36, .18, (-1, .0, 0))
|
|
rust(P, (.58, -.72, 1.325), .3, .22, (0, -.24, .97))
|
|
# rear: plate and red lamps
|
|
P.append(bx(-.5, .5, 1.92, 1.96, .72, 1.18, "P_G2", bev=0, name="rearplate"))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * .36 - .06, s * .36 + .06, 1.96, 1.975, .94, 1.08, "M_LightRed", bev=0, name="taillamp"))
|
|
# --------------------------------------------------- the jaws: a hood with teeth, the blades behind them
|
|
HX = 1.44
|
|
hood = [(-1.80, .62), (-1.77, .76), (-1.60, .92), (-1.30, .98), (-1.18, .92), (-1.18, .34), (-1.24, .34), (-1.24, .86), (-1.30, .91), (-1.57, .86), (-1.71, .72), (-1.74, .60)]
|
|
P.append(px(hood, -HX, HX, "P_REDD"))
|
|
|
|
def htop(out, col):
|
|
def zt(y):
|
|
return .92 + (y + 1.60) / .30 * .06
|
|
P.append(loft([[(x, y, zt(y) - .004) for (x, y) in out], [(x, y, zt(y) + .009) for (x, y) in out]], col, name="haztop"))
|
|
haz(-HX, HX, -1.58, -1.32, 22, htop)
|
|
# upper teeth along the lip
|
|
for k in range(17):
|
|
x = -HX + .06 + (2 * HX - .12) * k / 16
|
|
P.append(py([(x - .075, .63), (x + .075, .63), (x, .52)], -1.79, -1.74, "P_G5", name="fang"))
|
|
# the lower jaw, a toothed shelf
|
|
n = 15
|
|
pts = [(-HX, -1.26)]
|
|
for k in range(n):
|
|
x = -HX + 2 * HX * k / n
|
|
pts += [(x, -1.90), (x + HX / n, -2.0)]
|
|
pts += [(HX, -1.90), (HX, -1.26)]
|
|
P.append(pz(pts, .02, .055, "P_G2", name="lowerjaw"))
|
|
P.append(bx(-HX, HX, -1.24, -1.14, .03, .34, "P_G1", bev=0, name="backplate"))
|
|
# side plates cut like a scythe's blade, tip forward
|
|
for s in (-1, 1):
|
|
a, b = sorted((s * HX, s * 1.5))
|
|
P.append(px([(-1.96, .03), (-1.22, .03), (-1.2, 1.0), (-1.34, 1.04), (-1.62, .98), (-1.82, .78), (-1.9, .42)], a, b, "P_MUD", name="endplate"))
|
|
P.append(px([(-2.0, .03), (-1.96, .03), (-1.86, .46), (-1.78, .78), (-1.6, .98), (-1.62, 1.03), (-1.85, .82), (-1.95, .46)], a, b, "P_G5", name="scythe"))
|
|
for y, z in ((-1.34, .2), (-1.34, .84), (-1.72, .6)):
|
|
bolt(P, (s * 1.5, y, z), (s, 0, 0), r=.02)
|
|
# the sign bolted to the hood, a joke only a close look gets
|
|
sign_oct(P, (.92, -1.846, .82), .34, (0, -1, 0))
|
|
P.append(py([(.92 + a_ * .185, .82 + b_ * .185) for (a_, b_) in ((-.41, -1), (.41, -1), (1, -.41), (1, .41), (.41, 1), (-.41, 1), (-1, .41), (-1, -.41))], -1.844, -1.83, "P_G1", name="signback"))
|
|
for x in (.84, 1.0):
|
|
P.append(cy("signstrut", .012, -1.83, -1.70, x, .84, "P_G2", v=4))
|
|
# two amber lamps low in the middle of the face, close together: nostrils
|
|
for s in (-1, 1):
|
|
lamp_y(P, s * .13, -1.78, .78, .05)
|
|
P.append(cy("lampstalk", .03, -1.78, -1.70, s * .13, .78, "P_G1", v=6))
|
|
# rails down the hull so the deck isn't a bare slab, and a raised cowl with a filler
|
|
for s in (-1, 1):
|
|
P.append(ptube("rail", [(s * .78, -.56, 1.38), (s * .80, -.2, 1.43), (s * .80, .2, 1.46), (s * .80, .24, 1.40)], .02, "P_BLACK", segs=5))
|
|
P.append(loft([sec(-.46, .44, 1.33, 1.40, .03), sec(.20, .44, 1.40, 1.47, .03)], "P_G1", name="cowl"))
|
|
for k in range(4):
|
|
x = -.30 + k * .2
|
|
P.append(bx(x - .05, x + .05, -.3, -.1, 1.405 + .012 * 0, 1.425, "P_BLACK", bev=0, name="grille"))
|
|
# --------------------------------------------------- the launcher, a stub cannon laid over the hull
|
|
B = Vector((0, .98, 1.30))
|
|
d = Vector((0, -math.cos(math.radians(28)), math.sin(math.radians(28))))
|
|
LB = 1.16
|
|
q = d.to_track_quat("Z", "Y")
|
|
|
|
def along(o):
|
|
o.rotation_mode = "QUATERNION"
|
|
o.rotation_quaternion = q
|
|
o.location = B
|
|
apply_xform(o)
|
|
o.rotation_mode = "XYZ"
|
|
o.rotation_euler = (0, 0, 0)
|
|
return o
|
|
P.append(along(revm("barrel", [(0, 0), (.30, 0), (.37, .1), (.37, LB - .12), (.41, LB - .1), (.41, LB), (.31, LB), (.31, LB - .46), (0, LB - .46)],
|
|
["P_G1", "P_G1", "P_G1", "P_DGREY", "P_DGREY", "P_DGREY", "P_BLACK", "P_BLACK"], segs=14)))
|
|
P.append(along(cz("bandA", .385, .36, .46, m="P_GOLD", v=14)))
|
|
P.append(along(cz("bandB", .385, .46, .56, m="P_BLACK", v=14)))
|
|
P.append(along(cz("bandC", .385, .56, .66, m="P_GOLD", v=14)))
|
|
# trunnion cheeks and the mount
|
|
for s in (-1, 1):
|
|
a, b = sorted((s * .42, s * .56))
|
|
P.append(px([(.48, 1.40), (1.4, 1.40), (1.34, 1.72), (1.0, 1.84), (.66, 1.72)], a, b, "P_G2", name="cheek"))
|
|
P.append(cx("trunnion", .13, min(s * .56, s * .60), max(s * .56, s * .60), .98, 1.56, "P_RED", v=8))
|
|
# recoil cylinders
|
|
P.append(cyl_between("recoil", (s * .30, .86, 1.70), (s * .32, .42, 1.92), .05, "P_BLACK", v=6))
|
|
P.append(cyl_between("recoilrod", (s * .32, .42, 1.92), (s * .33, .22, 2.03), .024, "P_G5", v=5))
|
|
P.append(ptube("feedhose", soft([(.62, 1.1, 1.5), (.74, .9, 1.42), (.7, .5, 1.42), (.44, .36, 1.62)]), .03, "P_BLACK", segs=5))
|
|
# bundles waiting in a rack behind the breech, a magazine you can count
|
|
P.append(bx(-.62, .62, 1.30, 1.86, 1.44, 1.48, "P_G1", bev=0, name="rackfloor"))
|
|
for s in (-1, 1):
|
|
P.append(sb(s, .58, .62, 1.30, 1.86, 1.48, 1.56, "P_G2", name="rackrail"))
|
|
P.append(sb(s, .58, .62, 1.56, 1.60, 1.48, 1.92, "P_G1", name="rackpost"))
|
|
for (x, y, z) in ((-.28, 1.58, 1.48), (.28, 1.58, 1.48)):
|
|
c = bx(x - .25, x + .25, y - .25, y + .25, z, z + .48, "M_Clippings", bev=.02, name="bundle")
|
|
P.append(uv_wall(c))
|
|
for sx in (-1, 1):
|
|
P.append(bx(x + sx * .12 - .018, x + sx * .12 + .018, y - .255, y + .255, z - .002, z + .485, "P_DRED", bev=0, name="band"))
|
|
# a beacon and a whip with a rag of black flag on it
|
|
beacon(P, -.46, 1.14, 1.72)
|
|
P.append(cz("whip", .012, 1.44, 2.18, .86, 1.84, "P_BLACK", v=4))
|
|
P.append(py([(.86, 2.17), (1.06, 2.14), (1.2, 2.16), (1.13, 2.09), (1.2, 2.03), (1.06, 2.02), (.86, 1.97)], 1.834, 1.846, "P_BLACK", name="rag"))
|
|
pfin(P, "Body")
|
|
pfin(Eyes, "Lamp", ang=50)
|
|
|
|
reel("Reel", (0, -1.57, .36), 1.40, .25, bats=5, twist=.9, end="P_DRED", blade="P_G1", n=6, mids=1, hooks=9)
|
|
m = empty("Muzzle", tuple(B + d * LB))
|
|
m.rotation_mode = "QUATERNION"
|
|
m.rotation_quaternion = q
|
|
return dict(elev=22, azim=-40)
|
|
|
|
|
|
# ======================================================================= the dock
|
|
|
|
def robot_dock():
|
|
P = []
|
|
TOP = .16
|
|
# the pad: boards of slightly different lengths with gaps you could lose a spanner in
|
|
for k in range(10):
|
|
y = -1.35 + k * .3
|
|
e0, e1 = random.uniform(-.03, .03), random.uniform(-.03, .03)
|
|
P.append(bx(-1.38 + e0, 1.38 + e1, y - .137, y + .137, .09, TOP - random.choice((0, 0, .006)), DECK, bev=.008, name="plank"))
|
|
P.append(bx(-1.4, 1.4, -1.4, 1.4, 0, .09, TIM, bev=0, name="padbed"))
|
|
for x, y in ((-.92, -.75), (.62, .45)): # two patched boards, an offcut nailed over a split
|
|
P.append(bx(x - .24, x + .24, y - .065, y + .065, TOP - .004, TOP + .01, TIM, bev=.004, name="patch"))
|
|
for sx in (-1, 1):
|
|
bolt(P, (x + sx * .2, y, TOP + .01), (0, 0, 1), r=.009, m="P_G2")
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * 1.43 - .07, sx * 1.43 + .07, -1.5, 1.5, 0, .2, TIM, bev=.016, name="kerb"))
|
|
P.append(bx(-1.5, 1.5, 1.36, 1.5, 0, .2, TIM, bev=.016, name="kerb"))
|
|
# front kerb in two halves, the belt port in the middle
|
|
for sx in (-1, 1):
|
|
P.append(sb(sx, .34, 1.5, -1.492, -1.36, 0, .2, TIM, bev=.016, name="kerb"))
|
|
P.append(uv_wall(sb(sx, .62, 1.26, -1.5, -1.49, .05, .15, "M_Hazard", name="kerbstripe")))
|
|
P.append(sb(sx, .34, .40, -1.5, -1.2, .16, .40, TIM, bev=.01, name="chuteside"))
|
|
P.append(bx(-.34, .34, -1.5, -1.2, .16, .22, "P_G3", bev=0, name="chutetin"))
|
|
# a painted chevron run leading home, a brass contact plate where the robot parks
|
|
chevron_flat(P, -.70, .5, .16, .1, TOP, TOP + .006)
|
|
chevron_flat(P, -1.05, .5, .16, .1, TOP, TOP + .006)
|
|
P.append(bx(-.34, .34, .12, .32, TOP - .002, TOP + .012, "P_DGREY", bev=0, name="chargeplate"))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * .18 - .09, s * .18 + .09, .17, .27, TOP + .012, TOP + .02, "M_Brass", bev=0, name="contact"))
|
|
# --------------------------------------------------- the lean-to: tall at the front, low at the back
|
|
Yf, Yb, Zf, Zb = .52, 1.42, 1.84, 1.50
|
|
|
|
def roofz(y):
|
|
return Zf + (Zb - Zf) * (y - Yf) / (Yb - Yf)
|
|
for x in (-1.32, 1.32):
|
|
P.append(beam((x, Yf, .16), (x, Yf, Zf), .14, .14, name="post"))
|
|
P.append(beam((x, Yb, .16), (x, Yb, Zb), .14, .14, name="post"))
|
|
P.append(bx(x - .1, x + .1, Yf - .1, Yf + .1, .16, .22, "P_G1", bev=0, name="postshoe"))
|
|
P.append(beam((x, Yf + .02, 1.5), (x, Yf + .46, roofz(Yf + .46) - .1), .06, .08, name="brace"))
|
|
P.append(beam((-1.4, Yf, Zf + .02), (1.4, Yf, Zf + .02), .12, .16, name="header"))
|
|
P.append(beam((-1.4, Yb, Zb + .02), (1.4, Yb, Zb + .02), .1, .14, name="plate"))
|
|
for x in (-.88, -.3, .3, .88):
|
|
P.append(beam((x, Yf - .24, roofz(Yf - .24) + .06), (x, Yb + .03, roofz(Yb + .03) + .06), .07, .1, name="rafter"))
|
|
# back wall: red boards with gaps on dark backing, a timber rail
|
|
P.append(bx(-1.3, 1.3, Yb - .012, Yb + .002, .18, Zb, "P_BLACK", bev=0, name="backing"))
|
|
P.append(bx(1.325, 1.335, Yf + .02, Yb - .02, .24, 1.34, "P_BLACK", bev=0, name="backing"))
|
|
x = -1.3
|
|
while x < 1.3:
|
|
w = random.choice((.2, .24, .26))
|
|
x1 = min(1.3, x + w)
|
|
P.append(bx(x + .008, x1 - .008, Yb - .03, Yb + .02, .18, Zb, RED, bev=.006, name="wallboard"))
|
|
x = x1
|
|
P.append(bx(-1.3, 1.3, Yb - .055, Yb - .03, 1.0, 1.08, TIM, bev=0, name="rail"))
|
|
# side wall on one side only, half height with the barn's white X, so the shed stays open and light
|
|
for k in range(5):
|
|
z = .24 + k * .22
|
|
P.append(bx(1.30, 1.36, Yf + .02, Yb - .02, z, z + .2, RED, bev=.006, name="sideboard"))
|
|
P.append(beam((1.385, Yf + .06, .3), (1.385, Yb - .08, 1.26), .05, .09, m="P_WHITE", bev=0, name="xbrace"))
|
|
P.append(beam((1.385, Yf + .06, 1.26), (1.385, Yb - .08, .3), .05, .09, m="P_WHITE", bev=0, name="xbrace"))
|
|
# the tin roof: five overlapping sheets, one rusty, one sat crooked
|
|
for k in range(5):
|
|
x0 = -1.5 + k * .59
|
|
x1 = x0 + .64
|
|
yo = -.02 if k == 3 else 0
|
|
a, b, c, d = (x0, Yf - .36 + yo, roofz(Yf - .36) + .13), (x1, Yf - .36 + yo, roofz(Yf - .36) + .13), (x1, Yb + .08 + yo, roofz(Yb + .08) + .13), (x0, Yb + .08 + yo, roofz(Yb + .08) + .13)
|
|
P.append(uv_wall(board(a, b, c, d, .02, TIN, bev=0, along="ad", name="roof")))
|
|
for t in (.08, .5, .92):
|
|
bolt(P, ((x0 + x1) / 2, a[1] + (d[1] - a[1]) * t, a[2] + (d[2] - a[2]) * t), (0, .35, .94), r=.012, m="P_G1")
|
|
for (x, y, w, h) in ((.385, .62, .09, .34), (.975, .78, .07, .26), (-.8, .5, .08, .22), (-.21, .92, .06, .3)):
|
|
rust(P, (x, y, roofz(y) + .133), w, h, (0, .35, .94), heart=False)
|
|
# what a shed collects: a bench, bales, a can, a tool board
|
|
P.append(bx(-1.28, -.44, 1.02, 1.36, .56, .62, TIM, bev=.01, name="bench"))
|
|
for x in (-1.2, -.52):
|
|
P.append(bx(x - .03, x + .03, 1.06, 1.1, .16, .56, TIM, bev=0, name="benchleg"))
|
|
P.append(bx(x - .03, x + .03, 1.3, 1.34, .16, .56, TIM, bev=0, name="benchleg"))
|
|
P.append(bx(-1.2, -.52, 1.08, 1.32, .3, .33, TIM, bev=0, name="benchshelf"))
|
|
jerrycan(P, -.66, 1.2, .62, m="P_RED", rz=.3)
|
|
P.append(cz("oilcan", .05, .62, .72, -1.02, 1.2, "P_G3", v=8, r2=.03))
|
|
P.append(cyl_between("oilspout", (-1.02, 1.2, .71), (-.9, 1.14, .80), .008, "P_G3", v=4))
|
|
P.append(cz("tinbox", .08, .33, .43, -.92, 1.2, "P_ORANGE", v=8))
|
|
P.append(bx(-1.2, -.62, Yb - .05, Yb - .03, 1.14, 1.5, TIM, bev=0, name="toolboard"))
|
|
P.append(beam((-1.08, Yb - .06, 1.2), (-1.08, Yb - .06, 1.42), .025, .012, m="P_G4", bev=0, name="spanner"))
|
|
P.append(bx(-1.11, -1.05, Yb - .062, Yb - .05, 1.42, 1.46, "P_G4", bev=0, name="spannerhead"))
|
|
P.append(beam((-.9, Yb - .06, 1.2), (-.9, Yb - .06, 1.42), .02, .014, m=TIM, bev=0, name="hammer"))
|
|
P.append(bx(-.95, -.85, Yb - .066, Yb - .05, 1.4, 1.45, "P_G1", bev=0, name="hammerhead"))
|
|
bale(P, (.96, 1.12, .32), sx=.56, sy=.42, sz=.32)
|
|
bale(P, (.92, 1.1, .64), sx=.56, sy=.42, sz=.32, rz=.1)
|
|
rope_coil(P, (.42, 1.25, TOP), r=.13, turns=3, t=.016)
|
|
# --------------------------------------------------- the charging post
|
|
cxp, cyp = -1.22, -1.22
|
|
P.append(beam((cxp, cyp, .16), (cxp, cyp, 1.34), .12, .12, name="charger"))
|
|
P.append(bx(cxp - .1, cxp + .1, cyp - .1, cyp + .1, .16, .24, "P_G1", bev=0, name="chargerfoot"))
|
|
P.append(beam((cxp + .26, cyp, .16), (cxp, cyp, .62), .05, .05, name="stay"))
|
|
P.append(beam((cxp, cyp + .26, .16), (cxp, cyp, .62), .05, .05, name="stay"))
|
|
P.append(bx(cxp - .14, cxp + .14, cyp - .11, cyp + .11, .72, 1.12, "P_RED", bev=.012, name="chargerbox"))
|
|
P.append(bx(cxp - .15, cxp + .15, cyp - .12, cyp + .12, 1.10, 1.14, "P_G1", bev=0, name="chargerlid"))
|
|
# a dial and a mains lever on its door, a lightning flash in gold
|
|
P.append(cy("dial", .055, cyp - .118, cyp - .11, cxp, 1.0, "P_BLACK", v=10))
|
|
P.append(cy("dialface", .045, cyp - .124, cyp - .118, cxp, 1.0, "M_GaugeFace", v=10))
|
|
P.append(py([(cxp - .01, .92), (cxp + .05, .92), (cxp + .0, .86), (cxp + .05, .86), (cxp - .05, .75), (cxp - .01, .83), (cxp - .06, .83)], cyp - .12, cyp - .11, "P_GOLD", name="flash"))
|
|
P.append(bx(cxp + .14, cxp + .2, cyp - .03, cyp + .03, .86, .9, "P_G1", bev=0, name="leverbox"))
|
|
P.append(cyl_between("lever", (cxp + .19, cyp, .88), (cxp + .25, cyp, 1.0), .012, "P_G3", v=4))
|
|
P.append(cz("leverknob", .022, .98, 1.03, cxp + .25, cyp, "P_RED", v=6))
|
|
# the cable: hooked on the post, then along the boards to the contact plate
|
|
P.append(ptube("cable", soft([(cxp + .1, cyp + .1, .78), (cxp + .24, cyp + .24, .5), (cxp + .3, cyp + .34, .2), (-.8, -.4, TOP + .018), (-.4, .1, TOP + .018), (-.32, .22, TOP + .02)]), .018, "P_BLACK", segs=5))
|
|
P.append(torus("cablecoil", .1, .016, (cxp - .12, cyp, .62), "X", seg=10, rseg=4, m="P_BLACK"))
|
|
lo = lantern(P, cxp, cyp, 1.34, m="M_Emissive", r=.06)
|
|
one_uv(lo)
|
|
pfin(P, "Body", ang=36)
|
|
return dict(elev=26, azim=-35)
|
|
|
|
|
|
BUILDERS = {
|
|
"SM_PushMower": push_mower,
|
|
"SM_RiderMower": rider_mower,
|
|
"SM_MowerBar": mower_bar,
|
|
"SM_RobotMower": robot_mower,
|
|
"SM_Reaper": reaper,
|
|
"SM_RobotDock": robot_dock,
|
|
}
|
|
|
|
|
|
VIEWS = (("a", 24, -40, .6), ("b", 22, 140, .6), ("c", 6, -90, .6), ("d", 8, 0, .6), ("e", 55, -20, .6), ("far", 24, -40, 3.0))
|
|
|
|
|
|
def main():
|
|
args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
|
vd = os.environ.get("GC_VIEWS")
|
|
for n in (args or list(BUILDERS)):
|
|
common.reset()
|
|
random.seed(zlib.crc32(n.encode()))
|
|
res = BUILDERS[n]() or {}
|
|
print(f"[{n}] parts:", {o.name: tri_count([o]) for o in bpy.context.scene.objects if o.type == "MESH"})
|
|
common.finish(n, **res)
|
|
if vd:
|
|
for m in bpy.data.materials:
|
|
m.use_backface_culling = True
|
|
names = [o.name for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
zmin = min((o.matrix_world @ Vector(c)).z for o in bpy.context.scene.objects if o.type == "MESH" for c in o.bound_box)
|
|
for tag, el, az, dm in VIEWS:
|
|
g = cube("ground", (60, 60, .02), (0, 0, zmin - .012), "M_Grass")
|
|
uv_box(g, .5)
|
|
g["preview_only"] = True
|
|
common.preview(os.path.join(vd, f"{n}_{tag}"), elev=el, azim=az, dist_mul=dm, res=560, frame=names)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|