"""Run with Blender --background INPUT.blend --python this.py -- --output OUTPUT.blend. v010 pattern-language revision. Input: the public v009 model (blender/samford-solarpunk-wind-tour-v009.blend) or the private licensed v009 model. Never publish an output based on the licensed scene. Adds, using A Pattern Language (Alexander et al.) as the design vocabulary: - a higher common-room ceiling (+0.6 m) with transom over the sliding doors (Ceiling Height Variety 190, Common Areas at the Heart 129) - two low-ceilinged alcoves off the common room: a south study nook and a west window seat (Alcoves 179, Window Place 180) - a day-one children's realm wing beside the couple's realm, with bed alcoves, a shared play room and a covered north deck linked to the verandah (Children's Realm 137, Bed Alcove 188, Connected Buildings 108, Arcades 119) - a day-one step-free elder cottage on the shared garden court (Old Age Cottage 155, Old People Everywhere 40, Sleeping to the East 138) - an entrance arbour and bench on the arrival walk (Entrance Transition 112) - future module shadows on the 1.2 m planning grid (Gradual growth) - tour chapters 33-36 All dimensions are concept intent on unsurveyed terrain, not engineering. """ import argparse import bpy import math import sys from pathlib import Path from mathutils import Vector parser = argparse.ArgumentParser() parser.add_argument('--output', required=True) args = parser.parse_args(sys.argv[sys.argv.index('--') + 1:]) output = Path(args.output).resolve() output.parent.mkdir(parents=True, exist_ok=True) s = bpy.context.scene assert '40 PATTERN - children realm' not in bpy.data.collections, 'Already added' assert '39 WIND - property turbine concept' in bpy.data.collections, 'Expected a v009 model' detail = bpy.data.collections['DETAIL - full geometry for renders'] fast = bpy.data.collections['00 FAST TOUR - lightweight viewport'] detail.hide_viewport = False fast.hide_viewport = True bpy.context.view_layer.update() MAT = bpy.data.materials SILVER_X = MAT['Naturally silvered hardwood - horizontal X'] SILVER_Y = MAT['Naturally silvered hardwood - horizontal Y'] GUM = MAT['Oiled spotted gum posts - vertical grain'] BAMBOO = MAT['Bamboo lining - golden fibres'] ROOF = MAT['Pale Colorbond - powder coated steel'] SLAB = MAT['Warm oxide polished concrete - fine aggregate'] CLAY = MAT['Soft warm clay plaster - natural mineral texture'] GLASS = MAT['VIEW transparent / Clear glazing'] STONE = MAT['Split sandstone facing - mineral grain'] STEEL = MAT['Reusable dark steel bolts and shoes'] OAK = MAT['Unpainted hardwood - long X grain'] OAK_Y = MAT['Unpainted hardwood - long Y grain'] LINEN = MAT['Undyed flax linen'] MOSS = MAT['Reading chair moss linen'] CANE = MAT['Handwoven cane - fine warm fibres'] CERAMIC = MAT['Bathroom warm white ceramic'] STAINLESS = MAT['Bathroom satin stainless'] MARBLE = MAT['Honed natural marble - ivory and warm grey veins'] INDUCTION = MAT['Oven and induction reflective smoked glass'] GRAVEL = MAT['Path aggregate - warm river stone'] LEAF = MAT['Garden leaf 1'] GHOST_LINE = MAT['Future shadow - faint sage outline'] GHOST_FILL = MAT['Future shadow - translucent footprint'] CHARCOAL = MAT['Meditation cushion charcoal linen'] TERRACOTTA = MAT['Unglazed terracotta - fine mineral surface'] terrain = bpy.data.objects['Continuous gently north falling hillside'] def ground(x, y): inv = terrain.matrix_world.inverted() origin = inv @ Vector((x, y, 60)) direction = (inv.to_3x3() @ Vector((0, 0, -1))).normalized() hit, loc, _, _ = terrain.ray_cast(origin, direction) assert hit, (x, y) return (terrain.matrix_world @ loc).z def ground_max(x0, x1, y0, y1, step=.6): zs = [] x = x0 while x <= x1 + 1e-6: y = y0 while y <= y1 + 1e-6: zs.append(ground(x, y)) y += step x += step return max(zs) def new_coll(name): c = bpy.data.collections.new(name) detail.children.link(c) return c class Mesh: """Accumulates boxes and prisms into one object to keep object counts low.""" def __init__(self): self.v, self.f = [], [] def prism(self, x0, x1, y0, y1, z0, top): """Box whose four top corners follow top(x, y); top may be a number.""" t = top if callable(top) else (lambda x, y, k=top: k) n = len(self.v) for z in (None, 'top'): for x, y in ((x0, y0), (x1, y0), (x1, y1), (x0, y1)): self.v.append((x, y, z0 if z is None else t(x, y))) self.f += [(n, n+3, n+2, n+1), (n+4, n+5, n+6, n+7), (n, n+1, n+5, n+4), (n+1, n+2, n+6, n+5), (n+2, n+3, n+7, n+6), (n+3, n, n+4, n+7)] return self def box(self, x0, x1, y0, y1, z0, z1): return self.prism(min(x0, x1), max(x0, x1), min(y0, y1), max(y0, y1), min(z0, z1), max(z0, z1)) def slab(self, corners, thickness): """Sloped plate from four (x, y, z) corners, extruded downward.""" n = len(self.v) for x, y, z in corners: self.v.append((x, y, z)) for x, y, z in corners: self.v.append((x, y, z - thickness)) self.f += [(n, n+1, n+2, n+3), (n+7, n+6, n+5, n+4), (n, n+4, n+5, n+1), (n+1, n+5, n+6, n+2), (n+2, n+6, n+7, n+3), (n+3, n+7, n+4, n)] return self def build(self, coll, name, mat): me = bpy.data.meshes.new(name) me.from_pydata(self.v, [], self.f) me.update() me.materials.append(mat) ob = bpy.data.objects.new(name, me) coll.objects.link(ob) return ob def box(coll, name, mat, x0, x1, y0, y1, z0, z1): return Mesh().box(x0, x1, y0, y1, z0, z1).build(coll, name, mat) def area_light(coll, name, loc, size, energy, color=(1, .86, .72)): data = bpy.data.lights.new(name, 'AREA') data.energy = energy data.size = size data.color = color ob = bpy.data.objects.new(name, data) ob.location = loc coll.objects.link(ob) return ob # --------------------------------------------------------------------------- # 1. Raise the common-room ceiling 0.6 m (Ceiling Height Variety, 190). # Everything fully inside the living pavilion + verandah volume moves; objects # that cross the cut height stretch. The corridor, breezeway and landscape are # not wholly inside the region and stay at their existing heights. RAISE, CUT = .6, 3.52 REGION = (-6.6, 6.6, -3.7, 5.75) def world_bounds(ob): pts = [ob.matrix_world @ Vector(c) for c in ob.bound_box] return [min(p[i] for p in pts) for i in range(3)], [max(p[i] for p in pts) for i in range(3)] def inside(mn, mx, region=REGION): return mn[0] >= region[0] and mx[0] <= region[1] and mn[1] >= region[2] and mx[1] <= region[3] skip_colls = {'22 PLAY - guided camera tour', '00 FAST TOUR - lightweight viewport'} raised, stretched, gap_rows = [], [], [] for ob in list(s.objects): if ob.type == 'CAMERA' or any(c.name in skip_colls for c in ob.users_collection): continue if ob.parent is not None: continue if ob.type == 'MESH': mn, mx = world_bounds(ob) if not inside(mn, mx) or mx[2] <= CUT: continue if mn[2] >= CUT - .005: ob.location.z += RAISE raised.append(ob.name) if 'weatherboard' in ob.name and abs(mn[2] - CUT) < .006: gap_rows.append(ob) else: if ob.data.users > 1: ob.data = ob.data.copy() m, inv = ob.matrix_world.copy(), ob.matrix_world.inverted() for v in ob.data.vertices: w = m @ v.co if w.z > CUT: w.z += RAISE v.co = inv @ w ob.data.update() stretched.append(ob.name) elif ob.type in {'LIGHT', 'FONT', 'EMPTY'}: p = ob.matrix_world.translation if inside(p, p) and p.z > CUT: ob.location.z += RAISE raised.append(ob.name) bpy.context.view_layer.update() # Fill the opened band with weatherboards matching each wall's lowest raised row. rows = round(RAISE / .15) for ob in gap_rows: for k in range(rows): copy = ob.copy() copy.data = ob.data.copy() copy.name = ob.name + ' | v010 raised-band board %d' % (k+1) copy.location.z = ob.location.z - .15 * (k+1) for c in ob.users_collection: c.objects.link(copy) living = bpy.data.collections['01 Living pavilion 12 x 6 m'] raise_coll = new_coll('41 PATTERN - common room height and alcoves') transom = Mesh().box(-5.95, 5.95, 3.01, 3.12, CUT - .10, CUT + .02) transom.build(raise_coll, 'ALCOVE PROJECT - door-head transom rail; fixed glazing above', GUM) for name in ('Living ceiling light',): if name in bpy.data.objects: bpy.data.objects[name].data.energy *= 1.35 # --------------------------------------------------------------------------- # 2. Alcoves: split the existing south and west walls around new openings. def split_around(ob, axis, lo, hi, head, keep_head=True): """Replace a box-like object with pieces either side of [lo, hi] and above head.""" mn, mx = world_bounds(ob) pieces = [] specs = [('A', lambda w: setattr(w, axis, min(getattr(w, axis), lo))), ('B', lambda w: setattr(w, axis, max(getattr(w, axis), hi)))] if keep_head and mx[2] > head + .01: def clamp_head(w): setattr(w, axis, min(max(getattr(w, axis), lo), hi)) w.z = max(w.z, head) specs.append(('head', clamp_head)) for tag, fn in specs: copy = ob.copy() copy.data = ob.data.copy() copy.name = ob.name + ' | alcove ' + tag m, inv = ob.matrix_world.copy(), ob.matrix_world.inverted() for v in copy.data.vertices: w = m @ v.co fn(w) v.co = inv @ w copy.data.update() for c in ob.users_collection: c.objects.link(copy) pieces.append(copy) bpy.data.objects.remove(ob) return pieces def hits(x0, x1, y0, y1, z0, z1, names): out = [] for ob in s.objects: if ob.type != 'MESH' or any(c.name in skip_colls for c in ob.users_collection): continue if not any(n in ob.name for n in names): continue mn, mx = world_bounds(ob) if mx[0] > x0 and mn[0] < x1 and mx[1] > y0 and mn[1] < y1 and mx[2] > z0 and mn[2] < z1: out.append(ob) return out HEAD = 3.22 # 2.10 m clear alcove height above the 1.12 m floor FLOOR = 1.12 south_names = ['South insulated timber wall', 'South hardwood weatherboard', 'Surface mounted accessible services', 'Living soft clay south interior wall', 'Living selective hemp insulated south wall core'] south_cut = hits(2.7, 4.1, -3.4, -2.6, FLOOR + .05, HEAD - .02, south_names) west_names = ['End wall silvered weatherboard', 'Living west wall | clear corridor opening'] west_cut = hits(-6.4, -5.6, .7, 2.5, FLOOR + .05, HEAD - .02, west_names) assert len(south_cut) >= 18 and len(west_cut) >= 15, (len(south_cut), len(west_cut)) for ob in south_cut: split_around(ob, 'x', 2.7, 4.1, HEAD) for ob in west_cut: split_around(ob, 'y', .7, 2.5, HEAD) # Move the homelab desk into the new study alcove. for name in ('Small homelab work desk', 'Desk steel leg', 'Desk steel leg.001'): if name in bpy.data.objects: bpy.data.objects.remove(bpy.data.objects[name]) for name, d in (('Desk display', (.5, -1.38, -.03)), ('Desk display base', (.5, -1.38, -.03)), ('Desk keyboard', (.5, -1.38, -.03)), ('Desk timber stool', (.5, -1.55, 0))): ob = bpy.data.objects[name] ob.location += Vector(d) for ob in list(s.objects): if ob.name.startswith('Desk stool leg'): ob.location += Vector((.5, -1.55, 0)) def module(coll, tag, x0, x1, y0, y1, floor, h_s, h_n, openings, eaves=(.45, .6, .45, .45), piers=True, partitions=(), lining=True, wall_mat=SILVER_X, open_sides=()): """Insulated timber room module, mono-pitch rising to the north. openings: {'S'|'N'|'E'|'W': [(a, b, sill, head, kind)]} with sill/head above floor and kind in {'window', 'door'}. a, b run along x for S/N and along y for E/W. partitions: [(axis, fixed, a, b, [(gap_a, gap_b)])] interior clay walls. """ t = .18 top = lambda x, y: floor + h_s + (h_n - h_s) * (y - y0) / (y1 - y0) walls, lin, boards, frames, panes, doors = Mesh(), Mesh(), Mesh(), Mesh(), Mesh(), Mesh() sides = {'S': ('x', y0, y0 + t, x0, x1), 'N': ('x', y1 - t, y1, x0, x1), 'W': ('y', x0, x0 + t, y0, y1), 'E': ('y', x1 - t, x1, y0, y1)} for side, (axis, f0, f1, a0, a1) in sides.items(): if side in open_sides: continue ops = sorted(openings.get(side, [])) cuts, cursor = [], a0 for a, b, sill, head, kind in ops: cuts.append((cursor, a, None)) cuts.append((a, b, (sill, head, kind))) cursor = b cuts.append((cursor, a1, None)) out = -1 if side in 'SW' else 1 for a, b, op in cuts: if b - a < 1e-4: continue spans = [(floor, None)] if op is None else [] if op is not None: sill, head, kind = op if sill > 0: spans.append((floor, floor + sill)) spans.append((floor + head, None)) for za, zb in spans: upper = top if zb is None else zb if axis == 'x': walls.prism(a, b, f0, f1, za, upper) if lining: li = (f1, f1 + .02) if side == 'S' else (f0 - .02, f0) lin.prism(a, b, li[0], li[1], za, upper) else: walls.prism(f0, f1, a, b, za, upper) if lining: li = (f1, f1 + .02) if side == 'W' else (f0 - .02, f0) lin.prism(li[0], li[1], a, b, za, upper) # weatherboards on the outside face, rows of 150 mm below the lowest top zt = (zb if zb is not None else min(top(a if axis == 'x' else f0, a if axis == 'y' else f0), top(b if axis == 'x' else f0, b if axis == 'y' else f0))) z = za while z + .15 <= zt + 1e-6: if axis == 'x': yb = (f0 - .025, f0) if out < 0 else (f1, f1 + .025) boards.box(a, b, yb[0], yb[1], z, z + .148) else: xb = (f0 - .025, f0) if out < 0 else (f1, f1 + .025) boards.box(xb[0], xb[1], a, b, z, z + .148) z += .15 if op is not None: sill, head, kind = op zl, zh = floor + sill, floor + head fw = .06 if axis == 'x': frames.box(a, a + fw, f0, f1, zl, zh).box(b - fw, b, f0, f1, zl, zh) frames.box(a, b, f0, f1, zh - fw, zh) if sill > 0: frames.box(a - .03, b + .03, f0 - .05, f1 + .03, zl - .04, zl) (doors if kind == 'door' else panes).box(a + fw, b - fw, (f0+f1)/2 - .006, (f0+f1)/2 + .006, zl + (.02 if kind == 'door' else 0), zh - fw) if kind == 'door': frames.box((a+b)/2 - .02, (a+b)/2 + .02, f0 + .02, f1 - .02, zl, zh) else: frames.box(f0, f1, a, a + fw, zl, zh).box(f0, f1, b - fw, b, zl, zh) frames.box(f0, f1, a, b, zh - fw, zh) if sill > 0: frames.box(f0 - .05, f1 + .03, a - .03, b + .03, zl - .04, zl) (doors if kind == 'door' else panes).box((f0+f1)/2 - .006, (f0+f1)/2 + .006, a + fw, b - fw, zl + (.02 if kind == 'door' else 0), zh - fw) walls.build(coll, f'{tag} | insulated timber walls', wall_mat) if lining: lin.build(coll, f'{tag} | soft clay interior lining', CLAY) boards.build(coll, f'{tag} | silvered hardwood weatherboards', SILVER_X) frames.build(coll, f'{tag} | spotted gum window and door frames', GUM) if panes.v: panes.build(coll, f'{tag} | double glazed windows', GLASS) if doors.v: doors.build(coll, f'{tag} | glazed timber doors', GLASS) # floor, piers, posts box(coll, f'{tag} | insulated floor slab', SLAB, x0, x1, y0, y1, floor - .28, floor) if piers: pm = Mesh() nx, ny = max(2, round((x1 - x0) / 2.8) + 1), max(2, round((y1 - y0) / 2.4) + 1) for i in range(nx): for j in range(ny): px = x0 + .18 + (x1 - x0 - .36) * i / (nx - 1) py = y0 + .18 + (y1 - y0 - .36) * j / (ny - 1) pm.box(px - .17, px + .17, py - .17, py + .17, ground(px, py) - .12, floor - .28) pm.build(coll, f'{tag} | split sandstone piers', STONE) posts = Mesh() for px, py in ((x0, y0), (x1, y0), (x0, y1), (x1, y1)): posts.prism(px - .1, px + .1, py - .1, py + .1, floor, lambda x, y: top(x, y) + .02) # partitions for axis, fixed, a, b, gaps in partitions: cursor = a pm = Mesh() for ga, gb in sorted(gaps) + [(b, b)]: if ga - cursor > 1e-3: if axis == 'y': pm.prism(fixed - .05, fixed + .05, cursor, ga, floor, top) else: pm.prism(cursor, ga, fixed - .05, fixed + .05, floor, top) if gb < b: if axis == 'y': pm.prism(fixed - .05, fixed + .05, ga, gb, floor + 2.1, top) else: pm.prism(ga, gb, fixed - .05, fixed + .05, floor + 2.1, top) cursor = gb pm.build(coll, f'{tag} | clay partition {axis}={fixed:.2f}', CLAY) posts.build(coll, f'{tag} | exposed spotted gum corner posts', GUM) # roof, rafters, ceiling, gutter es, en, ew, ee = eaves ry0, ry1 = y0 - es, y1 + en rtop = lambda y: floor + h_s + (h_n - h_s) * (y - y0) / (y1 - y0) + .28 roof = Mesh().slab([(x0 - ew, ry0, rtop(ry0)), (x1 + ee, ry0, rtop(ry0)), (x1 + ee, ry1, rtop(ry1)), (x0 - ew, ry1, rtop(ry1))], .05) roof.build(coll, f'{tag} | pale Colorbond mono-pitch roof', ROOF) raf = Mesh() n = max(2, int((x1 - x0) / .6)) for i in range(n + 1): rx = x0 + .09 + (x1 - x0 - .18) * i / n raf.slab([(rx - .035, ry0 + .1, rtop(ry0 + .1) - .05), (rx + .035, ry0 + .1, rtop(ry0 + .1) - .05), (rx + .035, ry1 - .1, rtop(ry1 - .1) - .05), (rx - .035, ry1 - .1, rtop(ry1 - .1) - .05)], .40) raf.build(coll, f'{tag} | exposed spotted gum rafters', GUM) Mesh().slab([(x0 + t, y0 + t, top(0, y0 + t) - .01), (x1 - t, y0 + t, top(0, y0 + t) - .01), (x1 - t, y1 - t, top(0, y1 - t) - .01), (x0 + t, y1 - t, top(0, y1 - t) - .01)], .015 ).build(coll, f'{tag} | bamboo ceiling lining', BAMBOO) Mesh().box(x0 - ew, x1 + ee, ry0 - .14, ry0, rtop(ry0) - .16, rtop(ry0) - .04).build( coll, f'{tag} | low edge gutter', ROOF) return top # Study alcove (south) and window-seat alcove (west). Both have lower ceilings # than the raised common room and light on two sides. a_top = module(raise_coll, 'ALCOVE study nook', 2.52, 4.28, -4.32, -2.98, FLOOR, 2.24, 2.32, {'S': [(3.0, 3.8, .95, 1.95, 'window')], 'E': [(-4.02, -3.42, .95, 1.95, 'window')]}, eaves=(.35, .0, .2, .3), open_sides=('N',)) box(raise_coll, 'ALCOVE study nook | built-in hardwood desk', OAK, 2.72, 4.08, -4.12, -3.52, FLOOR + .72, FLOOR + .76) box(raise_coll, 'ALCOVE study nook | desk side panel west', OAK, 2.7, 2.74, -4.12, -3.52, FLOOR, FLOOR + .72) box(raise_coll, 'ALCOVE study nook | desk side panel east', OAK, 4.06, 4.1, -4.12, -3.52, FLOOR, FLOOR + .72) box(raise_coll, 'ALCOVE study nook | open book shelf', OAK, 2.72, 2.98, -4.12, -3.2, FLOOR + 1.45, FLOOR + 1.48) area_light(raise_coll, 'ALCOVE study nook warm light', (3.4, -3.7, FLOOR + 2.08), .5, 35) w_top = module(raise_coll, 'ALCOVE west window seat', -7.32, -6.1, .52, 2.68, FLOOR, 2.24, 2.32, {'W': [(.9, 2.3, .5, 2.0, 'window')], 'N': [(-7.0, -6.42, .5, 2.0, 'window')]}, eaves=(.2, .3, .35, .0), open_sides=('E',)) box(raise_coll, 'ALCOVE window seat | hardwood bench with cubbies', OAK, -7.14, -6.2, .72, 2.48, FLOOR, FLOOR + .42) box(raise_coll, 'ALCOVE window seat | linen seat cushion', LINEN, -7.12, -6.24, .74, 2.46, FLOOR + .42, FLOOR + .5) pm = Mesh() for py in (1.0, 2.15): pm.box(-7.12, -6.98, py - .22, py + .22, FLOOR + .5, FLOOR + .86) pm.build(raise_coll, 'ALCOVE window seat | back cushions', MOSS) area_light(raise_coll, 'ALCOVE window seat warm reading light', (-6.7, 1.6, FLOOR + 2.06), .5, 30) # --------------------------------------------------------------------------- # 3. Children's realm (137) beside the couple's realm, linked by a covered deck. kids = new_coll('40 PATTERN - children realm') KX0, KX1, KY0, KY1 = -16.8, -8.4, 0.0, 4.8 k_top = module(kids, "CHILDREN'S REALM", KX0, KX1, KY0, KY1, FLOOR, 2.55, 3.05, { 'N': [(-16.2, -15.0, .5, 2.3, 'window'), (-14.1, -13.0, .45, 2.3, 'window'), (-12.6, -11.4, 0, 2.3, 'door'), (-10.2, -9.0, .5, 2.3, 'window')], 'S': [(-16.0, -15.2, 1.5, 2.2, 'window'), (-13.9, -13.1, 1.6, 2.2, 'window'), (-11.9, -11.1, 1.5, 2.2, 'window'), (-10.0, -9.2, 1.5, 2.2, 'window')], 'W': [(1.8, 3.0, .6, 2.2, 'window')], 'E': [(1.8, 3.0, .6, 2.2, 'window')]}, eaves=(.45, 1.15, .45, .45), partitions=[('y', -14.4, KY0, KY1, [(2.95, 3.85)]), ('y', -10.8, KY0, KY1, [(2.95, 3.85)]), ('y', -12.6, KY0, 1.6, []), ('x', 1.6, -14.4, -12.6, [(-13.75, -12.95)])]) # bed alcoves (188): each bedroom has a bed tucked under a low timber canopy for tag, bx0, bx1 in (('west', -16.6, -15.6), ('east', -9.6, -8.6)): box(kids, f"CHILDREN'S REALM | {tag} bed alcove platform", OAK, bx0, bx1, .25, 2.35, FLOOR, FLOOR + .38) box(kids, f"CHILDREN'S REALM | {tag} bed mattress", LINEN, bx0 + .04, bx1 - .04, .29, 2.31, FLOOR + .38, FLOOR + .56) box(kids, f"CHILDREN'S REALM | {tag} folded wool blanket", MOSS, bx0 + .04, bx1 - .04, .3, 1.0, FLOOR + .56, FLOOR + .6) box(kids, f"CHILDREN'S REALM | {tag} pillow", LINEN, bx0 + .12, bx1 - .12, 1.9, 2.25, FLOOR + .56, FLOOR + .68) side = bx1 + .02 if tag == 'west' else bx0 - .06 box(kids, f"CHILDREN'S REALM | {tag} bed alcove canopy", OAK_Y, bx0 - .02, bx1 + .02, .2, 2.4, FLOOR + 1.95, FLOOR + 2.0) box(kids, f"CHILDREN'S REALM | {tag} bed alcove side screen", OAK, side, side + .04, .2, .55, FLOOR, FLOOR + 1.95) box(kids, f"CHILDREN'S REALM | {tag} bed alcove curtain", LINEN, side, side + .02, 1.7, 2.4, FLOOR + .6, FLOOR + 1.92) dx0 = -16.6 if tag == 'west' else -10.6 box(kids, f"CHILDREN'S REALM | {tag} desk under north window", OAK, dx0, dx0 + 1.2, 4.05, 4.58, FLOOR + .68, FLOOR + .72) box(kids, f"CHILDREN'S REALM | {tag} desk stool", OAK, dx0 + .4, dx0 + .75, 3.55, 3.9, FLOOR, FLOOR + .45) area_light(kids, f"CHILDREN'S REALM {tag} bedroom light", ((bx0 + bx1) / 2 + (1.0 if tag == 'west' else -1.0), 2.4, FLOOR + 2.45), .8, 70) # shared play room box(kids, "CHILDREN'S REALM | play room window seat", OAK, -14.25, -12.85, 4.07, 4.6, FLOOR, FLOOR + .42) box(kids, "CHILDREN'S REALM | window seat cushion", MOSS, -14.23, -12.87, 4.09, 4.6, FLOOR + .42, FLOOR + .5) box(kids, "CHILDREN'S REALM | woven play rug", CANE, -14.0, -11.2, 2.0, 3.9, FLOOR, FLOOR + .012) shelf = Mesh() for z in (0, .38, .76, 1.14): shelf.box(-12.5, -10.9, 1.62, 1.92, FLOOR + z, FLOOR + z + .03) for x in (-12.5, -11.7, -10.93): shelf.box(x, x + .03, 1.62, 1.92, FLOOR, FLOOR + 1.17) shelf.build(kids, "CHILDREN'S REALM | low toy and book shelves", OAK) box(kids, "CHILDREN'S REALM | low play table", OAK, -13.3, -12.5, 2.6, 3.3, FLOOR + .48, FLOOR + .52) for cx, cy in ((-13.55, 2.95), (-12.25, 2.95), (-12.9, 3.6)): box(kids, "CHILDREN'S REALM | floor cushion", TERRACOTTA if cx < -13 else LINEN, cx - .2, cx + .2, cy - .2, cy + .2, FLOOR, FLOOR + .14) box(kids, "CHILDREN'S REALM | bathroom basin", CERAMIC, -13.4, -12.9, .2, .55, FLOOR + .78, FLOOR + .88) box(kids, "CHILDREN'S REALM | bathroom toilet", CERAMIC, -14.25, -13.85, .25, .85, FLOOR, FLOOR + .42) box(kids, "CHILDREN'S REALM | shower screen", GLASS, -13.6, -13.58, .2, 1.5, FLOOR, FLOOR + 2.0) area_light(kids, "CHILDREN'S REALM play room light", (-12.6, 3.0, FLOOR + 2.55), 1.2, 110) area_light(kids, "CHILDREN'S REALM bathroom light", (-13.5, .8, FLOOR + 2.3), .5, 35) # covered north deck, link to the verandah, balustrade and garden steps deck = Mesh() y = 4.84 while y < 5.88: deck.box(KX0, KX1, y, y + .11, FLOOR - .05, FLOOR) y += .12 y = 3.62 while y < 5.38: deck.box(KX1, -6.02, y, y + .11, FLOOR - .05, FLOOR) y += .12 deck.build(kids, "CHILDREN'S REALM | replaceable hardwood deck boards", OAK) sub = Mesh() for px in (-16.7, -14.0, -11.2, -8.5): sub.box(px - .06, px + .06, 5.74, 5.86, ground(px, 5.8) - .05, FLOOR - .05) for px, py in ((-8.3, 3.7), (-6.15, 3.7), (-8.3, 5.3), (-6.15, 5.3)): sub.box(px - .06, px + .06, py - .06, py + .06, ground(px, py) - .05, FLOOR - .05) sub.box(KX0, KX1, 5.8, 5.9, FLOOR - .3, FLOOR - .05) sub.build(kids, "CHILDREN'S REALM | deck bearers and posts", GUM) rail = Mesh() for xa, xb in ((KX0, -15.65), (-14.55, KX1)): rail.box(xa, xb, 5.84, 5.9, FLOOR + .96, FLOOR + 1.0) x = xa + .05 while x < xb - .02: rail.box(x, x + .03, 5.85, 5.89, FLOOR, FLOOR + .96) x += .12 rail.box(KX0 - .04, KX0, 4.8, 5.9, FLOOR + .96, FLOOR + 1.0) x = 4.85 while x < 5.86: rail.box(KX0 - .04, KX0, x, x + .03, FLOOR, FLOOR + .96) x += .12 rail.build(kids, "CHILDREN'S REALM | timber balustrade with vertical slats", OAK) steps = Mesh() gz = ground(-15.1, 7.6) n = max(3, round((FLOOR - gz) / .17)) for i in range(n): zt = FLOOR - (i + 1) * (FLOOR - gz) / n steps.box(-15.6, -14.6, 5.9 + i * .28, 5.9 + (i + 1) * .28, zt - .04, zt + .0) steps.build(kids, "CHILDREN'S REALM | garden steps to the west lawn", OAK) link_roof = Mesh().slab([(-8.5, 3.5, FLOOR + 2.72), (-6.1, 3.5, FLOOR + 2.72), (-6.1, 5.5, FLOOR + 2.64), (-8.5, 5.5, FLOOR + 2.64)], .05) link_roof.build(kids, "CHILDREN'S REALM | covered link to verandah roof", ROOF) lp = Mesh() for px, py in ((-8.3, 5.3), (-6.3, 5.3), (-8.3, 3.7)): lp.box(px - .06, px + .06, py - .06, py + .06, FLOOR, FLOOR + 2.66) lp.build(kids, "CHILDREN'S REALM | covered link posts", GUM) deck_posts = Mesh() for px in (KX0 + .1, -14.0, -11.2, KX1 - .1): deck_posts.prism(px - .06, px + .06, 5.74, 5.86, FLOOR, lambda x, y: k_top(x, y) + .22) deck_posts.build(kids, "CHILDREN'S REALM | covered deck posts", GUM) # --------------------------------------------------------------------------- # 4. Elder cottage (Old Age Cottage 155) on the east side of the shared court. elder = new_coll('42 PATTERN - elder cottage') EX0, EX1, EY0, EY1 = 9.6, 16.8, 9.4, 14.2 EF = round(ground_max(EX0, EX1, EY0, EY1) + .12, 3) e_top = module(elder, 'ELDER COTTAGE', EX0, EX1, EY0, EY1, EF, 2.6, 3.1, { 'W': [(10.2, 11.8, .9, 2.2, 'window'), (12.6, 13.6, 0, 2.3, 'door')], 'N': [(10.0, 11.2, .45, 2.3, 'window'), (11.4, 12.8, 0, 2.3, 'door'), (14.2, 15.8, .8, 2.2, 'window')], 'E': [(9.8, 10.8, 1.5, 2.1, 'window'), (12.0, 13.4, .8, 2.2, 'window')], 'S': [(10.6, 12.2, 1.3, 2.0, 'window')]}, eaves=(.45, 1.3, .45, .45), piers=False, partitions=[('y', 13.2, EY0, EY1, [(11.4, 12.4)]), ('x', 11.2, 13.2, 16.8, [(13.3, 14.3), (15.2, 16.2)]), ('y', 14.4, EY0, 11.2, [])]) # kitchenette, table, armchairs, window seat box(elder, 'ELDER COTTAGE | kitchenette timber base', OAK, 9.85, 12.75, 9.6, 10.18, EF, EF + .86) box(elder, 'ELDER COTTAGE | kitchenette marble top', MARBLE, 9.83, 12.77, 9.58, 10.2, EF + .86, EF + .9) box(elder, 'ELDER COTTAGE | two-zone induction', INDUCTION, 11.9, 12.5, 9.7, 10.1, EF + .9, EF + .906) box(elder, 'ELDER COTTAGE | kitchenette sink', STAINLESS, 10.4, 10.9, 9.7, 10.08, EF + .78, EF + .901) box(elder, 'ELDER COTTAGE | open shelf', OAK, 10.0, 12.6, 9.58, 9.86, EF + 1.55, EF + 1.58) box(elder, 'ELDER COTTAGE | small round table for two', OAK, 10.55, 11.45, 11.8, 12.7, EF + .72, EF + .76) box(elder, 'ELDER COTTAGE | table pedestal', OAK, 10.94, 11.06, 12.19, 12.31, EF, EF + .72) for cx, cy in ((10.3, 12.25), (11.7, 12.25)): box(elder, 'ELDER COTTAGE | dining chair seat', OAK, cx - .22, cx + .22, cy - .22, cy + .22, EF + .44, EF + .48) box(elder, 'ELDER COTTAGE | dining chair base', OAK, cx - .2, cx + .2, cy - .2, cy + .2, EF, EF + .44) for cx in (11.75, 12.55): box(elder, 'ELDER COTTAGE | firm armchair base', MOSS, cx - .36, cx + .36, 13.0, 13.7, EF, EF + .46) box(elder, 'ELDER COTTAGE | armchair back', MOSS, cx - .36, cx + .36, 12.86, 13.02, EF, EF + .95) box(elder, 'ELDER COTTAGE | window place seat', OAK, 10.05, 11.15, 13.45, 14.02, EF, EF + .45) box(elder, 'ELDER COTTAGE | window place cushion', LINEN, 10.07, 11.13, 13.47, 14.02, EF + .45, EF + .52) box(elder, 'ELDER COTTAGE | woven rug', CANE, 11.2, 12.9, 12.0, 13.9, EF, EF + .012) # bedroom, sleeping to the east box(elder, 'ELDER COTTAGE | low accessible bed base', OAK, 13.35, 15.35, 12.1, 13.75, EF, EF + .38) box(elder, 'ELDER COTTAGE | mattress', LINEN, 13.38, 15.32, 12.13, 13.72, EF + .38, EF + .58) box(elder, 'ELDER COTTAGE | quilt', MOSS, 14.0, 15.32, 12.12, 13.73, EF + .58, EF + .62) box(elder, 'ELDER COTTAGE | pillows', LINEN, 13.42, 13.85, 12.25, 13.6, EF + .58, EF + .7) box(elder, 'ELDER COTTAGE | bed head', OAK, 13.26, 13.34, 12.0, 13.85, EF, EF + 1.0) box(elder, 'ELDER COTTAGE | bedside table', OAK, 13.35, 13.8, 13.85, 14.05, EF, EF + .55) box(elder, 'ELDER COTTAGE | steel bedside grab rail', STEEL, 15.35, 15.4, 12.5, 13.3, EF + .62, EF + .66) box(elder, 'ELDER COTTAGE | east window armchair', MOSS, 15.8, 16.5, 13.5, 14.0, EF, EF + .46) box(elder, 'ELDER COTTAGE | wardrobe', OAK, 13.3, 14.35, 9.6, 10.2, EF, EF + 2.1) # accessible wet room box(elder, 'ELDER COTTAGE | wet room toilet', CERAMIC, 16.0, 16.6, 9.6, 10.0, EF, EF + .46) box(elder, 'ELDER COTTAGE | wet room basin', CERAMIC, 14.65, 15.25, 9.6, 10.05, EF + .78, EF + .88) box(elder, 'ELDER COTTAGE | fold-down shower seat', OAK, 16.2, 16.6, 10.4, 10.9, EF + .45, EF + .49) gr = Mesh().box(15.6, 16.6, 10.98, 11.02, EF + .85, EF + .89).box(16.6, 16.64, 9.6, 10.9, EF + .8, EF + .84) gr.build(elder, 'ELDER COTTAGE | stainless grab rails', STAINLESS) area_light(elder, 'ELDER COTTAGE living light', (11.4, 11.8, EF + 2.6), 1.2, 110) area_light(elder, 'ELDER COTTAGE bedroom light', (14.8, 12.8, EF + 2.75), .9, 70) area_light(elder, 'ELDER COTTAGE wet room light', (15.5, 10.3, EF + 2.45), .5, 35) # north porch (north-facing outdoors), bench by the door, step-free landing pav = Mesh() gx = 9.7 while gx < 14.1: pav.box(gx, gx + .58, EY1 + .02, EY1 + 1.2, EF - .2, EF - .02) gx += .6 pav.box(8.75, EX0, 12.3, 13.9, ground(9.1, 13.1) - .1, EF - .02) pav.build(elder, 'ELDER COTTAGE | step-free sandstone porch and landing', STONE) box(elder, 'ELDER COTTAGE | bench by the front door', OAK, 9.75, 11.15, 14.75, 15.12, EF + .42, EF + .46) box(elder, 'ELDER COTTAGE | bench legs', OAK, 9.8, 11.1, 14.8, 15.07, EF - .02, EF + .42) pp = Mesh() for px in (9.75, 12.0, 14.0): pp.prism(px - .06, px + .06, 15.26, 15.38, EF - .02, lambda x, y: e_top(x, y) + .22) pp.build(elder, 'ELDER COTTAGE | porch posts', GUM) path = Mesh() py = 6.4 while py < 9.4: path.box(10.55, 11.75, py, py + .58, ground(11.15, py + .3) - .06, ground(11.15, py + .3) + .03) py += .6 path.build(elder, 'ELDER COTTAGE | level stone path to the dining terrace', STONE) # --------------------------------------------------------------------------- # 5. Entrance transition (112): arbour and bench on the arrival walk. arb = new_coll('43 PATTERN - entrance transition arbour') gz = ground(5.9, -8.0) am = Mesh() for px in (4.95, 6.85): for py in (-8.75, -7.35): am.box(px - .06, px + .06, py - .06, py + .06, gz - .1, gz + 2.55) am.box(px - .05, px + .05, -9.0, -7.1, gz + 2.42, gz + 2.62) x = 4.75 while x < 7.06: am.box(x, x + .05, -9.0, -7.1, gz + 2.62, gz + 2.7) x += .33 am.build(arb, 'ENTRANCE ARBOUR | spotted gum posts beams and battens', GUM) lm = Mesh() import random rng = random.Random(10) for i in range(260): lx, ly = rng.uniform(4.7, 7.1), rng.uniform(-9.0, -7.1) lz = gz + 2.7 + rng.uniform(0, .12) lm.box(lx, lx + rng.uniform(.06, .12), ly, ly + rng.uniform(.04, .08), lz, lz + .008) for px in (4.95, 6.85): for i in range(30): lz = gz + rng.uniform(.3, 2.5) ly = -7.35 + rng.uniform(-.1, .1) lm.box(px - .1, px - .02, ly, ly + .06, lz, lz + .008) lm.build(arb, 'ENTRANCE ARBOUR | climbing native jasmine leaves', LEAF) bg = ground(7.2, -8.1) box(arb, 'ENTRANCE ARBOUR | bench by the front path', OAK, 7.0, 7.4, -8.7, -7.5, bg + .42, bg + .46) box(arb, 'ENTRANCE ARBOUR | bench supports', OAK, 7.04, 7.36, -8.6, -7.6, bg - .05, bg + .42) # --------------------------------------------------------------------------- # 6. Future modules: remove the east shadow (now the built elder cottage), add a # north-east shadow for a second elder cottage or rooms to rent. later = bpy.data.collections['24 LATER - Shadow spaces only'] for ob in list(later.objects): mn, mx = world_bounds(ob) if mn[0] > 9.3 and mx[0] < 14.3 and mn[1] > 9.3: bpy.data.objects.remove(ob) gx0, gx1, gy0, gy1 = 9.6, 16.8, 19.6, 24.4 gm = Mesh() gf, gr_ = 1.12, (3.86, 4.22) for px, py in ((gx0, gy0), (gx1, gy0), (gx0, gy1), (gx1, gy1)): gm.box(px - .01, px + .01, py - .01, py + .01, gf, gr_[0] + (gr_[1] - gr_[0]) * (py - gy0) / (gy1 - gy0)) for z0, z1 in ((gf, gf), (gr_[0], gr_[1])): gm.box(gx0, gx1, gy0 - .01, gy0 + .01, z0 - .01, z0 + .01) gm.box(gx0, gx1, gy1 - .01, gy1 + .01, z1 - .01, z1 + .01) for px in (gx0, gx1): gm.prism(px - .01, px + .01, gy0, gy1, z0 - .01, lambda x, y, a=z0, b=z1: a + (b - a) * (y - gy0) / (gy1 - gy0) + .01) gm.build(later, 'Future space 3 | second elder cottage or rooms to rent | shadow edges', GHOST_LINE) gp = Mesh().slab([(gx0, gy0, ground(gx0, gy0) + .02), (gx1, gy0, ground(gx1, gy0) + .02), (gx1, gy1, ground(gx1, gy1) + .02), (gx0, gy1, ground(gx0, gy1) + .02)], .01) gp.build(later, 'Future space 3 | ground shadow', GHOST_FILL) # --------------------------------------------------------------------------- # 7. Clear grass and fallen leaves from the slab-on-ground cottage, porch and path. def clear_vertices(ob, rects, zmax=99): import bmesh bm = bmesh.new() bm.from_mesh(ob.data) m = ob.matrix_world dead = [] for v in bm.verts: w = m @ v.co if w.z < zmax and any(r[0] <= w.x <= r[1] and r[2] <= w.y <= r[3] for r in rects): dead.append(v) bmesh.ops.delete(bm, geom=dead, context='VERTS') bm.to_mesh(ob.data) bm.free() return len(dead) clear_rects = [(EX0 - .3, EX1 + .3, EY0 - .3, EY1 + 1.5), (8.6, 9.7, 12.2, 14.0), (10.4, 11.9, 6.3, 9.5)] cleared = 0 for name in ('Native grasses and lomandra - individual blade geometry', 'Scattered fallen eucalyptus leaves', 'Fuller garden borders - curved lanceolate leaves', 'FAST | 08 Native planting'): if name in bpy.data.objects: cleared += clear_vertices(bpy.data.objects[name], clear_rects) ob = bpy.data.objects.get('FAST | Crafted details and fuller gardens') if ob: cleared += clear_vertices(ob, clear_rects, zmax=.9) # --------------------------------------------------------------------------- # 8. Lightweight viewport. FAST copies of these collections are exact raw joins # of DETAIL, so rebuild them; join each new collection into one FAST mesh. def join_raw(objs, name): verts, faces, mats, mi = [], [], [], [] for ob in objs: if ob.type != 'MESH': continue m = ob.matrix_world off = len(verts) verts += [tuple(m @ v.co) for v in ob.data.vertices] slots = [sl for sl in ob.data.materials] for p in ob.data.polygons: faces.append([i + off for i in p.vertices]) mat = slots[p.material_index] if p.material_index < len(slots) else None if mat not in mats: mats.append(mat) mi.append(mats.index(mat)) me = bpy.data.meshes.new(name) me.from_pydata(verts, [], faces) for mat in mats: me.materials.append(mat) me.polygons.foreach_set('material_index', mi) me.update() proxy = bpy.data.objects.new(name, me) fast.objects.link(proxy) proxy.hide_render = True return proxy bpy.context.view_layer.update() rebuilt = [] for cname in ('01 Living pavilion 12 x 6 m', '05 Water and services', '10 Furniture', '12 Natural materials and reversible connections', '18 Starlink and single-server homelab', '19 Clay finishes and hemp wall infill', '20 Spacious site connections', '24 LATER - Shadow spaces only'): old = bpy.data.objects.get('FAST | ' + cname) if old: bpy.data.objects.remove(old) join_raw(bpy.data.collections[cname].all_objects, 'FAST | ' + cname) rebuilt.append(cname) # Remaining FAST meshes that include common-room details (pendants, bolts, kitchen # extraction) get the same height rule, vertex by vertex, inside the room only. for name in ('FAST | Crafted details and fuller gardens', 'FAST | Training gathering play and garden loop', 'FAST | Reading library and chair', 'FAST | Connected kitchen mixer riser'): ob = bpy.data.objects.get(name) if not ob: continue m, inv = ob.matrix_world.copy(), ob.matrix_world.inverted() for v in ob.data.vertices: w = m @ v.co if REGION[0] <= w.x <= REGION[1] and REGION[2] <= w.y <= 5.45 and w.z > CUT: w.z += RAISE v.co = inv @ w ob.data.update() for coll in (raise_coll, kids, elder, arb): join_raw(coll.all_objects, 'FAST | ' + coll.name) # --------------------------------------------------------------------------- # 9. Tour chapters 33-36 (5 s each) and scene notes. tour = bpy.data.collections['22 PLAY - guided camera tour'] cam = bpy.data.objects['PLAY TOUR camera'] ref = bpy.data.objects['Tour caption 32 - wind turbine concept'] ch22 = next((o for o in tour.objects if o.type == 'FONT' and o.data.body.startswith('22 /')), None) if ch22: ch22.data.body = '22 / ELDER COTTAGE & FUTURE MODULES' chapters = [ ('33 / COMMON ROOM - HIGHER CEILING & ALCOVES', [((-5.3, 2.75, 2.65), (3.4, -3.6, 2.2)), ((-4.7, 2.4, 2.6), (3.4, -3.8, 2.1))], 18), ("34 / CHILDREN'S REALM BESIDE THE COUPLE'S REALM", [((-17.0, 11.2, 4.4), (-12.0, 2.4, 2.0)), ((-15.6, 10.8, 4.2), (-11.6, 2.4, 2.0))], 22), ('35 / ELDER COTTAGE ON THE SHARED COURT', [((3.2, 18.6, 3.4), (13.0, 11.8, EF + 1.0)), ((4.2, 18.0, 3.3), (13.0, 11.8, EF + 1.0))], 26), ('36 / A HOME THAT GROWS BY MODULES', [((-10, 62, 46), (0, 4, 0)), ((10, 62, 46), (0, 4, 0))], 30), ] prev = ref start = 3841 for i, (title, keys, lens) in enumerate(chapters): f0, f1 = start + 120 * i, start + 120 * i + 119 for frame, (pos, target) in zip((f0, f1), keys): s.frame_set(frame) cam.location = pos cam.rotation_euler = (Vector(target) - Vector(pos)).to_track_quat('-Z', 'Y').to_euler() cam.keyframe_insert('location', frame=frame) cam.keyframe_insert('rotation_euler', frame=frame) cam.data.lens = lens cam.data.keyframe_insert('lens', frame=frame) prev.scale = (0, 0, 0) prev.keyframe_insert('scale', frame=f0) caption = ref.copy() caption.data = ref.data.copy() caption.animation_data_clear() tour.objects.link(caption) caption.name = 'Tour caption %s' % title.split(' / ')[0] + ' - pattern language' caption.data.body = title caption.location = ref.location for frame, value in ((1, 0), (f0 - 1, 0), (f0, 1), (f1, 1)): caption.scale = (value, value, value) caption.keyframe_insert('scale', frame=frame) s.timeline_markers.new(title, frame=f0) prev = caption for ob in tour.objects: if ob.type == 'FONT' and ob.animation_data and ob.animation_data.action: for layer in ob.animation_data.action.layers: for strip in layer.strips: for bag in strip.channelbags: for curve in bag.fcurves: for key in curve.keyframe_points: key.interpolation = 'CONSTANT' s.frame_end = start + 120 * len(chapters) - 1 s['Pattern language revision'] = ( "v010: A Pattern Language (Alexander) as design vocabulary. Common room ceiling +0.6 m " "(190 Ceiling Height Variety) with a door-head transom; study nook and west window-seat alcoves " "at 2.1 m clear (179 Alcoves, 180 Window Place); day-one children's realm wing beside the couple's " "realm (137, 136) with bed alcoves (188) and a covered deck to the verandah (108, 119); step-free elder " "cottage on the court (155, 40, 138); entrance arbour (112); future modules on a 1.2 m grid. " "Concept geometry on unsurveyed terrain; no engineering or approvals.") s['PLAY THE TOUR'] = ('Hover over the 3D view and press Space. 36 chapters, 3 min 00 sec. ' 'Shift+Left Arrow restarts. Pattern-language revision: chapters 33-36.') s['Orientation'] = ('X east, Y north, Z up. Living 12 x 6 m, v010 clear internal roof height north 4.0 m / ' 'south 3.3 m. North veranda 2.4 m. Alcoves 2.1 m clear.') s['Future additions'] = ('v010: elder cottage and children\'s realm are built on day one. Shadows remain for a ' 'north teenager\'s cottage or studio and a north-east second elder cottage or rooms to rent.') text = bpy.data.texts.get('START HERE - PRESS PLAY') if text: text.write('\n\n' + s['PLAY THE TOUR'] + '\n' + s['Pattern language revision']) s.frame_set(start) s.camera = cam detail.hide_viewport = True fast.hide_viewport = False s.render.resolution_x, s.render.resolution_y = 2560, 1440 s.render.resolution_percentage = 100 bpy.ops.wm.save_as_mainfile(filepath=str(output)) print('PATTERN_REVISION_SAVED', output, 'raised', len(raised), 'stretched', len(stretched), 'gap_rows', len(gap_rows), 'south_cut', len(south_cut), 'west_cut', len(west_cut), 'elder_floor', EF, 'cleared_vertices', cleared, 'rebuilt_fast', len(rebuilt), flush=True)