Files
grass-cutters/ArtSource/Blender/scripts/gc_farm_base.py
NiemandKG d1c3761e58 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>
2026-11-06 18:44:40 +06:00

1159 lines
64 KiB
Python

"""GRASS CUTTER - Herbaria homestead: the base buildings as a cheerful chunky farmstead on timber stilts.
Replaces the rig set of os_rig.py / os_harbour.py / gc_props.ramp. Model names, named parts, footprints and pivots are unchanged:
SM_DeckTile, SM_Ladder, SM_CrewCabin, SM_Terminal, SM_Harbour, SM_Dock, SM_LaunchPad, SM_LaunchLever, SM_Rocket.
Authored in Blender space: metres, Z up, front = -Y (Unity +Z), Unity +X = Blender -X. Deck surface is z = 0, the meadow z = -1.2.
Run from the project root:
blender -b --factory-startup --python ArtSource/Blender/scripts/gc_farm_base.py -- [SM_Name ...] [--extra]
--extra also renders back / low views into $GC_PREVIEW_EXTRA (default: system temp dir).
"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import numpy as np
from common import *
import common
from os_rig import M4, bx, cy, prism, pipe, annulus, arc_patch, quad, pill, dome, chaikin, mat_by
from os_machines import text as text_mesh, orient
from os_harbour import boat_icon
DEG = math.radians
WD, RD, CR, TN, IR = "M_Timber", "M_BarnRed", "M_HullWhite", "M_Tin", "M_Navy" # timber, barn red boards, cream boards, tin, dark iron
PK, ST, RO, HY = "M_Deck", "M_Steel", "M_Rope", "M_Hay" # nailed planks, galvanised steel, rope, hay
RP, YP, CP, GP = "M_PaintRed", "M_PaintYellow", "M_PaintWhite", "M_Teal" # flat paint: barn red, hay gold, cream, tractor green
GX, GY, GZ = (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)
L_PLATE = 5.6 / 3 # one M_Deck texture repeat, same as the old 3x3 deck plates
# What the farm textures look like (ArtSource/Textures/proc_farm.py): the texture axis the boards / ribs run along, boards per UV
# tile, UV per metre along the grain, width of one board on the model in metres. fin() runs the grain along each part.
WOODMAP = {
WD: ("V", 4, 0.45, 0.24),
RD: ("V", 7, 0.45, 0.30),
CR: ("V", 7, 0.45, 0.24),
TN: ("V", 10, 0.60, 0.17),
PK: ("U", 6, 1.0 / L_PLATE, L_PLATE / 6),
"M_WoodDeck": ("U", 12, 0.5, 0.24),
}
# ======================================================================= primitives
def g(o, axis):
"""Boards / grain of this part run along axis (default: its longest axis)."""
o["grain"] = list(axis)
return o
def ribs(o, axis):
"""Tin sheet whose ribs step along axis (they run down the slope of a prism extruded along axis)."""
o["uaxis"] = list(axis)
return o
def boxmap(o):
"""Plain box projection (fin's ms / uv scales) instead of the grain mapping."""
o["uvbox"] = True
return o
def xf(o, rot=(0, 0, 0), loc=(0, 0, 0)):
"""Bake rotation (deg, XYZ euler) then translation into the mesh; grain hints turn with it."""
apply_xform(o)
M = M4(rot, loc)
o.data.transform(M)
o.data.update()
for key in ("grain", "uaxis"):
if key in o:
o[key] = list(M.to_3x3() @ Vector(tuple(o[key])))
return o
def xfm(objs, rot=(0, 0, 0), loc=(0, 0, 0)):
for o in objs:
xf(o, rot, loc)
return objs
def frame_to(p0, p1, up=None):
p0, p1 = Vector(p0), Vector(p1)
X = (p1 - p0).normalized()
u = Vector(up or GZ)
if abs(X.dot(u)) > 0.97:
u = Vector(GY)
Y = u.cross(X).normalized()
Z = X.cross(Y)
return Matrix(((X.x, Y.x, Z.x, p0.x), (X.y, Y.y, Z.y, p0.y), (X.z, Y.z, Z.z, p0.z), (0, 0, 0, 1)))
def beam(name, p0, p1, w, h, m, bev=0.02, segs=1, up=None):
"""Sawn timber from p0 to p1: w across (horizontal), h through (the up side)."""
L = (Vector(p1) - Vector(p0)).length
o = rbox(name, (L, w, h), (L / 2, 0, 0), bevel=bev, segs=segs, m=m) if bev > 0 else cube(name, (L, w, h), (L / 2, 0, 0), m)
o.data.transform(frame_to(p0, p1, up))
o.data.update()
o["grain"] = list((Vector(p1) - Vector(p0)).normalized())
return o
def log(name, p0, p1, r, m, v=8, r2=None):
"""Round pole from p0 to p1."""
L = (Vector(p1) - Vector(p0)).length
o = cyl(name, r, L, (L / 2, 0, 0), axis="X", verts=v, m=m, r2=r2)
o.data.transform(frame_to(p0, p1))
o.data.update()
o["grain"] = list((Vector(p1) - Vector(p0)).normalized())
return o
def rv(c, r=0.024, m=ST):
return sphere("rivet", r, loc=c, seg=6, rings=3, m=m)
def nut(c, axis="Z", r=0.03, h=0.022, m=ST):
return cy("nut", r, h, c, m, axis=axis, v=6)
def rope_ring(c, R, r=0.016, axis="Z", seg=10):
return torus("lash", R, r, loc=c, axis=axis, seg=seg, rseg=4, m=RO)
def bale(P, x0, x1, y0, y1, z0, z1):
"""Square hay bale with two twine bands across its short side."""
P.append(bx("bale", x0, x1, y0, y1, z0, z1, HY, bev=0.045, segs=2))
along_x = (x1 - x0) >= (y1 - y0)
for t in (0.28, 0.72):
if along_x:
x = x0 + (x1 - x0) * t
P.append(bx("twine", x - 0.012, x + 0.012, y0 - 0.006, y1 + 0.006, z0 - 0.002, z1 + 0.006, "M_Twine"))
else:
y = y0 + (y1 - y0) * t
P.append(bx("twine", x0 - 0.006, x1 + 0.006, y - 0.012, y + 0.012, z0 - 0.002, z1 + 0.006, "M_Twine"))
def barn_window(P, x, y, z, w=0.86, h=1.0, ang=0.0, shutters=True, depth=0.02, sill=0.13):
"""Cream four-pane window, front face toward -Y before ang (deg about Z), green shutters."""
fw = 0.085
Q = [bx("wpane", -w / 2, w / 2, -0.02, depth, -h / 2, h / 2, "M_WindowGlass")]
for sx in (-1, 1):
x0, x1 = sorted((sx * w / 2, sx * (w / 2 - fw)))
Q.append(g(bx("wjamb", x0, x1, -0.07, depth, -h / 2, h / 2, CR, bev=0.018, segs=1), GZ))
for sz in (-1, 1):
z0, z1 = sorted((sz * h / 2, sz * (h / 2 - fw)))
Q.append(g(bx("whead", -w / 2, w / 2, -0.075, depth, z0, z1, CR, bev=0.018, segs=1), GX))
Q.append(g(bx("wmv", -0.022, 0.022, -0.05, -0.01, -h / 2 + fw, h / 2 - fw, CR), GZ))
Q.append(g(bx("wmh", -w / 2 + fw, w / 2 - fw, -0.05, -0.01, -0.022, 0.022, CR), GX))
Q.append(g(bx("wsill", -w / 2 - 0.09, w / 2 + 0.09, -sill, depth, -h / 2 - 0.09, -h / 2 + 0.0, CR, bev=0.02, segs=1), GX))
if shutters:
for sx in (-1, 1):
x0, x1 = sorted((sx * (w / 2 + 0.01), sx * (w / 2 + 0.3)))
Q.append(g(bx("wshut", x0, x1, -0.05, 0.0, -h / 2 + 0.03, h / 2 - 0.03, GP, bev=0.014, segs=1), GZ))
Q.append(beam("wshutz", ((x0 + 0.03), -0.055, -h / 2 + 0.12), ((x1 - 0.03), -0.055, h / 2 - 0.12), 0.012, 0.05, CP, bev=0))
xfm(Q, rot=(0, 0, ang), loc=(x, y, z))
P += Q
# ======================================================================= finishing
def long_axis(me):
co = np.array([tuple(v.co) for v in me.vertices], dtype=float)
if len(co) < 3:
return Vector(GZ)
c = co - co.mean(0)
w, v = np.linalg.eigh(c.T @ c)
return Vector(tuple(v[:, -1])).normalized()
def fin(P, name, uv=1.0, ang=40, ms=None, origin=None):
"""Join parts into one mesh. Wood and tin get UVs along each part's own grain, centred on a random board so narrow timbers
show no seam line; everything else is box projected (scale uv, or ms[material]). Parts flagged 'uvkeep' keep their UVs."""
sc = dict(ms or {})
rng = random.Random(1234)
bm = bmesh.new()
uvl = bm.loops.layers.uv.new("UVMap")
mats = []
for o in [p for p in P if p is not None]:
apply_xform(o)
src = bmesh.new()
src.from_mesh(o.data)
src.normal_update()
suv = src.loops.layers.uv.active if o.get("uvkeep") else None
names = list(o.data.materials)
idx = []
for mm in names:
if mm not in mats:
mats.append(mm)
idx.append(mats.index(mm))
co = [v.co.copy() for v in src.verts]
cen = Vector(tuple((min(c[i] for c in co) + max(c[i] for c in co)) / 2 for i in range(3))) if co else Vector()
grain = Vector(tuple(o["grain"])).normalized() if "grain" in o else None
uaxis = Vector(tuple(o["uaxis"])).normalized() if "uaxis" in o else None
if grain is None and uaxis is None:
grain = long_axis(o.data)
boxed = bool(o.get("uvbox"))
vm = {v: bm.verts.new(v.co) for v in src.verts}
board = {}
off = rng.random()
for f in src.faces:
try:
nf = bm.faces.new([vm[v] for v in f.verts])
except ValueError:
continue
mi = f.material_index if f.material_index < len(idx) else 0
nf.material_index = idx[mi] if idx else 0
mname = names[mi].name if names and names[mi] else ""
n = f.normal
if suv is None and not boxed and mname in WOODMAP:
axis, boards, along, bw = WOODMAP[mname]
cross = 1.0 / (boards * bw)
k = board.setdefault(mname, rng.randrange(boards))
if uaxis is not None:
S = uaxis - n * uaxis.dot(n)
if S.length < 0.3:
S = n.cross(Vector(GZ if abs(n.z) < 0.9 else GX))
S.normalize()
T = n.cross(S).normalized()
else:
T = grain - n * grain.dot(n)
if T.length < 0.3:
T = n.cross(Vector(GZ if abs(n.z) < 0.9 else GX))
T.normalize()
S = T.cross(n).normalized()
cs = cen.dot(S)
for ln in nf.loops:
p = ln.vert.co
a = p.dot(T) * along + off
b = (p.dot(S) - cs) * cross + (k + 0.5) / boards
ln[uvl].uv = (b, a) if axis == "V" else (a, b)
continue
s = sc.get(mname, uv)
offs = (0.0, 0.0)
if isinstance(s, tuple):
s, offs = s
ax = max(range(3), key=lambda i: abs(n[i]))
for ls, ln in zip(f.loops, nf.loops):
if suv is not None:
ln[uvl].uv = ls[suv].uv
continue
p = ls.vert.co
if ax == 0:
u, v = (p.y if n.x > 0 else -p.y), p.z
elif ax == 1:
u, v = (-p.x if n.y > 0 else p.x), p.z
else:
u, v = p.x, (p.y if n.z > 0 else -p.y)
ln[uvl].uv = (u * s + offs[0], v * s + offs[1])
src.free()
d = o.data
bpy.data.objects.remove(o)
if d.users == 0:
bpy.data.meshes.remove(d)
me = bpy.data.meshes.new(name)
bm.normal_update()
bm.to_mesh(me)
bm.free()
for mm in mats:
me.materials.append(mm)
ob = link(bpy.data.objects.new(name, me))
smooth(ob, ang)
if origin is not None:
set_origin(ob, origin)
return ob
# ======================================================================= 1. deck tile
def fence(alt):
"""Post-and-rail fence along the -Y edge. Corner posts differ in size so the two rails sharing a corner never z-fight, and
the E/W rails sit a little higher so they lap the N/S rails like a real split-rail corner. The side panels stay clear for
the ladders (x = +-1.5)."""
yc, yr, dz = -2.86, -2.96, 0.04 if alt else 0.0
Q = []
for x, w in ((-2.86, 0.15), (-0.95, 0.17), (0.95, 0.17), (2.86, 0.19)):
pts = [(x - w / 2, 0.02), (x + w / 2, 0.02), (x + w / 2, 0.97), (x, 1.05), (x - w / 2, 0.97)]
Q.append(g(prism("post", pts, "XZ", yc - w / 2, yc + w / 2, WD, bev=0.016, segs=1, ang=35), GZ))
Q.append(bx("shoe", x - w / 2 - 0.022, x + w / 2 + 0.022, yc - w / 2 - 0.022, yc + w / 2 + 0.022, 0.0, 0.05, IR, bev=0.012, segs=1))
Q.append(beam("rail", (-2.99, yr, 0.93 + dz), (2.99, yr, 0.93 + dz), 0.06, 0.12, WD, bev=0.02, segs=1))
Q.append(beam("rail", (-2.99, yr, 0.52 + dz), (2.99, yr, 0.52 + dz), 0.06, 0.11, WD, bev=0.02, segs=1))
Q.append(beam("brace", (-0.84, -2.9, 0.1), (0.84, -2.9, 0.86), 0.05, 0.1, WD, bev=0.016, segs=1))
for x in (-0.95, 0.95):
Q.append(nut((x, yr - 0.03, 0.93 + dz), axis="Y", r=0.022, h=0.012, m=IR))
Q.append(nut((x, yr - 0.03, 0.52 + dz), axis="Y", r=0.022, h=0.012, m=IR))
return Q
def deck_tile():
P = []
# plank floor: M_Deck, one texture repeat per 1.87 m like the old deck plates. The boards run to the x edges so they carry on
# across a tile seam; the y edges get a rim joist
P.append(boxmap(bx("plate", -3.0, 3.0, -2.8, 2.8, -0.08, 0.0, PK, bev=0.01, segs=1)))
for s in (-1, 1):
y0, y1 = sorted((s * 2.8, s * 3.0))
P.append(bx("rim", -3.0, 3.0, y0, y1, -0.14, 0.0, WD, bev=0.02, segs=1))
# fascia boards around the frame, chunky iron corner straps
for s in (-1, 1):
x0, x1 = sorted((s * 2.88, s * 2.985))
P.append(bx("fasciax", x0, x1, -2.86, 2.86, -0.46, -0.07, WD, bev=0.024, segs=1))
P.append(bx("fasciay", -2.86, 2.86, x0, x1, -0.46, -0.13, WD, bev=0.024, segs=1))
for sx in (-1, 1):
for sy in (-1, 1):
x0, x1 = sorted((sx * 3.0, sx * 2.66))
y0, y1 = sorted((sy * 3.0, sy * 2.66))
P.append(bx("corner", x0, x1, y0, y1, -0.44, -0.1, IR, bev=0.03, segs=1))
for t in (-0.34, -0.2):
P.append(nut((sx * 2.83, sy * 2.995, t), axis="Y", r=0.03, h=0.01))
P.append(nut((sx * 2.995, sy * 2.83, t), axis="X", r=0.03, h=0.01))
# joists under the boards, two carrying beams on the stilts
for x in (-2.3, -0.78, 0.78, 2.3):
P.append(bx("joist", x - 0.08, x + 0.08, -2.86, 2.86, -0.42, -0.08, WD, bev=0.02, segs=1))
for y in (-1.85, 1.85):
P.append(bx("beam", -2.6, 2.6, y - 0.16, y + 0.16, -0.66, -0.4, WD, bev=0.035, segs=1))
# hay-drop trapdoor (front-left), flush so machines can stand on it
hx, hy = -1.87, -1.87
P.append(bx("tframe", hx - 0.52, hx + 0.52, hy - 0.4, hy + 0.4, -0.02, 0.008, IR, bev=0.008, segs=1))
for k in range(3):
y0 = hy - 0.35 + k * 0.235
P.append(bx("tboard", hx - 0.47, hx + 0.47, y0 + 0.006, y0 + 0.23, -0.01, 0.02, WD, bev=0.008, segs=1))
for x in (hx - 0.3, hx + 0.3):
P.append(bx("tstrap", x - 0.035, x + 0.035, hy - 0.42, hy + 0.3, 0.012, 0.03, IR, bev=0.006, segs=1))
P.append(torus("tring", 0.07, 0.012, loc=(hx, hy + 0.2, 0.024), seg=12, rseg=4, m=IR))
# a few nail straps where the boards butt, loose straw
for (x, y) in ((1.4, -1.0), (-0.6, 1.5), (2.0, 2.1)):
P.append(bx("nstrap", x - 0.2, x + 0.2, y - 0.024, y + 0.024, -0.01, 0.009, IR, bev=0.004, segs=1))
rnd = random.Random(7)
for k in range(14):
c = Vector((rnd.choice((-1.2, 0.3, 1.9)) + rnd.uniform(-0.45, 0.45), rnd.choice((-0.2, 1.1, -2.2)) + rnd.uniform(-0.4, 0.4), 0.006))
d = Vector((math.cos(k * 2.4), math.sin(k * 2.4), 0.0)) * rnd.uniform(0.09, 0.17)
P.append(beam("straw", c - d, c + d, 0.012, 0.006, "M_Straw", bev=0))
fin(P, "Body", uv=1.0, ang=40, ms={PK: (1.0 / L_PLATE, (0.5, 0.5))})
# stilts: four chunky posts per tile on fieldstone pads in the meadow (the ground is 1.2 m below the deck), cross-braced
F = []
for x in (-1.85, 1.85):
for y in (-1.85, 1.85):
F.append(g(bx("stilt", x - 0.17, x + 0.17, y - 0.17, y + 0.17, -1.2, -0.64, WD, bev=0.055, segs=2), GZ))
F.append(bx("strap", x - 0.18, x + 0.18, y - 0.18, y + 0.18, -0.77, -0.71, IR, bev=0.018, segs=1))
F.append(bx("footing", x - 0.34, x + 0.34, y - 0.34, y + 0.34, -1.32, -1.16, "M_Concrete", bev=0.05, segs=2))
F.append(bx("foot", x - 0.21, x + 0.21, y - 0.21, y + 0.21, -1.18, -1.1, IR, bev=0.02, segs=1))
zh, zl = -0.7, -1.12
for s in (-1, 1):
for (d, p0, p1) in ((0.2, -1.68, 1.68), (-0.2, 1.68, -1.68)):
xx = s * 1.85 + d
F.append(beam("brace", (xx, p0, zh), (xx, p1, zl), 0.05, 0.13, WD, bev=0.016, segs=1))
yy = s * 1.85 + d
F.append(beam("brace", (p0, yy, zh), (p1, yy, zl), 0.05, 0.13, WD, bev=0.016, segs=1))
fin(F, "Floats", uv=1.0, ang=50)
# the fence, one edge per object so DeckTileView can toggle them. Same origins as the old railings
for nm, ang in (("Rail_N", 0), ("Rail_S", 180), ("Rail_E", -90), ("Rail_W", 90)):
o = fin(fence(ang in (-90, 90)), nm, uv=1.0, ang=45)
xf(o, rot=(0, 0, ang))
p = M4((0, 0, ang)) @ Vector((0, -2.86, 0))
set_origin(o, (round(p.x, 4), round(p.y, 4), 0.0))
return dict(elev=26, azim=-35)
# ======================================================================= 2. ladder
def ladder():
"""Hangs off the deck edge (y = 0): stringers just outside the fence, grab rails passing between its two rails onto the deck."""
P = []
for s in (-1, 1):
x = s * 0.26
P.append(g(bx("stringer", x - 0.055, x + 0.055, -0.2, -0.09, -2.16, 0.92, WD, bev=0.024, segs=2), GZ))
P.append(beam("grab", (x, -0.14, 0.74), (x, 0.42, 0.74), 0.07, 0.08, WD, bev=0.022, segs=2))
P.append(g(bx("grabpost", x - 0.04, x + 0.04, 0.38, 0.46, 0.02, 0.78, WD, bev=0.02, segs=1), GZ))
P.append(bx("foot", x - 0.09, x + 0.09, 0.33, 0.51, 0.0, 0.03, IR, bev=0.012, segs=1))
for dy in (-0.055, 0.055):
P.append(nut((x + 0.06, 0.42 + dy, 0.034), r=0.016, h=0.012))
P.append(nut((x - 0.06, 0.42 + dy, 0.034), r=0.016, h=0.012))
# iron hook over the deck edge, stand-off blocks against the fascia, ground spike
P.append(pipe("hook", [(x, 0.16, 0.012), (x, -0.02, 0.012), (x, -0.02, -0.2), (x, -0.09, -0.2)], 0.02, IR, segs=6, fil=0.04, fn=2))
P.append(bx("stand", x - 0.04, x + 0.04, -0.1, 0.0, -0.36, -0.28, WD, bev=0.014, segs=1))
P.append(bx("band", x - 0.066, x + 0.066, -0.211, -0.079, 0.02, 0.08, IR, bev=0.012, segs=1))
P.append(rope_ring((x, -0.145, 0.68), 0.083, r=0.014))
P.append(rope_ring((x, -0.145, 0.706), 0.083, r=0.014))
# round rungs through the stringers, lashed with rope
z = -0.4
while z > -2.1:
P.append(log("rung", (-0.34, -0.145, z), (0.34, -0.145, z), 0.042, WD, v=8))
for s in (-1, 1):
P.append(rope_ring((s * 0.26, -0.145, z + 0.02), 0.08, r=0.013))
P.append(rope_ring((s * 0.26, -0.145, z - 0.02), 0.08, r=0.013))
z -= 0.3
P.append(beam("bar", (-0.3, 0.13, 0.74), (0.3, 0.13, 0.74), 0.07, 0.07, WD, bev=0.02, segs=2))
fin(P, "Body", uv=1.0, ang=45)
return dict(elev=18, azim=-55)
# ======================================================================= 3. crew cabin: a small gambrel barn
def crew_cabin():
P = []
BY0, BY1 = -1.45, 1.9
HW, EV = 2.86, 2.35
half = [(HW, EV), (1.95, 3.42), (0.0, 4.1)]
pts = [(-HW, 0.2), (HW, 0.2)] + half + [(-half[1][0], half[1][1]), (-HW, EV)]
P.append(g(prism("walls", pts, "XZ", BY0, BY1, RD), GZ))
# sill beam on the deck, cream skirt board and loft band
P.append(bx("sill", -2.96, 2.96, BY0 - 0.08, BY1 + 0.08, 0.0, 0.24, WD, bev=0.04, segs=2))
P.append(g(bx("skirt", -2.9, 2.9, BY0 - 0.035, BY1 + 0.035, 0.24, 0.34, CR, bev=0.02, segs=1), GX))
for y in (BY0, BY1):
P.append(g(bx("loft", -HW - 0.02, HW + 0.02, y - 0.04, y + 0.04, 2.26, 2.42, CR, bev=0.02, segs=1), GX))
for sx in (-1, 1):
x0, x1 = sorted((sx * (HW - 0.14), sx * (HW + 0.04)))
for y in (BY0, BY1):
y0, y1 = sorted((y - 0.04, y + (0.14 if y == BY0 else -0.14)))
P.append(g(bx("cboard", x0, x1, y0, y1, 0.3, 2.3, CR, bev=0.022, segs=1), GZ))
# tin gambrel roof, ribs running down each slope
oz = [(3.0, 2.2), (2.08, 3.5), (0.0, 4.24)]
iz = [(2.93, 2.15), (2.03, 3.4), (0.0, 4.11)]
shell = [(-oz[0][0], oz[0][1]), (-oz[1][0], oz[1][1])] + [oz[2]] + [oz[1], oz[0]] + [iz[0], iz[1], iz[2]] + [(-iz[1][0], iz[1][1]), (-iz[0][0], iz[0][1])]
P.append(ribs(prism("roof", shell, "XZ", -1.62, 1.96, TN, bev=0.012, segs=1, ang=50), GY))
P.append(beam("ridge", (0.0, -1.66, 4.24), (0.0, 1.995, 4.24), 0.26, 0.05, ST, bev=0.018, segs=1))
# cream barge boards on the gable edges
for y in (-1.62, 1.95):
for sx in (-1, 1):
a = (sx * 2.94, y, oz[0][1] + 0.04)
b = (sx * oz[1][0], y, oz[1][1] - 0.04)
c = (0.0, y, oz[2][1] - 0.04)
P.append(beam("barge", a, b, 0.09, 0.15, CR, bev=0.022, segs=1))
P.append(beam("barge", b, c, 0.09, 0.15, CR, bev=0.022, segs=1))
# the door (same place as the old one): red ledged barn door in a cream frame with a cream X
dx0, dx1, yf = 0.6, 1.8, BY0
for x0, x1 in ((dx0, dx0 + 0.14), (dx1 - 0.14, dx1)):
P.append(g(bx("jamb", x0, x1, yf - 0.1, yf + 0.06, 0.2, 2.26, CR, bev=0.03, segs=2), GZ))
P.append(g(bx("header", dx0 - 0.06, dx1 + 0.06, yf - 0.1, yf + 0.06, 2.12, 2.28, CR, bev=0.03, segs=2), GX))
P.append(g(bx("leaf", dx0 + 0.13, dx1 - 0.13, yf - 0.05, yf + 0.02, 0.22, 2.14, RD, bev=0.02, segs=1), GZ))
yb = yf - 0.07
for (a, b) in (((dx0 + 0.15, 0.3), (dx1 - 0.15, 2.05)), ((dx1 - 0.15, 0.3), (dx0 + 0.15, 2.05))):
P.append(beam("dbrace", (a[0], yb, a[1]), (b[0], yb, b[1]), 0.035, 0.11, CR, bev=0.012, segs=1))
for z in (0.33, 1.17, 2.02):
P.append(g(bx("dledge", dx0 + 0.15, dx1 - 0.15, yb - 0.02, yb + 0.03, z - 0.055, z + 0.055, CR, bev=0.014, segs=1), GX))
P.append(pipe("dhandle", [(dx1 - 0.3, yb - 0.02, 0.98), (dx1 - 0.3, yb - 0.08, 1.02), (dx1 - 0.3, yb - 0.08, 1.3), (dx1 - 0.3, yb - 0.02, 1.34)],
0.02, IR, segs=6, fil=0.04, fn=2))
# barn lamp over the door
dcx = (dx0 + dx1) / 2
P.append(pipe("larm", [(dcx, yf - 0.04, 2.48), (dcx, yf - 0.3, 2.48), (dcx, yf - 0.34, 2.4)], 0.018, IR, segs=6, fil=0.08, fn=3))
P.append(cy("lshade", 0.17, 0.08, (dcx, yf - 0.34, 2.36), GP, v=12, r2=0.03))
P.append(dome("lbulb", 0.06, (dcx, yf - 0.34, 2.31), "M_Emissive", k=-1.0, seg=10, rings=3))
# porch and step in timber
P.append(boxmap(bx("porch", dx0 - 0.2, dx1 + 0.2, -1.84, yf + 0.02, 0.0, 0.2, PK, bev=0.025, segs=1)))
P.append(bx("step", dx0 - 0.05, dx1 + 0.05, -2.0, -1.8, 0.0, 0.1, WD, bev=0.024, segs=1))
for x in (dx0 - 0.14, dx1 + 0.14):
P.append(g(bx("ppost", x - 0.05, x + 0.05, -1.82, -1.72, 0.15, 1.0, WD, bev=0.02, segs=1), GZ))
P.append(beam("prail", (x, -1.8, 0.93), (x, yf, 0.93), 0.07, 0.07, WD, bev=0.02, segs=1))
P.append(beam("prail", (x, -1.8, 0.56), (x, yf, 0.56), 0.05, 0.06, WD, bev=0.016, segs=1))
# windows
barn_window(P, -1.45, yf, 1.32, w=0.95, h=1.05)
barn_window(P, -1.35, BY1, 1.32, w=0.95, h=1.05, ang=180, sill=0.09)
barn_window(P, 1.35, BY1, 1.32, w=0.95, h=1.05, ang=180, sill=0.09)
barn_window(P, -HW, 0.22, 1.32, w=0.9, h=1.05, ang=-90, sill=0.1)
barn_window(P, HW, 0.22, 1.32, w=0.9, h=1.05, ang=90, sill=0.1)
barn_window(P, 0.0, BY1, 3.05, w=0.7, h=0.8, ang=180, shutters=False, sill=0.09)
# GreenHaul plaque in the gable
P.append(g(bx("plaque", -0.68, 0.68, BY0 - 0.06, BY0 + 0.02, 2.56, 3.92, CR, bev=0.03, segs=2), GZ))
for sx in (-1, 1):
for z in (2.64, 3.84):
P.append(nut((sx * 0.6, BY0 - 0.065, z), axis="Y", r=0.022, h=0.012, m=IR))
yl = BY0 - 0.064
P.append(quad("logo", (-0.56, yl, 2.68), (0.56, yl, 2.68), (0.56, yl, 3.8), (-0.56, yl, 3.8), "M_Logo"))
# hoist beam under the ridge, rope and pulley
P.append(beam("hoist", (0.0, -1.3, 4.0), (0.0, -1.97, 4.0), 0.13, 0.13, WD, bev=0.03, segs=1))
P.append(torus("pulley", 0.07, 0.022, loc=(0.0, -1.86, 3.84), axis="X", seg=12, rseg=4, m=IR))
P.append(pipe("hookrope", [(0.0, -1.79, 3.84), (0.0, -1.79, 3.3)], 0.012, RO, segs=5))
P.append(pipe("hookrope", [(0.0, -1.93, 3.84), (0.0, -1.93, 3.1)], 0.012, RO, segs=5))
# stovepipe with a little hat, weathervane on the ridge
px, py = 1.15, 0.9
P.append(cy("flash", 0.17, 0.08, (px, py, 3.8), IR, v=10))
P.append(cy("stove", 0.09, 0.9, (px, py, 4.12), IR, v=10))
P.append(cy("stovehat", 0.17, 0.09, (px, py, 4.6), TN, v=10, r2=0.03))
vx, vy = 0.0, 1.0
P.append(cy("vmast", 0.016, 0.42, (vx, vy, 4.45), IR, v=6))
P.append(beam("varrow", (-0.26, vy, 4.56), (0.26, vy, 4.56), 0.012, 0.022, IR, bev=0))
P.append(prism("vhead", [(-0.36, 4.56), (-0.24, 4.62), (-0.24, 4.5)], "XZ", vy - 0.008, vy + 0.008, IR))
P.append(prism("vtail", [(0.2, 4.56), (0.3, 4.63), (0.3, 4.49)], "XZ", vy - 0.008, vy + 0.008, GP))
# hay against the front wall
bale(P, -2.78, -2.12, -1.98, -1.5, 0.0, 0.42)
bale(P, -2.06, -1.42, -1.96, -1.5, 0.0, 0.42)
bale(P, -2.62, -1.98, -1.94, -1.5, 0.42, 0.84)
fin(P, "Body", uv=1.0, ang=40, ms={PK: (1.0 / L_PLATE, (0.5, 0.5))})
return dict(elev=20, azim=-32)
# ======================================================================= 4. terminal: farm stand with a chalkboard
def terminal():
P = []
# plank counter on a timber frame (the Solid box in the scene is 1.2 x 0.9)
P.append(g(bx("boards", -0.5, 0.5, -0.3, 0.36, 0.1, 0.93, CR, bev=0.02, segs=1), GZ))
for x in (-0.54, 0.54):
for y in (-0.34, 0.38):
P.append(g(bx("cpost", x - 0.05, x + 0.05, y - 0.05, y + 0.05, 0.0, 0.94, WD, bev=0.024, segs=2), GZ))
for y in (-0.33, 0.37):
P.append(g(bx("rail", -0.52, 0.52, y - 0.04, y + 0.04, 0.03, 0.14, WD, bev=0.02, segs=1), GX))
P.append(g(bx("top", -0.6, 0.6, -0.45, 0.44, 0.92, 1.0, WD, bev=0.026, segs=2), GX))
# uprights, cross rail and a tin lean-to roof
for x in (-0.52, 0.52):
P.append(g(bx("upright", x - 0.05, x + 0.05, 0.04, 0.14, 0.98, 1.8, WD, bev=0.022, segs=1), GZ))
P.append(g(bx("fpost", x - 0.033, x + 0.033, -0.44, -0.374, 0.98, 1.78, WD, bev=0.014, segs=1), GZ))
roof = [(-0.54, 1.76), (0.47, 1.82), (0.47, 1.866), (-0.54, 1.806)]
P.append(ribs(prism("roof", roof, "YZ", -0.62, 0.62, TN, bev=0.01, segs=1, ang=50), GX))
for y, z in ((-0.42, 1.76), (0.09, 1.79)):
P.append(g(bx("purlin", -0.56, 0.56, y - 0.045, y + 0.045, z - 0.07, z + 0.02, WD, bev=0.02, segs=1), GX))
# gingham valance under the front eave
val = [(-0.6, 1.77), (0.6, 1.77)]
n = 10
for k in range(n + 1):
val.append((0.6 - 1.2 * k / n, 1.67 if k % 2 == 0 else 1.635))
P.append(g(prism("valance", val, "XZ", -0.482, -0.47, "M_Fabric"), GX))
# chalkboard (Screen below), tilted back 15 degrees like the old monitor
H = M4((-15, 0, 0), (0, -0.02, 1.4))
Hd = [bx("backboard", -0.4, 0.4, -0.08, -0.03, -0.27, 0.27, WD, bev=0.012, segs=1)]
for sz in (-1, 1):
z0, z1 = sorted((sz * 0.2, sz * 0.27))
Hd.append(g(bx("cframe", -0.4, 0.4, -0.11, -0.03, z0, z1, CR, bev=0.018, segs=1), GX))
for sx in (-1, 1):
x0, x1 = sorted((sx * 0.33, sx * 0.4))
Hd.append(g(bx("cframe", x0, x1, -0.11, -0.03, -0.27, 0.27, CR, bev=0.018, segs=1), GZ))
Hd.append(g(bx("ctray", -0.36, 0.36, -0.15, -0.09, -0.28, -0.25, WD, bev=0.008, segs=1), GX))
Hd.append(cy("chalk", 0.009, 0.08, (0.2, -0.125, -0.24), CP, axis="X", v=5))
for o in Hd:
apply_xform(o)
o.data.transform(H)
if "grain" in o:
o["grain"] = list(H.to_3x3() @ Vector(tuple(o["grain"])))
P += Hd
ys = -0.103
# chalk lettering floats a hair above the board
head = text_mesh("chalkhead", "SHOP", 0.13, CP)
orient(head, "-Y", (0.0, ys - 0.004, 0.105))
head.data.transform(H)
P.append(head)
for (x0, x1, z) in ((-0.27, 0.05, 0.0), (0.14, 0.27, 0.0), (-0.27, 0.0, -0.075), (0.14, 0.27, -0.075), (-0.27, 0.08, -0.15), (0.14, 0.27, -0.15)):
o = bx("chalkline", x0, x1, ys - 0.006, ys - 0.002, z - 0.011, z + 0.011, CP)
apply_xform(o)
o.data.transform(H)
P.append(o)
# back-brace between the uprights and the board
P.append(g(bx("brace", -0.47, 0.47, 0.01, 0.07, 1.3, 1.4, WD, bev=0.016, segs=1), GX))
# a crate of apples, a sack and a brass bell on the counter
cx_, cy_ = 0.34, -0.28
P.append(bx("crate", cx_ - 0.17, cx_ + 0.17, cy_ - 0.12, cy_ + 0.12, 1.0, 1.03, WD))
for sx in (-1, 1):
P.append(bx("crates", cx_ + sx * 0.165 - 0.012, cx_ + sx * 0.165 + 0.012, cy_ - 0.12, cy_ + 0.12, 1.0, 1.13, WD, bev=0.006, segs=1))
for sy in (-1, 1):
for z in (1.03, 1.1):
P.append(bx("crateb", cx_ - 0.17, cx_ + 0.17, cy_ + sy * 0.118 - 0.008, cy_ + sy * 0.118 + 0.008, z, z + 0.05, WD))
for k, (dx, dy, dz) in enumerate(((-0.09, -0.05, 0), (0.0, -0.05, 0), (0.09, -0.05, 0), (-0.09, 0.05, 0), (0.0, 0.05, 0), (0.09, 0.05, 0), (-0.04, 0.0, 0.06), (0.05, 0.0, 0.06))):
P.append(sphere("apple", 0.052, loc=(cx_ + dx, cy_ + dy, 1.09 + dz), seg=8, rings=5, m=(RP if k % 3 else YP)))
P.append(revolve("bell", [(0, 1.0), (0.05, 1.0), (0.05, 1.015), (0.04, 1.04), (0.02, 1.065), (0.0, 1.075)], segs=10, m="M_Brass",
loc=(-0.08, -0.33, 0), close_top=False))
lx_ = -0.38
P.append(bx("basket", lx_ - 0.15, lx_ + 0.15, cy_ - 0.1, cy_ + 0.1, 1.0, 1.08, "M_Burlap", bev=0.02, segs=1))
for (dx, dy) in ((-0.075, 0.0), (0.075, 0.0)):
P.append(sphere("cabbage", 0.082, loc=(lx_ + dx, cy_ + dy, 1.12), seg=8, rings=5, m="M_PaintGreen", scale=(1, 1, 0.85)))
# GreenHaul plaque on the counter front, and on the -X side like the old terminal
P.append(g(bx("plaque", -0.3, 0.3, -0.325, -0.29, 0.26, 0.86, WD, bev=0.012, segs=1), GZ))
yl = -0.33
P.append(quad("logo", (-0.26, yl, 0.3), (0.26, yl, 0.3), (0.26, yl, 0.82), (-0.26, yl, 0.82), "M_Logo"))
xl = -0.507
P.append(quad("logo", (xl, 0.26, 0.3), (xl, -0.2, 0.3), (xl, -0.2, 0.76), (xl, 0.26, 0.76), "M_Logo"))
fin(P, "Body", uv=1.0, ang=40, ms={"M_Fabric": 1.6, "M_Burlap": 2.0})
# Screen: UV 0..1 exactly over the board. Faces -Y, tilted up 15 deg, same corners as the old screen. Matte chalkboard, not M_Screen
corners = [H @ Vector(c) for c in ((-0.32, ys, -0.2), (0.32, ys, -0.2), (0.32, ys, 0.2), (-0.32, ys, 0.2))]
sc = quad("Screen", *[tuple(c) for c in corners], "M_Charcoal")
set_origin(sc, tuple(sum(corners, Vector()) / 4))
return dict(elev=16, azim=-35)
# ======================================================================= 5. harbour: the open-fronted tractor shed
def tractor(P, x, y):
"""Little green tractor parked nose-out (-Y). Set dressing, it doesn't drive."""
Q = []
Q.append(g(bx("thood", -0.26, 0.26, -0.82, 0.02, 0.56, 1.02, GP, bev=0.09, segs=2), GY))
Q.append(bx("tgrille", -0.2, 0.2, -0.84, -0.8, 0.62, 0.96, IR, bev=0.02, segs=1))
for k in range(3):
z = 0.68 + k * 0.1
Q.append(bx("tbar", -0.17, 0.17, -0.855, -0.83, z, z + 0.04, CP, bev=0.008, segs=1))
Q.append(bx("tframe", -0.14, 0.14, -0.9, 0.6, 0.4, 0.58, IR, bev=0.03, segs=1))
Q.append(bx("tcowl", -0.3, 0.3, 0.02, 0.5, 0.56, 0.78, GP, bev=0.06, segs=2))
Q.append(bx("tseat", -0.19, 0.19, 0.14, 0.46, 0.78, 0.86, YP, bev=0.03, segs=2))
Q.append(bx("tback", -0.19, 0.19, 0.42, 0.52, 0.84, 1.14, YP, bev=0.03, segs=2))
Q.append(pipe("tcol", [(0.0, 0.02, 0.78), (0.0, -0.1, 1.12)], 0.02, IR, segs=6))
Q.append(torus("twheel", 0.15, 0.018, loc=(0.0, -0.1, 1.13), seg=14, rseg=4, m=IR))
Q.append(cy("texhaust", 0.035, 0.5, (0.17, -0.5, 1.2), IR, v=8))
Q.append(cy("texcap", 0.045, 0.06, (0.17, -0.5, 1.47), ST, v=8))
for s in (-1, 1):
Q.append(cy("tyreb", 0.47, 0.26, (s * 0.46, 0.36, 0.59), "M_Rubber", axis="X", v=20, bev=0.05, segs=2))
Q.append(cy("hubb", 0.27, 0.03, (s * 0.6, 0.36, 0.59), YP, axis="X", v=14))
Q.append(bx("fender", s * 0.46 - 0.15, s * 0.46 + 0.15, 0.0, 0.72, 1.08, 1.12, GP, bev=0.015, segs=1))
Q.append(cy("tyref", 0.25, 0.15, (s * 0.34, -0.66, 0.37), "M_Rubber", axis="X", v=16, bev=0.03, segs=2))
Q.append(cy("hubf", 0.13, 0.03, (s * 0.42, -0.66, 0.37), YP, axis="X", v=10))
Q.append(log("axle", (-0.34, -0.66, 0.37), (0.34, -0.66, 0.37), 0.03, IR, v=6))
Q.append(log("axle", (-0.46, 0.36, 0.59), (0.46, 0.36, 0.59), 0.05, IR, v=6))
xfm(Q, loc=(x, y, 0.12))
P += Q
def harbour():
Y0, Y1, EV, PEAK = -1.0, 1.35, 2.3, 3.55
P = []
# plank floor with a front apron
P.append(bx("floor", -2.0, 2.0, -1.48, 1.48, 0.0, 0.12, PK, bev=0.03, segs=1))
# red board back and side walls, open front
back = [(-1.92, 0.12), (1.92, 0.12), (1.92, EV), (0.0, PEAK), (-1.92, EV)]
P.append(g(prism("back", back, "XZ", Y1 - 0.09, Y1, RD), GZ))
for sx in (-1, 1):
x0, x1 = sorted((sx * 1.92, sx * 1.83))
P.append(g(bx("side", x0, x1, Y0, Y1, 0.12, EV, RD, bev=0.012, segs=1), GZ))
P.append(g(bx("sideskirt", x0 - 0.02, x1 + 0.02, Y0, Y1 + 0.02, 0.12, 0.3, WD, bev=0.02, segs=1), GY))
# corner posts front and back
P.append(g(bx("post", sx * 1.86 - 0.11, sx * 1.86 + 0.11, Y0 - 0.11, Y0 + 0.11, 0.1, EV + 0.06, WD, bev=0.035, segs=2), GZ))
P.append(g(bx("postb", sx * 1.87 - 0.09, sx * 1.87 + 0.09, Y1 - 0.08, Y1 + 0.03, 0.1, EV, WD, bev=0.03, segs=1), GZ))
# knee braces at the opening
P.append(beam("knee", (sx * 1.78, Y0, 1.6), (sx * 1.16, Y0, 2.2), 0.09, 0.13, WD, bev=0.024, segs=1))
P.append(nut((sx * 1.72, Y0 - 0.05, 1.72), axis="Y", r=0.03, h=0.016, m=IR))
P.append(g(bx("header", -2.0, 2.0, Y0 - 0.12, Y0 + 0.12, EV - 0.14, EV + 0.1, WD, bev=0.035, segs=2), GX))
# cream gable over the opening
P.append(g(prism("gable", [(-1.94, EV + 0.09), (1.94, EV + 0.09), (0.0, PEAK)], "XZ", Y0 - 0.03, Y0 + 0.05, CR), GZ))
# tie beams and rafters, seen from the front
for y in (-0.15, 0.7):
P.append(beam("tie", (-1.9, y, EV - 0.02), (1.9, y, EV - 0.02), 0.1, 0.14, WD, bev=0.024, segs=1))
for sx in (-1, 1):
P.append(beam("rafter", (sx * 1.88, y, EV - 0.13), (0.0, y, PEAK - 0.12), 0.08, 0.13, WD, bev=0.02, segs=1))
P.append(beam("rpurlin", (0.0, Y0, PEAK - 0.16), (0.0, Y1, PEAK - 0.16), 0.1, 0.14, WD, bev=0.024, segs=1))
# tin roof, ridge along Y so the gable faces the pad
shell = [(-2.02, EV - 0.06), (0.0, PEAK + 0.07), (2.02, EV - 0.06), (2.02, EV - 0.14), (0.0, PEAK - 0.02), (-2.02, EV - 0.14)]
P.append(ribs(prism("roof", shell, "XZ", -1.47, 1.47, TN, bev=0.012, segs=1, ang=50), GY))
P.append(beam("ridge", (0.0, -1.49, PEAK + 0.07), (0.0, 1.49, PEAK + 0.07), 0.28, 0.05, ST, bev=0.018, segs=1))
for y in (-1.44, 1.44):
for sx in (-1, 1):
P.append(beam("barge", (sx * 1.96, y, EV - 0.07), (0.0, y, PEAK + 0.02), 0.08, 0.15, CR, bev=0.022, segs=1))
# GARAGE sign on the gable, mower pictogram above it
sg = bx("sign", -1.0, 1.0, Y0 - 0.1, Y0 - 0.03, EV + 0.17, EV + 0.63, RD, bev=0.026, segs=2)
P.append(g(sg, GX))
for sx in (-1, 1):
P.append(g(bx("signcap", sx * 0.96 - 0.04, sx * 0.96 + 0.04, Y0 - 0.11, Y0 - 0.03, EV + 0.17, EV + 0.63, CR, bev=0.014, segs=1), GZ))
t = text_mesh("label", "GARAGE", 0.3, CP)
P.append(orient(t, "-Y", (0.0, Y0 - 0.105, EV + 0.4)))
boat_icon(P, (0.0, Y0 - 0.045, EV + 0.92), "-Y", s=0.95)
# workbench where the old office counter was (Counter empty stands in front of it)
bz = 0.92
P.append(bx("bench", 0.34, 1.78, Y0 + 0.06, Y0 + 0.62, bz, bz + 0.09, WD, bev=0.024, segs=1))
for x in (0.42, 1.7):
for y in (Y0 + 0.14, Y0 + 0.54):
P.append(g(bx("benchleg", x - 0.05, x + 0.05, y - 0.05, y + 0.05, 0.12, bz, WD, bev=0.018, segs=1), GZ))
P.append(bx("benchshelf", 0.42, 1.7, Y0 + 0.14, Y0 + 0.54, 0.34, 0.39, WD, bev=0.014, segs=1))
P.append(revolve("bell", [(0, bz + 0.09), (0.07, bz + 0.09), (0.07, bz + 0.11), (0.055, bz + 0.145), (0.025, bz + 0.17), (0, bz + 0.18)], segs=12,
m="M_Brass", loc=(0.62, Y0 + 0.24, 0), close_top=False))
P.append(bx("ledger", 1.05, 1.42, Y0 + 0.14, Y0 + 0.4, bz + 0.09, bz + 0.13, GP, bev=0.01, segs=1))
P.append(cy("oilcan", 0.1, 0.24, (1.56, Y0 + 0.38, bz + 0.21), RP, v=10, bev=0.012, segs=1))
# tools on the back wall
ry = Y1 - 0.13
P.append(g(bx("toolboard", -1.1, 0.5, ry - 0.02, ry + 0.04, 1.05, 1.95, CR, bev=0.018, segs=1), GZ))
for (x, kind) in ((-0.8, "spade"), (-0.3, "rake"), (0.2, "fork")):
P.append(beam("thandle", (x, ry - 0.05, 1.05), (x, ry - 0.05, 1.86), 0.04, 0.04, WD, bev=0.012, segs=1))
if kind == "spade":
P.append(bx("thead", x - 0.13, x + 0.13, ry - 0.06, ry - 0.04, 0.8, 1.08, IR, bev=0.01, segs=1))
else:
P.append(bx("thead", x - 0.17, x + 0.17, ry - 0.07, ry - 0.03, 1.05, 1.09, IR, bev=0.008, segs=1))
for k in range(5 if kind == "rake" else 3):
xx = x - 0.15 + 0.3 * k / (4 if kind == "rake" else 2)
P.append(bx("ttine", xx - 0.011, xx + 0.011, ry - 0.06, ry - 0.04, 0.88, 1.06, IR))
# hay in the back corner, a spare tyre on the -X wall, tin drum
bale(P, 0.2, 0.98, 0.56, 1.22, 0.12, 0.6)
bale(P, 1.02, 1.78, 0.5, 1.2, 0.12, 0.6)
bale(P, 0.72, 1.48, 0.56, 1.2, 0.6, 1.08)
P.append(torus("tyre", 0.24, 0.062, loc=(-1.958, 0.15, 1.42), axis="X", seg=20, rseg=6, m="M_Rubber"))
P.append(cy("tyrerim", 0.17, 0.05, (-1.945, 0.15, 1.42), YP, axis="X", v=14))
P.append(cy("drum", 0.22, 0.62, (-1.52, 1.02, 0.44), TN, v=14, bev=0.02, segs=1))
for z in (0.26, 0.62):
P.append(annulus("drumband", 0.21, 0.228, z - 0.018, z + 0.018, IR, segs=14, c=(-1.52, 1.02)))
tractor(P, -0.78, -0.08)
# hitching posts with a rope coil on the apron, where the old bollards were
for x in (-1.78, 1.82):
P.append(cy("hitch", 0.09, 0.56, (x, -1.28, 0.38), WD, v=10, bev=0.03, segs=1))
P.append(cy("hitchb", 0.1, 0.05, (x, -1.28, 0.52), IR, v=10))
for k in range(3):
P.append(torus("rope", 0.17 - k * 0.014, 0.022, (-1.78, -1.28, 0.15 + k * 0.042), "Z", seg=16, rseg=5, m=RO))
# barn lamp hanging in the opening (the old model's Lamp part)
lx, ly = 0.42, Y0 + 0.02
P.append(pipe("lhang", [(lx, ly, EV - 0.14), (lx, ly, EV - 0.42)], 0.012, IR, segs=5))
P.append(cy("lshade", 0.2, 0.09, (lx, ly, EV - 0.46), GP, v=12, r2=0.04))
fin(P, "Body", uv=1.0, ang=40)
fin([dome("lbulb", 0.08, (lx, ly, EV - 0.5), "M_LightAmber", k=-1.0, seg=10, rings=3)], "Lamp", uv=1.0, ang=60, origin=(lx, ly, EV - 0.5))
empty("Counter", (1.1, Y0 - 0.6, 0.0))
return dict(elev=18, azim=-30)
# ======================================================================= 6. dock: timber loading ramp
def ramp():
"""Loading ramp from the deck edge (y = 0, z = 0) down to the meadow (y = -6, z = -1.2). Same slope and width as the old one,
its colliders (RampDeck, RampCurbL/R) are hard-coded in ProjectBuilder.Scene."""
L, W = 6.12, 3.0
F = [] # built flat, then tilted down as a whole
for x in (-0.8, 0.8):
F.append(bx("stringer", x - 0.08, x + 0.08, -L, -0.02, -0.32, -0.06, WD, bev=0.02, segs=1))
y = -L
while y < -0.18:
y1 = min(y + 0.31, -0.18)
F.append(bx("plank", -W / 2 + 0.12, W / 2 - 0.12, y, y1 - 0.02, -0.075, 0.0, PK, bev=0.014, segs=1))
y += 0.31
for sx in (-1, 1):
x0, x1 = sorted((sx * (W / 2 - 0.12), sx * W / 2))
F.append(bx("curb", x0, x1, -L, 0.0, -0.32, 0.1, WD, bev=0.03, segs=2))
for yy in (-1.0, -3.0, -5.0):
xc = sx * (W / 2 - 0.06)
pts = [(yy - 0.06, 0.08), (yy + 0.06, 0.08), (yy + 0.06, 0.55), (yy, 0.62), (yy - 0.06, 0.55)]
F.append(g(prism("rpost", pts, "YZ", xc - 0.06, xc + 0.06, WD, bev=0.012, segs=1, ang=35), GZ))
F.append(bx("rband", xc - 0.066, xc + 0.066, yy - 0.066, yy + 0.066, 0.42, 0.47, IR, bev=0.01, segs=1))
F.append(nut((sx * 1.497, yy, -0.1), axis="X", r=0.03, h=0.006, m=IR))
# rope handrail sagging between the posts
for (a, b) in ((-1.0, -3.0), (-3.0, -5.0)):
pts = []
for k in range(7):
t = k / 6
pts.append((sx * (W / 2 - 0.06), a + (b - a) * t, 0.5 - 0.14 * (1 - (2 * t - 1) ** 2)))
F.append(pipe("rrope", pts, 0.017, RO, segs=5))
# iron threshold at the top, iron lip at the bottom
F.append(bx("thresh", -W / 2 + 0.12, W / 2 - 0.12, -0.18, 0.0, -0.06, 0.008, IR, bev=0.01, segs=1))
for x in (-1.0, -0.33, 0.33, 1.0):
F.append(nut((x, -0.09, 0.012), r=0.022, h=0.012))
F.append(bx("lip", -W / 2 + 0.12, W / 2 - 0.12, -L - 0.3, -L + 0.02, -0.04, 0.0, IR, bev=0.012, segs=1))
for o in F:
xf(o, rot=(math.degrees(math.asin(0.2)), 0, 0))
P = list(F)
# legs down to the ground, cross braced
for yy in (-2.0, -4.0):
z = yy * 0.2 / math.cos(math.asin(0.2)) - 0.1
for sx in (-1, 1):
P.append(g(bx("leg", sx * 1.3 - 0.09, sx * 1.3 + 0.09, yy - 0.09, yy + 0.09, -1.3, z - 0.16, WD, bev=0.024, segs=1), GZ))
P.append(bx("foot", sx * 1.3 - 0.19, sx * 1.3 + 0.19, yy - 0.19, yy + 0.19, -1.35, -1.26, "M_Concrete", bev=0.03, segs=1))
P.append(bx("cross", -1.4, 1.4, yy - 0.05, yy + 0.05, z - 0.3, z - 0.14, WD, bev=0.02, segs=1))
z = -2.0 * 0.2 / math.cos(math.asin(0.2)) - 0.1
P.append(beam("xbrace", (-1.2, -2.08, z - 0.3), (1.2, -2.08, -1.2), 0.05, 0.11, WD, bev=0.016, segs=1))
P.append(beam("xbrace", (1.2, -1.92, z - 0.3), (-1.2, -1.92, -1.2), 0.05, 0.11, WD, bev=0.016, segs=1))
fin(P, "Body", uv=1.0, ang=40)
return dict(elev=26, azim=-50)
# ======================================================================= 7. launch pad: timber crib, iron-bound cradle
PAD_C = (0.0, 0.35)
PAD_TOP = 0.58
def chev(yb):
return [(-0.6, yb), (0.0, yb + 0.22), (0.6, yb), (0.6, yb + 0.11), (0.0, yb + 0.33), (-0.6, yb + 0.11)]
def launch_pad():
P = []
C = PAD_C
zt = 0.25
# timber crib base: two courses of baulks round a nailed plank top
P.append(bx("fill", -2.86, 2.86, -1.72, 2.86, 0.0, 0.16, WD))
P.append(bx("top", -2.82, 2.82, -1.67, 2.82, 0.17, zt, PK, bev=0.02, segs=1))
for k, (z0, z1) in enumerate(((0.0, 0.12), (0.12, 0.24))):
d = 0.0 if k == 0 else 0.05
P.append(bx("crib", -2.95 + d, 2.95 - d, -1.8 + d, -1.67 + d, z0, z1, WD, bev=0.03, segs=1))
P.append(bx("crib", -2.95 + d, 2.95 - d, 2.82 - d, 2.95 - d, z0, z1, WD, bev=0.03, segs=1))
for s in (-1, 1):
x0, x1 = sorted((s * (2.95 - d), s * (2.82 - d)))
P.append(bx("crib", x0, x1, -1.8 + d, 2.95 - d, z0, z1, WD, bev=0.03, segs=1))
for (x, y) in ((-2.87, -1.74), (2.87, -1.74), (-2.87, 2.87), (2.87, 2.87)):
P.append(cy("spike", 0.04, 0.03, (x, y, 0.245), IR, v=6))
# the cradle: two stacked rings of timber baulks, staggered, bound by iron hoops
n = 16
for k in range(n):
for tier, (r0, r1, z0, z1, a_off) in enumerate(((1.37, 2.12, zt, zt + 0.17, 0.0), (1.4, 2.04, zt + 0.17, PAD_TOP - 0.004, 180.0 / n))):
a0 = 360.0 * k / n + a_off + 0.45
a1 = 360.0 * (k + 1) / n + a_off - 0.45
o = annulus("cbaulk", r0, r1, z0, z1, WD, segs=2, a0=a0, a1=a1, c=C)
am = DEG((a0 + a1) / 2)
P.append(g(o, (-math.sin(am), math.cos(am), 0.0)))
for (r, z0, z1) in ((2.12, zt + 0.05, zt + 0.11), (2.04, zt + 0.22, zt + 0.28)):
P.append(annulus("hoop", r - 0.012, r + 0.014, z0, z1, IR, segs=40, c=C))
for k in range(20):
a = 2 * math.pi * k / 20
P.append(rv((C[0] + 2.137 * math.cos(a), C[1] + 2.137 * math.sin(a), zt + 0.08), r=0.022))
# iron strike plates where the rocket's feet land (fins sit on the diagonals)
for k in range(4):
a = 45.0 + 90.0 * k
P.append(annulus("strike", 1.44, 2.0, PAD_TOP - 0.012, PAD_TOP + 0.002, IR, segs=3, a0=a - 11, a1=a + 11, c=C))
# pit: iron floor, flame deflector cone, grate
P.append(cy("pit", 1.38, 0.04, (C[0], C[1], zt + 0.02), IR, v=32))
P.append(revolve("deflector", [(1.1, zt + 0.04), (0.7, zt + 0.07), (0.35, zt + 0.15), (0.12, zt + 0.21), (0.0, zt + 0.22)],
segs=20, m=ST, loc=(C[0], C[1], 0), close_top=False))
gz0, gz1 = zt + 0.19, zt + 0.25
for k in range(8):
bar = bx("gbar", 0.3, 1.39, -0.04, 0.04, gz0, gz1, IR, bev=0.012, segs=1)
xf(bar, rot=(0, 0, 45.0 * k + 22.5), loc=(C[0], C[1], 0))
P.append(bar)
for (r0, r1) in ((0.24, 0.32), (0.84, 0.9)):
P.append(annulus("gring", r0, r1, gz0, gz1, IR, segs=24, c=C))
# four cradle cheeks on the cardinals: timber knees with an iron shoe and a burlap pad against the hull
clamp_pts = chaikin([(1.55, PAD_TOP - 0.02), (2.02, PAD_TOP - 0.02), (1.95, 1.3), (1.78, 2.0), (1.34, 2.0), (1.34, 1.78), (1.56, 1.62)], 1)
for k in range(4):
a = 90.0 * k
Kp = [g(prism("cheek", clamp_pts, "XZ", -0.14, 0.14, WD, bev=0.04, segs=2, ang=40), GZ),
bx("cpad", 1.28, 1.36, -0.13, 0.13, 1.74, 1.98, "M_Burlap", bev=0.03, segs=2),
cy("cpin", 0.055, 0.34, (1.68, 0, 1.0), IR, axis="Y", v=10),
bx("cbase", 1.5, 2.06, -0.18, 0.18, PAD_TOP - 0.03, PAD_TOP + 0.07, IR, bev=0.025, segs=1),
bx("cstrap", 1.46, 1.9, -0.155, 0.155, 1.54, 1.6, IR, bev=0.012, segs=1)]
xfm(Kp, rot=(0, 0, a), loc=(C[0], C[1], 0))
P += Kp
# ---- service derrick (back-right corner, same place and height as the old gantry)
T = (2.33, 2.37)
hw = 0.47
lv = [zt, 1.7, 3.15, 4.6, 6.05, 7.3]
for sx in (-1, 1):
for sy in (-1, 1):
x, y = T[0] + sx * hw, T[1] + sy * hw
P.append(g(bx("col", x - 0.1, x + 0.1, y - 0.1, y + 0.1, zt, 7.32, WD, bev=0.035, segs=2), GZ))
P.append(bx("colfoot", x - 0.135, x + 0.135, y - 0.135, y + 0.135, zt, zt + 0.1, IR, bev=0.02, segs=1))
for z in lv[1:]:
for s in (-1, 1):
P.append(beam("girt", (T[0] - hw - 0.12, T[1] + s * hw, z), (T[0] + hw + 0.12, T[1] + s * hw, z), 0.1, 0.14, WD, bev=0.026, segs=1))
P.append(beam("girt", (T[0] + s * hw, T[1] - hw - 0.12, z + 0.0), (T[0] + s * hw, T[1] + hw + 0.12, z + 0.0), 0.09, 0.13, WD, bev=0.026, segs=1))
# little red tool shed in the bottom bay (door faces -Y)
P.append(g(bx("tbay", T[0] - hw + 0.02, T[0] + hw - 0.02, T[1] - hw + 0.02, T[1] + hw - 0.02, zt, lv[1] - 0.05, RD, bev=0.03, segs=1), GZ))
P.append(g(bx("tdoor", T[0] - 0.26, T[0] + 0.14, T[1] - hw - 0.0, T[1] - hw + 0.04, zt + 0.02, zt + 1.22, CR, bev=0.03, segs=1), GZ))
P.append(beam("tdz", (T[0] - 0.2, T[1] - hw - 0.006, zt + 0.1), (T[0] + 0.08, T[1] - hw - 0.006, zt + 1.14), 0.014, 0.07, RP, bev=0))
P.append(cy("tdknob", 0.022, 0.03, (T[0] + 0.06, T[1] - hw - 0.01, zt + 0.62), IR, axis="Y", v=8))
# cross bracing on the faces above the shed
for i in range(1, len(lv) - 1):
z0, z1 = lv[i] + 0.08, lv[i + 1] - 0.08
for (ax, s) in (("x", -1), ("x", 1), ("y", -1), ("y", 1)):
for flip in (0, 1):
a0, a1 = (-hw, hw) if not flip else (hw, -hw)
d = s * (0.118 if flip else -0.118)
if ax == "x":
p0, p1 = (T[0] + s * hw + d, T[1] + a0, z0), (T[0] + s * hw + d, T[1] + a1, z1)
else:
p0, p1 = (T[0] + a0, T[1] + s * hw + d, z0), (T[0] + a1, T[1] + s * hw + d, z1)
P.append(beam("brace", p0, p1, 0.036, 0.09, WD, bev=0.012, segs=1))
# plank floors at the arm levels
for z in (4.6, 6.05):
P.append(bx("floor", T[0] - hw, T[0] + hw, T[1] - hw, T[1] + hw, z + 0.06, z + 0.1, "M_WoodDeck", bev=0.012, segs=1))
# tin pyramid cap, lantern and a pennant on a pole
rf = revolve("troof", [(0.82, 7.36), (0.0, 7.82)], segs=4, m=TN, close_top=False, close_bottom=True)
xf(rf, rot=(0, 0, 45), loc=(T[0], T[1], 0))
P.append(g(rf, GZ))
P.append(bx("troofrim", T[0] - 0.6, T[0] + 0.6, T[1] - 0.6, T[1] + 0.6, 7.3, 7.38, WD, bev=0.02, segs=1))
P.append(cy("tmast", 0.024, 0.8, (T[0], T[1], 8.08), IR, v=8))
P.append(sphere("tball", 0.05, loc=(T[0], T[1], 8.445), seg=8, rings=5, m="M_Brass"))
P.append(prism("pennant", [(T[0] - 0.02, 8.3), (T[0] - 0.02, 8.04), (T[0] - 0.56, 8.17)], "XZ", T[1] - 0.006, T[1] + 0.006, RP))
P.append(cy("lamp", 0.08, 0.16, (T[0] + 0.46, T[1] - 0.46, 7.15), "M_LightAmber", v=8))
P.append(cy("lampcap", 0.1, 0.06, (T[0] + 0.46, T[1] - 0.46, 7.25), IR, v=8, r2=0.03))
# timber ladder up the front of the tower
ly = T[1] - hw - 0.17
lx = T[0] + 0.24
for dx in (-0.17, 0.17):
P.append(g(bx("lrail", lx + dx - 0.03, lx + dx + 0.03, ly - 0.03, ly + 0.03, lv[1], 7.22, WD, bev=0.012, segs=1), GZ))
z = lv[1] + 0.25
while z < 7.2:
P.append(log("lrung", (lx - 0.17, ly, z), (lx + 0.17, ly, z), 0.018, WD, v=6))
z += 0.34
for z in (2.4, 4.0, 5.5, 6.9):
for dx in (-0.17, 0.17):
P.append(bx("lbrk", lx + dx - 0.015, lx + dx + 0.015, ly, T[1] - hw, z - 0.02, z + 0.02, IR))
# service booms toward the rocket: a timber arm with hoses, a plank gangway on rope stays
d = Vector((C[0] - T[0], C[1] - T[1], 0))
Ld = d.length
phi = math.degrees(math.atan2(d.y, d.x))
La = Ld - 1.3
A1 = [bx("arm1", 0.3, La - 0.15, -0.1, 0.1, 4.62, 4.84, WD, bev=0.04, segs=2),
bx("head1", La - 0.22, La - 0.02, -0.17, 0.17, 4.52, 4.9, IR, bev=0.05, segs=1),
bx("pad1", La - 0.04, La + 0.04, -0.14, 0.14, 4.56, 4.86, "M_Burlap", bev=0.03, segs=2),
beam("kneeA", (0.25, 0.0, 3.9), (1.0, 0.0, 4.64), 0.08, 0.1, WD, bev=0.02, segs=1),
pipe("hose", [(0.25, 0.16, 4.62), (La * 0.45, 0.16, 4.3), (La - 0.15, 0.16, 4.62)], 0.05, "M_Rubber", segs=6, fil=0.6, fn=5),
pipe("hose2", [(0.25, -0.16, 4.66), (La * 0.5, -0.16, 4.42), (La - 0.15, -0.16, 4.66)], 0.035, GP, segs=6, fil=0.6, fn=5)]
A2 = [bx("arm2", 0.3, La - 0.12, -0.3, 0.3, 6.1, 6.17, PK, bev=0.018, segs=1),
bx("head2", La - 0.16, La + 0.02, -0.33, 0.33, 6.03, 6.2, IR, bev=0.04, segs=1),
bx("pad2", La - 0.02, La + 0.05, -0.28, 0.28, 6.05, 6.5, "M_Burlap", bev=0.03, segs=2)]
for s in (-1, 1):
A2.append(beam("gstring", (0.3, s * 0.27, 6.03), (La - 0.1, s * 0.27, 6.03), 0.07, 0.12, WD, bev=0.02, segs=1))
for x in (0.42, La - 0.2):
A2.append(g(bx("gpost", x - 0.03, x + 0.03, s * 0.3 - 0.03, s * 0.3 + 0.03, 6.1, 6.68, WD, bev=0.012, segs=1), GZ))
A2.append(pipe("grope", [(0.42, s * 0.3, 6.62), (La * 0.5, s * 0.3, 6.52), (La - 0.2, s * 0.3, 6.62)], 0.014, RO, segs=5, fil=0.7, fn=4))
for o in A1 + A2:
xf(o, rot=(0, 0, phi), loc=(T[0], T[1], 0))
P += A1 + A2
# fuel tanks (back-left): red farm diesel tanks on timber saddles
for x in (-2.48, -1.86):
P.append(pill("tank", 0.28, 1.25, (x, 2.28, zt + 0.42), RP, axis="Y", seg=14, cr=3))
for y in (1.95, 2.6):
band = annulus("tband", 0.27, 0.295, -0.04, 0.04, IR, segs=14)
xf(band, rot=(-90, 0, 0), loc=(x, y, zt + 0.42))
P.append(band)
P.append(bx("cradle", x - 0.2, x + 0.2, y - 0.07, y + 0.07, zt, zt + 0.22, WD, bev=0.02, segs=1))
P.append(cy("valve", 0.05, 0.1, (x, 2.28, zt + 0.74), IR, v=8))
P.append(cy("vwheel", 0.08, 0.025, (x, 2.28, zt + 0.8), "M_Brass", v=10))
P.append(pipe("fuel", [(-2.17, 1.7, zt + 0.42), (-2.17, 1.25, zt + 0.42), (-1.5, 0.9, zt + 0.12), (-1.2, 0.75, zt + 0.12)], 0.05, ST, segs=6, fil=0.3, fn=3))
# lanterns on posts at the front corners of the crib
for s in (-1, 1):
x, y = s * 2.62, -1.42
P.append(g(bx("wpost", x - 0.09, x + 0.09, y - 0.09, y + 0.09, zt, zt + 0.5, WD, bev=0.026, segs=1), GZ))
P.append(cy("wband", 0.13, 0.05, (x, y, zt + 0.5), IR, v=8))
P.append(cy("wlight", 0.075, 0.12, (x, y, zt + 0.58), "M_LightAmber", v=8))
P.append(cy("wcap", 0.11, 0.06, (x, y, zt + 0.67), IR, v=8, r2=0.03))
# ---- cargo bay (front, on the deck): same opening, marked with hay-gold boards and cream arrows
P.append(bx("bayfloor", -1.6, 1.6, -2.88, -1.9, 0.0, 0.03, WD, bev=0.008, segs=1))
for (x0, x1, y0, y1) in ((-1.7, 1.7, -2.98, -2.88), (-1.7, 1.7, -1.9, -1.8), (-1.7, -1.6, -2.88, -1.9), (1.6, 1.7, -2.88, -1.9)):
P.append(bx("bayframe", x0, x1, y0, y1, 0.0, 0.04, YP, bev=0.012, segs=1))
for yb in (-2.8, -2.53, -2.26):
P.append(prism("chev", chev(yb), "XY", 0.025, 0.036, CP))
for s in (-1, 1):
P.append(pill("baycurb", 0.05, 0.9, (s * 1.45, -2.39, 0.06), WD, axis="Y", seg=8, cr=2))
# gate posts with green "ready" lanterns (just inside the lever, so they no longer stand in its box)
for s in (-1, 1):
x, y = s * 1.78, -2.4
P.append(g(bx("pylon", x - 0.12, x + 0.12, y - 0.12, y + 0.12, 0.0, 1.05, WD, bev=0.035, segs=2), GZ))
for z in (0.12, 0.74):
P.append(bx("pyband", x - 0.13, x + 0.13, y - 0.13, y + 0.13, z, z + 0.06, IR, bev=0.014, segs=1))
P.append(bx("pycap", x - 0.15, x + 0.15, y - 0.15, y + 0.15, 1.04, 1.1, IR, bev=0.02, segs=1))
P.append(cy("pylight", 0.07, 0.1, (x, y, 1.15), "M_LightGreen", v=8))
P.append(cy("pyhat", 0.1, 0.05, (x, y, 1.225), IR, v=8, r2=0.03))
# loading chute in the crib front
P.append(bx("chute", -0.7, 0.7, -1.83, -1.75, 0.035, 0.2, IR, bev=0.02, segs=1))
P.append(bx("chutef", -0.78, 0.78, -1.815, -1.77, 0.02, 0.215, WD, bev=0.02, segs=1))
P.append(bx("chutefl", -0.64, 0.64, -1.84, -1.815, 0.05, 0.2, "M_Burlap", bev=0.008, segs=1))
fin(P, "Body", uv=1.0, ang=40, ms={"M_Burlap": 2.0})
empty("RocketMount", (C[0], C[1], PAD_TOP))
empty("Bay", (0.0, -2.39, 0.0))
return dict(elev=24, azim=-38)
# ======================================================================= 8. rocket: a galvanised silo with ambitions
RK_R = 1.18
def rocket():
P = []
R = RK_R
prof = [(0.0, 0.98), (0.55, 0.99), (0.82, 1.02), (1.02, 1.08), (1.16, 1.18), (1.235, 1.3), (1.262, 1.42), (1.245, 1.54), (1.21, 1.64), (R, 1.72)]
prof += [(R, z) for z in (2.2, 3.0, 3.6, 4.2, 5.0, 5.6, 6.2)]
NZ0, NL = 6.2, 2.8
rho = (R * R + NL * NL) / (2 * R)
def ogive(zz):
x = NZ0 + NL - zz
return math.sqrt(max(0.0, rho * rho - (NL - x) ** 2)) + R - rho
ztop = 8.744
zs = sorted([NZ0 + 0.03 + (ztop - NZ0 - 0.03) * (1 - (1 - k / 10) ** 1.5) for k in range(11)] + [6.75, 6.95])
prof += [(ogive(zz), zz) for zz in zs]
hull = revolve("hull", prof, segs=36, m=TN, close_top=True)
mat_by(hull, lambda c, n: CP if 6.75 < c.z < 6.95 else (RP if c.z > 6.2 else TN))
# corrugations run round the silo like a real grain bin: ribs step along z
uv_cyl(hull, axis=2, circ_scale=2 * math.pi * R * 0.5, len_scale=0.8)
uvd = hull.data.uv_layers.active.data
for lp in uvd:
lp.uv = (lp.uv[1], lp.uv[0])
hull["uvkeep"] = True
P.append(hull)
# iron hoops with rivets, vertical lap seams
hoops = (1.9, 3.74, 5.0, 6.2)
for z in hoops:
P.append(annulus("hoop", R - 0.01, R + 0.02, z - 0.055, z + 0.055, IR, segs=36))
for k in range(14):
a = 2 * math.pi * (k + 0.5) / 14
P.append(rv(((R + 0.024) * math.cos(a), (R + 0.024) * math.sin(a), z)))
for ac in (60.0, 120.0, 240.0, 300.0):
P.append(annulus("seam", R - 0.01, R + 0.008, 1.95, 6.15, ST, segs=1, a0=ac - 0.9, a1=ac + 0.9))
z = 2.1
while z < 6.1:
if not any(abs(z - h) < 0.1 for h in hoops):
a = DEG(ac)
P.append(rv(((R + 0.012) * math.cos(a), (R + 0.012) * math.sin(a), z), r=0.02))
z += 0.39
# bolted-on patches: somebody hit something
for (ac, z0, z1, hw_a) in ((212.0, 4.2, 4.78, 13.0), (328.0, 2.1, 2.6, 11.0)):
P.append(annulus("patch", R - 0.01, R + 0.016, z0, z1, ST, segs=4, a0=ac - hw_a, a1=ac + hw_a))
for (da, z) in ((-hw_a + 1.5, z0 + 0.05), (hw_a - 1.5, z0 + 0.05), (-hw_a + 1.5, z1 - 0.05), (hw_a - 1.5, z1 - 0.05), (0.0, z0 + 0.05), (0.0, z1 - 0.05)):
a = DEG(ac + da)
P.append(rv(((R + 0.02) * math.cos(a), (R + 0.02) * math.sin(a), z), r=0.02))
# nose: iron meridian seams, tip cap and a ball finial
for k in range(4):
am = DEG(45.0 + 90.0 * k)
for zz in (6.55, 7.05, 7.5, 7.9, 8.25):
rr_ = ogive(zz) + 0.008
P.append(rv((rr_ * math.cos(am), rr_ * math.sin(am), zz), r=0.02, m=IR))
P.append(torus("tipring", 0.245, 0.03, loc=(0, 0, 8.745), seg=16, rseg=4, m=IR))
P.append(sphere("tip", 0.25, loc=(0, 0, 8.745), seg=16, rings=8, m=IR, scale=(1, 1, 0.95)))
P.append(cy("ant", 0.022, 0.3, (0, 0, 9.1), IR, v=8))
P.append(sphere("antl", 0.06, loc=(0, 0, 9.28), seg=10, rings=6, m="M_Brass"))
# engine: an iron funnel
bell = revolve("bell", [(0.6, 0.32), (0.57, 0.45), (0.48, 0.65), (0.38, 0.84), (0.34, 1.0), (0.29, 1.0), (0.32, 0.84), (0.42, 0.65), (0.51, 0.45), (0.545, 0.33)],
segs=24, m=IR, close_top=False)
P.append(bell)
P.append(torus("lip", 0.572, 0.032, loc=(0, 0, 0.325), seg=24, rseg=6, m=ST))
for zr in (0.55, 0.75):
rr_ = 0.57 - (zr - 0.45) * 0.47
P.append(torus("bellring", rr_ + 0.005, 0.018, loc=(0, 0, zr), seg=24, rseg=4, m=ST))
P.append(cy("mount", 0.42, 0.12, (0, 0, 0.98), IR, v=20, bev=0.02, segs=1))
# barn-red board fins on hardwood feet, strapped on with iron
fpts = chaikin([(0.98, 3.35), (0.98, 1.3), (1.42, 0.12), (1.92, 0.12), (1.98, 0.85), (1.84, 1.85), (1.36, 3.1)], 2)
for k in range(4):
a = 45.0 + 90.0 * k
Fp = [g(prism("fin", fpts, "XZ", -0.13, 0.13, RD, bev=0.07, segs=2, ang=40), GZ),
bx("foot", 1.38, 1.93, -0.165, 0.165, 0.0, 0.17, WD, bev=0.05, segs=2),
bx("shoe", 1.36, 1.95, -0.175, 0.175, 0.1, 0.15, IR, bev=0.014, segs=1),
prism("finstripe", [(1.55, 0.5), (1.95, 0.5), (1.94, 0.68), (1.5, 0.68)], "XZ", -0.136, 0.136, CP, bev=0.012, segs=1),
bx("fstrap", 1.0, 1.9, -0.142, 0.142, 1.28, 1.36, IR, bev=0.012, segs=1),
bx("fstrap", 1.0, 1.66, -0.142, 0.142, 2.18, 2.26, IR, bev=0.012, segs=1)]
for z in (1.32, 2.22):
for s in (-1, 1):
Fp.append(rv((1.3, s * 0.146, z), r=0.018))
xfm(Fp, rot=(0, 0, a))
P += Fp
# a real barn window, cream frame (front, where the porthole was)
barn_window(P, 0.0, -(R + 0.04), 5.15, w=0.74, h=0.78, shutters=False, depth=0.16)
# painted GreenHaul sign panels on both sides (-X and +X), 2:1, UV 0..1
for ac in (180.0, 0.0):
P.append(annulus("dframe", R - 0.02, R + 0.01, 2.32, 3.43, CP, segs=14, a0=ac - 49, a1=ac + 49))
P.append(arc_patch("decal", R + 0.014, ac - 46, ac + 46, 2.4, 3.35, "M_RocketDecal", n=14))
for (da, z) in ((-47.5, 2.36), (47.5, 2.36), (-47.5, 3.39), (47.5, 3.39), (0.0, 2.36), (0.0, 3.39)):
aa = DEG(ac + da)
P.append(rv(((R + 0.012) * math.cos(aa), (R + 0.012) * math.sin(aa), z), r=0.02))
# cargo hatch on the back (+Y): a little barn door, red boards in a cream frame
P.append(annulus("hframe", R - 0.02, R + 0.016, 2.25, 3.65, CP, segs=8, a0=90 - 22, a1=90 + 22))
P.append(g(annulus("hdoor", R - 0.02, R + 0.028, 2.31, 3.59, RD, segs=8, a0=90 - 20, a1=90 + 20), GZ))
for (a0, z0, a1, z1) in ((90 - 18, 2.34, 90 + 18, 3.56), (90 + 18, 2.34, 90 - 18, 3.56)):
pa = ((R + 0.032) * math.cos(DEG(a0)), (R + 0.032) * math.sin(DEG(a0)), z0)
pb = ((R + 0.032) * math.cos(DEG(a1)), (R + 0.032) * math.sin(DEG(a1)), z1)
P.append(beam("hx", pa, pb, 0.022, 0.08, CP, bev=0, up=GY))
for z in (2.5, 3.4):
P.append(bx("hhinge", -0.46, -0.1, R + 0.0, R + 0.05, z - 0.03, z + 0.03, IR, bev=0.008, segs=1))
P.append(pipe("hhandle", [(0.2, R - 0.02, 2.75), (0.2, R + 0.08, 2.75), (0.2, R + 0.08, 3.05), (0.2, R - 0.02, 3.05)], 0.018, IR, segs=6, fil=0.03, fn=2))
# milk churns strapped on near the nose, where the old thruster pods sat: attitude control, allegedly
can = [(0.0, 0.0), (0.15, 0.0), (0.16, 0.02), (0.16, 0.4), (0.09, 0.48), (0.08, 0.6), (0.11, 0.62), (0.11, 0.66), (0.0, 0.67)]
for k in range(4):
a = 45.0 + 90.0 * k
Rp = [revolve("churn", can, segs=10, m=ST, loc=(R + 0.15, 0.0, 5.25), close_top=False),
torus("chstrap", 0.165, 0.014, loc=(R + 0.15, 0.0, 5.42), seg=10, rseg=4, m=IR),
bx("chshelf", R - 0.04, R + 0.32, -0.15, 0.15, 5.2, 5.25, WD, bev=0.012, segs=1)]
xfm(Rp, rot=(0, 0, a))
P += Rp
fin(P, "Body", uv=1.0, ang=40)
empty("Flame", (0.0, 0.0, 0.32))
return dict(elev=12, azim=-35)
# ======================================================================= 9. launch lever
def launch_lever():
P = []
P.append(bx("base", -0.36, 0.36, -0.36, 0.36, 0.0, 0.1, WD, bev=0.03, segs=2))
for s in (-1, 1):
P.append(bx("cleat", -0.3, 0.3, s * 0.27 - 0.05, s * 0.27 + 0.05, 0.1, 0.14, WD, bev=0.014, segs=1))
for (x, y) in ((-0.3, -0.3), (0.3, -0.3), (-0.3, 0.3), (0.3, 0.3)):
P.append(nut((x, y, 0.105), r=0.024, h=0.016))
# two heavy cheeks with the lever between them (the lever sweeps to the back, +Y)
hz = 0.8
hinge = Vector((0.0, -0.04, hz))
for s in (-1, 1):
x0, x1 = sorted((s * 0.07, s * 0.17))
pts = [(-0.26, 0.1), (0.2, 0.1), (0.08, 1.04), (-0.16, 1.04)]
P.append(g(prism("cheek", pts, "YZ", x0, x1, WD, bev=0.024, segs=2, ang=40), GZ))
P.append(bx("strap", x0 - 0.008, x1 + 0.008, -0.2, 0.09, 0.9, 0.96, IR, bev=0.012, segs=1))
P.append(bx("strap", x0 - 0.008, x1 + 0.008, -0.235, 0.17, 0.3, 0.36, IR, bev=0.012, segs=1))
P.append(cy("axle", 0.03, 0.46, tuple(hinge), IR, axis="X", v=10))
for s in (-1, 1):
P.append(nut((s * 0.23, hinge.y, hinge.z), axis="X", r=0.05, h=0.03, m=ST))
# tie blocks low between the cheeks
P.append(bx("tie", -0.07, 0.07, -0.22, 0.02, 0.14, 0.42, WD, bev=0.016, segs=1))
# ratchet quadrant on the +X cheek: iron teeth round the lever's sweep, behind the cheek so it reads from the back and side
arc = []
for k in range(11):
a = DEG(28 + k * 8.0)
ro = 0.3 if k % 2 == 0 else 0.33
arc.append((hinge.y + ro * math.sin(a), hinge.z + ro * math.cos(a)))
for k in range(10, -1, -5):
a = DEG(28 + k * 8.0)
arc.append((hinge.y + 0.2 * math.sin(a), hinge.z + 0.2 * math.cos(a)))
P.append(prism("quadrant", arc, "YZ", 0.17, 0.192, IR))
# cream board with a red arrow: this way up, pull
P.append(g(bx("board", -0.17, 0.17, -0.245, -0.2, 0.4, 0.72, CR, bev=0.014, segs=1), GZ))
P.append(prism("arrow", [(-0.07, 0.56), (0.0, 0.67), (0.07, 0.56), (0.03, 0.56), (0.03, 0.47), (-0.03, 0.47), (-0.03, 0.56)], "XZ", -0.252, -0.243, RP))
for x in (-0.14, 0.14):
P.append(nut((x, -0.25, 0.69), axis="Y", r=0.012, h=0.008, m=IR))
# coil of rope on the base
for k in range(3):
P.append(torus("coil", 0.095 - k * 0.008, 0.016, loc=(0.25, -0.25, 0.115 + k * 0.03), seg=12, rseg=4, m=RO))
fin(P, "Body", uv=1.0, ang=40)
# Lever: pivot on the hinge, rest position tilted back toward +Y, LaunchLever swings it 70 degrees further back
tilt = DEG(22)
dvec = Vector((0.0, math.sin(tilt), math.cos(tilt)))
h = hinge
def at(t):
return tuple(h + dvec * t)
Lv = [cy("hub", 0.06, 0.125, tuple(h), IR, axis="X", v=12, bev=0.012, segs=1),
beam("arm", at(-0.1), at(0.56), 0.1, 0.085, WD, bev=0.026, segs=2, up=GY),
beam("ferrule", at(0.1), at(0.15), 0.108, 0.093, IR, bev=0.01, segs=1, up=GY),
beam("ferrule", at(0.5), at(0.55), 0.108, 0.093, IR, bev=0.01, segs=1, up=GY),
beam("grip", at(0.54), at(0.73), 0.104, 0.09, RP, bev=0.03, segs=2, up=GY),
sphere("knob", 0.07, loc=at(0.76), seg=14, rings=8, m=RP)]
for t in (0.3, 0.35, 0.4, 0.45): # above the cheeks at rest, and clear of them through the whole sweep
lash = torus("gripr", 0.062, 0.012, seg=10, rseg=4, m=RO)
lash.data.transform(Matrix.Scale(1.05, 4, (1, 0, 0)))
xf(lash, rot=(-22, 0, 0), loc=at(t))
Lv.append(lash)
fin(Lv, "Lever", uv=1.0, ang=45, origin=tuple(h))
return dict(elev=20, azim=-35)
# ======================================================================= main
BUILDERS = {
"SM_DeckTile": deck_tile,
"SM_Ladder": ladder,
"SM_CrewCabin": crew_cabin,
"SM_Terminal": terminal,
"SM_Harbour": harbour,
"SM_Dock": ramp,
"SM_LaunchPad": launch_pad,
"SM_LaunchLever": launch_lever,
"SM_Rocket": rocket,
}
EXTRA_VIEWS = [("_back", dict(azim=150, elev=22)), ("_low", dict(azim=-35, elev=-12)), ("_front", dict(azim=0, elev=6))]
def main():
args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
extra = "--extra" in args
names = [a for a in args if not a.startswith("--")] or list(BUILDERS)
for n in names:
reset()
random.seed(1234)
pv = BUILDERS[n]() or {}
print(f"[{n}] tris={tri_count()}")
for o in sorted(bpy.context.scene.objects, key=lambda o: o.name):
print(f"[{n}] {o.type:6s} {o.name:12s} tris={tri_count([o]) if o.type == 'MESH' else '-'} loc={tuple(round(v, 3) for v in o.location)}")
export(n)
save_blend(n)
preview(n, **pv)
if extra:
old = common.PREVIEWS
common.PREVIEWS = os.environ.get("GC_PREVIEW_EXTRA", os.path.join(os.environ.get("TEMP", "/tmp"), "gc_farm_previews"))
for tag, kw in EXTRA_VIEWS:
preview(n + tag, **{**pv, **kw})
common.PREVIEWS = old
print(f"[{n}] done")
if __name__ == "__main__":
main()