"""GRASS CUTTER - Harbour office: the boathouse next to the dock where the crew buys and upgrades boats. Authored in Blender space: metres, Z up, front = -Y (Unity +Z, faces the dock / sea), pivot at bottom centre on the deck. Footprint 4 x 3 m (x in [-2, 2], y in [-1.5, 1.5]). Run (from project root): blender -b --factory-startup --python ArtSource/Blender/scripts/os_harbour.py """ import sys, os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import common from common import * from os_machines import (box, cz, cx, cy, xf, orient, plate, text, bolt, louvres, lamp, fin, pipe, hose, cyl_between, revm, W, OR, TE, DG, RB, ST, GL, HZ, NV, BR) PI = math.pi Y0 = -1.0 # front wall face Y1 = 1.35 # back wall face ZW = 2.55 # wall top def corrugated_door(P, x0, x1, z0, z1, y): """Roll-up garage door: horizontal slats with a bottom bar and handles.""" n = int((z1 - z0) / 0.16) h = (z1 - z0) / n for k in range(n): za = z0 + k * h P.append(box("slat", x0, x1, y - 0.03, y, za + 0.012, za + h - 0.012, "M_PaintWhite" if k % 2 else W, bev=0.02, segs=2)) P.append(box("dbar", x0, x1, y - 0.05, y, z0, z0 + 0.1, DG, bev=0.02, segs=1)) for hx in (x0 + 0.3, x1 - 0.3): P.append(box("dhandle", hx - 0.09, hx + 0.09, y - 0.08, y - 0.04, z0 + 0.32, z0 + 0.36, ST, bev=0.01, segs=1)) # roller housing on top P.append(cx("roller", 0.13, x0 - 0.04, x1 + 0.04, y - 0.06, z1 + 0.1, DG, v=20)) # hazard frame for (a0, a1, b0, b1) in ((x0 - 0.12, x0, z0, z1 + 0.22), (x1, x1 + 0.12, z0, z1 + 0.22)): P.append(box("dframe", a0, a1, y - 0.06, y + 0.01, b0, b1, OR, bev=0.02, segs=2)) for k in range(int((b1 - b0) / 0.3)): zz = b0 + 0.08 + k * 0.3 P.append(box("dhaz", a0 + 0.01, a1 - 0.01, y - 0.07, y - 0.055, zz, zz + 0.14, HZ, bev=0)) def boat_icon(P, c, facing, s=1.0): """Little boat pictogram on a round teal plate (built facing +Z, then oriented).""" G = [plate("bibase", 0.5 * s, 0.5 * s, 0.014, TE, r=0.25 * s)] z0, z1 = 0.006, 0.016 # ride-on mower pictogram over a row of grass blades G.append(box("bihull", -0.16 * s, 0.12 * s, -0.04 * s, 0.02 * s, z0, z1, "M_PaintWhite", bev=0.006, segs=1)) G.append(box("biseat", 0.02 * s, 0.08 * s, 0.02 * s, 0.09 * s, z0, z1, "M_PaintWhite", bev=0.004, segs=1)) G.append(box("bicol", -0.07 * s, -0.055 * s, 0.02 * s, 0.1 * s, z0, z1, "M_PaintWhite", bev=0.0, segs=1)) for (xx, rr) in ((-0.11, 0.035), (0.1, 0.05)): G.append(cyl("biwheel", rr * s, z1 - z0, (xx * s, -0.06 * s, (z0 + z1) / 2), verts=14, m="M_PaintWhite")) for k in range(7): xx = (-0.18 + k * 0.06) * s G.append(box("biblade", xx, xx + 0.018 * s, -0.17 * s, -0.12 * s + (k % 2) * 0.015 * s, z0, z1, "M_PaintWhite", bev=0.0, segs=1)) o = join(G, "boaticon") P.append(orient(o, facing, c)) def lifebuoy(P, c, facing): """A spare tyre hanging on the wall (the old lifebuoy slot), with an orange rim ring.""" tube = [(0.2 + 0.075 * math.cos(k * PI / 6), 0.06 * math.sin(k * PI / 6)) for k in range(12)] o = revm("buoy", tube, "M_Rubber", segs=32, closed=True) P.append(orient(o, facing, c)) big = [(0.2 + 0.059 * math.cos(k * PI / 6), 0.059 * math.sin(k * PI / 6)) for k in range(12)] rim = [(0.13 + 0.012 * math.cos(k * PI / 3), 0.012 * math.sin(k * PI / 3)) for k in range(6)] P.append(orient(revm("buoyband", rim, OR, segs=24, closed=True), facing, c)) def davit(P, x, y): """Small boat crane on the side of the building.""" P.append(cz("dbase", 0.16, 0.0, 0.14, x, y, DG, v=20, bev=0.02)) P.append(cz("dpost", 0.075, 0.14, 2.9, x, y, OR, v=18)) P.append(cz("dcollar", 0.1, 2.0, 2.1, x, y, DG, v=18, bev=0.01)) # arm reaching out over the water (front) P.append(cyl_between("darm", (x, y, 2.85), (x, y - 1.9, 2.75), 0.055, OR, v=14)) P.append(cyl_between("dbrace", (x, y, 2.2), (x, y - 1.0, 2.78), 0.035, OR, v=12)) P.append(cy("dpulley", 0.08, y - 1.92, y - 1.86, x, 2.7, ST, v=16)) P.append(cz("dcable", 0.008, 1.55, 2.68, x, y - 1.95, DG, v=6)) hook = revm("dhook", [(0, 1.56), (0.05, 1.55), (0.05, 1.5), (0.03, 1.42), (0, 1.4)], [ST, ST, ST, ST], segs=14, loc=(x, y - 1.95, 0)) P.append(hook) P.append(torus("dhookring", 0.05, 0.012, (x, y - 1.95, 1.38), "Y", seg=14, rseg=5, m=ST)) def vault(name, x0, x1, yc, z0, ry, rz, m, n=28): """Half-elliptic barrel vault along X (solid, closed): arc in YZ around (yc, z0).""" arc = [(yc - ry * math.cos(PI * k / n), z0 + rz * math.sin(PI * k / n)) for k in range(n + 1)] verts, faces = [], [] for x in (x0, x1): for (y, z) in arc: verts.append((x, y, z)) m1 = n + 1 for k in range(n): faces.append((k, k + 1, m1 + k + 1, m1 + k)) faces.append(tuple(range(n, -1, -1))) # end cap at x0 faces.append(tuple(range(m1, m1 + m1))) # end cap at x1 faces.append((0, m1, m1 + n, n)) # flat underside o = mesh_obj(name, verts=verts, faces=faces) set_mats(o, m) return o def rib(name, x, yc, z0, ry, rz, w, t, m, n=28): """A flat band following the vault, slightly proud of it.""" verts, faces = [], [] for k in range(n + 1): a = PI * k / n for (rr_y, rr_z) in ((ry, rz), (ry + t, rz + t)): y, z = yc - rr_y * math.cos(a), z0 + rr_z * math.sin(a) verts.append((x - w / 2, y, z)) verts.append((x + w / 2, y, z)) for k in range(n): i, j = 4 * k, 4 * (k + 1) faces.append((i + 2, i + 3, j + 3, j + 2)) # outer faces.append((i + 1, i + 0, j + 0, j + 1)) # inner faces.append((i + 0, i + 2, j + 2, j + 0)) # side -x faces.append((i + 3, i + 1, j + 1, j + 3)) # side +x o = mesh_obj(name, verts=verts, faces=faces) set_mats(o, m) return o def harbour(): P = [] # plinth P.append(box("plinth", -2.0, 2.0, -1.48, 1.48, 0.0, 0.12, DG, bev=0.04, segs=2)) for x in (-1.9, 1.9): for y in (-1.38, 1.38): bolt(P, (x, y, 0.12), "+Z", r=0.022, h=0.015) # walls P.append(box("walls", -1.9, 1.9, Y0, Y1, 0.12, ZW, W, bev=0.08, segs=3)) P.append(box("skirt", -1.92, 1.92, Y0 - 0.02, Y1 + 0.02, 0.12, 0.42, NV, bev=0.04, segs=2)) P.append(box("band", -1.915, 1.915, Y0 - 0.015, Y1 + 0.015, ZW - 0.42, ZW - 0.3, TE, bev=0.01, segs=1)) # barrel-vault roof (orange, ribbed) along X ry = (Y1 - Y0) * 0.5 + 0.1 rz = 0.62 yc = (Y0 + Y1) * 0.5 P.append(vault("roof", -2.0, 2.0, yc, ZW - 0.06, ry, rz, OR)) for k in range(7): P.append(rib("rib", -1.8 + k * 0.6, yc, ZW - 0.06, ry, rz, 0.06, 0.025, "M_PaintWhite")) for s_ in (-1, 1): P.append(rib("roofedge", s_ * 1.98, yc, ZW - 0.06, ry, rz, 0.08, 0.04, W)) P.append(box("eave", -2.0, 2.0, Y0 - 0.16, Y0 + 0.05, ZW - 0.1, ZW + 0.02, W, bev=0.04, segs=2)) # garage door (left two thirds of the front) corrugated_door(P, -1.62, 0.18, 0.12, 2.0, Y0) boat_icon(P, (-0.72, Y0 - 0.04, 1.35), "-Y", s=1.2) # office window + counter (right of the front) P.append(box("wframe", 0.5, 1.72, Y0 - 0.06, Y0 + 0.02, 0.98, 2.06, DG, bev=0.03, segs=2)) P.append(box("glass", 0.56, 1.66, Y0 - 0.07, Y0 - 0.05, 1.04, 2.0, GL, bev=0.01, segs=1)) P.append(box("wmullion", 1.09, 1.13, Y0 - 0.09, Y0 - 0.05, 1.04, 2.0, DG, bev=0.006, segs=1)) P.append(box("counter", 0.42, 1.8, Y0 - 0.32, Y0 + 0.02, 0.92, 1.0, NV, bev=0.03, segs=2)) P.append(box("countertop", 0.4, 1.82, Y0 - 0.34, Y0 + 0.02, 1.0, 1.04, ST, bev=0.015, segs=1)) for xx in (0.55, 1.67): P.append(box("cbracket", xx - 0.03, xx + 0.03, Y0 - 0.28, Y0, 0.72, 0.92, DG, bev=0.01, segs=1)) # awning over the window # awning over the window (built around its own centre, then tilted down toward the front) aw = box("awning", -0.73, 0.73, -0.25, 0.25, -0.03, 0.03, OR, bev=0.03, segs=2) P.append(xf(aw, rx=-0.22, t=(1.11, Y0 - 0.25, 2.2))) for k in range(6): xx = -0.67 + k * 0.24 st = box("awnstripe", xx, xx + 0.12, -0.25, 0.25, 0.03, 0.04, "M_PaintWhite", bev=0) P.append(xf(st, rx=-0.22, t=(1.11, Y0 - 0.25, 2.2))) # little screen + bell on the counter P.append(box("kiosk", 1.36, 1.62, Y0 - 0.22, Y0 - 0.12, 1.04, 1.34, DG, bev=0.02, segs=2)) P.append(box("kscreen", 1.39, 1.59, Y0 - 0.235, Y0 - 0.22, 1.1, 1.3, "M_Screen", bev=0.006, segs=1)) P.append(revm("bell", [(0, 1.04), (0.06, 1.04), (0.06, 1.06), (0.045, 1.09), (0.02, 1.11), (0, 1.12)], [BR, BR, BR, BR, BR], segs=16, loc=(0.75, Y0 - 0.18, 0))) # name sign on the roof front for sx in (-0.7, 0.7): P.append(box("signpost", sx - 0.04, sx + 0.04, Y0 + 0.08, Y0 + 0.16, ZW - 0.1, ZW + 0.4, DG, bev=0.01, segs=1)) sg = plate("sign", 2.2, 0.5, 0.06, NV, r=0.12) P.append(orient(sg, "-Y", (0, Y0 + 0.02, ZW + 0.55))) sb = plate("signborder", 2.28, 0.58, 0.04, OR, r=0.15) P.append(orient(sb, "-Y", (0, Y0 + 0.06, ZW + 0.55))) t = text("label", "GARAGE", 0.3, "M_PaintWhite") P.append(orient(t, "-Y", (0.12, Y0 - 0.05, ZW + 0.55))) # gear badge on the sign an = torus("gear", 0.075, 0.022, (0, 0, 0), "Z", seg=16, rseg=6, m=OR) P.append(orient(an, "-Y", (-0.78, Y0 - 0.02, ZW + 0.55))) # side wall details: lifebuoy, louvres, pipes lifebuoy(P, (-1.95, 0.1, 1.5), "-X") louvres(P, (1.92, 0.5, 1.3), "+X", 0.6, 5) louvres(P, (-0.4, Y1 + 0.02, 1.6), "+Y", 0.9, 5) pipe(P, [(1.3, Y1 + 0.08, 0.12), (1.3, Y1 + 0.08, 2.2), (0.9, Y1 + 0.08, 2.2)], 0.05, ST, rad=0.14, segs=10, n=4) # bollards at the front corners with a rope coil for x in (-1.78, 1.86): P.append(cz("bollard", 0.1, 0.12, 0.5, x, Y0 - 0.32, DG, v=18, bev=0.02)) P.append(cz("bollcap", 0.13, 0.5, 0.56, x, Y0 - 0.32, DG, v=18, bev=0.02)) for k in range(3): P.append(torus("rope", 0.17 - k * 0.012, 0.022, (-1.78, Y0 - 0.32, 0.18 + k * 0.04), "Z", seg=20, rseg=6, m="M_Rope")) # davit crane at the right side davit(P, 1.86, Y0 + 0.3) # antenna + lamp on the roof P.append(cz("antenna", 0.012, ZW + 0.3, ZW + 1.3, -1.5, 0.6, ST, v=8)) P.append(cz("antball", 0.035, ZW + 1.28, ZW + 1.34, -1.5, 0.6, "M_LightRed", v=10)) lamp(P, 1.55, 0.2, ZW + 0.45) fin(P, "Body", uv=1.0, haz=3.0) empty("Counter", (1.1, Y0 - 0.6, 0.0)) return dict(elev=22, azim=-38) if __name__ == "__main__": reset() random.seed(7) res = harbour() or {} finish("SM_Harbour", **res)