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>
658 lines
38 KiB
Python
658 lines
38 KiB
Python
"""GRASS CUTTER - model upgrade, the landmarks of the base and the world:
|
|
SM_Decor_Lamp yard lamp (Bulb) SM_Decor_Dish the travel terminal: a farm radio mast with a dish and a rooster vane (Dish)
|
|
SM_Hopper the Grass Depot (Mouth) SM_Spire_A/B/C big rock formations (one mesh each, MeshCollider at runtime)
|
|
SM_Hemp wild hemp (one mesh, one slot, instanced) SM_IconArrow flow arrow
|
|
|
|
The Depot keeps the old 1.92 m footprint and Mouth (0, 0, 1.1) but stands 6.7 m tall. Its Solid box in ProjectBuilder.Prefabs comes from the
|
|
bounds of the model, so that box has to be capped at the rim (about 1.2 m) or tossed bundles can no longer reach Mouth.
|
|
|
|
Run (from anywhere):
|
|
blender -b --factory-startup --python D:/PROJECTS/LOCAL/GrassCutter/ArtSource/Blender/scripts/gc_up_world.py -- [SM_Name ...]
|
|
"""
|
|
import sys, os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
from mathutils import noise
|
|
from gc_up_kit import * # noqa: F401,F403
|
|
from gc_up_base import uvbox
|
|
|
|
RLAMP = "M_LightRed"
|
|
|
|
|
|
# ======================================================================= yard lamp
|
|
|
|
def yard_lamp():
|
|
"""A timber yard pole: gooseneck arm with a green enamel shade (Bulb under it), crossarm with insulators, the feed cable clipped down the pole."""
|
|
P = []
|
|
# cross-lap foot, braces, a stone on each arm to hold it down
|
|
for (a, b) in (((-0.33, 0.33), (-0.055, 0.055)), ((-0.055, 0.055), (-0.33, 0.33))):
|
|
P.append(bx(a[0], a[1], b[0], b[1], 0.0, 0.085, TIM, bev=0.012, name="foot"))
|
|
for (x, y) in ((0.27, 0), (-0.27, 0), (0, 0.27), (0, -0.27)):
|
|
P.append(beam((x, y, 0.07), (x * 0.14, y * 0.14, 0.58), 0.055, 0.055, bev=0.008, name="brace"))
|
|
P.append(rock(0.075, (0.2, 0.2, 0.05), seed=4, sc=(1, 0.9, 0.7), amp=0.15))
|
|
P.append(rock(0.06, (-0.21, 0.17, 0.04), seed=5, sc=(1, 0.9, 0.7), amp=0.15))
|
|
# the pole: eight-sided, tapered, with straps and bolts
|
|
P.append(grain(cz("pole", 0.09, 0.03, 2.8, 0, 0, TIM, v=8, r2=0.07), (0, 0, 1)))
|
|
for z in (0.62, 1.7):
|
|
P.append(cz("strap", 0.092 - z * 0.008, z, z + 0.035, 0, 0, IRON, v=8))
|
|
# crossarm with two white insulators, a stay, the cable
|
|
P.append(grain(bx(-0.3, 0.3, 0.05, 0.13, 2.62, 2.7, TIM, bev=0.01, name="crossarm"), (1, 0, 0)))
|
|
for x in (-0.25, 0.25):
|
|
P.append(cz("insstem", 0.012, 2.7, 2.74, x, 0.09, IRON, v=5))
|
|
P.append(revm("insulator", [(0.03, 2.73), (0.042, 2.74), (0.03, 2.76), (0.038, 2.775), (0.018, 2.8), (0, 2.805)], INK, segs=6, loc=(x, 0.09, 0)))
|
|
P.append(cyl_between("astay", (0, 0.09, 2.3), (-0.2, 0.09, 2.62), 0.012, IRON, v=4))
|
|
P.append(cyl_between("astay", (0, 0.09, 2.3), (0.2, 0.09, 2.62), 0.012, IRON, v=4))
|
|
# the switch box with its conduit, a hanging tin tag, a horseshoe for luck
|
|
P.append(bx(-0.075, 0.075, 0.075, 0.13, 1.08, 1.3, GRN, bev=0.008, name="switchbox"))
|
|
P.append(ptube("handle", [(0.07, 0.11, 1.2), (0.125, 0.11, 1.17)], 0.011, PRED, segs=5))
|
|
P.append(cyl_between("conduit", (0, 0.095, 1.3), (0.0, 0.08, 2.62), 0.012, IRON, v=5))
|
|
for z in (1.5, 1.95, 2.35):
|
|
P.append(cz("clip", 0.08, z, z + 0.02, 0, 0, STL, v=8))
|
|
shoe = [(math.cos(a) * 0.05, -0.095, 1.58 + math.sin(a) * 0.06) for a in [math.radians(-55 + 290 * k / 8) for k in range(9)]]
|
|
P.append(ptube("shoe", shoe, 0.012, IRON, segs=4))
|
|
# gooseneck out to the shade
|
|
arm = rpath([(0, 0.0, 2.62), (0, -0.16, 2.74), (0, -0.4, 2.74), (0, -0.4, 2.6)], 0.09, 4)
|
|
P.append(ptube("goose", arm, 0.022, IRON, segs=6))
|
|
P.append(cyl_between("gstay", (0, -0.03, 2.42), (0, -0.25, 2.71), 0.01, IRON, v=4))
|
|
P.append(ptube("wire", [(-0.25, 0.09, 2.79), (-0.12, 0.0, 2.8), (0.0, -0.2, 2.82), (0.0, -0.36, 2.78), (0.0, -0.4, 2.7)], 0.006, IRON, segs=4))
|
|
# enamel shade: green outside, cream inside, rim wire
|
|
P.append(revm("shade", [(0.03, 2.62), (0.06, 2.6), (0.13, 2.52), (0.25, 2.44), (0.262, 2.43), (0.25, 2.435), (0.125, 2.51), (0.055, 2.585)],
|
|
[GRN, GRN, GRN, GRN, CRM, CRM, CRM], segs=12, loc=(0, -0.4, 0)))
|
|
P.append(cz("socket", 0.04, 2.5, 2.6, 0, -0.4, STL, v=8))
|
|
ffin(P, "Body", ang=35)
|
|
bulb = sphere("Bulb", 0.082, (0, -0.4, 2.46), seg=10, rings=6, m="M_Emissive", scale=(1, 1, 1.15))
|
|
uv_box(bulb, 1)
|
|
smooth(bulb, 80)
|
|
set_origin(bulb, (0, -0.4, 2.46)) # the scene parents the point light to this
|
|
return dict(elev=12, azim=-30, man=(0.75, -0.3, 0), views=[("_close", dict(elev=4, azim=-40, dist_mul=0.42, target=(0, -0.15, 2.45))), ("_far", dict(elev=8, azim=-40, dist_mul=2.4))])
|
|
|
|
|
|
# ======================================================================= radio mast
|
|
|
|
def rooster():
|
|
"""Cut-out rooster on a little arrow, about 0.8 m long, built around its spindle at z = 0, facing -X."""
|
|
Q = []
|
|
body = [(-0.3, 0.13), (-0.24, 0.02), (-0.08, -0.01), (0.1, 0.03), (0.2, 0.17), (0.12, 0.22), (0.0, 0.2), (-0.1, 0.25), (-0.13, 0.42), (-0.22, 0.48), (-0.3, 0.43), (-0.33, 0.3)]
|
|
Q.append(prism("rooster", body, "XZ", -0.03, 0.03, GOLD, bev=0.008))
|
|
for k, (dx, dz, m) in enumerate(((0.3, 0.46, GRN), (0.4, 0.36, PRED), (0.43, 0.24, GOLD), (0.38, 0.12, GRN))):
|
|
pts = [(0.06, 0.07 + 0.03 * k), (0.2, 0.2 + dz * 0.2), (dx - 0.03, dz + 0.1), (dx + 0.04, dz + 0.07), (0.24, 0.1 + dz * 0.3)]
|
|
Q.append(prism("feather", pts, "XZ", -0.016 - 0.004 * k, 0.016 + 0.004 * k, m))
|
|
Q.append(prism("comb", [(-0.32, 0.45), (-0.3, 0.53), (-0.265, 0.5), (-0.24, 0.56), (-0.21, 0.51), (-0.175, 0.53), (-0.17, 0.46)], "XZ", -0.014, 0.014, PRED))
|
|
Q.append(prism("wattle", [(-0.32, 0.36), (-0.31, 0.29), (-0.28, 0.31), (-0.285, 0.37)], "XZ", -0.014, 0.014, PRED))
|
|
Q.append(prism("beak", [(-0.31, 0.4), (-0.41, 0.385), (-0.31, 0.36)], "XZ", -0.014, 0.014, GOLD))
|
|
for s in (-1, 1):
|
|
Q.append(cy("eye", 0.016, s * 0.03, s * 0.036, -0.265, 0.415, "M_Pupil", v=6))
|
|
Q.append(cx("arrow", 0.014, -0.62, 0.62, 0, -0.12, IRON, v=5))
|
|
Q.append(prism("ahead", [(-0.74, -0.12), (-0.52, -0.02), (-0.57, -0.12), (-0.52, -0.22)], "XZ", -0.012, 0.012, IRON))
|
|
Q.append(prism("atail", [(0.42, -0.12), (0.72, 0.02), (0.66, -0.12), (0.72, -0.26)], "XZ", -0.012, 0.012, PRED))
|
|
return Q
|
|
|
|
|
|
def radio_mast():
|
|
"""The travel terminal: a plank stage with a green radio cabinet (the player faces its -Y side) and a galvanised lattice mast behind it,
|
|
a chunky tin dish halfway up, the rooster on top. Dish = the dish, its origin on the bearing."""
|
|
rng = random.Random(14)
|
|
P = []
|
|
# stage on two skids
|
|
for x in (-0.58, 0.58):
|
|
P.append(grain(bx(x - 0.08, x + 0.08, -0.72, 0.72, 0.0, 0.1, TIM, bev=0.012, name="skid"), (0, 1, 0)))
|
|
for k in range(6):
|
|
y = -0.72 + (k + 0.5) * 1.44 / 6
|
|
P.append(plank_x(-0.72 + 0.03 * (k % 2), 0.72 - 0.02 * (k % 3), y, 0.226, 0.1, 0.16, rng.choice((PK, PK, PKW, PKD)), rng))
|
|
# the radio cabinet, tractor green with a cream fascia
|
|
x0, x1, y0, y1, z0, z1 = -0.52, 0.52, -0.5, 0.02, 0.16, 1.22
|
|
P.append(uvbox(bx(x0, x1, y0, y1, z0, z1, GRN, bev=0.016, name="cab"), 1.0))
|
|
P.append(grain(bx(x0 - 0.02, x1 + 0.02, y0 - 0.02, y1 + 0.02, z1, z1 + 0.05, TIM, bev=0.012, name="cabtop"), (1, 0, 0)))
|
|
P.append(grain(plain(x0 - 0.016, x1 + 0.016, y0 - 0.016, y1 + 0.016, 0.16, 0.26, IRON, "kick"), (1, 0, 0)))
|
|
for sx in (-1, 1):
|
|
for z in (0.32, 1.14):
|
|
nut(P, (sx * 0.47, y0, z), (0, -1, 0), r=0.016, h=0.01, m=STL)
|
|
# faceplate: dials, a tuning wheel, a speaker grille, switches, a green "line open" lamp
|
|
P.append(plain(-0.45, 0.45, y0 - 0.012, y0, 0.74, 1.13, "M_PaintCream", "plate"))
|
|
gauge(P, (-0.27, y0 - 0.012, 0.95), "-Y", r=0.1, stem=0.0, needle=30.0)
|
|
gauge(P, (0.04, y0 - 0.012, 0.95), "-Y", r=0.1, stem=0.0, needle=-40.0)
|
|
handwheel(P, (0.3, y0 - 0.012, 0.95), "-Y", R=0.075, m=PRED, stem=0.03)
|
|
P.append(plain(-0.42, -0.02, y0 - 0.008, y0, 0.36, 0.68, IRON, "grille"))
|
|
for k in range(5):
|
|
z = 0.39 + k * 0.058
|
|
P.append(plain(-0.4, -0.04, y0 - 0.02, y0 - 0.006, z, z + 0.03, STL, "gbar"))
|
|
for k in range(3):
|
|
x = 0.1 + k * 0.1
|
|
P.append(plain(x - 0.024, x + 0.024, y0 - 0.008, y0, 0.6, 0.68, IRON, "swp"))
|
|
P.append(cyl_between("sw", (x, y0, 0.64), (x, y0 - 0.05, 0.655 - 0.03 * (k % 2)), 0.01, (PRED, STL, GOLD)[k], v=5))
|
|
P.append(cy("lens", 0.034, y0 - 0.02, y0, 0.36, 0.64, "M_LightGreen", v=8))
|
|
# handset on a hook with a sagging cord
|
|
P.append(plain(0.32, 0.4, y0 - 0.03, y0, 0.5, 0.53, IRON, "hook"))
|
|
hs = [cz("earp", 0.04, 0.47, 0.5, 0.36, y0 - 0.05, IRON, v=8), cz("earp", 0.04, 0.26, 0.29, 0.36, y0 - 0.05, IRON, v=8),
|
|
grain(bx(0.342, 0.378, y0 - 0.065, y0 - 0.035, 0.27, 0.49, IRON, bev=0.008, name="hset"), (0, 0, 1))]
|
|
P += hs
|
|
cord = [Vector((0.36, y0 - 0.05, 0.26)) + Vector((0.0, -0.02 * math.sin(k * 0.5), -0.1 * math.sin(k / 8 * PI))) + Vector((-0.02 * k, 0, 0.012 * k)) for k in range(9)]
|
|
P.append(ptube("cord", cord, 0.007, IRON, segs=4))
|
|
# a travel board on top: a pinned map of the stations with a red string
|
|
P.append(grain(bx(-0.44, 0.44, -0.16, -0.12, 1.27, 1.84, TIM, bev=0.01, name="mapboard"), (0, 0, 1)))
|
|
P.append(plain(-0.4, 0.4, -0.166, -0.16, 1.31, 1.8, "M_PaintCream", "map"))
|
|
for (a, b, c) in (((-0.3, 1.42), (-0.05, 1.68), (0.28, 1.5)),):
|
|
for p, q in ((a, b), (b, c)):
|
|
P.append(beam((p[0], -0.172, p[1]), (q[0], -0.172, q[1]), 0.01, 0.004, PRED, bev=0, name="string"))
|
|
for p in (a, b, c):
|
|
P.append(cy("pin", 0.02, -0.178, -0.166, p[0], p[1], GOLD, v=6))
|
|
P.append(prism("land", [(-0.36, 1.36), (-0.1, 1.33), (0.02, 1.44), (-0.12, 1.56), (-0.34, 1.54)], "XZ", -0.169, -0.166, LEAF))
|
|
P.append(prism("land", [(0.12, 1.6), (0.35, 1.52), (0.36, 1.74), (0.16, 1.76)], "XZ", -0.169, -0.166, LEAF))
|
|
P.append(grain(bx(-0.44, 0.44, -0.17, -0.11, 1.84, 2.0, RED, bev=0.01, name="sign"), (1, 0, 0)))
|
|
sign_text(P, "TRAVEL", 0.115, INK, (0, -0.174, 1.92))
|
|
|
|
# the lattice mast behind the cabinet, tapering to the bearing and the rooster
|
|
MY, ZT = 0.36, 5.05
|
|
hw = lambda z: 0.3 + (0.08 - 0.3) * (z - 0.16) / (ZT - 0.16)
|
|
for sx in (-1, 1):
|
|
for sy in (-1, 1):
|
|
P.append(cyl_between("leg", (sx * hw(0.16), MY + sy * hw(0.16), 0.16), (sx * hw(ZT), MY + sy * hw(ZT), ZT), 0.024, STL, v=6))
|
|
P.append(plain(sx * 0.3 - 0.06, sx * 0.3 + 0.06, MY + sy * 0.3 - 0.06, MY + sy * 0.3 + 0.06, 0.16, 0.19, IRON, "shoe"))
|
|
lv = [0.16, 0.85, 1.5, 2.1, 2.65, 3.15, 3.6, 4.0, 4.35, 4.7, ZT]
|
|
for i, z in enumerate(lv[1:], 1):
|
|
h = hw(z)
|
|
z_ = lv[i - 1]
|
|
h_ = hw(z_)
|
|
for (ax, ay) in ((1, 0), (-1, 0), (0, 1), (0, -1)):
|
|
a = Vector((ax * h + ay * h, ay * h - ax * h, z))
|
|
b = Vector((ax * h - ay * h, ay * h + ax * h, z))
|
|
ofs = Vector((0, MY, 0))
|
|
P.append(cyl_between("girt", a + ofs, b + ofs, 0.013, STL, v=4))
|
|
a_ = Vector((ax * h_ - ay * h_, ay * h_ + ax * h_, z_))
|
|
P.append(cyl_between("diag", a_ + ofs, a + ofs, 0.01, STL, v=4))
|
|
# guy wires, a coil of spare cable, a hurricane lantern on the mast
|
|
for (x, y, sy) in ((-0.68, 0.68, 1), (0.68, 0.68, 1), (0.68, -0.06, -1), (-0.68, -0.06, -1)):
|
|
P.append(cyl_between("guy", (math.copysign(hw(3.6), x), MY + sy * hw(3.6), 3.6), (x, y, 0.16), 0.006, IRON, v=4))
|
|
P.append(cz("anchor", 0.03, 0.16, 0.2, x, y, IRON, v=6))
|
|
rope_coil(P, (0.5, 0.56, 0.16), r=0.13, turns=3, t=0.016)
|
|
P.append(cyl_between("spindlebase", (0, MY, ZT - 0.05), (0, MY, ZT + 0.1), 0.05, STL, v=8))
|
|
# red warning lamp near the top, on a little bracket toward the front
|
|
P.append(cyl_between("lbrk", (0, MY, 4.62), (0, MY - 0.26, 4.62), 0.012, IRON, v=4))
|
|
P.append(cz("rlcap", 0.07, 4.76, 4.8, 0, MY - 0.26, IRON, v=8, r2=0.02))
|
|
P.append(cz("rlamp", 0.058, 4.63, 4.76, 0, MY - 0.26, RLAMP, v=8))
|
|
P.append(cz("rlbase", 0.065, 4.6, 4.63, 0, MY - 0.26, IRON, v=8))
|
|
# the rooster joins the Body: it is the vane on top of the mast
|
|
Rr = rooster()
|
|
xgs(Rr, rz=0.5, t=(0, MY, ZT + 0.22))
|
|
P += Rr
|
|
P.append(cyl_between("spindle", (0, MY, ZT + 0.05), (0, MY, ZT + 0.32), 0.018, IRON, v=6))
|
|
P.append(sphere("ball", 0.06, (0, MY, ZT + 0.16), seg=8, rings=5, m="M_Brass"))
|
|
ffin(P, "Body", ang=35, ms={CRM: 0.5})
|
|
|
|
# ---------- Dish: chunky tin paraboloid on the front of the mast, its origin on the bearing
|
|
R, f = 0.74, 0.62
|
|
n = 6
|
|
inner = [(R * k / n, (R * k / n) ** 2 / (4 * f)) for k in range(n + 1)]
|
|
prof = inner + [(r + 0.02, z - 0.05) for (r, z) in reversed(inner)]
|
|
Q = [revm("bowl", prof, [TIN] * n + [IRON] + ["M_TinOld"] * n + [IRON], segs=12, closed=True)]
|
|
uv_cyl(Q[0], 2, 6.0, 1.0)
|
|
uv_keep(Q[0])
|
|
Q.append(torus("rim", R, 0.022, (0, 0, R * R / (4 * f)), "Z", seg=12, rseg=4, m=RED))
|
|
# ribs across the back, a red feed horn held on three struts
|
|
for k in range(6):
|
|
a = k * PI / 3 + 0.26
|
|
c, s_ = math.cos(a), math.sin(a)
|
|
path = [(c * r_, s_ * r_, r_ * r_ / (4 * f) - 0.058) for r_ in (0.1, 0.34, 0.52, 0.7)]
|
|
Q.append(ptube("rib", path, 0.014, IRON, segs=4))
|
|
for k in range(3):
|
|
a = k * 2 * PI / 3 + PI / 2
|
|
Q.append(cyl_between("strut", (math.cos(a) * 0.52, math.sin(a) * 0.52, 0.52 ** 2 / (4 * f)), (0, 0, f - 0.09), 0.012, IRON, v=4))
|
|
Q.append(cz("horn", 0.1, f - 0.1, f + 0.06, 0, 0, PRED, v=8, r2=0.05))
|
|
Q.append(cz("hub", 0.07, -0.12, 0.05, 0, 0, IRON, v=8))
|
|
Q.append(revm("hornface", [(0, f - 0.1), (0.09, f - 0.1)], INK, segs=8))
|
|
tilt = math.radians(58)
|
|
B = (0, MY - hw(3.0) - 0.28, 3.0)
|
|
for o in Q:
|
|
xg(o, rx=tilt, rz=0.0, t=B)
|
|
# yoke from the mast to the back of the bowl, inside the Dish so it could turn with it
|
|
Q.append(cyl_between("yoke", (0, B[1] - 0.04, B[2] + 0.03), (0, MY - hw(3.0), 3.0), 0.04, IRON, v=8))
|
|
Q.append(cx("trunnion", 0.03, -0.17, 0.17, MY - hw(3.0), 3.0, IRON, v=6))
|
|
fpart(Q, "Dish", B, ang=35)
|
|
return dict(elev=16, azim=-32, man=(0.95, -1.0, 0), views=[("_close", dict(elev=10, azim=-18, dist_mul=0.34, target=(0, -0.4, 1.1))), ("_dish", dict(elev=4, azim=-40, dist_mul=0.45, target=(0, 0.1, 3.5))),
|
|
("_back", dict(elev=18, azim=150)), ("_far", dict(elev=6, azim=-40, dist_mul=2.0))])
|
|
|
|
|
|
# ======================================================================= the Grass Depot
|
|
|
|
def flat_funnel(P, z0, z1, h0, h1, rows, mats):
|
|
"""plank_funnel without the bevels."""
|
|
for side in range(4):
|
|
for k in range(rows):
|
|
a0, a1 = k / rows, (k + 1) / rows
|
|
za, zb = z0 + (z1 - z0) * a0 + 0.004, z0 + (z1 - z0) * a1 - 0.004
|
|
ha, hb = h0 + (h1 - h0) * a0, h0 + (h1 - h0) * a1
|
|
o = board((-ha, -ha, za), (ha, -ha, za), (hb, -hb, zb), (-hb, -hb, zb), 0.034, mats[k % len(mats)], bev=0)
|
|
P.append(xg(o, rz=side * PI / 2))
|
|
|
|
|
|
def hopper():
|
|
"""The Grass Depot: a country grain elevator. Bundles still drop into the old funnel at Mouth; above it the frame carries on up to a red head
|
|
house with the sign, a cupola and a flag. Everything stays inside the old bounds of +-0.96 m. The bay over the funnel stays open."""
|
|
P = []
|
|
Z0, Z1, H0, H1 = 0.44, 1.03, 0.2, 0.84
|
|
ZH = 3.7 # underside of the head house
|
|
hw = lambda z: 0.87 - 0.17 * z / ZH
|
|
flat_funnel(P, Z0, Z1, H0, H1, 7, (TIM, DECK, TIM, TIM, DECK, TIM, DECK))
|
|
hay_heap(P, (0, 0, 0.6), 0.42, 0.42, 0.2, tufts=6)
|
|
# chunky red rim with iron corners
|
|
RO, RI = 0.92, 0.8
|
|
for rz in (0, PI / 2, PI, -PI / 2):
|
|
o = grain(bx(-RO, RO, -RO, -RI, Z1 - 0.01, 1.124, RED, bev=0.02, name="rim"), (1, 0, 0))
|
|
P.append(xg(o, rz=rz))
|
|
for (sx, sy) in ((1, 1), (-1, 1), (1, -1), (-1, -1)):
|
|
P.append(plain(sx * (RO + 0.01), sx * (RO - 0.13), sy * (RO + 0.01), sy * (RO - 0.13), Z1 - 0.02, 1.135, IRON, "rimcorner"))
|
|
# the four corner posts run all the way up, with iron feet and a splice at the rim
|
|
P.append(beam((sx * hw(0), sy * hw(0), 0.0), (sx * hw(ZH), sy * hw(ZH), ZH), 0.15, 0.15, bev=0.02, name="post"))
|
|
P.append(plain(sx * 0.87 - 0.085, sx * 0.87 + 0.085, sy * 0.87 - 0.085, sy * 0.87 + 0.085, 0.0, 0.05, IRON, "foot"))
|
|
P.append(beam((sx * (H0 + 0.01), sy * (H0 + 0.01), Z0), (sx * (H1 + 0.01), sy * (H1 + 0.01), Z1 - 0.03), 0.075, 0.016, IRON, bev=0, roll=PI / 4 * sx * sy, name="cornerstrap"))
|
|
P.append(beam((sx * 0.84, sy * 0.84, 0.26), (sx * 0.28, sy * 0.28, 0.5), 0.07, 0.07, bev=0, name="strut"))
|
|
# low rails, leaving the belt ports open, X braces low on the back only
|
|
for rz in (0, PI / 2, PI, -PI / 2):
|
|
o = grain(bx(-0.84, 0.84, -0.89, -0.81, 0.2, 0.28, TIM, bev=0.012, name="rail"), (1, 0, 0))
|
|
P.append(xg(o, rz=rz))
|
|
# the tower: girts, braces in the two upper bays. The bay from the rim up to 2.2 m stays clear so bundles can be tossed in from any side
|
|
levels = (2.2, 3.0, ZH - 0.03)
|
|
for i, z in enumerate(levels):
|
|
h = hw(z)
|
|
for rz in (0, PI / 2, PI, -PI / 2):
|
|
G = [beam((-h - 0.08, -h - 0.09, z), (h + 0.08, -h - 0.09, z), 0.08, 0.13, bev=0.012, name="girt")]
|
|
if i > 0:
|
|
zl = levels[i - 1]
|
|
hl = hw(zl)
|
|
for s in (-1, 1):
|
|
G.append(beam((-s * hl, -hl - 0.11 - 0.012 * s, zl), (s * h, -h - 0.11 - 0.012 * s, z), 0.055, 0.09, bev=0, name="brace"))
|
|
xgs(G, rz=rz)
|
|
P += G
|
|
# knee braces under the first girt, so the open bay still looks strong
|
|
for rz in (0, PI / 2, PI, -PI / 2):
|
|
h = hw(2.2)
|
|
G = []
|
|
for s in (-1, 1):
|
|
G.append(beam((s * hw(1.6), -hw(1.6) - 0.09, 1.6), (s * (h - 0.5), -h - 0.09, 2.17), 0.055, 0.09, bev=0, name="knee"))
|
|
xgs(G, rz=rz)
|
|
P += G
|
|
# the feed chute down to the deck, gate and lever
|
|
P.append(uv_wall(plain(-0.2, 0.2, -0.2, 0.2, 0.05, Z0 + 0.03, TIM, "chute")))
|
|
for z in (0.14, 0.4):
|
|
P.append(plain(-0.212, 0.212, -0.212, 0.212, z - 0.022, z + 0.022, IRON, "hoop"))
|
|
P.append(bx(-0.36, 0.36, -0.36, 0.36, 0.0, 0.055, TIM, bev=0.012, name="slab"))
|
|
P.append(plain(0.2, 0.42, -0.14, 0.14, 0.2, 0.24, STL, "gate"))
|
|
P.append(beam((0.42, 0, 0.22), (0.56, 0, 0.5), 0.03, 0.03, IRON, bev=0, name="gatelever"))
|
|
P.append(sphere("gateknob", 0.04, (0.565, 0, 0.51), seg=8, rings=5, m=PRED))
|
|
# the rim stencil, hay over the edge, yard dressing
|
|
sign_text(P, "DROP GRASS", 0.082, INK, (0, -0.923, 1.07))
|
|
for (x, y, az) in ((-0.62, -0.83, -PI / 2), (0.4, -0.83, -PI / 2), (0.83, 0.3, 0.0), (-0.83, -0.2, PI)):
|
|
tuft(P, x, y, 1.125, L=0.09, n=4, az=az)
|
|
sack(P, (-0.5, -0.52, 0.0), r=0.16, h=0.34, rz=0.4)
|
|
sack(P, (-0.22, -0.62, 0.0), r=0.13, h=0.27, rz=1.2)
|
|
pitchfork(P, (0.86, -0.36, 0.0), (0.86, -0.7, 0.9))
|
|
|
|
# the bucket elevator up the +X side: tin back, leather belt, red scoops, tin boot at the bottom with a crank
|
|
XL = 0.84
|
|
P.append(grain(plain(XL - 0.03, XL - 0.005, -0.15, 0.15, 0.55, ZH + 0.1, TIN, "legback"), (0, 0, 1)))
|
|
for s in (-1, 1):
|
|
P.append(grain(plain(XL - 0.03, XL + 0.095, s * 0.15 - 0.02, s * 0.15 + 0.02, 0.55, ZH + 0.1, TIM, "legrail"), (0, 0, 1)))
|
|
P.append(plain(XL + 0.03, XL + 0.05, -0.08, 0.08, 0.6, ZH + 0.1, "M_Leather", "legbelt"))
|
|
z = 0.8
|
|
while z < ZH - 0.1:
|
|
pts = [(XL + 0.05, z), (XL + 0.115, z - 0.0), (XL + 0.115, z + 0.08), (XL + 0.05, z + 0.135)]
|
|
P.append(prism("scoop", pts, "XZ", -0.075, 0.075, PRED))
|
|
z += 0.46
|
|
P.append(uvbox(bx(XL - 0.05, XL + 0.11, -0.21, 0.21, 0.28, 0.7, TIN, bev=0.012, name="boot"), 1.0))
|
|
P.append(plain(XL + 0.11, XL + 0.122, -0.11, 0.11, 0.36, 0.6, RED, "hatch"))
|
|
handwheel(P, (XL + 0.03, -0.21, 0.48), "-Y", R=0.075, m=GOLD, stem=0.02)
|
|
for s in (-1, 1):
|
|
P.append(beam((XL - 0.03, s * 0.17, 2.2), (hw(2.2), s * 0.17, 2.2), 0.04, 0.04, IRON, bev=0, name="legtie"))
|
|
|
|
# the ladder up the -X side
|
|
XR = -0.93
|
|
for s in (-1, 1):
|
|
P.append(grain(plain(XR - 0.025, XR + 0.025, s * 0.2 - 0.022, s * 0.2 + 0.022, 1.15, ZH + 0.02, TIM, "lrail"), (0, 0, 1)))
|
|
z = 1.3
|
|
while z < ZH:
|
|
P.append(cy("lrung", 0.014, -0.2, 0.2, XR, z, IRON, v=4))
|
|
z += 0.3
|
|
|
|
# the head house on corbels: red boards, cream corners, the tin gable roof with its ridge along Y
|
|
WH, ZE, ZG = 0.84, 4.74, 5.5
|
|
pts = [(-WH, ZH), (WH, ZH), (WH, ZE), (0, ZG - 0.08), (-WH, ZE)]
|
|
P.append(uvbox(prism("head", pts, "XZ", -WH, WH, RED)))
|
|
P.append(grain(bx(-WH - 0.03, WH + 0.03, -WH - 0.03, WH + 0.03, ZH - 0.03, ZH + 0.1, CRM, bev=0.014, name="sillbelt"), (1, 0, 0)))
|
|
for sx in (-1, 1):
|
|
for sy in (-1, 1):
|
|
P.append(grain(plain(sx * (WH + 0.012), sx * (WH - 0.11), sy * (WH + 0.012), sy * (WH - 0.11), ZH + 0.1, ZE, CRM, "hcorner"), (0, 0, 1)))
|
|
P.append(beam((sx * hw(ZH - 0.55), sy * hw(ZH - 0.55), ZH - 0.55), (sx * (WH - 0.03), sy * (WH - 0.03), ZH - 0.03), 0.09, 0.09, bev=0, name="corbel"))
|
|
for s in (-1, 1):
|
|
ns = 5
|
|
for k in range(ns):
|
|
ya, yb = -0.96 + 1.92 * k / ns - (0.015 if k else 0), -0.96 + 1.92 * (k + 1) / ns + (0.015 if k < ns - 1 else 0)
|
|
dz = 0.007 * (k % 2)
|
|
q = [(s * 0.96, ya, ZE - 0.1 + dz), (0, ya, ZG + dz), (0, yb, ZG + dz), (s * 0.96, yb, ZE - 0.1 + dz)]
|
|
if s > 0:
|
|
q = q[::-1]
|
|
P.append(grain(board(*q, 0.03, "M_TinOld" if k == (3 if s > 0 else 1) else TIN, bev=0, along="ab", name="sheet"), (s, 0, 1)))
|
|
P.append(beam((s * 0.885, -0.93, ZE - 0.07), (0, -0.93, ZG - 0.02), 0.05, 0.15, CRM, bev=0, name="barge"))
|
|
P.append(beam((s * 0.885, 0.93, ZE - 0.07), (0, 0.93, ZG - 0.02), 0.05, 0.15, CRM, bev=0, name="barge"))
|
|
P.append(prism("ridge", [(-0.14, ZG - 0.13), (0, ZG + 0.03), (0.14, ZG - 0.13), (0.14, ZG - 0.09), (0, ZG + 0.07), (-0.14, ZG - 0.09)], "XZ", -0.96, 0.96, STL))
|
|
# the sign: green board, cream Georgia letters, cream frame, four bolts
|
|
YS = -WH - 0.04
|
|
P.append(grain(bx(-0.76, 0.76, YS, YS + 0.04, 3.84, 4.66, GRN, bev=0.012, name="signboard"), (1, 0, 0)))
|
|
for z in (3.84, 4.66):
|
|
P.append(grain(plain(-0.78, 0.78, YS - 0.012, YS + 0.03, z - 0.03, z + 0.03, CRM, "signframe"), (1, 0, 0)))
|
|
for sx in (-1, 1):
|
|
P.append(grain(plain(sx * 0.75, sx * 0.79, YS - 0.012, YS + 0.03, 3.84, 4.66, CRM, "signframe"), (0, 0, 1)))
|
|
sign_text(P, "GRASS", 0.31, INK, (0, YS - 0.003, 4.42))
|
|
sign_text(P, "DEPOT", 0.31, GOLD, (0, YS - 0.003, 4.08))
|
|
# the Earth over the sign: where it all goes. A blue roundel in a cream ring, green continents, a gold arrow going up to it
|
|
ZE0 = 4.98
|
|
P.append(cy("ering", 0.275, -WH - 0.03, -WH, 0, ZE0, CRM, v=16))
|
|
P.append(cy("earth", 0.235, -WH - 0.04, -WH - 0.03, 0, ZE0, SKY, v=16))
|
|
P.append(prism("land", [(-0.16, ZE0 + 0.14), (0.0, ZE0 + 0.17), (0.08, ZE0 + 0.06), (-0.03, ZE0 - 0.04), (-0.17, ZE0 - 0.01)], "XZ", -WH - 0.044, -WH - 0.04, LEAF))
|
|
P.append(prism("land", [(0.08, ZE0 - 0.1), (0.2, ZE0 - 0.04), (0.17, ZE0 - 0.15), (0.05, ZE0 - 0.2)], "XZ", -WH - 0.044, -WH - 0.04, LEAF))
|
|
# hoist beam under the head house, a pulley, a net of hay on its way up
|
|
P.append(beam((0, 0.2, ZH - 0.1), (0, -0.94, ZH - 0.1), 0.11, 0.14, bev=0.012, name="hoist"))
|
|
P.append(cx("pulley", 0.07, -0.03, 0.03, -0.84, ZH - 0.27, IRON, v=10))
|
|
P.append(cyl_between("phook", (0, -0.84, ZH - 0.17), (0, -0.84, ZH - 0.27), 0.012, IRON, v=4))
|
|
P.append(cyl_between("hrope", (0, -0.91, ZH - 0.27), (0, -0.91, 2.86), 0.011, ROPE, v=5))
|
|
P.append(ptube("hrope2", [(0, -0.77, ZH - 0.27), (0.06, -0.72, 3.0), (0.7, -0.72, 2.25), (hw(2.2), -hw(2.2) - 0.07, 2.27)], 0.011, ROPE, segs=4))
|
|
bale(P, (0, -0.72, 2.72), sx=0.52, sy=0.36, sz=0.3, rz=0.0)
|
|
for s in (-1, 1):
|
|
P.append(cyl_between("sling", (0, -0.91, 2.98), (s * 0.24, -0.8, 2.87), 0.009, ROPE, v=4))
|
|
# lit windows in the sides and back, so the Depot can be found at dusk
|
|
for (x, y, rz) in ((-WH, 0, -PI / 2), (WH, 0, PI / 2), (0, WH, PI)):
|
|
Q = [plain(-0.24, 0.24, -0.012, 0.01, -0.3, 0.3, "M_LightAmber", "glow")]
|
|
for sx in (-1, 1):
|
|
Q.append(plain(sx * 0.3, sx * 0.24, -0.04, 0.01, -0.36, 0.36, CRM, "wf"))
|
|
for sz in (-1, 1):
|
|
Q.append(plain(-0.3, 0.3, -0.04, 0.01, sz * 0.36, sz * 0.3, CRM, "wf"))
|
|
Q.append(plain(-0.018, 0.018, -0.034, -0.012, -0.3, 0.3, CRM, "wbar"))
|
|
Q.append(plain(-0.24, 0.24, -0.034, -0.012, -0.018, 0.018, CRM, "wbar"))
|
|
xgs(Q, rz=rz, t=(x, y, 4.24))
|
|
P += Q
|
|
# the cupola on the ridge, a brass ball and a red pennant at the very top
|
|
CW = 0.24
|
|
P.append(uvbox(bx(-CW, CW, -CW, CW, ZG - 0.06, ZG + 0.42, CRM, bev=0.012, name="cupola"), 0.5))
|
|
for (dx, dy, rz) in ((0, -CW, 0), (0, CW, PI), (-CW, 0, -PI / 2), (CW, 0, PI / 2)):
|
|
P.append(xf(plain(-0.13, 0.13, -0.008, 0.0, ZG + 0.06, ZG + 0.34, "M_LightAmber", "cglow"), rz=rz, t=(dx, dy, 0)))
|
|
P.append(xf(revm("croof", [(0.42, ZG + 0.4), (0.34, ZG + 0.46), (0.0, ZG + 0.78)], TIN, segs=4, cap_bot=True), rz=PI / 4))
|
|
P.append(cz("mast", 0.022, ZG + 0.74, ZG + 1.3, 0, 0, IRON, v=6))
|
|
P.append(sphere("ball", 0.05, (0, 0, ZG + 1.32), seg=8, rings=5, m="M_Brass"))
|
|
pen = [(0.02, ZG + 1.26), (0.02, ZG + 0.98), (0.3, ZG + 1.1), (0.56, ZG + 1.1)]
|
|
P.append(prism("pennant", pen, "XZ", -0.008, 0.008, PRED))
|
|
ffin(P, "Body", ang=35, ms={CRM: 0.45})
|
|
empty("Mouth", (0, 0, 1.1))
|
|
return dict(elev=20, azim=-35, man=(1.5, -1.5, 0), views=[("_low", dict(elev=7, azim=-30, dist_mul=0.55, target=(0, 0, 1.2))), ("_top", dict(elev=8, azim=-25, dist_mul=0.42, target=(0, 0, 4.6))),
|
|
("_back", dict(elev=18, azim=150)), ("_side", dict(elev=8, azim=70)), ("_far", dict(elev=5, azim=-40, dist_mul=2.2))])
|
|
|
|
|
|
# ======================================================================= the big rock formations
|
|
|
|
STRATA = (ROCK, "M_RockBand", "M_RockPale", "M_RockBand", ROCK, "M_RockRust", "M_RockPale", "M_RockBand")
|
|
TURF, MOSS = CLIP, "M_Barnacle" # M_GrassFill: the meadow green, and an olive moss
|
|
|
|
|
|
def lerp_prof(prof, t):
|
|
for (t0, r0), (t1, r1) in zip(prof, prof[1:]):
|
|
if t <= t1:
|
|
return r0 + (r1 - r0) * (t - t0) / max(1e-6, t1 - t0)
|
|
return prof[-1][1]
|
|
|
|
|
|
def rock_stack(H, prof, seed, n=30, strata=9, lean=(0.0, 0.0), lobes=((2, 0.1, 0.4),), gullies=3, zb=-1.2):
|
|
"""A closed shell of bedded rock: each bed bulges to a lip and steps back to a ledge, the ledges and the top carry turf. Staggered rings make
|
|
diamond facets. prof: (t, radius) with t = height / H. lobes: (k, amount, phase) cosine lobes of the plan. Returns the object."""
|
|
rng = random.Random(seed)
|
|
so = Vector((seed * 1.7, seed * 3.1, seed * 0.7))
|
|
w = [rng.uniform(0.65, 1.45) for _ in range(strata)]
|
|
tot = sum(w)
|
|
zs = [zb]
|
|
for x in w:
|
|
zs.append(zs[-1] + (H - zb) * x / tot)
|
|
gull = [(rng.uniform(0, 2 * PI), rng.uniform(0.12, 0.24), rng.uniform(0.16, 0.3)) for _ in range(gullies)]
|
|
rows = [] # z, radius, bed, kind
|
|
for i in range(strata):
|
|
za, zc = zs[i], zs[i + 1]
|
|
ra, rc = lerp_prof(prof, max(0.0, za) / H), lerp_prof(prof, zc / H)
|
|
d = zc - za
|
|
rows.append((za + 0.01, ra * rng.uniform(0.9, 0.95), i, "foot"))
|
|
rows.append((za + d * 0.42, (ra * 0.6 + rc * 0.4) * rng.uniform(0.98, 1.02), i, "face"))
|
|
rows.append((zc - d * 0.1, rc * rng.uniform(1.03, 1.08), i, "lip"))
|
|
rows.append((zc - d * 0.02, rc * rng.uniform(0.97, 1.0), i, "ledge"))
|
|
|
|
def centre(z):
|
|
k = max(0.0, z / H) ** 1.5
|
|
return lean[0] * k, lean[1] * k
|
|
|
|
def vert(i, k, z, r):
|
|
th = 2 * PI * (i + 0.5 * (k % 2)) / n
|
|
c, s_ = math.cos(th), math.sin(th)
|
|
q = 1.0 + 0.2 * noise.noise(Vector((c * 1.3, s_ * 1.3, z * 0.03)) + so) + 0.08 * noise.noise(Vector((c * 3.1, s_ * 3.1, z * 0.09)) + so * 2)
|
|
for (lk, amt, ph) in lobes:
|
|
q += amt * math.cos(lk * th + ph)
|
|
for (g, wd, dp) in gull:
|
|
dd = math.atan2(math.sin(th - g), math.cos(th - g)) / wd
|
|
q -= dp * math.exp(-dd * dd)
|
|
q *= 1 + rng.uniform(-0.025, 0.025)
|
|
cx_, cy_ = centre(z)
|
|
return Vector((cx_ + r * q * c, cy_ + r * q * s_, z + rng.uniform(-0.012, 0.012) * H * 0.3))
|
|
|
|
bm = bmesh.new()
|
|
R = [[bm.verts.new(vert(i, k, z, r)) for i in range(n)] for k, (z, r, bed, kind) in enumerate(rows)]
|
|
names = list(dict.fromkeys(STRATA)) + [TURF, MOSS]
|
|
def paint_f(f, m_):
|
|
f.material_index = names.index(m_)
|
|
for k in range(len(rows) - 1):
|
|
bed, kind = rows[k][2], rows[k][3]
|
|
m_ = STRATA[bed % len(STRATA)]
|
|
for i in range(n):
|
|
j = (i + 1) % n
|
|
a, b = R[k], R[k + 1]
|
|
if k % 2 == 0:
|
|
fs = (bm.faces.new((a[i], a[j], b[i])), bm.faces.new((a[j], b[j], b[i])))
|
|
else:
|
|
fs = (bm.faces.new((a[i], a[j], b[j])), bm.faces.new((a[i], b[j], b[i])))
|
|
for f in fs:
|
|
paint_f(f, m_)
|
|
# the top: a turf mound fanned to one peak
|
|
zt, rt = rows[-1][0], rows[-1][1]
|
|
top = []
|
|
for f_, dz in ((0.72, 0.012), (0.36, 0.022)):
|
|
top.append([bm.verts.new(vert(i, 0, zt + H * dz, rt * f_)) for i in range(n)])
|
|
cc = centre(zt)
|
|
tip = bm.verts.new((cc[0], cc[1], zt + H * 0.028))
|
|
last = R[-1]
|
|
for a, b in ((last, top[0]), (top[0], top[1])):
|
|
for i in range(n):
|
|
j = (i + 1) % n
|
|
paint_f(bm.faces.new((a[i], a[j], b[j])), TURF)
|
|
paint_f(bm.faces.new((a[i], b[j], b[i])), TURF)
|
|
for i in range(n):
|
|
paint_f(bm.faces.new((top[1][i], top[1][(i + 1) % n], tip)), TURF)
|
|
# closed underneath, so the MeshCollider gets a solid
|
|
bot = bm.verts.new((0, 0, zb))
|
|
for i in range(n):
|
|
paint_f(bm.faces.new((R[0][(i + 1) % n], R[0][i], bot)), ROCK)
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
# turf on the ledges and in drifts over the lips
|
|
bm.normal_update()
|
|
for f in bm.faces:
|
|
c = f.calc_center_median()
|
|
if f.material_index >= len(STRATA) and names[f.material_index] in (TURF, MOSS):
|
|
continue
|
|
if f.normal.z > 0.62 and noise.noise(c * 0.17 + so) > 0.03:
|
|
f.material_index = names.index(TURF)
|
|
elif f.normal.z > 0.5 and noise.noise(c * 0.21 + so * 3) > 0.16:
|
|
f.material_index = names.index(MOSS)
|
|
me = bpy.data.meshes.new("rockbody")
|
|
for m_ in names:
|
|
me.materials.append(mat(m_)) # slots first: set_mats would clear them and reset the face indices
|
|
bm.to_mesh(me)
|
|
bm.free()
|
|
o = link(bpy.data.objects.new("rockbody", me))
|
|
uv_box(o, 0.11)
|
|
return uv_keep(o)
|
|
|
|
|
|
def pine(P, x, y, z, h, seed=1):
|
|
"""A wind-bent little fir on a ledge: gives the rock its size."""
|
|
rr = random.Random(seed)
|
|
P.append(cz("trunk", h * 0.05, z - 0.2, z + h * 0.3, x, y, "M_Bark", v=5))
|
|
for k, (a, b, r) in enumerate(((0.16, 0.62, 0.3), (0.42, 0.84, 0.23), (0.66, 1.0, 0.15))):
|
|
P.append(cz("fir", h * r, z + h * a, z + h * b, x + rr.uniform(-0.02, 0.02) * h, y, LEAFD if k != 1 else LEAF, v=7, r2=h * 0.01))
|
|
|
|
|
|
def spire_a():
|
|
"""A broad, squat butte with a low shelf round one side."""
|
|
P = [rock_stack(16.0, [(0, 7.0), (0.3, 6.7), (0.34, 5.6), (0.8, 5.0), (1, 4.3)], 3, n=30, strata=7, lean=(0.5, 0.3), lobes=((1, 0.1, 0.9), (2, 0.09, 2.0)), gullies=3)]
|
|
for (x, y, r, s) in ((-6.3, -4.2, 1.5, 5), (5.9, 3.9, 1.2, 6), (6.2, -3.4, 0.9, 7), (-4.0, 6.0, 1.3, 8), (0.8, -7.1, 0.8, 9)):
|
|
P.append(rock(r, (x, y, r * 0.3 - 0.4), seed=s, sc=(1.2, 1, 0.8), m=ROCK, sub=2, amp=0.16, name="boulder"))
|
|
for (x, y, z, h, s) in ((-3.5, -5.2, 6.1, 2.4, 1), (-4.6, -3.6, 6.2, 1.9, 2), (0.9, 0.4, 16.5, 2.8, 3), (2.4, 1.4, 16.3, 2.1, 4)):
|
|
pine(P, x, y, z, h, s)
|
|
return P
|
|
|
|
|
|
def spire_b():
|
|
"""A leaning butte on a wide skirt, two great shoulders."""
|
|
P = [rock_stack(27.5, [(0, 7.4), (0.22, 6.8), (0.26, 5.4), (0.56, 4.6), (0.6, 3.6), (0.9, 3.3), (1, 2.5)], 7, n=30, strata=9, lean=(2.4, -1.0), lobes=((1, 0.12, 2.4), (3, 0.06, 0.4)), gullies=4)]
|
|
for (x, y, r, s) in ((6.6, 3.2, 1.6, 15), (-6.6, 3.4, 1.3, 16), (-1.2, -6.8, 1.1, 17), (4.2, -5.6, 0.9, 18), (-5.3, -4.0, 1.0, 19)):
|
|
P.append(rock(r, (x, y, r * 0.3 - 0.4), seed=s, sc=(1.2, 1, 0.8), m="M_RockBand", sub=2, amp=0.16, name="boulder"))
|
|
for (x, y, z, h, s) in ((4.4, -4.1, 6.5, 2.5, 5), (-3.6, 3.9, 6.5, 2.0, 6), (2.3, -1.0, 28.1, 2.6, 7)):
|
|
pine(P, x, y, z, h, s)
|
|
return P
|
|
|
|
|
|
def spire_c():
|
|
"""The tall one: a stepped hoodoo with a balanced cap, the kind you steer by."""
|
|
P = [rock_stack(41.5, [(0, 10.2), (0.14, 9.4), (0.18, 7.0), (0.42, 5.7), (0.46, 4.4), (0.74, 3.5), (0.84, 2.9), (0.87, 4.2), (0.95, 4.3), (1, 3.3)], 13, n=30, strata=12, lean=(-2.2, 1.4),
|
|
lobes=((1, 0.08, 4.0), (2, 0.1, 1.0)), gullies=4)]
|
|
for (x, y, r, s) in ((-9.2, -3.6, 1.9, 25), (8.6, -5.0, 1.5, 26), (2.6, 9.3, 1.7, 27), (-5.4, 8.1, 1.1, 28), (7.8, 5.4, 1.2, 29), (-1.0, -9.8, 1.0, 30)):
|
|
P.append(rock(r, (x, y, r * 0.3 - 0.4), seed=s, sc=(1.2, 1, 0.8), m=ROCK, sub=2, amp=0.16, name="boulder"))
|
|
for (x, y, z, h, s) in ((6.2, -4.6, 6.6, 3.0, 8), (4.5, -6.4, 6.6, 2.3, 9), (-6.2, 3.0, 6.6, 2.6, 10), (-2.2, 1.4, 42.3, 2.6, 11)):
|
|
pine(P, x, y, z, h, s)
|
|
return P
|
|
|
|
|
|
def finish_rock(P, name, k=1.0):
|
|
"""k scales the plan, so the bounds land on the old rock (Ground uses them for the keep-out radius)."""
|
|
for o in P:
|
|
apply_xform(o)
|
|
o.data.transform(Matrix.Diagonal((k, k, 1.0, 1.0)))
|
|
o = ffin(P, name, ang=30, wn=False, ms={ROCK: 0.5, "M_RockBand": 0.5, "M_RockRust": 0.5})
|
|
flat(o)
|
|
return o
|
|
|
|
|
|
def rock_view():
|
|
return dict(elev=8, azim=-35, bg=(0.62, 0.72, 0.84), views=[("_top", dict(elev=34, azim=-60)), ("_close", dict(elev=4, azim=-30, dist_mul=0.42, target=(4, -6, 4))), ("_back", dict(elev=8, azim=140))])
|
|
|
|
|
|
def spire_builder(fn, name, k):
|
|
def build():
|
|
finish_rock(fn(), name, k)
|
|
return rock_view()
|
|
return build
|
|
|
|
|
|
# ======================================================================= hemp
|
|
|
|
def hemp_leaf(base, yaw, pitch, L, W, bend=0.25, fold=0.1):
|
|
"""One fan leaf on a card folded along its midrib (2 x 2 quads, 8 tris). v = 0 at the stem end. The stem end is narrowed so the card stays off the
|
|
little stalk patch in the corner of T_HempLeaf."""
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
rows = []
|
|
uvs = []
|
|
for t, ins in ((0.0, 0.1), (0.5, 0.0), (1.0, 0.0)):
|
|
y = -L * t
|
|
z = -bend * L * t * t
|
|
hw_ = W / 2 * (1 - 2 * ins)
|
|
rows.append([bm.verts.new((-hw_, y, z + fold * W)), bm.verts.new((0.0, y, z)), bm.verts.new((hw_, y, z + fold * W))])
|
|
uvs.append(((ins, t), (0.5, t), (1 - ins, t)))
|
|
for k in range(2):
|
|
for j in range(2):
|
|
f = bm.faces.new((rows[k][j], rows[k][j + 1], rows[k + 1][j + 1], rows[k + 1][j]))
|
|
for l, uv in zip(f.loops, (uvs[k][j], uvs[k][j + 1], uvs[k + 1][j + 1], uvs[k + 1][j])):
|
|
l[uvl].uv = uv
|
|
o = mesh_obj("leaf", bm)
|
|
set_mats(o, "M_HempCard")
|
|
o.data.transform(Matrix.Rotation(math.radians(-pitch), 4, "X"))
|
|
o.data.transform(Matrix.Translation(Vector(base)) @ Matrix.Rotation(math.radians(yaw), 4, "Z"))
|
|
return uv_keep(o)
|
|
|
|
|
|
def hemp():
|
|
"""Instanced by the grass shader: 1 m tall, origin at the root, one mesh, one slot. A real hemp plant in outline: paired fan leaves in tiers, wide and
|
|
drooping low down, short and raised up top, ending in a tight cola. The stalk samples the green patch of the leaf texture."""
|
|
rnd = random.Random(11)
|
|
PATCH = 0.03
|
|
P = []
|
|
st = cyl("stalk", 0.016, 0.96, (0, 0, 0.48), verts=4, m="M_HempCard", r2=0.006, cap=False)
|
|
bm = bmesh.new()
|
|
bm.from_mesh(st.data)
|
|
uvl = bm.loops.layers.uv.verify()
|
|
for f in bm.faces:
|
|
for l in f.loops:
|
|
l[uvl].uv = (PATCH, PATCH)
|
|
bm.to_mesh(st.data)
|
|
bm.free()
|
|
P.append(uv_keep(st))
|
|
tiers = ((0.16, 0.46, 12, 0.3), (0.31, 0.44, 22, 0.27), (0.46, 0.38, 32, 0.23), (0.6, 0.31, 42, 0.18), (0.72, 0.25, 54, 0.14))
|
|
for k, (z, L, pitch, bend) in enumerate(tiers):
|
|
n = 3 if k % 2 == 0 else 4
|
|
for j in range(n):
|
|
yaw = 360 * j / n + k * 57 + rnd.uniform(-14, 14)
|
|
P.append(hemp_leaf((0, 0, z), yaw, pitch + rnd.uniform(-5, 6), L * rnd.uniform(0.92, 1.08), L * 1.12, bend=bend))
|
|
for j in range(3):
|
|
P.append(hemp_leaf((0, 0, 0.8), 120 * j + 25, 72, 0.22, 0.2, bend=0.08, fold=0.16))
|
|
o = ffin(P, "SM_Hemp", ang=80, wn=False)
|
|
# review shots only: show the alpha cut-out the game applies (M_Hemp), Blender ignores it otherwise
|
|
m_ = o.data.materials[0]
|
|
nt = m_.node_tree
|
|
tn = next(n_ for n_ in nt.nodes if n_.type == "TEX_IMAGE")
|
|
bsdf = next(n_ for n_ in nt.nodes if n_.type == "BSDF_PRINCIPLED")
|
|
nt.links.new(tn.outputs["Alpha"], bsdf.inputs["Alpha"])
|
|
try:
|
|
m_.surface_render_method = "DITHERED"
|
|
except Exception:
|
|
pass
|
|
return dict(elev=14, azim=-30, bg=(0.55, 0.7, 0.5), views=[("_top", dict(elev=55, azim=-30)), ("_side", dict(elev=3, azim=40))])
|
|
|
|
|
|
# ======================================================================= flow arrow
|
|
|
|
def chamfered(name, pts, t, c, m):
|
|
"""The seven-point arrow as a plate in XZ, half thickness t, every edge chamfered by c: sides lofted, caps as explicit faces (polyfill closes
|
|
the left notch of this outline on one cap)."""
|
|
ip = inset(pts, c)
|
|
bm = bmesh.new()
|
|
n = len(pts)
|
|
R = [[bm.verts.new((x, y, z)) for (x, z) in ring] for ring, y in ((ip, -t), (pts, -t + c), (pts, t - c), (ip, t))]
|
|
for f_ in ((0, 1, 2, 6), (6, 2, 4), (2, 3, 4), (5, 6, 4)):
|
|
bm.faces.new([R[0][i] for i in f_])
|
|
bm.faces.new([R[3][i] for i in reversed(f_)])
|
|
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]))
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
o = mesh_obj(name, bm)
|
|
set_mats(o, m)
|
|
return o
|
|
|
|
|
|
def icon_arrow():
|
|
"""The flow arrow over belts: a chunky painted board, tractor green with a cream inlay. Same size and axis as ever (points to +Z, flat in XZ)."""
|
|
pts = [(-0.09, -0.26), (0.09, -0.26), (0.09, 0.02), (0.21, 0.02), (0.0, 0.26), (-0.21, 0.02), (-0.09, 0.02)]
|
|
P = [chamfered("arrow", pts, 0.05, 0.018, "M_PaintGreen")]
|
|
ip = [(-0.042, -0.21), (0.042, -0.21), (0.042, 0.07), (0.11, 0.07), (0.0, 0.195), (-0.11, 0.07), (-0.042, 0.07)]
|
|
P.append(chamfered("inlay", ip, 0.056, 0.003, INK))
|
|
ffin(P, "SM_IconArrow", ang=30, wn=False)
|
|
return dict(elev=5, azim=-15)
|
|
|
|
|
|
BUILDERS = {"SM_Decor_Lamp": yard_lamp, "SM_Decor_Dish": radio_mast, "SM_Hopper": hopper, "SM_Spire_A": spire_builder(spire_a, "SM_Spire_A", 0.89), "SM_Spire_B": spire_builder(spire_b, "SM_Spire_B", 0.93),
|
|
"SM_Spire_C": spire_builder(spire_c, "SM_Spire_C", 0.91), "SM_Hemp": hemp, "SM_IconArrow": icon_arrow}
|
|
BUDGET = {"SM_Decor_Lamp": 2000, "SM_Decor_Dish": 8000, "SM_Hopper": 8000, "SM_Spire_A": 8000, "SM_Spire_B": 8000, "SM_Spire_C": 8000, "SM_Hemp": 300, "SM_IconArrow": 400}
|
|
|
|
if __name__ == "__main__":
|
|
build_main(BUILDERS, BUDGET)
|