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>
1987 lines
102 KiB
Python
1987 lines
102 KiB
Python
"""GRASS CUTTER - the "Herbaria homestead" world set: everything that used to be seaside decor, rebuilt for a farm meadow.
|
|
|
|
Old name -> what it is now
|
|
SM_Wreck_Ship -> giant abandoned rusty combine harvester, half sunk in the meadow
|
|
SM_Wreck_Probe -> crashed crop-duster biplane
|
|
SM_Buoy -> survey stake with a red flag and a hay tuft
|
|
SM_Decor_Beacon -> wooden windmill (Light = the sails)
|
|
SM_Decor_Pool -> tin water trough + hand pump (Water = the water)
|
|
SM_Decor_Palm -> apple tree in a half-barrel
|
|
SM_Decor_Dish -> weather vane with a rooster (Dish = the turning vane)
|
|
SM_Decor_Vending -> roadside honesty stall
|
|
SM_Decor_Sofa -> hay-bale sofa + blanket
|
|
SM_Decor_Umbrella -> canvas market parasol
|
|
SM_Decor_Lamp -> timber post + iron lantern (Bulb = the glowing flame globe)
|
|
SM_Decor_Hammock -> burlap hammock on timber posts
|
|
SM_Decor_Bench / Crates / Grill / Flag / Gnome -> same idea, farm materials (Flag keeps Cloth)
|
|
SM_HoverTanker -> tin-and-timber hover harvester (Fan_L / Fan_R, Fill, Seat, Intake)
|
|
SM_TugPump -> gc_vehicles' combine; only the cab roof changes from cream boards to tin
|
|
(SM_SlurpSki and SM_Decor_Lifebuoy were checked against the new palette and left alone.)
|
|
|
|
Conventions as os_decor.py: meters, Z-up, front = -Y, origin = bottom centre, transforms applied except where a part must
|
|
keep a local spin axis:
|
|
Light (windmill sails): local Z = the sail shaft, rotation (90, 0, 0) left unapplied
|
|
Fan_L / Fan_R: local Y = vertical (Vehicle.cs spins them about local Y), rotation (90, 0, 0) left unapplied
|
|
Wrecks: Ground.Place() drops the origin 0.4 m (x scale) under the soil, so the meadow surface is model z = 0.4.
|
|
|
|
Run (from project root):
|
|
blender -b --factory-startup --python ArtSource/Blender/scripts/gc_farm_world.py -- [SM_Buoy SM_Decor_Beacon ...]
|
|
"""
|
|
import sys, os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
from os_decor import * # noqa: F401,F403
|
|
import os_decor as D
|
|
import common
|
|
import gc_vehicles as GV
|
|
|
|
D.DECAL_MATS = ("M_Label", "M_Logo", "M_Tread")
|
|
_join0 = D.join
|
|
UVS = [1.0] # default box-projection scale of the model being built
|
|
GR = random.Random(7) # plank-to-plank UV offsets
|
|
|
|
# ======================================================================= helpers
|
|
|
|
|
|
def join(objs, name):
|
|
"""os_decor.join that keeps per-part UVs: a part flagged 'uvok' keeps its own, the rest get a box projection."""
|
|
objs = [o for o in objs if o is not None]
|
|
for o in objs:
|
|
if not o.get("uvok"):
|
|
uv_box(o, UVS[0])
|
|
me = o.data
|
|
act = me.uv_layers.active or me.uv_layers[0]
|
|
for l in [l for l in me.uv_layers if l.name != act.name]:
|
|
me.uv_layers.remove(l)
|
|
me.uv_layers[0].name = "UVMap"
|
|
o = _join0(objs, name)
|
|
o["uvok"] = 1
|
|
return o
|
|
|
|
|
|
def done(o, ang=45):
|
|
smooth(o, ang)
|
|
return o
|
|
|
|
|
|
def uv_grain(o, scale=1.0, axis=None):
|
|
"""Board textures have their grain along V: run V along the part's long axis, whatever way it points."""
|
|
me = o.data
|
|
bm = bmesh.new()
|
|
bm.from_mesh(me)
|
|
uv = bm.loops.layers.uv.verify()
|
|
bm.normal_update()
|
|
if axis is None:
|
|
vs = [v.co for v in bm.verts]
|
|
ext = [max(v[i] for v in vs) - min(v[i] for v in vs) for i in range(3)]
|
|
k = ext.index(max(ext))
|
|
axis = Vector([1.0 if i == k else 0.0 for i in range(3)])
|
|
axis = Vector(axis).normalized()
|
|
ref = Vector((0, 0, 1)) if abs(axis.z) < 0.9 else Vector((1, 0, 0))
|
|
a = axis.cross(ref).normalized()
|
|
b = axis.cross(a)
|
|
uo, vo = GR.random(), GR.random()
|
|
for f in bm.faces:
|
|
side = b if abs(f.normal.dot(a)) > abs(f.normal.dot(b)) else a
|
|
for l in f.loops:
|
|
p = l.vert.co
|
|
l[uv].uv = (p.dot(side) * scale + uo, p.dot(axis) * scale + vo)
|
|
bm.to_mesh(me)
|
|
bm.free()
|
|
o["uvok"] = 1
|
|
return o
|
|
|
|
|
|
def pl(x0, x1, y0, y1, z0, z1, m="M_Timber", bevel=0.012, segs=1, uv=1.0, name="plank"):
|
|
x0, x1 = sorted((x0, x1))
|
|
y0, y1 = sorted((y0, y1))
|
|
return uv_grain(bx(x0, x1, y0, y1, z0, z1, m, bevel=bevel, segs=segs, name=name), uv)
|
|
|
|
|
|
def beam(p0, p1, w, h=None, m="M_Timber", bevel=0.01, uv=1.0, name="beam"):
|
|
"""Square timber from p0 to p1 (h = the side that faces up)."""
|
|
h = w if h is None else h
|
|
p0, p1 = Vector(p0), Vector(p1)
|
|
d = p1 - p0
|
|
o = bx(-w / 2, w / 2, -h / 2, h / 2, 0, d.length, m, bevel=bevel, segs=1, name=name)
|
|
uv_grain(o, uv, (0, 0, 1))
|
|
o.rotation_euler = d.to_track_quat("Z", "Y").to_euler()
|
|
o.location = p0
|
|
apply_xform(o)
|
|
return o
|
|
|
|
|
|
def log(p0, p1, r, m="M_Timber", verts=8, r2=None, uv=1.0):
|
|
o = rod(p0, p1, r, m, verts=verts, r2=r2)
|
|
return uv_grain(o, uv, Vector(p1) - Vector(p0))
|
|
|
|
|
|
def dc(name, center, w, h, facing, m):
|
|
o = decal(name, center, w, h, facing, m)
|
|
o["uvok"] = 1
|
|
return o
|
|
|
|
|
|
def blob(r, loc, seed=1.0, sc=(1, 1, 1), m="M_Leaf", sub=2, amp=0.22):
|
|
bm = bmesh.new()
|
|
bmesh.ops.create_icosphere(bm, subdivisions=sub, radius=r)
|
|
so = Vector((seed * 3.3, seed * 1.7, seed * 5.9))
|
|
for v in bm.verts:
|
|
p = v.co.copy()
|
|
k = 1 + amp * noise.noise(p / r * 1.6 + so)
|
|
v.co = Vector((p.x * sc[0], p.y * sc[1], p.z * sc[2])) * k
|
|
bmesh.ops.translate(bm, vec=Vector(loc), verts=bm.verts)
|
|
o = mesh_obj("blob", bm)
|
|
set_mats(o, m)
|
|
return o
|
|
|
|
|
|
def straw(c, n, r, h, rnd, m="M_Straw", rad=0.008, up=1.0):
|
|
"""Stiff straws (or grass blades) poking out around c."""
|
|
out = []
|
|
for _ in range(n):
|
|
a = rnd.uniform(0, TAU)
|
|
rr = rnd.uniform(0.2, 1.0) * r
|
|
p0 = Vector((c[0] + math.cos(a) * rr, c[1] + math.sin(a) * rr, c[2]))
|
|
lean = rnd.uniform(0.15, 0.6) * h
|
|
p1 = p0 + Vector((math.cos(a) * lean, math.sin(a) * lean, rnd.uniform(0.5, 1.0) * h * up))
|
|
out.append(rod(p0, p1, rad, m, verts=3, r2=rad * 0.35))
|
|
return out
|
|
|
|
|
|
def apple(loc, r=0.055, m="M_PaintRed"):
|
|
loc = Vector(loc)
|
|
return [sphere("apple", r, loc, seg=7, rings=4, m=m, scale=(1, 1, 0.92)),
|
|
rod(loc + Vector((0, 0, r * 0.75)), loc + Vector((0.008, 0.004, r * 1.35)), r * 0.09, "M_Bark", verts=3)]
|
|
|
|
|
|
def swap_mat(o, table):
|
|
me = o.data
|
|
for i, m_ in enumerate(me.materials):
|
|
if m_ and m_.name in table:
|
|
me.materials[i] = mat(table[m_.name])
|
|
return o
|
|
|
|
|
|
def keep_rot(o, eul):
|
|
"""Leave a rotation on the object without moving its mesh (the object's local axes become the spin axes)."""
|
|
e = Euler(eul)
|
|
o.data.transform(e.to_matrix().to_4x4().inverted())
|
|
o.rotation_euler = e
|
|
return o
|
|
|
|
|
|
def plan_band(name, rows, mats, n=48, pn=3.2, uu=10.0, vv=1.0):
|
|
"""Loft through superellipse rings; rows = [(half_x, half_y, y_centre, z), ...], mats = one name or one per band.
|
|
U runs around the plan (uu repeats per lap)."""
|
|
if isinstance(mats, str):
|
|
mats = [mats] * (len(rows) - 1)
|
|
slots = list(dict.fromkeys(mats))
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
R = []
|
|
for (a, b, yc, z) in rows:
|
|
ring = []
|
|
for i in range(n):
|
|
th = TAU * (i + 0.5) / n
|
|
c, s_ = math.cos(th), math.sin(th)
|
|
ring.append(bm.verts.new((a * math.copysign(abs(c) ** (2 / pn), c), yc + b * math.copysign(abs(s_) ** (2 / pn), s_), z)))
|
|
R.append(ring)
|
|
for k in range(len(rows) - 1):
|
|
for i in range(n):
|
|
j = (i + 1) % n
|
|
f = bm.faces.new((R[k][i], R[k][j], R[k + 1][j], R[k + 1][i]))
|
|
f.material_index = slots.index(mats[k])
|
|
for l, (uu_i, vk) in zip(f.loops, ((i, k), (i + 1, k), (i + 1, k + 1), (i, k + 1))):
|
|
l[uvl].uv = (uu_i / n * uu, rows[vk][3] * vv)
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
o = mesh_obj(name, bm)
|
|
add_mats(o, *slots)
|
|
o["uvok"] = 1
|
|
return o
|
|
|
|
|
|
def weather(o, seed, base, rust=0.05, moss=0.28, freq=1.3, mossm="M_Barnacle"):
|
|
"""Patchy paint on a single-material part: noise picks base paint / rust per face, up-facing faces collect moss."""
|
|
so = Vector((seed * 2.1, seed * 5.3, seed * 1.7))
|
|
|
|
def fn(c, n, i):
|
|
if n.z > 0.3 and noise.noise(c * freq * 1.6 + so * 2) > 0.2 - moss:
|
|
return 2
|
|
return 1 if noise.noise(c * freq + so) > rust else 0
|
|
paint(o, fn, [base, "M_Rust", mossm])
|
|
return o
|
|
|
|
|
|
def canopy(R, top, drop, m_a, m_b, panels=8, sub=4, nr=6, thick=0.014):
|
|
"""Pleated parasol skin with a scalloped valance (from the old patio umbrella). Returns the mesh."""
|
|
na = panels * sub
|
|
bm = bmesh.new()
|
|
grid = []
|
|
for i in range(nr + 1):
|
|
row = []
|
|
for j in range(na):
|
|
th = TAU * j / na
|
|
frac = (j % sub) / sub
|
|
rr = 0.06 + (R - 0.06) * i / nr
|
|
rr *= 1.0 - 0.07 * math.sin(math.pi * frac) * (i / nr)
|
|
z = top - drop * (rr / R) ** 1.5 - 0.07 * (rr / R) * math.sin(math.pi * frac)
|
|
row.append(bm.verts.new((math.cos(th) * rr, math.sin(th) * rr, z)))
|
|
grid.append(row)
|
|
val = []
|
|
for j in range(na):
|
|
frac = (j % sub) / sub
|
|
v = grid[nr][j].co
|
|
val.append(bm.verts.new((v.x * 1.01, v.y * 1.01, v.z - 0.08 - 0.06 * math.sin(math.pi * frac))))
|
|
for i in range(nr):
|
|
for j in range(na):
|
|
f = bm.faces.new((grid[i][j], grid[i][(j + 1) % na], grid[i + 1][(j + 1) % na], grid[i + 1][j]))
|
|
f.material_index = (j // sub) % 2
|
|
for j in range(na):
|
|
f = bm.faces.new((grid[nr][j], grid[nr][(j + 1) % na], val[(j + 1) % na], val[j]))
|
|
f.material_index = 1 - (j // sub) % 2
|
|
bm.faces.new([grid[0][j] for j in range(na)]).material_index = 1
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
can = mesh_obj("canopy", bm)
|
|
add_mats(can, m_a, m_b)
|
|
bm2 = bmesh.new()
|
|
bm2.from_mesh(can.data)
|
|
for f in bm2.faces:
|
|
if f.normal.z < -0.2:
|
|
f.normal_flip()
|
|
bm2.to_mesh(can.data)
|
|
bm2.free()
|
|
mod(can, "SOLIDIFY", thickness=thick, offset=-1)
|
|
bake(can)
|
|
return can
|
|
|
|
|
|
def bale(x0, x1, y0, y1, z0, z1, rnd, bands="x"):
|
|
"""Square hay bale: soft brick + two twine bands + stray straws."""
|
|
w, d, h = x1 - x0, y1 - y0, z1 - z0
|
|
c = ((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2)
|
|
o = softbox("bale", (w, d, h), c, r=0.05, m="M_Hay", bulge=(0.012, 0.012, 0.018), na=1, nf=3)
|
|
wobble(o, 0.012, 7.0, seed=rnd.uniform(0, 9))
|
|
P = [o]
|
|
for t in (0.26, 0.74):
|
|
if bands == "x": # twine runs around the short way (bands sit at x fractions)
|
|
x = x0 + w * t
|
|
P.append(bx(x - 0.008, x + 0.008, y0 - 0.007, y1 + 0.007, z0 - 0.002, z1 + 0.007, "M_Twine", bevel=0.0, name="twine"))
|
|
else:
|
|
y = y0 + d * t
|
|
P.append(bx(x0 - 0.007, x1 + 0.007, y - 0.008, y + 0.008, z0 - 0.002, z1 + 0.007, "M_Twine", bevel=0.0, name="twine"))
|
|
return P
|
|
|
|
|
|
# ======================================================================= the world markers
|
|
|
|
def survey_stake():
|
|
"""The ring of stakes around the clearing. A red-and-cream ranging pole you can pick out at 70 m."""
|
|
rnd = random.Random(12)
|
|
P = []
|
|
# the pole, striped like a surveyor's rod; a touch out of plumb
|
|
bands = [(-0.07, 0.42, "M_Timber"), (0.42, 0.72, "M_PaintRed"), (0.72, 1.02, "M_PaintWhite"), (1.02, 1.32, "M_PaintRed"),
|
|
(1.32, 1.62, "M_PaintWhite"), (1.62, 1.86, "M_PaintRed")]
|
|
for z0, z1, mm in bands:
|
|
P.append(pl(-0.055, 0.055, -0.055, 0.055, z0, z1, mm, bevel=0.012, name="pole"))
|
|
cap = rev("cap", [(0.0, 1.86), (0.06, 1.86), (0.06, 1.89), (0.03, 1.93), (0.0, 1.95)], "M_Navy", segs=4, phase=math.pi / 4)
|
|
P.append(cap)
|
|
# black survey ticks up the front face
|
|
for k in range(9):
|
|
z = 0.5 + k * 0.15
|
|
P.append(bx(-0.057, 0.0 if k % 2 else 0.03, -0.058, -0.054, z, z + 0.035, "M_Navy", bevel=0.0, name="tick"))
|
|
# twine lashings and a little hanging tag
|
|
P.append(bx(-0.062, 0.062, -0.062, 0.062, 1.4, 1.425, "M_Twine", bevel=0.0, name="lash"))
|
|
P.append(bx(-0.062, 0.062, -0.062, 0.062, 1.8, 1.825, "M_Twine", bevel=0.0, name="lash"))
|
|
tag = slab("tag", fillet2d([(-0.075, -0.1), (0.075, -0.1), (0.075, 0.03), (0.0, 0.08), (-0.075, 0.03)], 0.015, n=1), -0.008, 0.008, "M_PaintYellow", plane="XZ", bevel=0.004, segs=1)
|
|
xf(tag, loc=(-0.11, -0.05, 1.27), rot=(0, 7, 0))
|
|
P.append(tag)
|
|
P.append(ptube("tie", [(-0.05, -0.055, 1.402), (-0.1, -0.055, 1.38), (-0.11, -0.05, 1.35)], 0.005, "M_Twine", rs=0))
|
|
# the red flag, flying off +X
|
|
W, Hh, nu, nv = 0.6, 0.46, 10, 4
|
|
top = 1.86
|
|
bm = bmesh.new()
|
|
G = []
|
|
for i in range(nu + 1):
|
|
u = i / nu
|
|
col = []
|
|
for j in range(nv + 1):
|
|
v = j / nv
|
|
x = 0.055 + W * u
|
|
y = 0.075 * math.sin(u * 6.5 + v * 0.7 + 0.4) * u ** 0.7
|
|
hh = Hh * (1 - 0.34 * u)
|
|
z = top - Hh / 2 + hh * (v - 0.5) - 0.05 * u * u
|
|
col.append(bm.verts.new((x, y, z)))
|
|
G.append(col)
|
|
for i in range(nu):
|
|
for j in range(nv):
|
|
f = bm.faces.new((G[i][j], G[i + 1][j], G[i + 1][j + 1], G[i][j + 1]))
|
|
f.material_index = 1 if i == 0 else 0
|
|
flag = mesh_obj("flag", bm)
|
|
add_mats(flag, "M_PaintRed", "M_PaintWhite")
|
|
mod(flag, "SOLIDIFY", thickness=0.012, offset=0)
|
|
bake(flag)
|
|
P.append(flag)
|
|
for z in (top - 0.03, top - Hh + 0.03):
|
|
P.append(torus("ring", 0.058 * 1.05, 0.009, loc=(0, 0, z), seg=4, rseg=3, m="M_Navy"))
|
|
# hay tuft around the foot
|
|
P.append(blob(0.235, (0.02, 0.0, 0.05), 3.0, sc=(1.1, 0.95, 0.68), m="M_Hay", sub=2, amp=0.3))
|
|
P.append(blob(0.13, (-0.2, 0.08, 0.02), 5.0, sc=(1.0, 0.9, 0.7), m="M_Hay", sub=1, amp=0.3))
|
|
P += straw((0.02, 0, 0.16), 22, 0.2, 0.2, rnd, rad=0.009)
|
|
P.append(torus("band", 0.14, 0.012, loc=(0.02, 0, 0.17), seg=8, rseg=3, m="M_Twine"))
|
|
o = join(P, "SM_Buoy")
|
|
for v in o.data.vertices: # nudge the whole thing out of plumb (not below ground)
|
|
v.co.x += v.co.z * 0.012
|
|
done(o, 55)
|
|
return dict(elev=12)
|
|
|
|
|
|
# ======================================================================= windmill
|
|
|
|
def windmill():
|
|
UVS[0] = 0.8
|
|
P = []
|
|
zb, zt, rb, rt = 0.2, 2.05, 0.52, 0.34
|
|
ph = math.pi / 8
|
|
apo = math.cos(math.pi / 8)
|
|
|
|
def rad(z):
|
|
return rb + (rt - rb) * (z - zb) / (zt - zb)
|
|
|
|
# fieldstone-coloured timber plinth + boarded smock tower
|
|
P.append(rev("plinth", [(0, 0), (0.575, 0), (0.6, 0.025), (0.6, 0.15), (0.57, 0.19), (0.52, 0.21)], "M_Timber", segs=8, phase=ph))
|
|
tw = rev("tower", [(rb, zb), (rad(0.8), 0.8), (rad(1.4), 1.4), (rt, zt)], "M_HullWhite", segs=8, phase=ph, close_top=False)
|
|
D.uv_cyl(tw, 2, 4.0, 0.75)
|
|
tw["uvok"] = 1
|
|
P.append(tw)
|
|
# hoops of dark iron + timber collars
|
|
for z, h, mm in ((0.2, 0.05, "M_Navy"), (1.98, 0.09, "M_Timber")):
|
|
P.append(rev("collar", [(rad(z) + 0.02, z), (rad(z + h) + 0.02, z + h)], mm, segs=8, phase=ph, close_top=False))
|
|
tilt = math.degrees(math.atan2((rb - rt) * apo, zt - zb))
|
|
|
|
def on_face(parts, z, az):
|
|
"""Lay parts (built on the XZ plane around z = 0, facing -Y) onto the tower face at height z, azimuth az."""
|
|
r = rad(z) * apo + 0.002
|
|
for o in parts:
|
|
xf(o, rot=(-tilt, 0, 0))
|
|
xf(o, loc=(0, -r, z))
|
|
xf(o, rot=(0, 0, az))
|
|
return parts
|
|
|
|
# barn-red ledged door with a Z-brace, iron hinges and a stone step
|
|
door = [pl(-0.16 + k * 0.08, -0.08 + k * 0.08, -0.03, 0.02, 0.0, 0.6, "M_BarnRed", bevel=0.006, uv=0.8) for k in range(4)]
|
|
door += [pl(-0.17, 0.17, -0.05, -0.02, zz, zz + 0.07, "M_BarnRed", bevel=0.006, uv=0.8) for zz in (0.07, 0.46)]
|
|
door.append(beam((-0.14, -0.04, 0.13), (0.14, -0.04, 0.46), 0.06, 0.03, "M_BarnRed", bevel=0.006, uv=0.8))
|
|
door += [pl(-0.195, 0.195, -0.04, 0.03, 0.6, 0.68, "M_Timber", bevel=0.01), pl(-0.195, -0.17, -0.04, 0.03, 0.0, 0.62, "M_Timber", bevel=0.008),
|
|
pl(0.17, 0.195, -0.04, 0.03, 0.0, 0.62, "M_Timber", bevel=0.008)]
|
|
door += [bx(-0.16, -0.02, -0.058, -0.05, zz + 0.02, zz + 0.05, "M_Navy", bevel=0.0, name="hinge") for zz in (0.07, 0.46)]
|
|
door.append(sphere("knob", 0.02, (0.1, -0.06, 0.3), seg=6, rings=4, m="M_Brass"))
|
|
P += on_face(door, 0.22, 0)
|
|
# little four-pane windows
|
|
for z, az in ((1.5, 0), (1.15, 90), (1.15, -90), (1.5, 180)):
|
|
w = [pl(-0.13, 0.13, -0.03, 0.03, -0.14, 0.14, "M_BarnRed", bevel=0.01, uv=0.8), bx(-0.1, 0.1, -0.045, -0.02, -0.11, 0.11, "M_Navy", bevel=0.0, name="pane"),
|
|
bx(-0.012, 0.012, -0.05, -0.03, -0.12, 0.12, "M_PaintWhite", bevel=0.0, name="bar"), bx(-0.12, 0.12, -0.05, -0.03, -0.012, 0.012, "M_PaintWhite", bevel=0.0, name="bar")]
|
|
P += on_face(w, z, az)
|
|
# reefing stage round the middle: planked ring on braces, posts and a rail
|
|
ze = 1.0
|
|
deck = rev("deck", [(rad(ze) - 0.02, ze), (0.595, ze), (0.6, ze + 0.015), (0.6, ze + 0.05), (0.59, ze + 0.06), (rad(ze) - 0.02, ze + 0.06)], "M_Timber", segs=8, phase=ph, close_top=False)
|
|
P.append(deck)
|
|
for k in range(8):
|
|
a = TAU * k / 8 + ph
|
|
c, s_ = math.cos(a), math.sin(a)
|
|
P.append(beam((c * 0.575, s_ * 0.575, ze + 0.05), (c * 0.575, s_ * 0.575, ze + 0.33), 0.045, 0.045, bevel=0.008))
|
|
P.append(beam((c * 0.5, s_ * 0.5, ze + 0.01), (c * 0.43, s_ * 0.43, 0.68), 0.05, 0.05, bevel=0.008))
|
|
a1 = TAU * (k + 1) / 8 + ph
|
|
P.append(beam((c * 0.575, s_ * 0.575, ze + 0.31), (math.cos(a1) * 0.575, math.sin(a1) * 0.575, ze + 0.31), 0.05, 0.04, bevel=0.008))
|
|
# cap: a chunky barn-red bonnet on a timber curb
|
|
P.append(rev("curb", [(0.36, 2.06), (0.4, 2.07), (0.41, 2.1), (0.4, 2.14), (0.36, 2.15)], "M_Timber", segs=16, close_top=False))
|
|
capm = rev("cap", [(0.385, 2.14), (0.375, 2.26), (0.33, 2.44), (0.255, 2.62), (0.15, 2.78), (0.05, 2.87), (0.0, 2.885)], "M_BarnRed", segs=16)
|
|
D.uv_cyl(capm, 2, 3.0, 0.8)
|
|
capm["uvok"] = 1
|
|
P.append(capm)
|
|
P.append(torus("capband", 0.31, 0.022, loc=(0, 0, 2.5), seg=16, rseg=4, m="M_Navy"))
|
|
# finial with a brass ball
|
|
P.append(rod((0, 0, 2.86), (0, 0, 3.05), 0.016, "M_Navy", verts=6))
|
|
P.append(sphere("ball", 0.05, (0, 0, 3.08), seg=10, rings=6, m="M_Brass"))
|
|
# wind shaft (fixed) sticking out of the bonnet + tail pole down to the stage
|
|
P.append(log((0, -0.2, 2.3), (0, -0.56, 2.3), 0.075, verts=10))
|
|
P.append(torus("neck", 0.082, 0.018, loc=(0, -0.42, 2.3), axis="Y", seg=10, rseg=4, m="M_Navy"))
|
|
P.append(beam((0, 0.28, 2.32), (0, 0.585, 1.33), 0.08, 0.08))
|
|
body = join(P, "Body")
|
|
done(body, 40)
|
|
# ---------------------------------------------------------- Light: the sails (the only thing that turns)
|
|
hub_y, L = -0.66, 0.99
|
|
S = [cyl("hub", 0.115, 0.14, (0, hub_y, 0), axis="Y", verts=12, m="M_Navy", bevel=0.02, segs=1),
|
|
sphere("nut", 0.06, (0, hub_y - 0.08, 0), seg=8, rings=5, m="M_Brass")]
|
|
|
|
def sail(k):
|
|
Q = [beam((0, 0, 0.0), (0, 0, L), 0.06, 0.05, bevel=0.01)]
|
|
for b in range(8):
|
|
z = 0.24 + b * (L - 0.27) / 7
|
|
Q.append(pl(-0.075, 0.27, -0.012, 0.012, z, z + 0.022, "M_Timber", bevel=0.0))
|
|
Q.append(beam((0.27, 0, 0.22), (0.27, 0, L), 0.03, 0.03, bevel=0.0))
|
|
Q.append(beam((-0.075, 0, 0.22), (-0.075, 0, L), 0.025, 0.025, bevel=0.0))
|
|
cv = dc("canvas", (0.13, 0.014, 0.22 + (L - 0.22) * 0.44), 0.27, (L - 0.22) * 0.86, (0, -1, 0), "M_Canvas")
|
|
dbl(cv, 0.006)
|
|
Q.append(cv)
|
|
tp = dc("tip", (0.13, 0.014, L - (L - 0.22) * 0.06), 0.27, (L - 0.22) * 0.13, (0, -1, 0), "M_PaintRed")
|
|
dbl(tp, 0.006)
|
|
Q.append(tp)
|
|
for o in Q:
|
|
xf(o, rot=(0, 90 * k, 0))
|
|
xf(o, loc=(0, hub_y, 0))
|
|
return Q
|
|
|
|
for k in range(4):
|
|
S += sail(k)
|
|
light = join(S, "Light")
|
|
xf(light, loc=(0, 0, 2.3))
|
|
done(light, 50)
|
|
set_origin(light, (0, 0, 2.3)) # same pivot as the old lens: on the tower axis
|
|
keep_rot(light, (math.pi / 2, 0, 0)) # local Z = sail shaft
|
|
return dict(elev=14, azim=-32, extra=[dict(elev=10, azim=150)])
|
|
|
|
|
|
# ======================================================================= weather vane
|
|
|
|
def weather_vane():
|
|
UVS[0] = 0.8
|
|
P = []
|
|
# a stout post on four braces
|
|
P.append(beam((0, 0, 0.0), (0, 0, 1.46), 0.15, 0.15, bevel=0.022))
|
|
P.append(pl(-0.74, 0.74, -0.075, 0.075, 0.0, 0.1, bevel=0.018))
|
|
P.append(pl(-0.075, 0.075, -0.68, 0.68, 0.0, 0.102, bevel=0.018))
|
|
for (x, y) in ((0.6, 0), (-0.6, 0), (0, 0.56), (0, -0.56)):
|
|
P.append(beam((x, y, 0.1), (x * 0.08, y * 0.08, 0.74), 0.07, 0.07, bevel=0.012))
|
|
P.append(bx(-0.085, 0.085, -0.085, 0.085, 0.82, 0.86, "M_Navy", bevel=0.006, segs=1, name="strap"))
|
|
P.append(bx(-0.085, 0.085, -0.085, 0.085, 1.3, 1.34, "M_Navy", bevel=0.006, segs=1, name="strap"))
|
|
# cardinal arms + letters (N = model front -Y, facing out of the piece)
|
|
P.append(cy(0.095, 1.34, 1.38, "M_Navy", verts=12, bevel=0.01, segs=1, name="seat"))
|
|
P.append(cy(0.052, 1.44, 1.5, "M_Brass", verts=10, name="bearing"))
|
|
P.append(rod((-0.5, 0, 1.4), (0.5, 0, 1.4), 0.014, "M_Navy", verts=6))
|
|
P.append(rod((0, -0.5, 1.4), (0, 0.5, 1.4), 0.014, "M_Navy", verts=6))
|
|
P.append(cy(0.05, 1.38, 1.46, "M_Navy", verts=10, name="stem"))
|
|
|
|
def bars(pts, c, az):
|
|
"""Thick letter strokes on the XZ plane, stood at c, turned by az."""
|
|
out = []
|
|
for (a, b) in pts:
|
|
o = beam((a[0], 0, a[1]), (b[0], 0, b[1]), 0.022, 0.022, "M_Navy", bevel=0.0)
|
|
xf(o, rot=(0, 0, az))
|
|
xf(o, loc=c)
|
|
out.append(o)
|
|
return out
|
|
|
|
s = 0.075
|
|
N = [((-s, -s), (-s, s)), ((-s, s), (s, -s)), ((s, -s), (s, s))]
|
|
E = [((-s, -s), (-s, s)), ((-s, s), (s, s)), ((-s, 0), (s * 0.7, 0)), ((-s, -s), (s, -s))]
|
|
SS = [((s, s), (-s, s)), ((-s, s), (-s, 0)), ((-s, 0), (s, 0)), ((s, 0), (s, -s)), ((s, -s), (-s, -s))]
|
|
W = [((-s, s), (-s * 0.5, -s)), ((-s * 0.5, -s), (0, s * 0.4)), ((0, s * 0.4), (s * 0.5, -s)), ((s * 0.5, -s), (s, s))]
|
|
P += bars(N, (0, -0.56, 1.4), 0) + bars(SS, (0, 0.56, 1.4), 180) + bars(E, (-0.58, 0, 1.4), -90) + bars(W, (0.58, 0, 1.4), 90)
|
|
for x, y in ((0.5, 0), (-0.5, 0), (0, 0.5), (0, -0.5)):
|
|
P.append(sphere("ball", 0.028, (x, y, 1.4), seg=8, rings=5, m="M_Brass"))
|
|
body = join(P, "Body")
|
|
done(body)
|
|
# ---------------------------------------------------------- Dish: the turning vane (pivot on the bearing)
|
|
Q = [cy(0.03, 1.5, 2.03, "M_Navy", verts=8, name="spindle"), sphere("ball", 0.07, (0, 0, 1.62), seg=10, rings=6, m="M_Brass")]
|
|
# arrow along X
|
|
az = 1.82
|
|
Q.append(rod((-0.72, 0, az), (0.72, 0, az), 0.016, "M_Navy", verts=6))
|
|
head = slab("head", [(-0.74, 0.0), (-0.52, 0.11), (-0.57, 0.0), (-0.52, -0.11)], -0.012, 0.012, "M_Navy", plane="XZ", bevel=0.004, segs=1)
|
|
xf(head, loc=(0, 0, az))
|
|
Q.append(head)
|
|
tail = slab("tail", [(0.42, 0.0), (0.74, 0.15), (0.68, 0.0), (0.74, -0.15)], -0.012, 0.012, "M_PaintRed", plane="XZ", bevel=0.004, segs=1)
|
|
xf(tail, loc=(0, 0, az))
|
|
Q.append(tail)
|
|
# the rooster: a thick cut-out, fanned tail, red comb
|
|
b0 = 1.87
|
|
bodyp = fillet2d([(-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)],
|
|
[0.03, 0.05, 0.06, 0.05, 0.02, 0.04, 0.05, 0.05, 0.04, 0.05, 0.03, 0.05], n=2)
|
|
rb_ = slab("rooster", bodyp, -0.035, 0.035, "M_PaintYellow", plane="XZ", bevel=0.012, segs=1)
|
|
xf(rb_, loc=(0, 0, b0))
|
|
Q.append(rb_)
|
|
for k, (dx, dz, mm) in enumerate(((0.33, 0.42, "M_Teal"), (0.4, 0.33, "M_PaintRed"), (0.42, 0.22, "M_Brass"), (0.38, 0.11, "M_Teal"))):
|
|
pts = bez([(0.06, 0.0, 0.1 + 0.02 * k), (0.19, 0.0, 0.17 + dz * 0.35), (dx - 0.04, 0.0, dz + 0.1), (dx, 0.0, dz)], 7)
|
|
f = sweep_rings("feather", pts, [(0.03, 0.06), (0.028, 0.065), (0.025, 0.065), (0.022, 0.055), (0.018, 0.045), (0.012, 0.03), (0.005, 0.012)], mm, verts=6)
|
|
xf(f, loc=(0, 0, b0))
|
|
Q.append(f)
|
|
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)]
|
|
cb = slab("comb", comb, -0.016, 0.016, "M_PaintRed", plane="XZ", bevel=0.006, segs=1)
|
|
xf(cb, loc=(0, 0, b0))
|
|
Q.append(cb)
|
|
wat = slab("wattle", [(-0.32, 0.36), (-0.31, 0.29), (-0.28, 0.31), (-0.285, 0.37)], -0.016, 0.016, "M_PaintRed", plane="XZ", bevel=0.005, segs=1)
|
|
xf(wat, loc=(0, 0, b0))
|
|
Q.append(wat)
|
|
beak = slab("beak", [(-0.31, 0.4), (-0.41, 0.385), (-0.31, 0.36)], -0.016, 0.016, "M_PaintYellow", plane="XZ", bevel=0.004, segs=1)
|
|
xf(beak, loc=(0, 0, b0))
|
|
Q.append(beak)
|
|
for sy in (-1, 1):
|
|
Q.append(sphere("eye", 0.017, (-0.265, sy * 0.036, b0 + 0.415), seg=6, rings=4, m="M_Pupil"))
|
|
dish = join(Q, "Dish")
|
|
done(dish, 45)
|
|
set_origin(dish, (0, 0, 1.5))
|
|
return dict(elev=16, azim=-32)
|
|
|
|
|
|
# ======================================================================= lamp
|
|
|
|
def timber_lamp():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
# cross-lap foot + braces
|
|
P.append(pl(-0.33, 0.33, -0.05, 0.05, 0.0, 0.08, bevel=0.016))
|
|
P.append(pl(-0.05, 0.05, -0.33, 0.33, 0.0, 0.082, bevel=0.016))
|
|
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.56), 0.055, 0.055, bevel=0.01))
|
|
# the post, chamfered and strapped
|
|
P.append(pl(-0.078, 0.078, -0.078, 0.078, 0.02, 2.08, bevel=0.02, segs=2))
|
|
for z in (0.62, 1.86):
|
|
P.append(bx(-0.086, 0.086, -0.086, 0.086, z, z + 0.04, "M_Navy", bevel=0.006, segs=1, name="strap"))
|
|
for sx in (-1, 1):
|
|
P.append(hexbolt(sx * 0.05, -0.09, z + 0.02, r=0.012, h=0.012, m="M_Brass", axis="Y"))
|
|
# small sign bracket with a hanging horseshoe (a bit of luck for the night shift)
|
|
P.append(log((0, -0.07, 1.62), (0, -0.2, 1.62), 0.012, "M_Navy", verts=6))
|
|
shoe = [(math.cos(a) * 0.05, -0.2, 1.54 + math.sin(a) * 0.058) for a in [math.radians(-55 + 290 * k / 12) for k in range(13)]]
|
|
P.append(ptube("shoe", shoe, 0.012, "M_Navy", rs=0))
|
|
# iron lantern: dished base, four cage bars, conical hat, carry ring
|
|
P.append(rev("base", [(0.0, 2.08), (0.1, 2.08), (0.15, 2.11), (0.195, 2.15), (0.2, 2.17), (0.17, 2.18), (0.0, 2.18)], "M_Navy", segs=12))
|
|
for k in range(4):
|
|
a = TAU * k / 4 + math.pi / 4
|
|
c, s_ = math.cos(a), math.sin(a)
|
|
P.append(ptube("cage", [(c * 0.178, s_ * 0.178, 2.17), (c * 0.215, s_ * 0.215, 2.3), (c * 0.215, s_ * 0.215, 2.42), (c * 0.165, s_ * 0.165, 2.53)], 0.012, "M_Navy", rs=0))
|
|
P.append(torus("cring", 0.215, 0.009, loc=(0, 0, 2.36), seg=12, rseg=3, m="M_Navy"))
|
|
gl = rev("pane", [(0.15, 2.17), (0.19, 2.3), (0.19, 2.42), (0.14, 2.53)], "M_Glass", segs=8, phase=math.pi / 8, close_top=False)
|
|
P.append(gl)
|
|
P.append(rev("hat", [(0.0, 2.51), (0.15, 2.52), (0.245, 2.52), (0.255, 2.54), (0.13, 2.62), (0.08, 2.66), (0.05, 2.67), (0.0, 2.67)], "M_Navy", segs=12))
|
|
P.append(torus("ring", 0.05, 0.012, loc=(0, 0, 2.72), axis="Y", seg=10, rseg=3, m="M_Navy"))
|
|
P.append(cy(0.022, 2.65, 2.69, "M_Brass", verts=6, name="stem"))
|
|
body = join(P, "Body")
|
|
done(body)
|
|
bulb = sphere("Bulb", 0.125, (0, 0, 2.34), seg=14, rings=9, m="M_Emissive", scale=(1, 1, 1.15))
|
|
uv_box(bulb, 1)
|
|
smooth(bulb, 80)
|
|
set_origin(bulb, (0, 0, 2.34)) # the code parents the point light to this: it now really shines from the lantern
|
|
return dict(elev=12, azim=-30)
|
|
|
|
|
|
# ======================================================================= apple tree
|
|
|
|
def half_barrel(R=0.36, H=0.5, staves=14):
|
|
P = []
|
|
prof = [(0.0, 0.0), (R * 0.82, 0.0), (R * 0.86, 0.015), (R * 0.97, 0.3 * H / 0.5), (R, H - 0.02), (R * 0.985, H), (R * 0.9, H), (R * 0.9, H - 0.08), (0.0, H - 0.08)]
|
|
b = rev("barrel", prof, "M_Timber", segs=staves * 2, close_top=False)
|
|
D.uv_cyl(b, 2, 4.0, 1.0)
|
|
b["uvok"] = 1
|
|
P.append(b)
|
|
# dark gaps between staves give it a coopered look without any extra geometry to speak of
|
|
for k in range(staves):
|
|
a = TAU * k / staves
|
|
o = rod((R * 0.87, 0, 0.02), (R * 1.004, 0, H - 0.01), 0.005, "M_Navy", verts=3)
|
|
xf(o, rot=(0, 0, math.degrees(a)))
|
|
P.append(o)
|
|
for z, rr in ((0.12, 0.905), (H - 0.1, 0.985)):
|
|
P.append(rev("hoop", [(R * rr + 0.004, z - 0.03), (R * rr + 0.012, z - 0.022), (R * rr + 0.012, z + 0.022), (R * rr + 0.004, z + 0.03)], "M_Navy", segs=staves * 2, close_top=False))
|
|
return P
|
|
|
|
|
|
def apple_tree():
|
|
UVS[0] = 1.0
|
|
rnd = random.Random(9)
|
|
P = half_barrel(0.36, 0.5, staves=10)
|
|
P.append(cy(0.33, 0.42, 0.455, "M_Soil", verts=16, name="soil"))
|
|
# trunk + three main limbs
|
|
P.append(sweep_rings("trunk", bez([(0.0, 0.02, 0.44), (0.015, 0.0, 0.72), (-0.02, 0.02, 0.95), (0.0, 0.0, 1.14)], 6), [0.075, 0.068, 0.06, 0.055, 0.048, 0.04], "M_Bark", verts=8))
|
|
for (a, b, c) in (((0.0, 0.0, 0.95), (0.18, 0.05, 1.13), (0.32, 0.1, 1.3)), ((0.0, 0.0, 1.0), (-0.2, -0.04, 1.18), (-0.34, -0.08, 1.3)), ((0.0, 0.0, 1.06), (0.03, 0.2, 1.24), (0.05, 0.3, 1.34))):
|
|
P.append(sweep_rings("limb", bez([a, b, c], 4), [0.035, 0.03, 0.024, 0.015], "M_Bark", verts=6))
|
|
# canopy of leaf clumps
|
|
L = [(0.0, 0.0, 1.5, 0.36, "M_Leaf"), (0.3, 0.1, 1.34, 0.26, "M_LeafDark"), (-0.3, -0.08, 1.36, 0.27, "M_Leaf"), (0.05, 0.3, 1.37, 0.24, "M_LeafDark"),
|
|
(-0.06, -0.3, 1.33, 0.24, "M_Leaf"), (0.2, -0.17, 1.55, 0.2, "M_LeafDark"), (-0.2, 0.2, 1.58, 0.2, "M_Leaf")]
|
|
for k, (x, y, z, r, mm) in enumerate(L):
|
|
P.append(blob(r, (x, y, z), 2.0 + k, sc=(1, 1, 0.84), m=mm, sub=2, amp=0.26))
|
|
# apples peeking out of the leaves
|
|
for k in range(10):
|
|
a = rnd.uniform(0, TAU)
|
|
z = rnd.uniform(1.17, 1.72)
|
|
rr = 0.51 * math.sqrt(max(0.05, 1 - ((z - 1.42) / 0.42) ** 2))
|
|
P += apple((math.cos(a) * rr, math.sin(a) * rr, z), 0.052, "M_PaintRed" if k % 5 else "M_PaintYellow")
|
|
# one in the soil, one on the rim
|
|
P += apple((0.16, -0.18, 0.49), 0.05)
|
|
P.append(blob(0.07, (-0.16, 0.14, 0.45), 4.0, sc=(1, 1, 0.5), m="M_Hay", sub=1))
|
|
o = join(P, "SM_Decor_Palm")
|
|
done(o, 18)
|
|
return dict(elev=14, azim=-30)
|
|
|
|
|
|
# ======================================================================= bench
|
|
|
|
def plank_bench():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
side_h, seat_z = 0.44, 0.45
|
|
for sx in (-1, 1):
|
|
x = sx * 0.78
|
|
# A-frame end: two splayed legs, cross rail, back upright, arm
|
|
P.append(beam((x, -0.3, 0.0), (x, -0.2, seat_z - 0.02), 0.09, 0.07, bevel=0.016))
|
|
P.append(beam((x, 0.3, 0.0), (x, 0.15, seat_z - 0.02), 0.09, 0.07, bevel=0.016))
|
|
P.append(pl(x - 0.045, x + 0.045, -0.3, 0.3, 0.18, 0.26, bevel=0.014))
|
|
P.append(pl(x - 0.05, x + 0.05, -0.28, 0.25, seat_z - 0.08, seat_z - 0.01, bevel=0.014))
|
|
P.append(beam((x, 0.14, seat_z - 0.05), (x, 0.28, 0.9), 0.08, 0.06, bevel=0.014))
|
|
P.append(pl(x - 0.055, x + 0.055, -0.25, 0.2, 0.66, 0.71, bevel=0.018))
|
|
P.append(log((x, -0.18, seat_z), (x, -0.18, 0.67), 0.027, verts=8))
|
|
for yy in (-0.2, 0.15):
|
|
P.append(hexbolt(x + sx * 0.052, yy, 0.22, r=0.016, h=0.012, m="M_Navy", axis="X"))
|
|
# stout seat planks, slightly bowed
|
|
for k, yy in enumerate((-0.2, -0.05, 0.1)):
|
|
p = pl(-0.92, 0.92, yy - 0.072, yy + 0.072, seat_z, seat_z + 0.055, "M_Timber", bevel=0.02, segs=1)
|
|
P.append(p)
|
|
# back boards painted barn red, top one cream
|
|
for k, (y0, z0, mm) in enumerate(((0.2, 0.62, "M_BarnRed"), (0.25, 0.8, "M_HullWhite"))):
|
|
s = pl(-0.92, 0.92, -0.026, 0.026, -0.085, 0.085, mm, bevel=0.009)
|
|
xf(s, rot=(-14, 0, 0), loc=(0, y0, z0))
|
|
P.append(s)
|
|
P.append(pl(-0.74, 0.74, -0.03, 0.04, seat_z - 0.13, seat_z - 0.04, bevel=0.015))
|
|
# gingham seat cushion + a folded burlap sack on the end
|
|
cu = softbox("cushion", (0.72, 0.42, 0.07), (-0.34, -0.05, seat_z + 0.09), r=0.03, m="M_Fabric", bulge=(0.01, 0.01, 0.02), na=2, nf=3)
|
|
P.append(cu)
|
|
uv_box(cu, 2.2)
|
|
cu["uvok"] = 1
|
|
o = join(P, "SM_Decor_Bench")
|
|
done(o)
|
|
return dict(elev=20, azim=-32)
|
|
|
|
|
|
# ======================================================================= parasol
|
|
|
|
def market_parasol():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
# timber cross foot weighed down by two sacks of feed
|
|
P.append(pl(-0.4, 0.4, -0.055, 0.055, 0.0, 0.09, bevel=0.018))
|
|
P.append(pl(-0.055, 0.055, -0.4, 0.4, 0.0, 0.092, bevel=0.018))
|
|
for (x, y) in ((0.33, 0), (-0.33, 0), (0, 0.33), (0, -0.33)):
|
|
P.append(beam((x, y, 0.08), (x * 0.12, y * 0.12, 0.5), 0.06, 0.06, bevel=0.012))
|
|
P.append(bx(-0.075, 0.075, -0.075, 0.075, 0.1, 0.24, "M_Timber", bevel=0.02, name="socket"))
|
|
P.append(bx(-0.08, 0.08, -0.08, 0.08, 0.2, 0.235, "M_Navy", bevel=0.005, segs=1, name="strap"))
|
|
P.append(blob(0.11, (0.26, 0.24, 0.1), 2.0, sc=(1, 0.85, 0.75), m="M_Burlap", sub=2))
|
|
P.append(blob(0.09, (-0.25, -0.26, 0.08), 3.0, sc=(1, 0.9, 0.7), m="M_Burlap", sub=1))
|
|
# pole: one fat log with a brass ferrule and a wooden pulley + rope cleat
|
|
top, R = 2.28, 1.05
|
|
P.append(log((0, 0, 0.1), (0, 0, top + 0.02), 0.058, verts=10, r2=0.044))
|
|
P.append(cy(0.062, 1.24, 1.3, "M_Brass", verts=10, name="ferrule"))
|
|
P.append(rev("runner", [(0.04, top - 0.47), (0.06, top - 0.46), (0.06, top - 0.38), (0.04, top - 0.37)], "M_Timber", segs=10, close_top=False))
|
|
P.append(ptube("cord", [(0.055, 0, top - 0.4), (0.08, 0, 1.3), (0.07, -0.02, 1.08)], 0.008, "M_Rope", rs=0))
|
|
P.append(torus("wrap", 0.062, 0.011, loc=(0, 0, 1.07), seg=10, rseg=3, m="M_Rope"))
|
|
# skin
|
|
can = canopy(R, top, 0.45, "M_Canvas", "M_PaintRed", panels=8, sub=4, nr=5)
|
|
can["uvok"] = 0
|
|
P.append(can)
|
|
# timber ribs + stretchers
|
|
for k in range(8):
|
|
th = TAU * k / 8
|
|
pts = []
|
|
for i in range(6):
|
|
rr = 0.05 + (R - 0.05) * i / 5
|
|
pts.append((math.cos(th) * rr, math.sin(th) * rr, top - 0.45 * (rr / R) ** 1.5 - 0.026))
|
|
P.append(ptube("rib", pts, 0.013, "M_Timber", rs=0))
|
|
P.append(sphere("tip", 0.024, (math.cos(th) * (R + 0.01), math.sin(th) * (R + 0.01), top - 0.45), seg=6, rings=4, m="M_Timber"))
|
|
rr = R * 0.5
|
|
P.append(rod((0, 0, top - 0.42), (math.cos(th) * rr, math.sin(th) * rr, top - 0.42 * 0.5 ** 1.6 - 0.03), 0.009, "M_Timber", verts=5))
|
|
P.append(cy(0.055, top - 0.02, top + 0.05, "M_Timber", verts=10, bevel=0.015, segs=1, name="hub"))
|
|
P.append(sphere("finial", 0.05, (0, 0, top + 0.1), seg=10, rings=6, m="M_PaintRed"))
|
|
o = join(P, "SM_Decor_Umbrella")
|
|
done(o, 45)
|
|
return dict(elev=20, azim=-30)
|
|
|
|
|
|
# ======================================================================= flag
|
|
|
|
def pennant_flag():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
# timber foot: cross + four braces, like the parasol's but bigger brother to the mast
|
|
P.append(pl(-0.25, 0.25, -0.06, 0.06, 0.0, 0.1, bevel=0.018))
|
|
P.append(pl(-0.06, 0.06, -0.25, 0.25, 0.0, 0.102, bevel=0.018))
|
|
for (x, y) in ((0.21, 0), (-0.21, 0), (0, 0.21), (0, -0.21)):
|
|
P.append(beam((x, y, 0.08), (x * 0.2, y * 0.2, 0.56), 0.06, 0.06, bevel=0.012))
|
|
# the pole: tapered log with iron bands
|
|
P.append(log((0, 0, 0.05), (0, 0, 4.3), 0.072, verts=10, r2=0.04))
|
|
for z, rr in ((0.58, 0.075), (2.1, 0.062)):
|
|
P.append(cy(rr, z, z + 0.06, "M_Navy", verts=10, name="band"))
|
|
P.append(cy(0.04, 4.27, 4.31, "M_Navy", verts=10, name="truck"))
|
|
P.append(sphere("finial", 0.07, (0, 0, 4.36), seg=12, rings=8, m="M_Brass"))
|
|
# rope halyard, belayed round a wooden peg
|
|
P.append(ptube("halyard", [(-0.05, 0.0, 4.28), (-0.064, 0.0, 2.6), (-0.076, 0.0, 1.16)], 0.007, "M_Rope", rs=0))
|
|
P.append(log((-0.1, 0, 1.13), (0.1, 0, 1.13), 0.016, verts=6))
|
|
for k in range(4):
|
|
P.append(torus("coil", 0.072, 0.009, loc=(0, 0, 1.08 - k * 0.018), seg=10, rseg=3, m="M_Rope"))
|
|
for z in (4.18, 3.18):
|
|
P.append(torus("ring", 0.052, 0.009, loc=(0, 0, z), seg=10, rseg=3, m="M_Navy"))
|
|
body = join(P, "Body")
|
|
done(body)
|
|
# Cloth: swallow-free farm pennant, barn red with a hay-gold stripe and a cream hoist carrying the logo
|
|
W, H, nu, nv = 1.5, 1.0, 24, 12
|
|
top = 4.2
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
G = []
|
|
for i in range(nu + 1):
|
|
u = i / nu
|
|
col = []
|
|
for j in range(nv + 1):
|
|
v = j / nv
|
|
x = 0.05 + W * u
|
|
y = 0.09 * math.sin(u * 7.0 + v * 0.8) * u ** 0.8
|
|
hh = H * (1 - 0.94 * u ** 0.9) # tapers to a point
|
|
z = (top - H / 2) + hh * (v - 0.5) - 0.06 * u * u
|
|
col.append(bm.verts.new((x, y, z)))
|
|
G.append(col)
|
|
for i in range(nu):
|
|
for j in range(nv):
|
|
f = bm.faces.new((G[i][j], G[i + 1][j], G[i + 1][j + 1], G[i][j + 1]))
|
|
uc, vc = (i + 0.5) / nu, (j + 0.5) / nv
|
|
if 1 <= i <= 6 and 3 <= j <= 8:
|
|
mi = 3
|
|
elif i <= 7:
|
|
mi = 1
|
|
elif 5 <= j <= 6:
|
|
mi = 2
|
|
else:
|
|
mi = 0
|
|
f.material_index = mi
|
|
for l, (ii, jj) in zip(f.loops, ((i, j), (i + 1, j), (i + 1, j + 1), (i, j + 1))):
|
|
if mi == 3:
|
|
l[uvl].uv = ((ii - 1) / 6, (jj - 3) / 6)
|
|
else:
|
|
l[uvl].uv = (ii / nu * 1.5, jj / nv)
|
|
cloth = mesh_obj("Cloth", bm)
|
|
add_mats(cloth, "M_PaintRed", "M_PaintWhite", "M_PaintYellow", "M_Logo")
|
|
mod(cloth, "SOLIDIFY", thickness=0.012, offset=0)
|
|
bake(cloth)
|
|
smooth(cloth, 80)
|
|
set_origin(cloth, (0, 0, top - H / 2))
|
|
return dict(elev=12, azim=-25)
|
|
|
|
|
|
# ======================================================================= crates
|
|
|
|
def apple_crate(w, d, h, m="M_Timber", apples=0, seed=1, stencil=True, ms=None, lid=False):
|
|
"""Open slatted crate with a heap of apples on top. Origin bottom centre."""
|
|
rnd = random.Random(seed)
|
|
ms = ms or m
|
|
P = []
|
|
t, pw = 0.018, 0.075
|
|
for sx in (-1, 1):
|
|
for sy in (-1, 1):
|
|
P.append(pl(sx * (w / 2 - pw / 2) - pw / 2, sx * (w / 2 - pw / 2) + pw / 2, sy * (d / 2 - pw / 2) - pw / 2, sy * (d / 2 - pw / 2) + pw / 2, 0.0, h, m, bevel=0.01))
|
|
rows = 3
|
|
sh = (h - 0.04) / rows * 0.74
|
|
for r in range(rows):
|
|
z = 0.03 + r * (h - 0.04) / rows
|
|
for sy in (-1, 1):
|
|
P.append(pl(-w / 2 + 0.01, w / 2 - 0.01, sy * (d / 2) - t, sy * (d / 2) + t, z, z + sh, ms, bevel=0.0, uv=1.0))
|
|
for sx in (-1, 1):
|
|
P.append(pl(sx * (w / 2) - t, sx * (w / 2) + t, -d / 2 + 0.01, d / 2 - 0.01, z, z + sh, ms, bevel=0.0, uv=1.0))
|
|
P.append(bx(-w / 2 + 0.02, w / 2 - 0.02, -d / 2 + 0.02, d / 2 - 0.02, 0.012, 0.03, m, bevel=0.0, name="floor"))
|
|
# a thick grip rail on each short side
|
|
for sx in (-1, 1):
|
|
P.append(pl(sx * (w / 2) + (0.012 if sx > 0 else -0.04), sx * (w / 2) + (0.04 if sx > 0 else -0.012), -d * 0.22, d * 0.22, h - 0.12, h - 0.065, "M_Timber", bevel=0.01))
|
|
if stencil:
|
|
P.append(dc("label", (0, -d / 2 - t - 0.002, h * 0.5), w * 0.36, w * 0.18, (0, -1, 0), "M_Label"))
|
|
if lid:
|
|
for k in range(4):
|
|
xa = -w / 2 + k * w / 4
|
|
P.append(pl(xa + 0.006, xa + w / 4 - 0.006, -d / 2, d / 2, h, h + 0.03, m, bevel=0.0))
|
|
if apples:
|
|
# inner bed so you see apples, not a hole
|
|
P.append(bx(-w / 2 + 0.03, w / 2 - 0.03, -d / 2 + 0.03, d / 2 - 0.03, h - 0.1, h - 0.06, "M_Hay", bevel=0.0, name="bed"))
|
|
nx, ny = 4, 3
|
|
n = 0
|
|
for i in range(nx):
|
|
for j in range(ny):
|
|
if n >= apples:
|
|
break
|
|
n += 1
|
|
x = (-0.5 + (i + 0.5) / nx) * (w - 0.14) + rnd.uniform(-0.012, 0.012)
|
|
y = (-0.5 + (j + 0.5) / ny) * (d - 0.14) + rnd.uniform(-0.012, 0.012)
|
|
P += apple((x, y, h - 0.02 + rnd.uniform(0, 0.03)), 0.062, rnd.choice(["M_PaintRed", "M_PaintRed", "M_PaintRed", "M_PaintYellow"]))
|
|
return join(P, "crate")
|
|
|
|
|
|
def apple_crates():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
c = apple_crate(0.8, 0.55, 0.44, "M_Timber", seed=1, lid=True); xf(c, loc=(-0.42, -0.25, 0), rot=(0, 0, 2)); P.append(c)
|
|
c = apple_crate(0.8, 0.55, 0.44, "M_Timber", seed=2, ms="M_BarnRed", lid=True); xf(c, loc=(0.44, -0.18, 0), rot=(0, 0, -4)); P.append(c)
|
|
c = apple_crate(0.8, 0.55, 0.44, "M_Timber", seed=3, ms="M_HullWhite", lid=True); xf(c, loc=(-0.05, 0.42, 0), rot=(0, 0, 88)); P.append(c)
|
|
c = apple_crate(0.62, 0.44, 0.34, "M_Timber", apples=12, seed=4, stencil=True); xf(c, loc=(0.0, -0.2, 0.47), rot=(0, 0, 9)); P.append(c)
|
|
# a spilled couple on the ground and a tin milk churn standing in for the old water jug
|
|
P += apple((0.52, -0.56, 0.06), 0.06)
|
|
P += apple((0.74, -0.5, 0.06), 0.06, "M_PaintYellow")
|
|
P += apple((-0.72, 0.1, 0.06), 0.06)
|
|
prof = [(0.0, 0.0), (0.15, 0.0), (0.165, 0.02), (0.165, 0.34), (0.15, 0.4), (0.09, 0.46), (0.085, 0.52), (0.11, 0.54), (0.11, 0.57), (0.0, 0.6)]
|
|
ch = rev("churn", prof, ["M_Steel"] * 5 + ["M_Tin"] * 2 + ["M_Steel"] * 2, segs=14)
|
|
ch = join([ch, torus("cring", 0.168, 0.013, loc=(0, 0, 0.17), seg=14, rseg=3, m="M_Navy"),
|
|
torus("cring", 0.168, 0.013, loc=(0, 0, 0.32), seg=14, rseg=3, m="M_Navy")], "churn")
|
|
xf(ch, scale=(1.25, 1.25, 1.35), loc=(-0.05, 0.44, 0.475))
|
|
P.append(ch)
|
|
o = join(P, "SM_Decor_Crates")
|
|
done(o)
|
|
return dict(elev=24, azim=-30)
|
|
|
|
|
|
# ======================================================================= grill
|
|
|
|
def iron_grill():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
zr = 0.86
|
|
bowl = rev("bowl", [(0, 0.54), (0.12, 0.545), (0.23, 0.58), (0.31, 0.65), (0.345, 0.75), (0.35, zr - 0.01), (0.355, zr + 0.005), (0.345, zr + 0.012),
|
|
(0.335, zr), (0.325, 0.76), (0.29, 0.67), (0.22, 0.61), (0.11, 0.58), (0, 0.575)],
|
|
["M_Navy"] * 6 + ["M_Steel"] * 2 + ["M_Charcoal"] * 5, segs=20)
|
|
P.append(bowl)
|
|
# coals
|
|
rnd = random.Random(11)
|
|
P.append(cy(0.24, 0.6, 0.64, "M_Charcoal", verts=16, name="bed"))
|
|
for k in range(9):
|
|
a = rnd.uniform(0, TAU); rr = rnd.uniform(0, 0.2)
|
|
P.append(sphere("lump", rnd.uniform(0.035, 0.05), (math.cos(a) * rr, math.sin(a) * rr, 0.65), seg=6, rings=4, m="M_Ember" if k % 3 else "M_Charcoal", scale=(1, 1, 0.7)))
|
|
# wrought grate
|
|
P.append(torus("grate", 0.315, 0.009, loc=(0, 0, 0.79), seg=20, rseg=4, m="M_Navy"))
|
|
for k in range(-5, 6):
|
|
x = k * 0.055
|
|
hw = math.sqrt(max(0.0, 0.315 ** 2 - x * x))
|
|
P.append(rod((x, -hw, 0.79), (x, hw, 0.79), 0.007, "M_Navy", verts=4))
|
|
# sausages + corn cobs from the garden
|
|
for k, (x, y) in enumerate(((-0.12, -0.12), (-0.04, -0.14), (0.04, -0.13))):
|
|
P.append(ptube("sausage", [(x, y - 0.08, 0.815), (x + 0.01, y, 0.818), (x, y + 0.08, 0.815)], 0.026, "M_Sausage", rs=2))
|
|
for (x, y) in ((0.1, 0.1), (-0.1, 0.12)):
|
|
P.append(sphere("cob", 0.038, (x, y, 0.828), seg=8, rings=6, m="M_PaintYellow", scale=(2.1, 1, 1)))
|
|
# side handles (timber grips)
|
|
for sx in (-1, 1):
|
|
P.append(rod((sx * 0.35, 0, 0.81), (sx * 0.4, 0, 0.81), 0.012, "M_Navy", verts=6))
|
|
P.append(log((sx * 0.405, -0.09, 0.81), (sx * 0.405, 0.09, 0.81), 0.022, verts=8))
|
|
# lid: enamel barn red, hinged open at the back
|
|
lid = rev("lid", [(0.0, 0.25), (0.14, 0.235), (0.26, 0.16), (0.33, 0.06), (0.355, 0.0), (0.345, -0.01), (0.29, 0.07), (0.18, 0.18), (0, 0.215)],
|
|
["M_PaintRed"] * 4 + ["M_Steel"] * 1 + ["M_Navy"] * 3, segs=20)
|
|
lp = [lid]
|
|
lp.append(log((-0.09, 0, 0.285), (0.09, 0, 0.285), 0.022, verts=8))
|
|
for sx in (-1, 1):
|
|
lp.append(bx(sx * 0.07 - 0.012, sx * 0.07 + 0.012, -0.012, 0.012, 0.24, 0.27, "M_Navy", bevel=0.004, name="lhp"))
|
|
lid = join(lp, "lid")
|
|
xf(lid, loc=(0, -0.355, 0))
|
|
xf(lid, rot=(-100, 0, 0))
|
|
xf(lid, loc=(0, 0.36, zr + 0.01))
|
|
P.append(lid)
|
|
P.append(rod((-0.1, 0.36, zr - 0.02), (0.1, 0.36, zr - 0.02), 0.012, "M_Navy", verts=8))
|
|
# three log legs, two little wagon wheels, a plank shelf
|
|
for k in range(3):
|
|
a = TAU * k / 3 - math.pi / 2
|
|
top = Vector((math.cos(a) * 0.24, math.sin(a) * 0.24, 0.6))
|
|
foot = Vector((math.cos(a) * 0.36, math.sin(a) * 0.36, 0.06 if k else 0.0))
|
|
P.append(log(foot, top, 0.03, verts=8, r2=0.024))
|
|
if k:
|
|
x, y = foot.x + math.copysign(0.035, foot.x), foot.y
|
|
P.append(cyl("wheel", 0.075, 0.04, (x, y, 0.075), axis="X", verts=12, m="M_Timber", bevel=0.01, segs=1))
|
|
P.append(torus("tyre", 0.075, 0.011, loc=(x, y, 0.075), axis="X", seg=12, rseg=3, m="M_Navy"))
|
|
P.append(hexbolt(x + math.copysign(0.024, foot.x), y, 0.075, r=0.018, h=0.008, m="M_Brass", axis="X"))
|
|
else:
|
|
P.append(cy(0.04, 0.0, 0.025, "M_Navy", x=foot.x, y=foot.y, verts=8, name="foot"))
|
|
for k in range(4):
|
|
y = -0.21 + k * 0.14
|
|
hw = 0.25 - abs(y - 0.0) * 0.5
|
|
P.append(pl(-hw, hw, y - 0.06, y + 0.06, 0.24, 0.27, bevel=0.006, name="shelf"))
|
|
# kindling on the shelf + tin ash pail
|
|
for k, (x, y) in enumerate(((-0.1, 0.05), (0.0, 0.1), (0.1, 0.03))):
|
|
P.append(log((x - 0.03, y - 0.13, 0.3), (x + 0.03, y + 0.1, 0.3), 0.03, verts=6))
|
|
# tool bar + tools hanging on the right
|
|
bar_x = 0.4
|
|
P.append(rod((bar_x, -0.1, 0.72), (bar_x, 0.1, 0.72), 0.01, "M_Navy", verts=6))
|
|
for yy in (-0.1, 0.1):
|
|
P.append(rod((bar_x - 0.05, yy, 0.74), (bar_x, yy, 0.72), 0.008, "M_Navy", verts=6))
|
|
sp = [rod((0, 0, 0), (0, 0, -0.22), 0.007, "M_Navy", verts=6)]
|
|
sp.append(bx(-0.014, 0.014, -0.018, 0.018, 0.0, 0.1, "M_Timber", bevel=0.008, segs=1, name="sh"))
|
|
sp.append(bx(-0.004, 0.004, -0.045, 0.045, -0.33, -0.22, "M_Steel", bevel=0.003, segs=1, name="blade"))
|
|
spat = join(sp, "spat"); xf(spat, loc=(bar_x + 0.015, -0.05, 0.62), rot=(0, 4, 0)); P.append(spat)
|
|
tg = [bx(-0.014, 0.014, -0.018, 0.018, 0.0, 0.08, "M_Timber", bevel=0.008, segs=1, name="th")]
|
|
for s in (-1, 1):
|
|
tg.append(rod((0, 0, 0.0), (0, s * 0.03, -0.26), 0.006, "M_Navy", verts=6))
|
|
tongs = join(tg, "tongs"); xf(tongs, loc=(bar_x + 0.015, 0.06, 0.64), rot=(0, -3, 0)); P.append(tongs)
|
|
o = join(P, "SM_Decor_Grill")
|
|
done(o, 40)
|
|
return dict(elev=26, azim=-30)
|
|
|
|
|
|
# ======================================================================= hammock
|
|
|
|
def burlap_hammock():
|
|
UVS[0] = 1.2
|
|
P = []
|
|
span = 1.6
|
|
rnd = random.Random(3)
|
|
for sx in (-1, 1):
|
|
x = sx * span
|
|
# cross feet
|
|
P.append(pl(x - 0.27, x + 0.27, -0.065, 0.065, 0.0, 0.09, bevel=0.018))
|
|
P.append(pl(x - 0.065, x + 0.065, -0.27, 0.27, 0.0, 0.092, bevel=0.018))
|
|
# post, cap, struts
|
|
P.append(pl(x - 0.075, x + 0.075, -0.075, 0.075, 0.02, 1.6, bevel=0.024, segs=2))
|
|
cp = rev("cap", [(0.0, 1.6), (0.105, 1.6), (0.105, 1.625), (0.06, 1.66), (0.0, 1.68)], "M_Timber", segs=4, phase=math.pi / 4)
|
|
xf(cp, loc=(x, 0, 0))
|
|
P.append(cp)
|
|
P.append(beam((x - sx * 0.07, 0, 0.62), (x - sx * 0.26, 0, 0.08), 0.07, 0.07, bevel=0.012))
|
|
for yy in (-0.24, 0.24):
|
|
P.append(beam((x, yy, 0.08), (x, yy * 0.2, 0.46), 0.05, 0.05, bevel=0.01))
|
|
P.append(bx(x - 0.082, x + 0.082, -0.082, 0.082, 0.3, 0.34, "M_Navy", bevel=0.006, segs=1, name="strap"))
|
|
eye = torus("eye", 0.045, 0.012, loc=(0, 0, 0), axis="Y", seg=10, rseg=4, m="M_Navy")
|
|
xf(eye, loc=(x - sx * 0.11, 0, 1.38))
|
|
P.append(eye)
|
|
# spreader bars + ropes
|
|
sb_x = 1.08
|
|
W = 0.86
|
|
for sx in (-1, 1):
|
|
x = sx * sb_x
|
|
P.append(log((x, -W / 2 - 0.05, 0.95), (x, W / 2 + 0.05, 0.95), 0.024, verts=8))
|
|
ring = Vector((sx * (span - 0.11 - 0.05), 0, 1.36))
|
|
for k in range(5):
|
|
yy = -W / 2 + W * k / 4
|
|
P.append(rod(ring, (x, yy, 0.97), 0.008, "M_Rope", verts=4))
|
|
P.append(torus("ring", 0.04, 0.011, loc=tuple(ring), axis="Y", seg=10, rseg=4, m="M_Navy"))
|
|
# the burlap bed, sewn with a barn-red edge stripe
|
|
nu, nv = 24, 9
|
|
bm = bmesh.new()
|
|
G = []
|
|
for i in range(nu + 1):
|
|
u = -1 + 2 * i / nu
|
|
col = []
|
|
for j in range(nv + 1):
|
|
v = -1 + 2 * j / nv
|
|
x = sb_x * u
|
|
w = W / 2 * (1 - 0.12 * (1 - u * u))
|
|
y = v * w
|
|
z = 0.95 - 0.42 * (1 - u * u) + 0.13 * v * v * (1 - 0.3 * u * u)
|
|
col.append(bm.verts.new((x, y, z)))
|
|
G.append(col)
|
|
stripes = [1, 0, 0, 0, 0, 0, 0, 0, 1]
|
|
for i in range(nu):
|
|
for j in range(nv):
|
|
f = bm.faces.new((G[i][j], G[i + 1][j], G[i + 1][j + 1], G[i][j + 1]))
|
|
f.material_index = stripes[j]
|
|
bed = mesh_obj("bed", bm)
|
|
add_mats(bed, "M_Burlap", "M_CushionOrange")
|
|
bm2 = bmesh.new(); bm2.from_mesh(bed.data)
|
|
for f in bm2.faces:
|
|
f.normal_update()
|
|
if sum(f.normal.z for f in bm2.faces) < 0:
|
|
for f in bm2.faces:
|
|
f.normal_flip()
|
|
bm2.to_mesh(bed.data); bm2.free()
|
|
dbl(bed, 0.014)
|
|
P.append(bed)
|
|
# gingham pillow + an abandoned straw hat
|
|
pil = softbox("pillow", (0.3, 0.5, 0.13), (0, 0, 0), r=0.05, m="M_Fabric", bulge=(0, 0, 0.03))
|
|
uv_box(pil, 2.4)
|
|
pil["uvok"] = 1
|
|
xf(pil, loc=(-0.78, 0, 0.74), rot=(0, -28, 0))
|
|
P.append(pil)
|
|
hat = rev("hat", [(0.0, 0.0), (0.2, -0.008), (0.215, 0.006), (0.1, 0.022), (0.09, 0.085), (0.0, 0.1)], "M_Straw", segs=14, close_top=False)
|
|
hat = join([hat, cy(0.095, 0.02, 0.045, "M_Twine", verts=14, name="hatband")], "hat")
|
|
xf(hat, loc=(0.28, 0.08, 0.56), rot=(4, 3, 0))
|
|
P.append(hat)
|
|
o = join(P, "SM_Decor_Hammock")
|
|
done(o, 50)
|
|
return dict(elev=22, azim=-28)
|
|
|
|
|
|
# ======================================================================= sofa
|
|
|
|
def hay_sofa():
|
|
UVS[0] = 1.5
|
|
rnd = random.Random(4)
|
|
P = []
|
|
# seat: two bales, a back of one long + two upper bales, arms stood on end
|
|
P += bale(-0.7, -0.005, -0.41, 0.13, 0.0, 0.41, rnd)
|
|
P += bale(0.005, 0.7, -0.41, 0.13, 0.0, 0.41, rnd)
|
|
P += bale(-0.93, 0.93, 0.13, 0.45, 0.0, 0.5, rnd)
|
|
P += bale(-0.9, -0.01, 0.17, 0.44, 0.5, 0.95, rnd)
|
|
P += bale(0.01, 0.9, 0.17, 0.44, 0.5, 0.95, rnd)
|
|
for sx in (-1, 1):
|
|
x0, x1 = sorted((sx * 0.7, sx * 0.93))
|
|
P += bale(x0, x1, -0.41, 0.13, 0.0, 0.63, rnd, bands="y")
|
|
# the blanket, thrown over the back and spilling across the left seat (gingham)
|
|
path = [(0.5, 0.86), (0.36, 0.97), (0.19, 0.97), (0.14, 0.82), (0.135, 0.56), (0.1, 0.45), (-0.08, 0.43), (-0.25, 0.42), (-0.38, 0.415), (-0.44, 0.3), (-0.44, 0.14)]
|
|
n = len(path)
|
|
nv = 7
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
G = []
|
|
acc = 0.0
|
|
prev = None
|
|
for i, (y, z) in enumerate(path):
|
|
if prev:
|
|
acc += math.hypot(y - prev[0], z - prev[1])
|
|
prev = (y, z)
|
|
col = []
|
|
for j in range(nv + 1):
|
|
v = j / nv
|
|
x = -0.64 + 0.62 * v + 0.05 * math.sin(i * 0.5)
|
|
zz = z + 0.012 + 0.012 * math.sin(v * 9 + i)
|
|
col.append((bm.verts.new((x, y, zz)), x, acc))
|
|
G.append(col)
|
|
for i in range(n - 1):
|
|
for j in range(nv):
|
|
f = bm.faces.new((G[i][j][0], G[i + 1][j][0], G[i + 1][j + 1][0], G[i][j + 1][0]))
|
|
for l, (ii, jj) in zip(f.loops, ((i, j), (i + 1, j), (i + 1, j + 1), (i, j + 1))):
|
|
l[uvl].uv = (G[ii][jj][1] * 2.0, G[ii][jj][2] * 2.0)
|
|
bk = mesh_obj("blanket", bm)
|
|
set_mats(bk, "M_Fabric")
|
|
bm2 = bmesh.new(); bm2.from_mesh(bk.data)
|
|
for f in bm2.faces:
|
|
f.normal_update()
|
|
if sum(f.normal.z - f.normal.y for f in bm2.faces) < 0:
|
|
for f in bm2.faces:
|
|
f.normal_flip()
|
|
bm2.to_mesh(bk.data); bm2.free()
|
|
mod(bk, "SOLIDIFY", thickness=0.018, offset=1)
|
|
bake(bk)
|
|
bk["uvok"] = 1
|
|
P.append(bk)
|
|
# burlap cushion on the right seat
|
|
pil = softbox("pillow", (0.4, 0.14, 0.38), (0, 0, 0), r=0.06, m="M_Burlap", na=2, nf=3, bulge=(0, 0.04, 0))
|
|
wobble(pil, 0.01, 9.0, seed=2.0)
|
|
xf(pil, loc=(0.42, -0.02, 0.62), rot=(-18, 6, -14))
|
|
P.append(pil)
|
|
for (x, y, z) in ((-0.68, -0.41, 0.3), (0.7, -0.41, 0.2), (0.93, -0.1, 0.4), (-0.93, -0.3, 0.45), (0.0, -0.41, 0.25), (0.55, 0.3, 0.95)):
|
|
d = Vector((math.copysign(0.3, x) if abs(x) > 0.8 else rnd.uniform(-0.3, 0.3), -0.5 if abs(x) < 0.8 and y < 0 else 0.0, 0.6 if z > 0.9 else rnd.uniform(-0.4, 0.3)))
|
|
for _ in range(3):
|
|
p0 = Vector((x, y, z)) + Vector((rnd.uniform(-0.05, 0.05), 0, rnd.uniform(-0.05, 0.05)))
|
|
P.append(rod(p0, p0 + (d + Vector((rnd.uniform(-0.3, 0.3), 0, rnd.uniform(-0.3, 0.3)))).normalized() * rnd.uniform(0.05, 0.1), 0.005, "M_Straw", verts=3))
|
|
o = join(P, "SM_Decor_Sofa")
|
|
xf(o, scale=(0.95, 0.88, 0.92), loc=(0, -0.01, 0.018))
|
|
done(o, 50)
|
|
return dict(elev=20, azim=-28)
|
|
|
|
|
|
# ======================================================================= honesty stall
|
|
|
|
def honesty_stall():
|
|
UVS[0] = 0.9
|
|
P = []
|
|
W, Dd = 1.0, 0.78
|
|
x0, x1 = -W / 2, W / 2
|
|
y0, y1 = -0.38, 0.36
|
|
# four posts on a low sill
|
|
for (x, y, h) in ((x0 + 0.05, y0 + 0.05, 1.72), (x1 - 0.05, y0 + 0.05, 1.72), (x0 + 0.05, y1 - 0.05, 1.86), (x1 - 0.05, y1 - 0.05, 1.86)):
|
|
P.append(pl(x - 0.05, x + 0.05, y - 0.05, y + 0.05, 0.0, h, bevel=0.014))
|
|
P.append(pl(x0, x1, y0, y0 + 0.08, 0.0, 0.06, bevel=0.012))
|
|
P.append(pl(x0, x1, y1 - 0.08, y1, 0.0, 0.06, bevel=0.012))
|
|
# cream board back + side panels up to the counter
|
|
for k in range(6):
|
|
xa = x0 + 0.06 + k * (W - 0.12) / 6
|
|
P.append(pl(xa, xa + (W - 0.12) / 6 - 0.006, y1 - 0.05, y1 - 0.02, 0.05, 1.8, "M_HullWhite", bevel=0.006, uv=0.9))
|
|
for sx in (-1, 1):
|
|
for k in range(4):
|
|
yy = y0 + 0.08 + k * 0.145
|
|
P.append(pl(sx * (W / 2 - 0.035) - 0.016, sx * (W / 2 - 0.035) + 0.016, yy, yy + 0.135, 0.06, 0.72, "M_HullWhite", bevel=0.006, uv=0.9))
|
|
# counter + two shelves
|
|
P.append(pl(x0 - 0.015, x1 + 0.015, y0 - 0.05, y1 - 0.02, 0.72, 0.78, bevel=0.016))
|
|
for z in (1.08, 1.4):
|
|
P.append(pl(x0 + 0.08, x1 - 0.08, y0 + 0.22, y1 - 0.05, z, z + 0.035, bevel=0.008))
|
|
|
|
def jar(x, y, z, m="M_Bottle", lid="M_Fabric", s=1.0):
|
|
j = rev("jar", [(0.0, 0.0), (0.05, 0.0), (0.056, 0.012), (0.056, 0.1), (0.04, 0.125), (0.04, 0.135), (0.0, 0.135)], m, segs=8)
|
|
c = cy(0.05, 0.125, 0.15, lid, verts=8, name="lid")
|
|
if lid == "M_Fabric":
|
|
uv_box(c, 2.5)
|
|
c["uvok"] = 1
|
|
b = cy(0.05, 0.002, 0.095, "M_PaintYellow", verts=8, name="honey")
|
|
o = join([b, j, c], "jar")
|
|
xf(o, loc=(x, y, z), scale=(s, s, s))
|
|
return o
|
|
|
|
for z, lid in ((1.115, "M_Fabric"), (1.435, "M_Timber")):
|
|
for k in range(4):
|
|
P.append(jar(-0.3 + k * 0.2, 0.13 + 0.012 * (k % 2), z, lid=lid, s=1.2))
|
|
# front of the counter: more jars, an honesty tin, an apple bowl
|
|
for k in range(2):
|
|
P.append(jar(0.14 + k * 0.17, -0.2 + 0.03 * k, 0.78, s=1.25))
|
|
box = bx(-0.31, -0.06, -0.34, -0.12, 0.78, 0.92, "M_Tin", bevel=0.012, segs=1, name="tin")
|
|
P.append(box)
|
|
P.append(bx(-0.32, -0.05, -0.35, -0.11, 0.92, 0.945, "M_Steel", bevel=0.008, segs=1, name="tinlid"))
|
|
P.append(bx(-0.24, -0.13, -0.28, -0.26, 0.942, 0.948, "M_Navy", bevel=0.0, name="slot"))
|
|
P.append(bx(-0.09, -0.04, -0.2, -0.17, 0.87, 0.91, "M_Brass", bevel=0.004, segs=1, name="hasp"))
|
|
# chalkboard hung on the front of the counter, framed in timber
|
|
bd = []
|
|
bd.append(bx(-0.42, 0.42, -0.012, 0.0, 0.0, 0.6, "M_Navy", bevel=0.0, name="board"))
|
|
bd += [pl(-0.46, 0.46, -0.03, 0.01, 0.6, 0.65), pl(-0.46, 0.46, -0.03, 0.01, -0.05, 0.0), pl(-0.46, -0.42, -0.03, 0.01, -0.02, 0.62), pl(0.42, 0.46, -0.03, 0.01, -0.02, 0.62)]
|
|
# chalk: title scribble, three price rows, a little apple
|
|
for (a, b, z) in ((-0.34, 0.34, 0.5), (-0.34, 0.06, 0.37), (0.14, 0.33, 0.37), (-0.34, 0.1, 0.27), (0.14, 0.33, 0.27), (-0.34, 0.0, 0.17), (0.14, 0.33, 0.17)):
|
|
bd.append(bx(a, b, -0.015, -0.012, z, z + (0.042 if z > 0.45 else 0.026), "M_PaintWhite", bevel=0.0, name="chalk"))
|
|
bd.append(cyl("redapple", 0.05, 0.004, (0.3, -0.014, 0.52), axis="Y", verts=10, m="M_PaintRed"))
|
|
bd.append(bx(0.299, 0.301, -0.018, -0.014, 0.56, 0.585, "M_Leaf", bevel=0.0, name="stalk"))
|
|
for o in bd:
|
|
xf(o, rot=(-5, 0, 0))
|
|
xf(o, loc=(0, y0 - 0.045, 0.08))
|
|
P += bd
|
|
# galvanised pent roof with a gingham valance
|
|
ptilt = math.degrees(math.atan2(0.2, 1.0))
|
|
rf = bx(-0.56, 0.56, -0.56, 0.56, -0.012, 0.012, "M_Tin", bevel=0.0, name="roof")
|
|
uv_box(rf, 1.5)
|
|
rf["uvok"] = 1
|
|
rfy, rfz = -0.09, 1.86
|
|
xf(rf, rot=(ptilt, 0, 0), scale=(1.0, 0.82, 1))
|
|
xf(rf, loc=(0, rfy, rfz))
|
|
P.append(rf)
|
|
for x in (x0 + 0.05, x1 - 0.05):
|
|
P.append(beam((x, y0 - 0.12, 1.72), (x, y1 + 0.02, 1.86), 0.06, 0.07, bevel=0.01))
|
|
P.append(pl(x0, x1, y0 + 0.01, y0 + 0.08, 1.67, 1.75, bevel=0.01))
|
|
P.append(pl(x0, x1, y1 - 0.08, y1 - 0.01, 1.8, 1.87, bevel=0.01))
|
|
nv = 12
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
tv = []
|
|
bv = []
|
|
for i in range(nv + 1):
|
|
x = -0.54 + 1.08 * i / nv
|
|
tv.append(bm.verts.new((x, -0.5, 1.77)))
|
|
bv.append(bm.verts.new((x, -0.5, 1.61 + (0.05 if i % 2 else 0.0))))
|
|
for i in range(nv):
|
|
f = bm.faces.new((bv[i], bv[i + 1], tv[i + 1], tv[i]))
|
|
for l, uu in zip(f.loops, ((i / nv, 0.0), ((i + 1) / nv, 0.0), ((i + 1) / nv, 0.2), (i / nv, 0.2))):
|
|
l[uvl].uv = (uu[0] * 2.4, uu[1] * 2.4)
|
|
val = mesh_obj("valance", bm)
|
|
set_mats(val, "M_Fabric")
|
|
dbl(val, 0.006)
|
|
val["uvok"] = 1
|
|
P.append(val)
|
|
o = join(P, "SM_Decor_Vending")
|
|
done(o, 40)
|
|
return dict(elev=14, azim=-28)
|
|
|
|
|
|
# ======================================================================= trough
|
|
|
|
def water_trough():
|
|
UVS[0] = 1.0
|
|
rnd = random.Random(8)
|
|
P = []
|
|
sy, yc, ht = 0.64, -0.26, 0.58 # oval stock tank: scale in Y + offset
|
|
# two timber skids
|
|
for x in (-0.55, 0.55):
|
|
P.append(pl(x - 0.07, x + 0.07, yc - 0.56, yc + 0.56, 0.0, 0.08, bevel=0.016))
|
|
prof = [(0.0, 0.07), (0.93, 0.07), (0.955, 0.1), (0.96, 0.54), (0.955, ht), (0.92, ht), (0.915, 0.54), (0.915, 0.14), (0.0, 0.14)]
|
|
tank = rev("tank", prof, ["M_Tin"] * 8, segs=28, close_top=False)
|
|
D.uv_cyl(tank, 2, 7.0, 1.0)
|
|
tank["uvok"] = 1
|
|
xf(tank, scale=(1, sy, 1), loc=(0, yc, 0))
|
|
P.append(tank)
|
|
for z, r_ in ((0.12, 0.015), (0.34, 0.012), (ht + 0.002, 0.022)):
|
|
t = torus("rib", 0.962 if z < 0.5 else 0.942, r_, loc=(0, 0, z), seg=28, rseg=4, m="M_Steel")
|
|
xf(t, scale=(1, sy, 1), loc=(0, yc, 0))
|
|
P.append(t)
|
|
# rivets along the band
|
|
# pump stand: stubby timber plinth behind the tank, a cast-iron pitcher pump on top with a spout over the rim
|
|
px, py = 0.3, 0.68
|
|
P.append(pl(px - 0.26, px + 0.26, py - 0.27, py + 0.27, 0.0, 0.1, bevel=0.018))
|
|
P.append(pl(px - 0.11, px + 0.11, py - 0.11, py + 0.11, 0.08, 0.62, bevel=0.022))
|
|
P.append(bx(px - 0.12, px + 0.12, py - 0.12, py + 0.12, 0.5, 0.54, "M_Navy", bevel=0.006, segs=1, name="strap"))
|
|
pz = 0.62
|
|
pump = rev("pump", [(0.0, 0.0), (0.135, 0.0), (0.135, 0.03), (0.075, 0.05), (0.07, 0.1), (0.095, 0.16), (0.095, 0.36), (0.1, 0.38), (0.12, 0.4), (0.12, 0.44), (0.07, 0.46), (0.05, 0.52), (0.0, 0.53)], "M_Navy", segs=12)
|
|
xf(pump, loc=(px, py, pz))
|
|
P.append(pump)
|
|
P.append(torus("bandp", 0.1, 0.012, loc=(px, py, pz + 0.3), seg=12, rseg=3, m="M_PaintRed"))
|
|
spout = ptube("spout", bez([(px, py - 0.08, pz + 0.27), (px, py - 0.28, pz + 0.27), (px, py - 0.42, pz + 0.2), (px, py - 0.46, pz + 0.1)], 7), 0.043, "M_Navy", rs=1)
|
|
P.append(spout)
|
|
P.append(rev("nozzle", [(0.05, 0.0), (0.06, 0.03), (0.05, 0.08)], "M_Brass", segs=8, loc=(px, py - 0.46, pz + 0.05), close_top=False))
|
|
# pump handle + plunger rod
|
|
P.append(log((px, py, pz + 0.48), (px, py, pz + 0.62), 0.016, "M_Steel", verts=6))
|
|
P.append(log((px + 0.06, py, pz + 0.56), (px - 0.42, py, pz + 0.66), 0.022, "M_Navy", verts=6))
|
|
P.append(log((px - 0.38, py, pz + 0.65), (px - 0.62, py, pz + 0.7), 0.03, "M_Timber", verts=8))
|
|
P.append(rod((px - 0.1, py, pz + 0.3), (px - 0.2, py, pz + 0.61), 0.016, "M_Navy", verts=6))
|
|
# tin pail hung on the plinth's corner + a wet patch of moss under the spout
|
|
pail = rev("pail", [(0.0, 0.0), (0.1, 0.0), (0.13, 0.2), (0.133, 0.22), (0.125, 0.22), (0.1, 0.03), (0.0, 0.03)], "M_Tin", segs=12)
|
|
wbar = cy(0.11, 0.14, 0.145, "M_TroughWater", verts=12, name="pw")
|
|
hdl = ptube("hdl", [(math.cos(a) * 0.132, 0.0, 0.22 + math.sin(a) * 0.14) for a in [math.pi * k / 8 for k in range(9)]], 0.006, "M_Navy", rs=0)
|
|
pl_ = join([pail, wbar, hdl], "pailj")
|
|
xf(pl_, loc=(-0.54, 0.68, 0.0), rot=(0, 0, 30))
|
|
P.append(pl_)
|
|
# apples bobbing in the water
|
|
P += apple((-0.32, -0.3, 0.495), 0.06)
|
|
P += apple((-0.08, -0.5, 0.49), 0.06, "M_PaintYellow")
|
|
o = join(P, "Body")
|
|
done(o, 40)
|
|
water = cy(0.92, 0.1, 0.48, "M_TroughWater", verts=28, name="Water")
|
|
xf(water, scale=(1, sy, 1), loc=(0, yc, 0))
|
|
smooth(water, 30)
|
|
uv_box(water, 1)
|
|
return dict(elev=30, azim=-32)
|
|
|
|
|
|
# ======================================================================= gnome
|
|
|
|
def garden_gnome():
|
|
UVS[0] = 1.0
|
|
P = []
|
|
# grassy clod
|
|
P.append(rev("base", [(0, 0), (0.2, 0), (0.215, 0.012), (0.215, 0.03), (0.2, 0.045), (0, 0.05)], ["M_Soil", "M_Soil", "M_Soil", "M_Soil", "M_LeafDark"], segs=16))
|
|
tufts = random.Random(6)
|
|
for (x, y) in ((0.16, -0.09), (-0.15, 0.1), (0.13, 0.13), (-0.17, -0.06), (-0.02, 0.17)):
|
|
P += straw((x, y, 0.04), 4, 0.03, 0.09, tufts, m="M_Leaf", rad=0.008)
|
|
for sx in (-1, 1):
|
|
P.append(sphere("boot", 0.06, (sx * 0.06, -0.04, 0.075), seg=10, rings=6, m="M_Leather", scale=(0.85, 1.35, 0.7)))
|
|
# bib-and-brace dungarees over a hay-gold smock
|
|
P.append(rev("coat", [(0.0, 0.06), (0.11, 0.06), (0.135, 0.1), (0.14, 0.16), (0.128, 0.24), (0.1, 0.3), (0.07, 0.33), (0.0, 0.34)],
|
|
["M_Teal", "M_Teal", "M_Teal", "M_Teal", "M_PaintYellow", "M_PaintYellow", "M_PaintYellow"], segs=18))
|
|
P.append(rev("belt", [(0.137, 0.115), (0.14, 0.12), (0.14, 0.14), (0.136, 0.145)], "M_Leather", segs=18, close_top=False))
|
|
P.append(bx(-0.025, 0.025, -0.15, -0.13, 0.115, 0.145, "M_Brass", bevel=0.006, name="buckle"))
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * 0.055 - 0.016, sx * 0.055 + 0.016, -0.135, -0.09, 0.16, 0.31, "M_Teal", bevel=0.006, segs=1, name="brace"))
|
|
# head
|
|
hz = 0.39
|
|
P.append(sphere("head", 0.085, (0, -0.01, hz), seg=14, rings=9, m="M_Skin"))
|
|
for sx in (-1, 1):
|
|
P.append(sphere("ear", 0.022, (sx * 0.083, 0.0, hz), seg=8, rings=6, m="M_Skin", scale=(0.6, 1, 1.2)))
|
|
P.append(sphere("cheek", 0.025, (sx * 0.045, -0.075, hz - 0.012), seg=8, rings=6, m="M_PaintRed", scale=(1, 0.5, 0.8)))
|
|
P.append(sphere("eye", 0.014, (sx * 0.032, -0.084, hz + 0.018), seg=8, rings=6, m="M_Pupil", scale=(1, 1, 1.25)))
|
|
P.append(sphere("brow", 0.022, (sx * 0.036, -0.08, hz + 0.042), seg=8, rings=5, m="M_Beard", scale=(1.3, 0.6, 0.45)))
|
|
P.append(sphere("nose", 0.034, (0, -0.105, hz - 0.008), seg=10, rings=8, m="M_Skin"))
|
|
beard = sphere("beard", 0.1, (0, 0, 0), seg=16, rings=12, m="M_Beard")
|
|
for v in beard.data.vertices:
|
|
p = v.co
|
|
t = (p.z + 0.1) / 0.2
|
|
p.x *= 0.95 + 0.25 * (1 - t)
|
|
p.y *= 0.62
|
|
p.z *= 1.05
|
|
if p.z < -0.05:
|
|
p.y -= (p.z + 0.05) * 0.6
|
|
wobble(beard, 0.01, 22.0, seed=3)
|
|
xf(beard, loc=(0, -0.07, hz - 0.11))
|
|
P.append(beard)
|
|
P.append(sphere("mous", 0.03, (0, -0.11, hz - 0.035), seg=10, rings=6, m="M_Beard", scale=(1.8, 0.7, 0.6)))
|
|
# proper floppy barn-red hat, felt band
|
|
path = bez([(0, 0, hz + 0.05), (0, 0.0, hz + 0.15), (0, 0.03, hz + 0.26), (0, 0.1, hz + 0.32)], 9)
|
|
radii = [0.102, 0.09, 0.076, 0.06, 0.047, 0.035, 0.024, 0.014, 0.004]
|
|
P.append(sweep_rings("hat", path, radii, "M_PaintRed", verts=14))
|
|
P.append(torus("brim", 0.1, 0.018, loc=(0, 0, hz + 0.055), seg=18, rseg=5, m="M_PaintRed"))
|
|
# arms: left forward holding the pail, right resting on the tummy
|
|
sh = Vector((0.11, -0.01, 0.29))
|
|
for sx in (-1, 1):
|
|
s = Vector((sx * sh.x, sh.y, sh.z))
|
|
mid, hand = ((-0.16, -0.05, 0.26), Vector((-0.15, -0.12, 0.2))) if sx < 0 else ((0.15, -0.06, 0.22), Vector((0.08, -0.13, 0.18)))
|
|
P.append(sweep_rings("arm", bez([s, mid, hand], 6), [0.035, 0.034, 0.032, 0.031, 0.03, 0.028], "M_PaintYellow", verts=8))
|
|
P.append(sphere("hand", 0.034, tuple(hand), seg=10, rings=8, m="M_Leather"))
|
|
# tiny tin pail with an apple in it
|
|
bk = [rev("pail", [(0, 0), (0.045, 0), (0.06, 0.09), (0.064, 0.095), (0.056, 0.095), (0.05, 0.03), (0, 0.03)], "M_Tin", segs=12)]
|
|
bk += apple((0, 0, 0.09), 0.04)
|
|
hpts = [(math.cos(a) * 0.062, 0.0, 0.095 + math.sin(a) * 0.07) for a in [math.pi * k / 8 for k in range(9)]]
|
|
bk.append(ptube("handle", hpts, 0.005, "M_Navy", rs=0))
|
|
b = join(bk, "pail")
|
|
xf(b, loc=(-0.15, -0.12, 0.2 - 0.165 + 0.05 - 0.03))
|
|
P.append(b)
|
|
o = join(P, "SM_Decor_Gnome")
|
|
done(o, 60)
|
|
return dict(elev=12, azim=-25)
|
|
|
|
|
|
# ======================================================================= hover harvester
|
|
|
|
def lift_fan(name, c, R=1.56, blades=6):
|
|
"""Big barn fan built flat (spins about world Z). Object keeps rotation (90,0,0) so Vehicle.cs' local-Y spin is vertical."""
|
|
F = [rev("hub", [(0.0, -0.1), (0.2, -0.09), (0.26, -0.03), (0.26, 0.05), (0.19, 0.11), (0.0, 0.13)], "M_Navy", segs=14)]
|
|
F.append(cy(0.3, -0.03, 0.02, "M_Steel", verts=14, name="flange"))
|
|
for k in range(blades):
|
|
a = k * 360 / blades
|
|
q = []
|
|
arm = beam((0.2, 0, 0), (R * 0.62, 0, 0), 0.07, 0.05, bevel=0.01)
|
|
q.append(arm)
|
|
q.append(pl(0.42, R - 0.2, -0.28, 0.28, -0.026, 0.026, "M_BarnRed" if k % 2 else "M_Timber", bevel=0.02))
|
|
q.append(pl(R - 0.21, R, -0.285, 0.285, -0.03, 0.03, "M_PaintYellow", bevel=0.02))
|
|
for o in q:
|
|
xf(o, rot=(32, 0, 0)) # pitch: steep enough to show from the side
|
|
xf(o, rot=(0, 0, a))
|
|
F += q
|
|
o = join(F, name)
|
|
done(o, 45)
|
|
keep_rot(o, (math.pi / 2, 0, 0))
|
|
o.location = c
|
|
return o
|
|
|
|
|
|
def hover_harvester():
|
|
UVS[0] = 1.0
|
|
rnd = random.Random(21)
|
|
P = []
|
|
# ---- tin skirt: a flared galvanised apron, open at the bottom, with a riveted band
|
|
Yc, A, Bb = -0.15, 2.06, 3.34
|
|
P.append(plan_band("skirt", [(A - 0.2, Bb - 0.2, Yc, 0.02), (A - 0.1, Bb - 0.1, Yc, 0.05), (A, Bb, Yc, 0.36), (A + 0.04, Bb + 0.04, Yc, 0.44), (A + 0.04, Bb + 0.04, Yc, 0.58), (A - 0.02, Bb - 0.02, Yc, 0.62),
|
|
(A - 0.1, Bb - 0.1, Yc, 0.62), (A - 0.2, Bb - 0.2, Yc, 0.5), (A - 0.22, Bb - 0.22, Yc, 0.04)],
|
|
["M_Navy", "M_Tin", "M_Steel", "M_BarnRed", "M_Steel", "M_Tin", "M_Tin", "M_Tin"], uu=16.0, vv=1.0))
|
|
# ---- ten stout timber legs lifting the body clear of the fans
|
|
for (x, y) in ((1.9, -2.7), (-1.9, -2.7), (1.96, -0.2), (-1.96, -0.2), (1.9, 2.4), (-1.9, 2.4), (0.95, -3.4), (-0.95, -3.4), (0.95, 3.1), (-0.95, 3.1)):
|
|
P.append(beam((x, y, 0.52), (x * 0.9, Yc + (y - Yc) * 0.95, 1.24), 0.13, 0.13, bevel=0.016))
|
|
# ---- tractor-green body: a square-shouldered wagon tub on a dark chassis, timber deck on top
|
|
P.append(softbox("hull", (3.46, 6.5, 0.58), (0, Yc, 1.48), r=0.12, m="M_Teal", na=2, nf=3))
|
|
P.append(bx(-1.66, 1.66, -3.3, 3.0, 1.1, 1.22, "M_Navy", bevel=0.03, segs=1, name="chassis"))
|
|
for fy in (-1.72, 1.42):
|
|
P.append(cy(0.17, 0.98, 1.14, "M_Navy", y=fy, verts=12, name="fanmast"))
|
|
for k in range(8):
|
|
y = -3.0 + k * 0.5
|
|
if y > -1.3:
|
|
break
|
|
P.append(pl(-1.5, 1.5, y - 0.235, y + 0.235, 1.75, 1.8, "M_Timber", bevel=0.01))
|
|
for k in range(3):
|
|
P.append(pl(-1.5, 1.5, 2.46 + k * 0.2, 2.64 + k * 0.2, 1.75, 1.8, "M_Timber", bevel=0.01))
|
|
for sy in (-1, 1):
|
|
P.append(pl(sy * 1.36, sy * 1.68, -1.4, 3.0, 1.75, 1.8, "M_Timber", bevel=0.01))
|
|
for sx in (-1, 1):
|
|
P.append(dc("logo", (sx * 1.737, 0.5, 1.42), 0.8, 0.4, (sx, 0, 0), "M_Logo"))
|
|
P.append(bx(sx * 1.73 - 0.012, sx * 1.73 + 0.012, -3.2, 2.9, 1.64, 1.68, "M_PaintYellow", bevel=0.0, name="pinstripe"))
|
|
for k in range(9):
|
|
P.append(hexbolt(sx * 1.735, -2.4 + k * 0.6, 1.27, r=0.02, h=0.015, m="M_Steel", axis="X"))
|
|
# ---- tractor nose: long hood, big grille, headlamps on stalks, a timber bumper
|
|
P.append(softbox("hood", (1.76, 1.12, 0.78), (0, -2.87, 2.12), r=0.2, m="M_Teal", bulge=(0.02, 0.0, 0.04), na=2, nf=3))
|
|
P.append(bx(-0.66, 0.66, -3.47, -3.4, 1.82, 2.42, "M_Navy", bevel=0.014, name="grille"))
|
|
for k in range(8):
|
|
P.append(bx(-0.62, 0.62, -3.485, -3.46, 1.85 + k * 0.07, 1.885 + k * 0.07, "M_Steel", bevel=0.0, name="slat"))
|
|
for sx in (-1, 1):
|
|
for k in range(4):
|
|
P.append(bx(sx * 0.885 - 0.01, sx * 0.885 + 0.01, -3.2 + k * 0.2, -3.08 + k * 0.2, 2.0, 2.28, "M_Navy", bevel=0.0, name="louvre"))
|
|
P.append(rod((sx * 0.8, -3.1, 2.2), (sx * 1.08, -3.3, 2.28), 0.03, "M_Navy", verts=6))
|
|
P.append(cyl("lamp", 0.15, 0.13, (sx * 1.1, -3.36, 2.3), axis="Y", verts=14, m="M_Navy"))
|
|
P.append(cyl("lens", 0.125, 0.03, (sx * 1.1, -3.43, 2.3), axis="Y", verts=14, m="M_LightAmber"))
|
|
P.append(torus("lampring", 0.13, 0.016, loc=(sx * 1.1, -3.44, 2.3), axis="Y", seg=14, rseg=4, m="M_Brass"))
|
|
P.append(pl(-1.34, 1.34, -3.58, -3.38, 1.4, 1.6, "M_Timber", bevel=0.024))
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * 0.9 - 0.06, sx * 0.9 + 0.06, -3.6, -3.3, 1.38, 1.62, "M_Navy", bevel=0.01, segs=1, name="bracket"))
|
|
# stack + rain flap
|
|
P.append(log((0.5, -3.16, 2.45), (0.5, -3.16, 3.3), 0.06, "M_Navy", verts=10))
|
|
P.append(cy(0.08, 3.26, 3.3, "M_Steel", x=0.5, y=-3.16, verts=10, name="stackcollar"))
|
|
fl = bx(-0.08, 0.08, -0.08, 0.08, 0.0, 0.012, "M_Steel", bevel=0.0, name="flap")
|
|
xf(fl, rot=(-32, 0, 0), loc=(0.5, -3.16, 3.34))
|
|
P.append(fl)
|
|
# ---- driver's station: sprung seat, wheel on a column, timber posts, curved tin roof
|
|
P.append(softbox("cseat", (0.56, 0.5, 0.12), (0, -1.95, 1.85), r=0.045, m="M_SeatVinyl", bulge=(0, 0, 0.02)))
|
|
bk = softbox("cback", (0.54, 0.1, 0.46), (0, 0, 0), r=0.04, m="M_SeatVinyl")
|
|
xf(bk, rot=(-10, 0, 0), loc=(0, -1.66, 2.14))
|
|
P.append(bk)
|
|
P.append(rod((0, -2.3, 2.0), (0, -2.26, 2.22), 0.03, "M_Navy", verts=8))
|
|
wh = torus("wheel", 0.2, 0.022, loc=(0, 0, 0), seg=18, rseg=5, m="M_Rubber")
|
|
spk = [rod((0, 0, 0), (math.cos(TAU * k / 3 + 0.5) * 0.2, math.sin(TAU * k / 3 + 0.5) * 0.2, 0), 0.012, "M_Navy", verts=5) for k in range(3)]
|
|
sw = join([wh] + spk, "sw")
|
|
xf(sw, rot=(-60, 0, 0), loc=(0, -2.25, 2.26))
|
|
P.append(sw)
|
|
for sx in (-1, 1):
|
|
P.append(beam((sx * 1.0, -2.75, 1.78), (sx * 1.0, -2.75, 3.08), 0.11, 0.11, bevel=0.016))
|
|
P.append(beam((sx * 1.0, -1.32, 1.78), (sx * 1.0, -1.32, 3.1), 0.11, 0.11, bevel=0.016))
|
|
P.append(pl(sx * 1.0 - 0.05, sx * 1.0 + 0.05, -2.85, -1.24, 3.04, 3.1, bevel=0.012))
|
|
rows = []
|
|
for i in range(9):
|
|
t = -1 + 2 * i / 8
|
|
rows.append((t * 1.16, 3.1 + 0.2 * (1 - t * t)))
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
Lr, Rr = [], []
|
|
for (x, z) in rows:
|
|
Lr.append(bm.verts.new((x, -2.98, z)))
|
|
Rr.append(bm.verts.new((x, -1.14, z)))
|
|
for i in range(8):
|
|
f = bm.faces.new((Lr[i], Lr[i + 1], Rr[i + 1], Rr[i]))
|
|
for l, (u_, v_) in zip(f.loops, ((rows[i][0], 0.0), (rows[i + 1][0], 0.0), (rows[i + 1][0], 1.84), (rows[i][0], 1.84))):
|
|
l[uvl].uv = (u_ * 1.0, v_ * 1.0)
|
|
rf = mesh_obj("roof", bm)
|
|
set_mats(rf, "M_Tin")
|
|
mod(rf, "SOLIDIFY", thickness=0.03, offset=0)
|
|
bake(rf)
|
|
rf["uvok"] = 1
|
|
P.append(rf)
|
|
# ---- the hopper: timber frame, slatted sides you can see the clippings through, tin ends
|
|
x0, x1, y0, y1, z0, z1 = -1.2, 1.2, -1.22, 2.26, 1.78, 3.42
|
|
for x in (x0, x1):
|
|
for y in (y0, (y0 + y1) / 2, y1):
|
|
P.append(pl(x - 0.075, x + 0.075, y - 0.075, y + 0.075, z0 - 0.02, z1 + 0.1, bevel=0.016))
|
|
for z in (z0 + 0.07, z1 + 0.04):
|
|
for sy in (y0, y1):
|
|
P.append(pl(x0 - 0.05, x1 + 0.05, sy - 0.05, sy + 0.05, z - 0.06, z + 0.06, "M_BarnRed", bevel=0.012))
|
|
for sx in (x0, x1):
|
|
P.append(pl(sx - 0.05, sx + 0.05, y0 - 0.05, y1 + 0.05, z - 0.06, z + 0.06, "M_BarnRed", bevel=0.012))
|
|
for k in range(5):
|
|
z = z0 + 0.24 + k * 0.28
|
|
for sx in (x0, x1):
|
|
P.append(pl(sx - 0.018, sx + 0.018, y0 + 0.06, y1 - 0.06, z, z + 0.15, "M_Timber", bevel=0.006))
|
|
for y in (y0, y1):
|
|
t = bx(x0 + 0.06, x1 - 0.06, y - 0.012, y + 0.012, z0 + 0.1, z1 - 0.02, "M_Tin", bevel=0.0, name="tinend")
|
|
uv_box(t, 1.1)
|
|
t["uvok"] = 1
|
|
P.append(t)
|
|
P.append(bx(x0 + 0.05, x1 - 0.05, y0, y1, z0 - 0.02, z0 + 0.03, "M_Navy", bevel=0.0, name="floor"))
|
|
# iron straps on the corner posts
|
|
for sx in (-1, 1):
|
|
for z in (2.26, 2.82):
|
|
P.append(bx(sx * 1.2 - 0.082, sx * 1.2 + 0.082, y1 - 0.082, y1 + 0.082, z, z + 0.05, "M_Navy", bevel=0.0, name="cstrap"))
|
|
# ---- intake: tin suction bell on a riveted pipe that climbs the left flank and spits into the hopper
|
|
P.append(rev("bell", [(0.14, 0.42), (0.16, 0.34), (0.21, 0.2), (0.3, 0.09), (0.34, 0.02), (0.345, 0.0), (0.3, 0.0), (0.24, 0.06), (0.13, 0.22)], "M_Tin", segs=16, loc=(0, -4.15, 0.0), close_top=False))
|
|
P.append(torus("ilip", 0.33, 0.028, loc=(0, -4.15, 0.02), seg=16, rseg=4, m="M_Navy"))
|
|
pipe = bez([(0, -4.15, 0.4), (0.05, -4.1, 0.95), (0.75, -3.85, 1.5), (1.45, -3.0, 2.0), (1.58, -1.6, 2.3), (1.55, -0.6, 3.1), (1.32, -0.15, 3.6), (0.95, 0.1, 3.64), (0.7, 0.1, 3.55), (0.62, 0.1, 3.38)], 24)
|
|
P.append(ptube("pipe", pipe, 0.125, "M_Tin", rs=1))
|
|
for t in range(1, 7):
|
|
p = Vector(pipe[t * 3])
|
|
d = (Vector(pipe[t * 3 + 1]) - Vector(pipe[t * 3 - 1])).normalized()
|
|
b = torus("pband", 0.13, 0.02, seg=12, rseg=3, m="M_Navy")
|
|
b.rotation_euler = d.to_track_quat("Z", "Y").to_euler()
|
|
b.location = p
|
|
P.append(apply_xform(b))
|
|
# flared spout, blowing down into the hopper
|
|
P.append(rev("spout", [(0.125, 0.0), (0.17, -0.1), (0.24, -0.2)], "M_Steel", segs=12, close_top=False, loc=(0.62, 0.1, 3.38)))
|
|
# clamp post that holds the pipe up
|
|
P.append(beam((1.56, -1.05, 1.78), (1.56, -1.05, 2.5), 0.09, 0.09, bevel=0.012))
|
|
P.append(beam((1.26, -0.28, 2.9), (1.26, -0.2, 3.52), 0.07, 0.07, bevel=0.01))
|
|
# ---- belt drive on the right flank: flywheel, pulley and a rubber belt (it reads as a contraption from the side)
|
|
fw_c, pu_c = (-1.84, -1.25, 1.62), (-1.84, 1.0, 1.42)
|
|
fw = rev("flywheel", [(0.0, -0.05), (0.18, -0.05), (0.2, -0.03), (0.42, -0.03), (0.44, -0.08), (0.5, -0.08), (0.52, -0.05), (0.52, 0.05), (0.5, 0.08), (0.44, 0.08), (0.42, 0.03), (0.2, 0.03), (0.18, 0.05), (0.0, 0.05)], "M_Navy", segs=20)
|
|
xf(fw, rot=(0, 90, 0), loc=fw_c)
|
|
P.append(fw)
|
|
pu = cyl("pulley", 0.22, 0.14, pu_c, axis="X", verts=14, m="M_Steel", bevel=0.02, segs=1)
|
|
P.append(pu)
|
|
for s_ in (-1, 1):
|
|
P.append(beam((-1.84, fw_c[1], fw_c[2] + s_ * 0.525), (-1.84, pu_c[1], pu_c[2] + s_ * 0.235), 0.09, 0.022, "M_Rubber", bevel=0.0, name="belt"))
|
|
P.append(pl(-1.82, -1.73, -1.4, 1.2, 1.3, 1.4, "M_Timber", bevel=0.012))
|
|
P.append(rod((-1.92, fw_c[1], fw_c[2]), (-1.72, fw_c[1], fw_c[2]), 0.06, "M_Steel", verts=8))
|
|
P.append(rod((-1.92, pu_c[1], pu_c[2]), (-1.72, pu_c[1], pu_c[2]), 0.05, "M_Steel", verts=8))
|
|
# ---- back end: two timber rudders with barn-red tin, a lantern, a crate of tools
|
|
for sx in (-1, 1):
|
|
P.append(pl(sx * 0.9 - 0.04, sx * 0.9 + 0.04, 3.12, 3.56, 1.0, 2.6, "M_BarnRed", bevel=0.016))
|
|
P.append(pl(sx * 0.9 - 0.05, sx * 0.9 + 0.05, 3.02, 3.14, 1.1, 2.5, bevel=0.012))
|
|
P.append(bx(sx * 0.9 - 0.045, sx * 0.9 + 0.045, 3.12, 3.58, 1.72, 1.8, "M_PaintYellow", bevel=0.0, name="rudstripe"))
|
|
P.append(pl(-1.0, 1.0, 3.0, 3.1, 1.9, 2.0, bevel=0.012))
|
|
P.append(pl(-1.0, 1.0, 3.0, 3.1, 2.3, 2.4, bevel=0.012))
|
|
# roof lantern + hook
|
|
P.append(cy(0.1, 3.28, 3.33, "M_Navy", x=0.55, y=-2.0, verts=10, name="lbase"))
|
|
P.append(cy(0.075, 3.33, 3.47, "M_LightAmber", x=0.55, y=-2.0, verts=10, name="lglow"))
|
|
P.append(rev("lhat", [(0.11, 3.47), (0.06, 3.53), (0.0, 3.55)], "M_Navy", segs=10, loc=(0.55, -2.0, 0)))
|
|
# hay sticking through the slats, for luck
|
|
P += straw((1.2, 0.5, 3.2), 8, 0.9, 0.16, rnd, rad=0.01)
|
|
body = join(P, "Body")
|
|
done(body, 40)
|
|
# ---- Fill: the clippings heap, origin at its bottom (Vehicle.cs scales local Z)
|
|
GV.fill_box("Fill", -1.12, 1.12, -1.14, 2.18, 1.82, 3.36)
|
|
# ---- the two big lift fans, front and rear, seen in the gap under the body
|
|
lift_fan("Fan_L", (0.0, -1.72, 0.9))
|
|
lift_fan("Fan_R", (0.0, 1.42, 0.9))
|
|
empty("Seat", (0.0, -1.95, 1.91))
|
|
empty("Intake", (0.0, -4.15, 0.0))
|
|
return dict(elev=22, azim=-40, dist_mul=0.82, extra=[dict(elev=4, azim=-90, dist_mul=0.8), dict(elev=18, azim=150, dist_mul=0.8)])
|
|
|
|
|
|
# ======================================================================= combine (only the roof)
|
|
|
|
def tug_tin_roof():
|
|
r = GV.combine()
|
|
swap_mat(bpy.data.objects["Body"], {"M_HullWhite": "M_Tin"})
|
|
return r
|
|
|
|
|
|
# ======================================================================= wrecks
|
|
|
|
def meadow_mound(a, b, yc, top, skirt, seed, rings=9, seg=36, ground=0.4, moss=0.1):
|
|
"""Heap of churned soil that sits the wreck in the meadow: it fades to ground level at the rim, with a skirt down to
|
|
`skirt` so a wreck on a slope never shows daylight underneath. Returns (object, height function)."""
|
|
so = Vector((seed * 1.3, seed * 2.9, seed * 0.7))
|
|
|
|
def hgt(x, y):
|
|
t = math.hypot(x / a, (y - yc) / b)
|
|
n = noise.noise(Vector((x * 0.09, y * 0.09, seed)) + so)
|
|
base = max(0.0, 1 - min(1.0, t) ** 2.2)
|
|
return ground - 0.03 + top * base * (0.8 + 0.5 * n)
|
|
|
|
bm = bmesh.new()
|
|
G = []
|
|
for i in range(1, rings + 1):
|
|
t = i / rings
|
|
row = []
|
|
for j in range(seg):
|
|
th = TAU * j / seg
|
|
x, y = a * t * math.cos(th), yc + b * t * math.sin(th)
|
|
row.append(bm.verts.new((x, y, hgt(x, y))))
|
|
G.append(row)
|
|
c = bm.verts.new((0, yc, hgt(0, yc)))
|
|
for j in range(seg):
|
|
bm.faces.new((c, G[0][j], G[0][(j + 1) % seg]))
|
|
for i in range(rings - 1):
|
|
for j in range(seg):
|
|
bm.faces.new((G[i][j], G[i + 1][j], G[i + 1][(j + 1) % seg], G[i][(j + 1) % seg]))
|
|
low = []
|
|
for j in range(seg):
|
|
v = G[-1][j].co
|
|
low.append(bm.verts.new((v.x * 1.0, v.y, skirt)))
|
|
for j in range(seg):
|
|
bm.faces.new((G[-1][j], low[j], low[(j + 1) % seg], G[-1][(j + 1) % seg]))
|
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
|
bm.normal_update()
|
|
if sum(f.normal.z for f in bm.faces) < 0:
|
|
bmesh.ops.reverse_faces(bm, faces=bm.faces)
|
|
o = mesh_obj("mound", bm)
|
|
|
|
def fn(cc, n, i):
|
|
r = math.hypot(cc.x / a, (cc.y - yc) / b)
|
|
nn = noise.noise(cc * 0.16 + so)
|
|
if r > 0.82 or nn > 0.12 - moss:
|
|
return 1
|
|
return 0
|
|
paint(o, fn, ["M_Soil", "M_Barnacle"])
|
|
return o, hgt
|
|
|
|
|
|
def rusty_wheel(hub, R, W, lugs=12, seed=1.0, ax="X"):
|
|
hw = W / 2
|
|
tyre = rev("tyre", [(R * 0.62, -hw), (R * 0.9, -hw), (R * 0.98, -hw * 0.8), (R, -hw * 0.45), (R, hw * 0.45), (R * 0.98, hw * 0.8), (R * 0.9, hw), (R * 0.62, hw)], "M_Rubber", segs=20, close_top=False)
|
|
P = [tyre]
|
|
for k in range(lugs):
|
|
a = TAU * k / lugs
|
|
for s in (-1, 1):
|
|
lug = bx(-R * 0.03, R * 0.03, -R * 0.05, R * 0.05, 0, hw * 0.92, "M_Rubber", bevel=0.0, name="lug")
|
|
xf(lug, rot=(0, 0, s * 24))
|
|
xf(lug, rot=(0, 180 if s < 0 else 0, 0))
|
|
xf(lug, loc=(R * 1.012, 0, 0))
|
|
xf(lug, rot=(0, 0, math.degrees(a)))
|
|
P.append(lug)
|
|
rim = rev("rim", [(0.0, -hw * 0.55), (R * 0.6, -hw * 0.6), (R * 0.64, -hw * 0.3), (R * 0.64, hw * 0.3), (R * 0.6, hw * 0.6), (0.0, hw * 0.55)], "M_Rust", segs=14)
|
|
weather(rim, seed, "M_PaintYellow", rust=-0.05, moss=0.1, freq=2.0)
|
|
P.append(rim)
|
|
P.append(cy(R * 0.22, -hw * 0.64, hw * 0.64, "M_Rust", verts=10, name="hub"))
|
|
o = join(P, "wheel")
|
|
if ax == "X":
|
|
xf(o, rot=(0, 90, 0))
|
|
xf(o, loc=hub)
|
|
return o
|
|
|
|
|
|
def wreck_combine():
|
|
"""Everything is modelled in 'combine units', scaled up as one at the end: 1 unit = 4.7 m in plan, 3.7 m in height."""
|
|
UVS[0] = 0.2
|
|
rnd = random.Random(42)
|
|
GREEN = "M_Teal"
|
|
P = []
|
|
# ---- thresher body
|
|
body = softbox("body", (2.05, 3.5, 1.56), (0, 0.5, 1.46), r=0.2, m=GREEN, bulge=(0.03, 0.0, 0.03), na=2, nf=8)
|
|
weather(body, 1.0, GREEN, rust=0.02, moss=-0.02, freq=0.62)
|
|
P.append(body)
|
|
P.append(bx(-1.05, 1.05, -1.15, 2.2, 0.62, 0.74, "M_Rust", bevel=0.03, segs=1, name="sill"))
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * 1.03 - 0.012, sx * 1.03 + 0.012, -1.0, 2.15, 1.04, 1.13, "M_PaintYellow", bevel=0.0, name="stripe"))
|
|
for k in range(5):
|
|
P.append(bx(sx * 1.03 - 0.016, sx * 1.03 + 0.016, 1.3 + k * 0.17, 1.42 + k * 0.17, 1.5, 2.0, "M_Rust", bevel=0.0, name="vent"))
|
|
# bolted-on side hatch hanging by one hinge
|
|
hatch = bx(-0.02, 0.02, -0.4, 0.4, -0.3, 0.3, "M_Rust", bevel=0.01, segs=1, name="hatch")
|
|
xf(hatch, rot=(9 * sx, 0, 0), loc=(sx * 1.05, 0.2, 1.48))
|
|
P.append(hatch)
|
|
P.append(rod((-1.08, -0.9, 0.9), (1.08, -0.9, 0.9), 0.17, "M_Rust", verts=10)) # drive axle
|
|
# ---- rear chopper + spreader, with hay still hanging out of it
|
|
P.append(bx(-0.78, 0.78, 2.2, 2.5, 0.75, 1.3, "M_Rust", bevel=0.04, segs=1, name="chopper"))
|
|
for k in range(4):
|
|
P.append(bx(-0.7 + k * 0.4, -0.45 + k * 0.4, 2.45, 2.56, 0.68, 0.8, "M_Rust", bevel=0.0, name="spreader"))
|
|
# ---- cab: bent pillars, one pane left, a sagging tin roof
|
|
y0, y1 = -1.6, -0.42
|
|
P.append(bx(-0.74, 0.74, y0, y1, 2.18, 2.28, "M_Rust", bevel=0.02, segs=1, name="cabfloor"))
|
|
for x in (-0.72, 0.72):
|
|
for y in (y0 + 0.04, y1 - 0.04):
|
|
top = 3.14 if not (x < 0 and y < -1) else 3.04
|
|
P.append(bx(x - 0.05, x + 0.05, y - 0.05, y + 0.05, 2.24, top, "M_Rust", bevel=0.012, segs=1, name="pillar"))
|
|
for (c, w, h, n) in (((0.0, y1, 2.68), 1.34, 0.86, (0, 1, 0)), ((0.74, (y0 + y1) / 2, 2.68), 1.06, 0.86, (1, 0, 0))):
|
|
g = dc("cabglass", c, w, h, n, "M_WindowGlass")
|
|
dbl(g, 0.006)
|
|
P.append(g)
|
|
roof = softbox("roof", (1.72, 1.42, 0.14), (0, (y0 + y1) / 2 - 0.05, 3.17), r=0.05, m="M_Tin", na=1, nf=5)
|
|
for v in roof.data.vertices:
|
|
v.co.z -= 0.14 * max(0.0, -v.co.x) * (0.3 + 0.7 * max(0.0, (-v.co.y - 0.5)))
|
|
weather(roof, 3.0, "M_Tin", rust=0.0, moss=0.0, freq=0.8)
|
|
P.append(roof)
|
|
P.append(softbox("cabseat", (0.55, 0.5, 0.13), (0, -0.85, 2.42), r=0.04, m="M_SeatVinyl", na=1, nf=2))
|
|
P.append(softbox("cabback", (0.55, 0.11, 0.52), (0, -0.6, 2.7), r=0.04, m="M_SeatVinyl", na=1, nf=2))
|
|
P.append(rod((0, -1.3, 2.28), (0, -1.2, 2.62), 0.035, "M_Rust", verts=6))
|
|
P.append(torus("cabwheel", 0.18, 0.024, loc=(0, -1.18, 2.64), seg=14, rseg=4, m="M_Rubber"))
|
|
# ladder + rail
|
|
for y in (-0.64, -0.36):
|
|
P.append(rod((1.16, y, 0.35), (1.07, y, 2.2), 0.03, "M_Rust", verts=5))
|
|
for k in range(6):
|
|
z = 0.5 + k * 0.28
|
|
P.append(rod((1.15 - k * 0.012, -0.64, z), (1.15 - k * 0.012, -0.36, z), 0.025, "M_Rust", verts=5))
|
|
P.append(ptube("handrail", [(0.8, -0.45, 2.26), (0.82, -0.45, 2.72), (1.13, -0.52, 2.62)], 0.028, "M_PaintYellow", rs=0))
|
|
# ---- grain tank: walls, gone to moss and a sapling
|
|
T = (-0.88, 0.88, -0.3, 1.55, 2.2, 3.0)
|
|
for (a, b, c, d) in ((T[0], T[1], T[2] - 0.08, T[2]), (T[0], T[1], T[3], T[3] + 0.08), (T[0] - 0.08, T[0], T[2], T[3]), (T[1], T[1] + 0.08, T[2], T[3])):
|
|
w = softbox("tankwall", (b - a, d - c, T[5] - T[4]), ((a + b) / 2, (c + d) / 2, (T[4] + T[5]) / 2), r=0.02, m=GREEN, na=1, nf=4)
|
|
weather(w, 4.0 + a + c, GREEN, rust=0.0, moss=-0.3, freq=0.8)
|
|
P.append(w)
|
|
P.append(bx(T[0], T[1], T[2], T[3], T[4] - 0.05, T[5] - 0.18, "M_Soil", bevel=0.0, name="tankfill"))
|
|
for (a, b, c, d) in ((T[0] - 0.1, T[1] + 0.1, T[2] - 0.1, T[2] - 0.03), (T[0] - 0.1, T[1] + 0.1, T[3] + 0.03, T[3] + 0.1)):
|
|
P.append(bx(a, b, c, d, T[5] - 0.02, T[5] + 0.05, "M_PaintYellow", bevel=0.01, segs=1, name="tankrim"))
|
|
# ---- feeder + header (the nose that dug in)
|
|
feeder = softbox("feeder", (1.2, 1.05, 0.9), (0, -1.475, 0.85), r=0.06, m=GREEN, na=1, nf=4)
|
|
weather(feeder, 5.0, GREEN, rust=0.0, moss=0.0, freq=0.8)
|
|
P.append(feeder)
|
|
HX = 1.78
|
|
P.append(bx(-HX, HX, -2.65, -1.9, 0.12, 0.22, "M_Rust", bevel=0.02, segs=1, name="headerfloor"))
|
|
hb = softbox("headerback", (2 * HX, 0.12, 0.83), (0, -1.94, 0.535), r=0.02, m="M_PaintYellow", na=1, nf=6)
|
|
weather(hb, 6.0, "M_PaintYellow", rust=0.05, moss=-0.1, freq=0.9)
|
|
P.append(hb)
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * HX - 0.07, sx * HX + 0.07, -2.65, -1.88, 0.1, 0.9, "M_PaintYellow", bevel=0.02, segs=1, name="headerside"))
|
|
d_ = cyl("divider", 0.16, 0.75, (0, 0, 0), axis="Y", verts=8, m="M_PaintYellow", r2=0.01)
|
|
xf(d_, rot=(-8, 0, 0), loc=(sx * HX, -3.0, 0.22))
|
|
P.append(d_)
|
|
P.append(rod((sx * (HX - 0.1), -1.95, 0.92), (sx * (HX - 0.1), -2.35, 1.42), 0.05, "M_Rust", verts=6))
|
|
P.append(rod((-HX + 0.1, -2.1, 0.38), (HX - 0.1, -2.1, 0.38), 0.17, "M_Rust", verts=10))
|
|
for k in range(9):
|
|
x = -HX + 0.2 + k * 0.42
|
|
a0 = k * 0.9
|
|
pts = [(x - 0.17, -2.1 + 0.19 * math.cos(a0), 0.38 + 0.19 * math.sin(a0)), (x, -2.1 + 0.2 * math.cos(a0 + 1.4), 0.38 + 0.2 * math.sin(a0 + 1.4)),
|
|
(x + 0.17, -2.1 + 0.19 * math.cos(a0 + 2.8), 0.38 + 0.19 * math.sin(a0 + 2.8))]
|
|
P.append(ptube("flight", pts, 0.03, "M_Rust", rs=0))
|
|
# the reel, one bat hanging loose
|
|
Rc, Rr, Rh = Vector((0, -2.42, 1.26)), 0.5, HX - 0.2
|
|
Zk = 4.7 / 3.7 # keeps the reel round once the whole machine is squashed in Z
|
|
for x in (-Rh, -Rh / 3, Rh / 3, Rh):
|
|
t = torus("spider", Rr, 0.05, axis="X", seg=14, rseg=4, m="M_PaintOrange")
|
|
xf(t, scale=(1, 1, Zk), loc=(x, Rc.y, Rc.z))
|
|
P.append(t)
|
|
for k in range(6):
|
|
a = TAU * k / 6 + 0.3
|
|
P.append(rod((x, Rc.y, Rc.z), (x, Rc.y + math.cos(a) * Rr, Rc.z + math.sin(a) * Rr * Zk), 0.024, "M_Rust", verts=5))
|
|
for k in range(6):
|
|
a = TAU * k / 6 + 0.3
|
|
p0 = Vector((-Rh, Rc.y + math.cos(a) * Rr, Rc.z + math.sin(a) * Rr * Zk))
|
|
p1 = Vector((Rh, Rc.y + math.cos(a) * Rr, Rc.z + math.sin(a) * Rr * Zk))
|
|
if k == 4:
|
|
p1 = p1 + Vector((-0.2, 0.2, -0.65))
|
|
P.append(rod(p0, p1, 0.035, "M_Rust", verts=5))
|
|
P.append(cyl("shaft", 0.06, 2 * Rh + 0.2, tuple(Rc), axis="X", verts=8, m="M_Rust"))
|
|
# ---- bent stack + air cleaner
|
|
P.append(ptube("stack", bez([(-0.62, 1.9, 2.2), (-0.62, 1.9, 2.9), (-0.72, 2.0, 3.25), (-0.95, 2.2, 3.3)], 7), 0.075, "M_Rust", rs=1))
|
|
P.append(cy(0.28, 2.2, 2.44, "M_Rust", x=0.5, y=1.85, verts=12, name="aircleaner"))
|
|
# ---- unloading auger: swung out and up, the first thing you see from afar
|
|
A0, A1, A2 = Vector((0.9, 1.25, 2.42)), Vector((1.38, 0.98, 2.86)), Vector((2.02, -1.75, 3.28))
|
|
P.append(rod(A0, A1, 0.17, GREEN, verts=10))
|
|
tube_ = rod(A1, A2, 0.14, GREEN, verts=10)
|
|
bm_ = bmesh.new(); bm_.from_mesh(tube_.data)
|
|
bmesh.ops.subdivide_edges(bm_, edges=[e for e in bm_.edges if (e.verts[0].co - e.verts[1].co).length > 0.5], cuts=8)
|
|
bm_.to_mesh(tube_.data); bm_.free()
|
|
weather(tube_, 7.0, GREEN, rust=0.02, moss=-0.1, freq=0.9)
|
|
P.append(tube_)
|
|
P.append(rod(A2, A2 + Vector((0.0, -0.18, -0.34)), 0.12, "M_Rust", verts=8))
|
|
for t in (0.25, 0.5, 0.75, 1.0):
|
|
b = torus("band", 0.15, 0.022, axis="Y", seg=10, rseg=3, m="M_PaintYellow")
|
|
b.rotation_euler = (A2 - A1).to_track_quat("Y", "Z").to_euler()
|
|
b.location = A1.lerp(A2, t)
|
|
P.append(apply_xform(b))
|
|
P.append(rod((0.86, 1.3, 2.3), (0.98, 0.1, 2.72), 0.04, "M_Rust", verts=5))
|
|
machine = join(P, "machine")
|
|
# ---- scale up; wheels are added after the squash so they stay round
|
|
xf(machine, scale=(4.7, 4.7, 3.7))
|
|
UVS[0] = 0.22
|
|
wheels = [rusty_wheel((5.6, -4.2, 3.2), 3.75, 3.1, lugs=11, seed=1.0), rusty_wheel((-5.6, -4.2, 3.2), 3.75, 3.1, lugs=11, seed=2.0),
|
|
rusty_wheel((4.7, 8.2, 1.9), 2.3, 1.8, lugs=9, seed=3.0), rusty_wheel((-4.7, 8.2, 1.9), 2.3, 1.8, lugs=9, seed=4.0)]
|
|
machine = join([machine] + wheels, "machine")
|
|
# ---- dip the nose, list to one side and sink it
|
|
xf(machine, rot=(5.5, -7.0, 4.0))
|
|
xf(machine, loc=(0.0, 0.8, -1.7))
|
|
# ---- soil heap, debris
|
|
mound, hgt = meadow_mound(9.75, 16.1, 0.5, 1.45, -2.45, 3.0)
|
|
uv_box(mound, 0.2)
|
|
mound["uvok"] = 1
|
|
deb = []
|
|
# a torn-off tyre half sunk behind the machine, a rolled bale gone mouldy, tin panels
|
|
tyre = rusty_wheel((0, 0, 0), 2.3, 1.6, lugs=10, seed=5.0, ax="N")
|
|
xf(tyre, rot=(26, 10, 30), loc=(7.1, 11.2, hgt(7.1, 11.2) + 0.5))
|
|
deb.append(tyre)
|
|
for (x, y, r_, seed) in ((-7.6, 9.0, 1.15, 1.0), (-8.0, 11.2, 1.0, 2.0), (6.9, -7.8, 1.25, 3.0)):
|
|
b = cyl("oldbale", r_, 1.9, (0, 0, 0), axis="X", verts=14, m="M_Hay", bevel=0.14, segs=1)
|
|
wobble(b, 0.06, 2.0, seed=seed)
|
|
weather(b, seed + 8.0, "M_Hay", rust=9.0, moss=0.5, freq=0.6)
|
|
xf(b, rot=(0, 0, rnd.uniform(-40, 40)), loc=(x, y, hgt(x, y) + r_ * 0.55))
|
|
deb.append(b)
|
|
for k in range(6):
|
|
a = rnd.uniform(0, TAU)
|
|
rr = rnd.uniform(0.62, 0.9)
|
|
x, y = math.cos(a) * 9.75 * rr, 0.5 + math.sin(a) * 16.1 * rr
|
|
pl_ = bx(-1.7, 1.7, -1.1, 1.1, -0.05, 0.05, rnd.choice(("M_Rust", "M_Tin", "M_Rust")), bevel=0.0, name="plate")
|
|
bm_ = bmesh.new(); bm_.from_mesh(pl_.data)
|
|
bmesh.ops.subdivide_edges(bm_, edges=bm_.edges, cuts=3, use_grid_fill=True)
|
|
for v in bm_.verts:
|
|
v.co.z += 0.22 * math.sin(v.co.x * 1.6 + k) * math.cos(v.co.y * 1.2)
|
|
bm_.to_mesh(pl_.data); bm_.free()
|
|
xf(pl_, rot=(rnd.uniform(-14, 14), rnd.uniform(-14, 14), rnd.uniform(0, 360)), loc=(x, y, hgt(x, y) + 0.1))
|
|
deb.append(pl_)
|
|
o = join([machine, mound] + deb, "SM_Wreck_Ship")
|
|
# ---- moss, ivy and weeds: rays down onto whatever faces up, drapes off the side panels
|
|
bvh = bvh_of(o)
|
|
UVS[0] = 0.5
|
|
deco = []
|
|
for k in range(70):
|
|
x = rnd.uniform(-9.0, 9.0)
|
|
y = rnd.uniform(-14.0, 12.5)
|
|
hit = bvh.ray_cast(Vector((x, y, 40)), Vector((0, 0, -1)))
|
|
if hit[0] is None or hit[0].z < 1.2 or hit[1].z < 0.55:
|
|
continue
|
|
r_ = rnd.uniform(0.5, 1.2)
|
|
deco.append(blob(r_, hit[0], rnd.uniform(1, 9), sc=(1.25, 1.05, 0.42), m=rnd.choice(("M_Barnacle", "M_Barnacle", "M_LeafDark")), sub=2 if r_ > 0.8 else 1, amp=0.3))
|
|
for k in range(15):
|
|
side = rnd.choice((-1, 1))
|
|
y = rnd.uniform(-5.5, 12.0)
|
|
z = rnd.uniform(3.8, 6.2)
|
|
hit = bvh.ray_cast(Vector((side * 30, y, z)), Vector((-side, 0, 0)))
|
|
if hit[0] is None:
|
|
continue
|
|
top = hit[0]
|
|
ln = rnd.uniform(1.8, 4.2)
|
|
ph = rnd.uniform(0, TAU)
|
|
bm = bmesh.new()
|
|
Lv, Rv = [], []
|
|
for i in range(7):
|
|
t = i / 6
|
|
p = top + Vector((side * (0.12 + 0.18 * t), 0.35 * math.sin(ph + t * 5), -ln * t))
|
|
hw = 0.42 * (1 - 0.55 * t)
|
|
Lv.append(bm.verts.new(p - Vector((0, hw, 0))))
|
|
Rv.append(bm.verts.new(p + Vector((0, hw, 0))))
|
|
for i in range(6):
|
|
bm.faces.new((Lv[i], Rv[i], Rv[i + 1], Lv[i + 1]))
|
|
wd = mesh_obj("ivy", bm)
|
|
set_mats(wd, rnd.choice(("M_LeafDark", "M_Barnacle")))
|
|
dbl(wd, 0.02)
|
|
deco.append(wd)
|
|
# sapling growing out of the grain tank + weed tufts all over the heap
|
|
tank_c = Vector((0.0, 3.0, 8.4))
|
|
hit = bvh.ray_cast(tank_c + Vector((0, 0, 20)), Vector((0, 0, -1)))
|
|
base = hit[0] if hit[0] is not None else tank_c
|
|
deco.append(sweep_rings("sapling", bez([base - Vector((0, 0, 0.3)), base + Vector((0.4, 0.1, 1.2)), base + Vector((0.15, 0.4, 2.2))], 5), [0.34, 0.28, 0.22, 0.16, 0.08], "M_Bark", verts=6))
|
|
for (dx, dy, dz, r_, mm) in ((0.15, 0.4, 2.3, 1.3, "M_Leaf"), (1.15, 0.2, 1.75, 0.95, "M_LeafDark"), (-0.9, 0.7, 1.8, 1.0, "M_LeafDark")):
|
|
deco.append(blob(r_, base + Vector((dx, dy, dz)), 3.0 + dx, sc=(1, 1, 0.8), m=mm, sub=2, amp=0.28))
|
|
for k in range(60):
|
|
a = rnd.uniform(0, TAU)
|
|
rr = rnd.uniform(0.25, 0.97)
|
|
x, y = math.cos(a) * 9.75 * rr, 0.5 + math.sin(a) * 16.1 * rr
|
|
hit = bvh.ray_cast(Vector((x, y, 40)), Vector((0, 0, -1)))
|
|
if hit[0] is None or hit[0].z > 3.2:
|
|
continue
|
|
deco += straw(hit[0], 4, 0.3, rnd.uniform(0.9, 1.7), rnd, m=rnd.choice(("M_Leaf", "M_LeafDark", "M_Barnacle", "M_Straw")), rad=0.09)
|
|
o = join([o] + deco, "SM_Wreck_Ship")
|
|
done(o, 40)
|
|
return dict(elev=20, azim=-50, dist_mul=0.8, ground=0.4, extra=[dict(elev=16, azim=125, dist_mul=0.8), dict(elev=4, azim=-20, dist_mul=0.72)])
|
|
|
|
|
|
def wreck_biplane():
|
|
"""A crop-duster that didn't pull up. Built level (nose -Y), then pitched into the ground with one wing folded under it."""
|
|
UVS[0] = 0.7
|
|
rnd = random.Random(5)
|
|
P = []
|
|
# ---- fuselage: fabric-and-tin body tapering to the tail
|
|
Fp = [(0, -1.9, 0.0), (0, -1.5, 0.03), (0, -0.8, 0.06), (0, 0.0, 0.08), (0, 0.9, 0.12), (0, 1.8, 0.18), (0, 2.6, 0.26), (0, 3.05, 0.3)]
|
|
Fr = [(0.5, 0.5), (0.54, 0.54), (0.54, 0.6), (0.5, 0.56), (0.42, 0.44), (0.3, 0.33), (0.17, 0.2), (0.07, 0.09)]
|
|
fus = sweep_rings("fuselage", Fp, Fr, "M_PaintRed", verts=14)
|
|
weather(fus, 2.0, "M_PaintRed", rust=0.12, moss=-0.1, freq=0.8)
|
|
P.append(fus)
|
|
# cream stripe down the flank
|
|
for s in (-1, 1):
|
|
for k in range(6):
|
|
y0_, y1_ = -1.3 + k * 0.6, -0.72 + k * 0.6
|
|
r0 = 0.54 - 0.038 * max(0, k - 1)
|
|
P.append(bx(s * (r0 - 0.03) - 0.015, s * (r0 - 0.03) + 0.015, y0_, y1_, 0.08, 0.17, "M_PaintWhite", bevel=0.0, name="stripe"))
|
|
# tin engine cowl + radial cylinders + bent prop
|
|
P.append(rev("cowl", [(0.5, 0.0), (0.56, 0.05), (0.58, 0.2), (0.56, 0.36), (0.42, 0.42), (0.38, 0.38)], "M_Tin", segs=16, close_top=False))
|
|
xf(P[-1], rot=(90, 0, 0), loc=(0, -1.72, 0.0))
|
|
P.append(cyl("crank", 0.26, 0.3, (0, -2.14, 0), axis="Y", verts=12, m="M_Navy"))
|
|
for k in range(7):
|
|
a = TAU * k / 7
|
|
c = cyl("cyl", 0.08, 0.3, (0.42, -1.96, 0), axis="X", verts=6, m="M_Rust")
|
|
xf(c, rot=(0, -math.degrees(a), 0))
|
|
P.append(c)
|
|
P.append(sphere("spinner", 0.13, (0, -2.34, 0), seg=8, rings=5, m="M_Navy"))
|
|
pr = []
|
|
pr.append(beam((0, 0, 0.0), (0, 0, 0.95), 0.14, 0.05, bevel=0.016))
|
|
bl = beam((0, 0, 0.0), (0, 0, -0.42), 0.14, 0.05, bevel=0.016) # snapped blade
|
|
pr.append(bl)
|
|
sp_ = join(pr, "prop")
|
|
xf(sp_, rot=(0, 24, 0), loc=(0, -2.38, 0))
|
|
P.append(sp_)
|
|
# ---- cockpit, hopper
|
|
P.append(torus("coaming", 0.34, 0.05, loc=(0, 0.25, 0.63), seg=14, rseg=4, m="M_Leather"))
|
|
xf(P[-1], scale=(1, 1.25, 1))
|
|
P.append(cy(0.33, 0.56, 0.64, "M_Navy", y=0.25, verts=10, name="well"))
|
|
P.append(softbox("headrest", (0.2, 0.32, 0.26), (0, 0.72, 0.6), r=0.06, m="M_Leather", na=1, nf=2))
|
|
P.append(rod((0, 0.05, 0.62), (0, 0.05, 0.86), 0.016, "M_Navy", verts=5))
|
|
scr = dc("screen", (0, -0.2, 0.78), 0.4, 0.26, (0, -1, 0.6), "M_WindowGlass")
|
|
dbl(scr, 0.006)
|
|
P.append(scr)
|
|
# dust hopper: a riveted tin box ahead of the cockpit (that's the crop-duster bit)
|
|
P.append(bx(-0.4, 0.4, -1.2, -0.38, 0.4, 0.86, "M_Tin", bevel=0.05, segs=1, name="hopper"))
|
|
P.append(bx(-0.28, 0.28, -1.05, -0.5, 0.86, 0.92, "M_BarnRed", bevel=0.02, segs=1, name="hopperlid"))
|
|
# ---- wings: upper = one long plank of fabric, snapped on the left; lower = right side folded up
|
|
def wing(x0, x1, ch, th, z, seed, ym=0.0):
|
|
w = softbox("wing", (x1 - x0, ch, th), ((x0 + x1) / 2, ym, z), r=th * 0.46, m="M_PaintYellow", bulge=(0, 0, th * 0.25), na=2, nf=5)
|
|
weather(w, seed, "M_PaintYellow", rust=0.22, moss=-0.12, freq=0.8)
|
|
return w
|
|
|
|
def tip(x, ch, th, z, sx, m="M_PaintRed", ym=0.0):
|
|
return softbox("wtip", (0.34, ch * 1.01, th * 1.06), (x, ym, z), r=th * 0.46, m=m, bulge=(0, 0, th * 0.25), na=1, nf=2)
|
|
|
|
# upper wing
|
|
P.append(wing(-1.9, 3.5, 1.2, 0.19, 1.28, 3.0, -0.1))
|
|
P.append(tip(3.36, 1.2, 0.19, 1.28, 1, ym=-0.1))
|
|
# lower wing, right half + the stump of the left half
|
|
P.append(wing(-1.3, 3.4, 1.16, 0.17, -0.42, 4.0, -0.1))
|
|
P.append(tip(3.26, 1.16, 0.17, -0.42, 1, ym=-0.1))
|
|
# torn part of the left upper wing, folded and hanging: open ribs
|
|
W = []
|
|
W.append(log((0, -0.42, 0), (1.6, -0.42, 0), 0.04, verts=6))
|
|
W.append(log((0, 0.3, 0), (1.6, 0.3, 0), 0.04, verts=6))
|
|
for k in range(6):
|
|
x = 0.1 + k * 0.29
|
|
W.append(beam((x, -0.68, 0.0), (x, 0.52, 0.0), 0.04, 0.09, bevel=0.0))
|
|
cv = dc("rag", (1.2, -0.05, 0.03), 0.85, 1.2, (0, 0, 1), "M_PaintYellow")
|
|
dbl(cv, 0.01)
|
|
W.append(cv)
|
|
tp = tip(1.5, 1.2, 0.19, 0.0, -1)
|
|
W.append(tp)
|
|
wj = join(W, "brokenwing")
|
|
xf(wj, rot=(0, 118, 0)) # hinged down at the root
|
|
xf(wj, rot=(0, 0, 0), loc=(-1.9, -0.1, 1.28))
|
|
P.append(wj)
|
|
# interplane struts + bracing wires
|
|
for x in (-1.5, -0.62, 0.62, 1.7, 2.8):
|
|
for yy in (-0.42, 0.25):
|
|
P.append(beam((x, yy, -0.36), (x + 0.04, yy, 1.22), 0.06, 0.09, bevel=0.012))
|
|
for (a, b) in (((-0.62, -0.42, -0.36), (1.7, -0.42, 1.2)), ((0.62, -0.42, -0.36), (2.8, -0.42, 1.2)), ((0.62, 0.25, 1.2), (2.8, 0.25, -0.36))):
|
|
P.append(rod(a, b, 0.012, "M_Steel", verts=4))
|
|
# ---- tail
|
|
fin = slab("fin", fillet2d([(2.2, 0.28), (3.1, 0.3), (3.28, 0.42), (3.22, 1.08), (2.98, 1.16), (2.72, 0.92)], 0.05, n=2), -0.055, 0.055, "M_PaintRed", plane="YZ", bevel=0.018, segs=1)
|
|
P.append(fin)
|
|
P.append(bx(-0.06, 0.06, 3.1, 3.2, 0.62, 0.94, "M_PaintWhite", bevel=0.0, name="fin_band"))
|
|
tp_ = slab("tailplane", fillet2d([(-1.32, 2.45), (1.32, 2.45), (1.42, 2.72), (1.2, 3.08), (-1.2, 3.08), (-1.42, 2.72)], 0.08, n=2), 0.24, 0.3, "M_PaintYellow", plane="XY", bevel=0.018, segs=1)
|
|
xf(tp_, rot=(0, 7, 0), loc=(0.0, 0.0, 0.05))
|
|
P.append(tp_)
|
|
# ---- undercarriage: one wheel still on, the other leg folded back
|
|
P.append(beam((0.42, -0.5, -0.4), (0.82, -0.75, -1.2), 0.08, 0.05, bevel=0.01))
|
|
P.append(beam((0.42, 0.2, -0.45), (0.82, -0.75, -1.2), 0.07, 0.05, bevel=0.01))
|
|
P.append(rod((-0.82, -0.75, -1.2), (0.92, -0.75, -1.2), 0.03, "M_Navy", verts=6))
|
|
wl = rusty_wheel((0.98, -0.75, -1.2), 0.34, 0.16, lugs=0, seed=7.0)
|
|
P.append(wl)
|
|
# ---- spray/dust bar under the lower wing
|
|
P.append(rod((-1.25, 0.34, -0.56), (3.1, 0.34, -0.56), 0.03, "M_Steel", verts=6))
|
|
for k in range(6):
|
|
x = -0.9 + k * 0.72
|
|
P.append(cyl("nozzle", 0.05, 0.1, (x, 0.34, -0.63), verts=6, m="M_Brass", r2=0.02))
|
|
plane = join(P, "plane")
|
|
# ---- crash pose
|
|
xf(plane, rot=(34, -9, 14))
|
|
xf(plane, loc=(0.1, 0.2, 1.42))
|
|
# ---- soil heap thrown up around the nose, one scar, one wheel lying off to the side, torn fabric, a hay bale it hit
|
|
mound, hgt = meadow_mound(3.54, 3.06, 0.0, 0.62, -0.42, 5.0, rings=7, seg=28)
|
|
uv_box(mound, 0.5)
|
|
mound["uvok"] = 1
|
|
deco = []
|
|
wh = rusty_wheel((0, 0, 0), 0.34, 0.16, lugs=0, seed=8.0, ax="N")
|
|
xf(wh, rot=(84, 0, 24), loc=(-2.3, -1.45, hgt(-2.3, -1.45) + 0.14))
|
|
deco.append(wh)
|
|
# a dislodged bale
|
|
b = cyl("bale", 0.46, 0.8, (0, 0, 0), axis="X", verts=12, m="M_Hay", bevel=0.05, segs=1)
|
|
wobble(b, 0.03, 3.0, seed=2.0)
|
|
xf(b, rot=(0, 0, 36), loc=(2.35, -1.95, hgt(2.35, -1.95) + 0.28))
|
|
deco.append(b)
|
|
deco += straw((2.35, -1.95, hgt(2.35, -1.95) + 0.2), 14, 0.55, 0.32, rnd, rad=0.018, m="M_Straw")
|
|
o = join([plane, mound] + deco, "SM_Wreck_Probe")
|
|
bvh = bvh_of(o)
|
|
deco = []
|
|
for k in range(28):
|
|
x, y = rnd.uniform(-3.4, 3.4), rnd.uniform(-2.9, 2.9)
|
|
hit = bvh.ray_cast(Vector((x, y, 14)), Vector((0, 0, -1)))
|
|
if hit[0] is None or hit[1].z < 0.5:
|
|
continue
|
|
deco.append(blob(rnd.uniform(0.12, 0.3), hit[0], rnd.uniform(1, 9), sc=(1.25, 1.05, 0.42), m="M_Barnacle", sub=1, amp=0.3))
|
|
for k in range(34):
|
|
a = rnd.uniform(0, TAU)
|
|
rr = rnd.uniform(0.3, 0.96)
|
|
x, y = math.cos(a) * 3.54 * rr, math.sin(a) * 3.06 * rr
|
|
hit = bvh.ray_cast(Vector((x, y, 14)), Vector((0, 0, -1)))
|
|
if hit[0] is None or hit[0].z > 1.2:
|
|
continue
|
|
deco += straw(hit[0], 3, 0.12, rnd.uniform(0.3, 0.6), rnd, m=rnd.choice(("M_Leaf", "M_LeafDark", "M_Barnacle")), rad=0.03)
|
|
o = join([o] + deco, "SM_Wreck_Probe")
|
|
done(o, 40)
|
|
return dict(elev=20, azim=-35, dist_mul=0.85, ground=0.4, extra=[dict(elev=14, azim=140, dist_mul=0.85)])
|
|
|
|
|
|
# ======================================================================= runner
|
|
|
|
BUILDERS = {
|
|
"SM_Buoy": survey_stake,
|
|
"SM_Decor_Beacon": windmill,
|
|
"SM_Decor_Dish": weather_vane,
|
|
"SM_Decor_Lamp": timber_lamp,
|
|
"SM_Decor_Palm": apple_tree,
|
|
"SM_Decor_Bench": plank_bench,
|
|
"SM_Decor_Umbrella": market_parasol,
|
|
"SM_Decor_Flag": pennant_flag,
|
|
"SM_Decor_Crates": apple_crates,
|
|
"SM_Decor_Grill": iron_grill,
|
|
"SM_Decor_Hammock": burlap_hammock,
|
|
"SM_Decor_Sofa": hay_sofa,
|
|
"SM_Decor_Vending": honesty_stall,
|
|
"SM_Decor_Pool": water_trough,
|
|
"SM_Decor_Gnome": garden_gnome,
|
|
"SM_HoverTanker": hover_harvester,
|
|
"SM_TugPump": tug_tin_roof,
|
|
"SM_Wreck_Ship": wreck_combine,
|
|
"SM_Wreck_Probe": wreck_biplane,
|
|
}
|
|
BUDGET = {"SM_Wreck_Ship": 25000, "SM_Wreck_Probe": 10000, "SM_HoverTanker": 20000, "SM_TugPump": 13000, "SM_Decor_Palm": 2500, "SM_Buoy": 2500}
|
|
|
|
|
|
def meadow_plane(z):
|
|
"""Preview only: the soil line, so a half-sunk wreck can be judged as it will sit."""
|
|
bm = bmesh.new()
|
|
bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=90.0)
|
|
bmesh.ops.translate(bm, vec=Vector((0, 0, z)), verts=bm.verts)
|
|
o = mesh_obj("PrevMeadow", bm)
|
|
o["preview_only"] = True
|
|
m = bpy.data.materials.get("PrevMeadow")
|
|
if not m:
|
|
m = bpy.data.materials.new("PrevMeadow")
|
|
m.use_nodes = True
|
|
b = next(n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED")
|
|
b.inputs["Base Color"].default_value = (0.22, 0.42, 0.1, 1)
|
|
b.inputs["Roughness"].default_value = 1.0
|
|
o.data.materials.append(m)
|
|
|
|
|
|
def main():
|
|
args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
|
names = args or list(BUILDERS.keys())
|
|
noexport = os.environ.get("GFW_NOEXPORT") == "1"
|
|
for n in names:
|
|
reset()
|
|
random.seed(zlib.crc32(n.encode()))
|
|
GR.seed(zlib.crc32(n.encode()))
|
|
UVS[0] = 1.0
|
|
res = BUILDERS[n]() or {}
|
|
extra = res.pop("extra", [])
|
|
ground = res.pop("ground", None)
|
|
meshes = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
total = 0
|
|
for o in meshes:
|
|
tri_ngons(o)
|
|
total += ntris(o)
|
|
budget = BUDGET.get(n, 4000)
|
|
info = ", ".join(f"{o.name}:{ntris(o)}" for o in meshes)
|
|
print(f"[{n}] tris={total} budget={budget} {'OK' if total <= budget else 'OVER'} | {info}")
|
|
if not noexport:
|
|
export(n)
|
|
save_blend(n)
|
|
D.preview_tints()
|
|
frame = [o.name for o in meshes]
|
|
for k, pv in enumerate([res] + extra):
|
|
if ground is not None:
|
|
meadow_plane(ground)
|
|
preview(n if k == 0 else f"{n}_{k}", frame=frame, **pv)
|
|
print(f"[{n}] done")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|