"""GRASS CUTTER - rig structures: deck tile, launch pad, rocket, launch lever, dock, ladder, crew cabin, terminal. Authored directly in BLENDER coordinates (meters, Z-up, asset front = -Y = Unity +Z, Unity +X = Blender -X). Deck surface is z = 0 in every model, sea level in game is z = -1.2. Run from the project root: blender -b --factory-startup --python ArtSource/Blender/scripts/os_rig.py -- [SM_Name ...] [--extra] --extra additionally renders back/top views into $OS_PREVIEW_EXTRA (default: system temp dir). """ import sys, os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from common import * import common DEG = math.radians # UV scale (UV units per meter) per material for the box projection, optional offset UVS = { "M_Deck": 0.5, "M_HullWhite": 1.0, "M_DeckEdge": 1.6, "M_Hazard": 1.6, "M_WoodDeck": 0.5, "M_Steel": 1.0, "M_Metal": 1.0, "M_Rust": 0.5, } # ======================================================================= primitives def M4(rot=(0, 0, 0), loc=(0, 0, 0)): return Matrix.Translation(Vector(loc)) @ Euler([DEG(a) for a in rot]).to_matrix().to_4x4() def xf(o, rot=(0, 0, 0), loc=(0, 0, 0)): """Bake rotation (deg, XYZ euler) then translation into the mesh.""" apply_xform(o) o.data.transform(M4(rot, loc)) o.data.update() return o def xfm(objs, rot=(0, 0, 0), loc=(0, 0, 0)): for o in objs: xf(o, rot, loc) return objs def bx(name, x0, x1, y0, y1, z0, z1, m, bev=0.0, segs=2): size = (x1 - x0, y1 - y0, z1 - z0) c = ((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2) if bev > 0: return rbox(name, size, c, bevel=bev, segs=segs, m=m) return cube(name, size, c, m) def cy(name, r, h, c, m, axis="Z", v=16, bev=0.0, segs=2, r2=None, cap=True): return cyl(name, r, h, loc=c, axis=axis, verts=v, bevel=bev, segs=segs, m=m, r2=r2, cap=cap) def tri_ngons(o): bm = bmesh.new() bm.from_mesh(o.data) ng = [f for f in bm.faces if len(f.verts) > 4] if ng: bmesh.ops.triangulate(bm, faces=ng, quad_method="BEAUTY", ngon_method="BEAUTY") bm.to_mesh(o.data) bm.free() return o def puff(o, w, segs=2, ang=35): b = o.modifiers.new("bev", "BEVEL") b.width = w b.segments = segs b.limit_method = "ANGLE" b.angle_limit = DEG(ang) b.miter_outer = "MITER_ARC" bake(o) return o def prism(name, pts, plane, d0, d1, m, bev=0.0, segs=2, ang=35): """2D polygon extruded. plane 'XY': pts (x, y) extruded along Z (d = z); 'XZ': (x, z) along Y; 'YZ': (y, z) along X.""" def P(a, b, d): return {"XY": (a, b, d), "XZ": (a, d, b), "YZ": (d, a, b)}[plane] bm = bmesh.new() f0 = [bm.verts.new(P(a, b, d0)) for a, b in pts] f1 = [bm.verts.new(P(a, b, d1)) for a, b in pts] bm.faces.new(f0) bm.faces.new(list(reversed(f1))) n = len(pts) for i in range(n): j = (i + 1) % n bm.faces.new((f0[i], f0[j], f1[j], f1[i])) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) if bev > 0: puff(o, bev, segs, ang) return tri_ngons(o) def rr(cx, cy_, w, h, r, n=3): """Rounded rectangle polygon, CCW.""" r = max(1e-3, min(r, w / 2 - 1e-4, h / 2 - 1e-4)) pts = [] for (ox, oy, a0) in ((w / 2 - r, -h / 2 + r, -90), (w / 2 - r, h / 2 - r, 0), (-w / 2 + r, h / 2 - r, 90), (-w / 2 + r, -h / 2 + r, 180)): for i in range(n + 1): a = DEG(a0 + 90.0 * i / n) pts.append((cx + ox + r * math.cos(a), cy_ + oy + r * math.sin(a))) return pts def rr_ring(name, cx, cy_, w, h, r, z0, z1, t_out, t_in, m, n=4): """Band around a rounded rectangle (outer offset t_out, inner offset t_in), z0..z1.""" po = rr(cx, cy_, w + 2 * t_out, h + 2 * t_out, r + t_out, n) pi_ = rr(cx, cy_, w - 2 * t_in, h - 2 * t_in, max(0.002, r - t_in), n) bm = bmesh.new() o0 = [bm.verts.new((x, y, z0)) for x, y in po] o1 = [bm.verts.new((x, y, z1)) for x, y in po] i0 = [bm.verts.new((x, y, z0)) for x, y in pi_] i1 = [bm.verts.new((x, y, z1)) for x, y in pi_] N = len(po) for k in range(N): j = (k + 1) % N bm.faces.new((o0[k], o0[j], o1[j], o1[k])) bm.faces.new((i0[j], i0[k], i1[k], i1[j])) bm.faces.new((o1[k], o1[j], i1[j], i1[k])) bm.faces.new((o0[j], o0[k], i0[k], i0[j])) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) return o def fillet(P, r, n, closed=False): out = [] if closed else [P[0]] idx = range(len(P)) if closed else range(1, len(P) - 1) for i in idx: p0, p1, p2 = P[i - 1], P[i], P[(i + 1) % len(P)] a, b = p0 - p1, p2 - p1 la, lb = a.length, b.length if la < 1e-6 or lb < 1e-6: out.append(p1.copy()) continue ang = a.angle(b) if ang > math.pi - 1e-3: out.append(p1.copy()) continue t = min(r / math.tan(ang / 2), la * 0.5, lb * 0.5) A = p1 + a.normalized() * t Bp = p1 + b.normalized() * t for k in range(n + 1): s = k / n out.append(A * (1 - s) ** 2 + p1 * (2 * (1 - s) * s) + Bp * (s * s)) if not closed: out.append(P[-1]) return out def pipe(name, pts, r, m, segs=10, fil=0.0, fn=4, caps=True, closed=False): """Round tube swept along a polyline (optionally filleted corners), parallel-transport frames.""" P = [Vector(p) for p in pts] if fil > 0 and len(P) > 2: P = fillet(P, fil, fn, closed) Q = [P[0]] for p in P[1:]: if (p - Q[-1]).length > 1e-5: Q.append(p) if closed and (Q[0] - Q[-1]).length < 1e-5: Q.pop() P = Q N = len(P) T = [] for i in range(N): d = (P[(i + 1) % N] - P[i - 1]) if closed else (P[min(i + 1, N - 1)] - P[max(i - 1, 0)]) T.append(d.normalized()) ref = Vector((0, 0, 1)) if abs(T[0].z) < 0.9 else Vector((1, 0, 0)) nrm = T[0].cross(ref).normalized() bm = bmesh.new() rings = [] for i in range(N): t = T[i] nrm = (nrm - t * nrm.dot(t)).normalized() b = t.cross(nrm) rings.append([bm.verts.new(P[i] + (nrm * math.cos(2 * math.pi * k / segs) + b * math.sin(2 * math.pi * k / segs)) * r) for k in range(segs)]) pairs = list(zip(rings, rings[1:])) + ([(rings[-1], rings[0])] if closed else []) for a, c in pairs: for k in range(segs): bm.faces.new((a[k], a[(k + 1) % segs], c[(k + 1) % segs], c[k])) if caps and not closed: bm.faces.new(list(reversed(rings[0]))) bm.faces.new(rings[-1]) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) return o def annulus(name, r0, r1, z0, z1, m, segs=32, a0=0.0, a1=360.0, c=(0.0, 0.0)): """Annular sector solid around Z (angles in degrees from +X, CCW).""" full = abs(a1 - a0) >= 359.9 n = segs if full else segs + 1 bm = bmesh.new() rows = [] for i in range(n): a = DEG(a0 + (a1 - a0) * i / segs) ca, sa = math.cos(a), math.sin(a) rows.append([bm.verts.new((c[0] + r * ca, c[1] + r * sa, z)) for (r, z) in ((r0, z0), (r1, z0), (r1, z1), (r0, z1))]) for i in range(n if full else n - 1): A, Bq = rows[i], rows[(i + 1) % n] for k in range(4): bm.faces.new((A[k], Bq[k], Bq[(k + 1) % 4], A[(k + 1) % 4])) if not full: bm.faces.new(rows[0]) bm.faces.new(list(reversed(rows[-1]))) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) return o def arc_patch(name, R, a0, a1, z0, z1, m, n=16): """Curved decal patch on a cylinder of radius R around Z; UV 0..1 (u along increasing angle = viewer's right).""" bm = bmesh.new() uvl = bm.loops.layers.uv.new("UVMap") rows = [] for i in range(n + 1): a = DEG(a0 + (a1 - a0) * i / n) rows.append([bm.verts.new((R * math.cos(a), R * math.sin(a), z)) for z in (z0, z1)]) for i in range(n): f = bm.faces.new((rows[i][0], rows[i + 1][0], rows[i + 1][1], rows[i][1])) for l, uv in zip(f.loops, ((i / n, 0), ((i + 1) / n, 0), ((i + 1) / n, 1), (i / n, 1))): l[uvl].uv = uv o = mesh_obj(name, bm) set_mats(o, m) o["uvkeep"] = True return o def quad(name, c0, c1, c2, c3, m): """Single quad (BL, BR, TR, TL as seen by the viewer) with UV exactly 0..1.""" bm = bmesh.new() uvl = bm.loops.layers.uv.new("UVMap") f = bm.faces.new([bm.verts.new(c) for c in (c0, c1, c2, c3)]) for l, uv in zip(f.loops, ((0, 0), (1, 0), (1, 1), (0, 1))): l[uvl].uv = uv o = mesh_obj(name, bm) set_mats(o, m) o["uvkeep"] = True return o def pill(name, r, L, c, m, axis="Z", seg=16, cr=4): """Capsule of total length L (along axis), radius r, centred at c.""" h = max(0.0, L / 2 - r) prof = [(0.0, -h - r)] for k in range(1, cr + 1): t = k / cr * math.pi / 2 prof.append((r * math.sin(t), -h - r * math.cos(t))) for k in range(cr if h > 1e-4 else cr - 1, 0, -1): t = k / cr * math.pi / 2 prof.append((r * math.sin(t), h + r * math.cos(t))) prof.append((0.0, h + r)) return revolve(name, prof, segs=seg, m=m, loc=c, close_top=False, axis=axis) def dome(name, r, c, m, k=1.0, seg=16, rings=6): prof = [(r * math.cos(i / rings * math.pi / 2), k * r * math.sin(i / rings * math.pi / 2)) for i in range(rings + 1)] prof[-1] = (0.0, k * r) return revolve(name, prof, segs=seg, m=m, loc=c, close_top=False, close_bottom=True) def chaikin(pts, it=2): for _ in range(it): out = [] n = len(pts) for i in range(n): a, b = pts[i], pts[(i + 1) % n] out.append((0.75 * a[0] + 0.25 * b[0], 0.75 * a[1] + 0.25 * b[1])) out.append((0.25 * a[0] + 0.75 * b[0], 0.25 * a[1] + 0.75 * b[1])) pts = out return pts def mat_by(o, fn): """Assign materials per face: fn(center: Vector, normal: Vector) -> material name.""" me = o.data names, idx = [], [] for p in me.polygons: nm = fn(Vector(p.center), Vector(p.normal)) if nm not in names: names.append(nm) idx.append(names.index(nm)) me.materials.clear() for nm in names: me.materials.append(mat(nm)) for p, i in zip(me.polygons, idx): p.material_index = i return o def fit01(o): """Box-project the part and normalise its UVs into 0..1 (small screens / decals that must stay inside the texture).""" me = o.data bm = bmesh.new() bm.from_mesh(me) uvl = bm.loops.layers.uv.verify() raw = [] for f in bm.faces: n = f.normal ax = max(range(3), key=lambda i: abs(n[i])) for l in f.loops: p = l.vert.co if ax == 0: uv = ((p.y if n.x > 0 else -p.y), p.z) elif ax == 1: uv = ((-p.x if n.y > 0 else p.x), p.z) else: uv = (p.x, (p.y if n.z > 0 else -p.y)) raw.append((l, uv)) us = [uv[0] for _, uv in raw] vs = [uv[1] for _, uv in raw] u0, u1, v0, v1 = min(us), max(us), min(vs), max(vs) for l, (u, v) in raw: l[uvl].uv = ((u - u0) / max(1e-6, u1 - u0), (v - v0) / max(1e-6, v1 - v0)) bm.to_mesh(me) bm.free() o["uvkeep"] = True return o def bolt(name, c, axis="Z", r=0.03, h=0.025, m="M_Steel"): return cy(name, r, h, c, m, axis=axis, v=6) def rivet(name, c, r=0.025, m="M_Steel"): return sphere(name, r, loc=c, seg=8, rings=4, m=m) def window_round(P, c, axis, sign, R, frame_m="M_DarkGrey", bolts=6): """Round window on a wall whose outward normal is +-axis ('X' or 'Y'): rubber frame torus, navy backing, glass bubble.""" ax = {"X": 0, "Y": 1}[axis] def off(d): p = list(c) p[ax] += sign * d return tuple(p) P.append(torus("wframe", R + 0.03, 0.065, loc=off(0.02), axis=axis, seg=28, rseg=8, m=frame_m)) P.append(cy("wback", R, 0.08, off(-0.02), "M_Navy", axis=axis, v=24)) sc = [1, 1, 1] sc[ax] = 0.22 P.append(sphere("wglass", R - 0.01, loc=off(0.0), seg=24, rings=12, m="M_Glass", scale=tuple(sc))) for k in range(bolts): a = 2 * math.pi * (k + 0.5) / bolts p = list(off(0.075)) u, v = [i for i in range(3) if i != ax] p[u] += (R + 0.03) * math.cos(a) p[v] += (R + 0.03) * math.sin(a) P.append(rivet("wbolt", tuple(p), r=0.018)) # ======================================================================= finishing def fin(P, name, uv=1.0, ang=40, ms=None, origin=None): """Join parts into one mesh; per-material box UV (parts flagged 'uvkeep' keep their UVs); smooth by angle.""" sc = dict(UVS) sc.update(ms or {}) bm = bmesh.new() uvl = bm.loops.layers.uv.new("UVMap") mats = [] for o in [p for p in P if p is not None]: apply_xform(o) src = bmesh.new() src.from_mesh(o.data) src.normal_update() suv = src.loops.layers.uv.active if o.get("uvkeep") else None names = list(o.data.materials) idx = [] for mm in names: if mm not in mats: mats.append(mm) idx.append(mats.index(mm)) vm = {v: bm.verts.new(v.co) for v in src.verts} for f in src.faces: try: nf = bm.faces.new([vm[v] for v in f.verts]) except ValueError: continue mi = f.material_index if f.material_index < len(idx) else 0 nf.material_index = idx[mi] if idx else 0 mname = names[mi].name if names and names[mi] else "" s = sc.get(mname, uv) offs = (0.0, 0.0) if isinstance(s, tuple): s, offs = s n = f.normal ax = max(range(3), key=lambda i: abs(n[i])) for ls, ln in zip(f.loops, nf.loops): if suv is not None: ln[uvl].uv = ls[suv].uv continue p = ls.vert.co if ax == 0: u, v = (p.y if n.x > 0 else -p.y), p.z elif ax == 1: u, v = (-p.x if n.y > 0 else p.x), p.z else: u, v = p.x, (p.y if n.z > 0 else -p.y) ln[uvl].uv = (u * s + offs[0], v * s + offs[1]) src.free() d = o.data bpy.data.objects.remove(o) if d.users == 0: bpy.data.meshes.remove(d) me = bpy.data.meshes.new(name) bm.normal_update() bm.to_mesh(me) bm.free() for mm in mats: me.materials.append(mm) ob = link(bpy.data.objects.new(name, me)) smooth(ob, ang) if origin is not None: set_origin(ob, origin) return ob # ======================================================================= 1. deck tile def rail_parts(yc=-2.86, xe=2.7): Q = [pipe("top", [(-xe, yc, 0.03), (-xe, yc, 1.0), (xe, yc, 1.0), (xe, yc, 0.03)], 0.05, "M_PaintOrange", segs=8, fil=0.24, fn=4)] Q.append(pipe("mid", [(-xe, yc, 0.56), (xe, yc, 0.56)], 0.032, "M_PaintWhite", segs=8)) for x in (-0.9, 0.9): Q.append(cy("post", 0.042, 0.97, (x, yc, 0.5), "M_PaintWhite", v=8)) Q.append(cy("collar", 0.052, 0.07, (x, yc, 0.95), "M_PaintOrange", v=8)) for x in (-xe, -0.9, 0.9, xe): Q.append(bx("flange", x - 0.09, x + 0.09, yc - 0.08, yc + 0.08, 0.0, 0.04, "M_DarkGrey", bev=0.016, segs=1)) Q.append(bx("toe", -xe + 0.07, xe - 0.07, yc - 0.016, yc + 0.016, 0.07, 0.19, "M_PaintWhite", bev=0.012, segs=1)) return Q def deck_tile(): P = [] # slab: white hull sides P.append(bx("slab", -2.97, 2.97, -2.97, 2.97, -0.45, -0.1, "M_HullWhite", bev=0.06, segs=2)) # hazard band (sides) with dark lips for s in (-1, 1): for (a, b, m, z0, z1) in ((0.012, 0.012, "M_DeckEdge", -0.34, -0.22),): P.append(bx("band", -2.6, 2.6, s * 2.97 - a, s * 2.97 + b, z0, z1, m)) P.append(bx("band", s * 2.97 - a, s * 2.97 + b, -2.6, 2.6, z0, z1, m)) # orange coaming rim, flush with the deck w = 0.2 for s in (-1, 1): P.append(bx("rim", -2.8, 2.8, (2.8 if s > 0 else -3.0), (3.0 if s > 0 else -2.8), -0.17, 0.0, "M_PaintOrange", bev=0.035, segs=2)) P.append(bx("rim", (2.8 if s > 0 else -3.0), (3.0 if s > 0 else -2.8), -2.8, 2.8, -0.17, 0.0, "M_PaintOrange", bev=0.035, segs=2)) # rubber corner bumpers for sx in (-1, 1): for sy in (-1, 1): x0, x1 = sorted((sx * 3.0, sx * 2.56)) y0, y1 = sorted((sy * 3.0, sy * 2.56)) P.append(bx("corner", x0, x1, y0, y1, -0.42, 0.012, "M_DarkGrey", bev=0.07, segs=2)) # dark tray + 3x3 deck plates (one plate == one UV tile) P.append(bx("tray", -2.79, 2.79, -2.79, 2.79, -0.12, -0.03, "M_DarkGrey")) L = 5.6 / 3 g = 0.022 for i in range(3): for j in range(3): x0 = -2.8 + i * L y0 = -2.8 + j * L P.append(bx("plate", x0 + g, x0 + L - g, y0 + g, y0 + L - g, -0.08, 0.0, "M_Deck", bev=0.016, segs=1)) # junction fasteners for x in (-L / 2, L / 2): for y in (-L / 2, L / 2): P.append(cy("fast", 0.075, 0.014, (x, y, 0.002), "M_DarkGrey", v=8)) # rim bolts for t in (-1.8, 1.8): for (x, y) in ((t, 2.9), (t, -2.9), (2.9, t), (-2.9, t)): P.append(bolt("rbolt", (x, y, 0.004), r=0.032, h=0.018)) # round hatch (front-left plate) hx, hy = -1.87, -1.87 P.append(annulus("hring", 0.3, 0.39, -0.012, 0.012, "M_DarkGrey", segs=20, c=(hx, hy))) P.append(cy("hlid", 0.305, 0.018, (hx, hy, 0.0), "M_Steel", v=20)) P.append(pipe("hhandle", [(hx - 0.13, hy, 0.0), (hx - 0.13, hy, 0.04), (hx + 0.13, hy, 0.04), (hx + 0.13, hy, 0.0)], 0.017, "M_PaintOrange", segs=6, fil=0.03, fn=2)) for k in range(4): a = 2 * math.pi * (k + 0.5) / 4 P.append(bolt("hbolt", (hx + 0.345 * math.cos(a), hy + 0.345 * math.sin(a), 0.014), r=0.022, h=0.012)) # square access hatch (back-right plate) sx_, sy_ = 1.87, 1.87 P.append(bx("sqframe", sx_ - 0.45, sx_ + 0.45, sy_ - 0.35, sy_ + 0.35, -0.02, 0.006, "M_DarkGrey", bev=0.02, segs=1)) P.append(bx("sqlid", sx_ - 0.4, sx_ + 0.4, sy_ - 0.3, sy_ + 0.3, -0.01, 0.014, "M_Steel", bev=0.012, segs=1)) P.append(bx("sqhaz", sx_ - 0.36, sx_ + 0.36, sy_ - 0.27, sy_ - 0.2, 0.0, 0.017, "M_DeckEdge")) for (dx, dy) in ((-0.34, -0.25), (0.34, -0.25), (-0.34, 0.25), (0.34, 0.25)): P.append(bolt("sqbolt", (sx_ + dx, sy_ + dy, 0.016), r=0.022, h=0.012)) # drain slots near the -X edge for k in range(5): y = -0.4 + k * 0.2 P.append(bx("drain", -2.62, -2.22, y - 0.035, y + 0.035, -0.02, 0.004, "M_Navy")) P.append(bx("drainf", -2.66, -2.18, -0.5, 0.5, -0.02, 0.002, "M_DarkGrey", bev=0.02, segs=1)) # cross beams under the slab for y in (-1.85, 1.85): P.append(bx("beam", -2.45, 2.45, y - 0.13, y + 0.13, -0.66, -0.44, "M_DarkGrey", bev=0.03, segs=1)) fin(P, "Body", uv=1.0, ang=40, ms={"M_Deck": (1.0 / L, (0.5, 0.5))}) # stilts: four steel legs per tile down to concrete footings in the meadow (ground is 1.2 m below the deck) F = [] for x in (-1.85, 1.85): for y in (-1.85, 1.85): F.append(cy("stilt", 0.11, 0.62, (x, y, -0.95), "M_Steel", v=10)) F.append(cy("collar", 0.15, 0.08, (x, y, -0.68), "M_PaintOrange", v=10, bev=0.015, segs=1)) F.append(bx("footing", x - 0.3, x + 0.3, y - 0.3, y + 0.3, -1.32, -1.18, "M_Concrete", bev=0.03, segs=1)) F.append(cy("baseplate", 0.2, 0.04, (x, y, -1.17), "M_DarkGrey", v=10)) for x in (-1.85, 1.85): F.append(pipe("braceA", [(x, -1.75, -0.7), (x, 1.75, -1.1)], 0.035, "M_Steel", segs=6)) F.append(pipe("braceB", [(x, 1.75, -0.7), (x, -1.75, -1.1)], 0.035, "M_Steel", segs=6)) fin(F, "Floats", uv=1.0, ang=50) # railings (each spans its full edge, inset 0.14) for nm, ang in (("Rail_N", 0), ("Rail_S", 180), ("Rail_E", -90), ("Rail_W", 90)): o = fin(rail_parts(), nm, uv=1.0, ang=45) xf(o, rot=(0, 0, ang)) p = M4((0, 0, ang)) @ Vector((0, -2.86, 0)) set_origin(o, (round(p.x, 4), round(p.y, 4), 0.0)) return dict(elev=32, azim=-35) # ======================================================================= 2. launch pad PAD_C = (0.0, 0.35) PAD_TOP = 0.58 def launch_pad(): P = [] C = PAD_C zt = 0.25 # base slab P.append(bx("base", -2.95, 2.95, -1.8, 2.95, 0.0, 0.22, "M_HullWhite", bev=0.06, segs=2)) P.append(bx("top", -2.82, 2.82, -1.67, 2.82, 0.17, zt, "M_Deck", bev=0.02, segs=1)) P.append(bx("fhaz", -2.75, 2.75, -1.812, -1.79, 0.05, 0.16, "M_DeckEdge")) for s in (-1, 1): P.append(bx("sstripe", s * 2.95 - 0.01, s * 2.95 + 0.01, -1.6, 2.75, 0.07, 0.15, "M_PaintOrange")) P.append(bx("bstripe", -2.75, 2.75, 2.94, 2.96, 0.07, 0.15, "M_PaintOrange")) # pad ring prof = [(2.1, zt - 0.03), (2.12, zt + 0.04), (2.12, zt + 0.15), (2.11, zt + 0.24), (2.07, zt + 0.3), (1.99, zt + 0.33), (1.9, zt + 0.335), (1.47, zt + 0.335), (1.41, zt + 0.32), (1.375, zt + 0.27), (1.37, zt + 0.0)] ring = revolve("ring", prof, segs=56, m="M_HullWhite", loc=(C[0], C[1], 0), close_top=False) def ring_m(c, n): r = math.hypot(c.x - C[0], c.y - C[1]) if n.z > 0.9 and r < 1.95: return "M_DarkGrey" if r < 1.43: return "M_Steel" if zt + 0.04 < c.z < zt + 0.15: return "M_PaintOrange" return "M_HullWhite" mat_by(ring, ring_m) P.append(ring) # orange landing dashes on the ring top for k in range(16): a = 360.0 * k / 16 P.append(annulus("dash", 1.62, 1.76, PAD_TOP - 0.005, PAD_TOP + 0.008, "M_PaintOrange", segs=3, a0=a - 7, a1=a + 7, c=C)) # skirt vents for k in range(10): a = 360.0 * (k + 0.5) / 10 P.append(annulus("vent", 2.1, 2.13, zt + 0.165, zt + 0.225, "M_DarkGrey", segs=3, a0=a - 6, a1=a + 6, c=C)) # skirt bolts for k in range(16): a = 2 * math.pi * k / 16 P.append(bolt("sbolt", (C[0] + 2.1 * math.cos(a), C[1] + 2.1 * math.sin(a), zt + 0.012), r=0.03, h=0.03)) # pit floor, flame deflector cone, grate P.append(cy("pit", 1.38, 0.04, (C[0], C[1], zt + 0.02), "M_DarkGrey", v=48)) P.append(revolve("deflector", [(1.1, zt + 0.04), (0.7, zt + 0.07), (0.35, zt + 0.15), (0.12, zt + 0.21), (0.0, zt + 0.22)], segs=24, m="M_Steel", loc=(C[0], C[1], 0), close_top=False)) gz0, gz1 = zt + 0.19, zt + 0.25 for k in range(16): bar = bx("gbar", 0.3, 1.375, -0.03, 0.03, gz0, gz1, "M_Steel", bev=0.01, segs=1) xf(bar, rot=(0, 0, 360.0 * k / 16 + 11.25), loc=(C[0], C[1], 0)) P.append(bar) for (r0, r1) in ((0.24, 0.32), (0.66, 0.71), (1.02, 1.07)): P.append(annulus("gring", r0, r1, gz0, gz1, "M_DarkGrey", segs=32, c=C)) # hold-down clamps (cardinal directions; rocket fins sit on the diagonals) clamp_pts = chaikin([(1.55, PAD_TOP - 0.02), (1.98, PAD_TOP - 0.02), (1.95, 1.3), (1.78, 2.0), (1.34, 2.0), (1.34, 1.78), (1.56, 1.62)], 1) for k in range(4): a = 90.0 * k Kp = [prism("clamp", clamp_pts, "XZ", -0.12, 0.12, "M_PaintOrange", bev=0.035, segs=2, ang=40), bx("cpad", 1.29, 1.35, -0.1, 0.1, 1.79, 1.97, "M_Rubber", bev=0.02, segs=1), cy("cpin", 0.05, 0.3, (1.68, 0, 1.0), "M_DarkGrey", axis="Y", v=12), bx("cbase", 1.5, 2.02, -0.17, 0.17, PAD_TOP - 0.03, PAD_TOP + 0.06, "M_DarkGrey", bev=0.025, segs=1)] xfm(Kp, rot=(0, 0, a), loc=(C[0], C[1], 0)) P += Kp # ring warning studs for k in range(8): a = 2 * math.pi * (k + 0.5) / 8 p = (C[0] + 1.86 * math.cos(a), C[1] + 1.86 * math.sin(a), PAD_TOP) P.append(cy("studb", 0.075, 0.03, (p[0], p[1], p[2] + 0.01), "M_DarkGrey", v=12)) P.append(dome("stud", 0.055, (p[0], p[1], p[2] + 0.025), "M_LightRed", k=0.7, seg=10, rings=3)) # ---- service gantry tower (back-right corner) T = (2.33, 2.37) hw = 0.47 lv = [zt, 1.7, 3.15, 4.6, 6.05, 7.3] for sx in (-1, 1): for sy in (-1, 1): x, y = T[0] + sx * hw, T[1] + sy * hw P.append(bx("col", x - 0.09, x + 0.09, y - 0.09, y + 0.09, zt, 7.32, "M_HullWhite", bev=0.04, segs=2)) P.append(bx("colfoot", x - 0.14, x + 0.14, y - 0.14, y + 0.14, zt, zt + 0.09, "M_DarkGrey", bev=0.025, segs=1)) for z in lv[1:]: P.append(rr_ring("lvl", T[0], T[1], 2 * hw + 0.18, 2 * hw + 0.18, 0.09, z - 0.07, z + 0.07, 0.0, 0.11, "M_PaintOrange", n=2)) # enclosed service bay at the bottom of the tower (door faces -Y) P.append(bx("tbay", T[0] - hw + 0.02, T[0] + hw - 0.02, T[1] - hw + 0.02, T[1] + hw - 0.02, zt, lv[1] - 0.05, "M_HullWhite", bev=0.05, segs=2)) P.append(bx("tbays", T[0] - hw + 0.01, T[0] + hw - 0.01, T[1] - hw + 0.01, T[1] + hw - 0.01, zt + 0.12, zt + 0.22, "M_PaintOrange")) P.append(bx("tdoor", T[0] - 0.24, T[0] + 0.12, T[1] - hw - 0.0, T[1] - hw + 0.04, zt + 0.02, zt + 1.22, "M_DarkGrey", bev=0.04, segs=2)) P.append(bx("tdwin", T[0] - 0.16, T[0] + 0.04, T[1] - hw - 0.012, T[1] - hw + 0.0, zt + 0.82, zt + 1.06, "M_Glass", bev=0.02, segs=1)) P.append(bx("tdlamp", T[0] - 0.12, T[0] + 0.0, T[1] - hw - 0.03, T[1] - hw + 0.0, zt + 1.28, zt + 1.34, "M_Emissive", bev=0.01, segs=1)) P.append(bx("tsign", -hw + T[0] + 0.02, T[0] - hw + 0.04, T[1] - 0.25, T[1] + 0.25, zt + 0.5, zt + 1.0, "M_DeckEdge")) # cross bracing on the 4 faces for i in range(len(lv) - 1): z0, z1 = lv[i] + 0.08, lv[i + 1] - 0.08 for (ax, s) in (("x", -1), ("x", 1), ("y", -1), ("y", 1)): for flip in (0, 1): a0, a1 = (-hw, hw) if not flip else (hw, -hw) if ax == "x": p0 = (T[0] + s * hw, T[1] + a0, z0) p1 = (T[0] + s * hw, T[1] + a1, z1) else: p0 = (T[0] + a0, T[1] + s * hw, z0) p1 = (T[0] + a1, T[1] + s * hw, z1) P.append(pipe("brace", [p0, p1], 0.024, "M_DarkGrey", segs=6)) # grating floors at arm levels for z in (4.6, 6.05): P.append(bx("floor", T[0] - hw, T[0] + hw, T[1] - hw, T[1] + hw, z + 0.02, z + 0.05, "M_Steel")) # roof + beacons + antenna P.append(bx("roof", T[0] - 0.58, T[0] + 0.58, T[1] - 0.55, T[1] + 0.55, 7.3, 7.46, "M_PaintOrange", bev=0.06, segs=2)) for (dx, dy) in ((-0.4, -0.4), (0.4, 0.4)): P.append(cy("bbase", 0.09, 0.08, (T[0] + dx, T[1] + dy, 7.48), "M_DarkGrey", v=12, bev=0.015, segs=1)) P.append(dome("beacon", 0.075, (T[0] + dx, T[1] + dy, 7.52), "M_LightRed", k=1.3, seg=12, rings=4)) P.append(cy("bcap", 0.04, 0.03, (T[0] + dx, T[1] + dy, 7.63), "M_DarkGrey", v=8)) P.append(cy("ant", 0.02, 1.0, (T[0] + 0.3, T[1] - 0.3, 7.94), "M_DarkGrey", v=6)) P.append(sphere("anttip", 0.045, loc=(T[0] + 0.3, T[1] - 0.3, 8.45), seg=10, rings=5, m="M_LightRed")) # ladder on the front face of the tower ly = T[1] - hw - 0.14 lx = T[0] + 0.28 for dx in (-0.15, 0.15): P.append(cy("lrail", 0.024, 5.7, (lx + dx, ly, lv[1] + 2.85), "M_PaintWhite", v=6)) z = lv[1] + 0.25 while z < 7.2: P.append(cy("lrung", 0.016, 0.3, (lx, ly, z), "M_DarkGrey", axis="X", v=6)) z += 0.33 for z in (2.4, 4.0, 5.5, 6.9): for dx in (-0.15, 0.15): P.append(bx("lbrk", lx + dx - 0.015, lx + dx + 0.015, ly, T[1] - hw, z - 0.02, z + 0.02, "M_DarkGrey")) # service arms toward the rocket d = Vector((C[0] - T[0], C[1] - T[1], 0)) Ld = d.length phi = math.degrees(math.atan2(d.y, d.x)) La = Ld - 1.3 A1 = [bx("arm1", 0.3, La - 0.15, -0.11, 0.11, 4.62, 4.84, "M_PaintOrange", bev=0.06, segs=2), bx("arm1t", 0.3, La - 0.25, -0.08, 0.08, 4.5, 4.62, "M_DarkGrey", bev=0.02, segs=1), bx("head1", La - 0.22, La - 0.02, -0.17, 0.17, 4.52, 4.9, "M_DarkGrey", bev=0.05, segs=2), bx("pad1", La - 0.04, La + 0.04, -0.14, 0.14, 4.56, 4.86, "M_Rubber", bev=0.03, segs=2), pipe("hose", [(0.25, 0.16, 4.62), (La * 0.45, 0.16, 4.3), (La - 0.15, 0.16, 4.62)], 0.05, "M_Rubber", segs=8, fil=0.6, fn=6), pipe("hose2", [(0.25, -0.16, 4.66), (La * 0.5, -0.16, 4.42), (La - 0.15, -0.16, 4.66)], 0.035, "M_Teal", segs=8, fil=0.6, fn=6)] A2 = [bx("arm2", 0.3, La - 0.12, -0.3, 0.3, 6.08, 6.55, "M_HullWhite", bev=0.12, segs=3), bx("arm2s", 0.35, La - 0.2, -0.305, 0.305, 6.24, 6.32, "M_PaintOrange"), bx("head2", La - 0.16, La + 0.02, -0.33, 0.33, 6.05, 6.58, "M_Rubber", bev=0.1, segs=2)] for xw in (0.75, 1.25): for s in (-1, 1): A2.append(bx("awin", xw - 0.14, xw + 0.14, s * 0.3 - 0.012, s * 0.3 + 0.012, 6.36, 6.48, "M_Navy", bev=0.02, segs=1)) for o in A1 + A2: xf(o, rot=(0, 0, phi), loc=(T[0], T[1], 0)) P += A1 + A2 # fuel tanks (back-left) for x in (-2.48, -1.86): P.append(pill("tank", 0.28, 1.25, (x, 2.28, zt + 0.42), "M_Teal", axis="Y", seg=18, cr=4)) for y in (1.95, 2.6): P.append(annulus("tband", 0.27, 0.295, -0.06, 0.06, "M_PaintWhite", segs=18)) xf(P[-1], rot=(-90, 0, 0), loc=(x, y, zt + 0.42)) P.append(bx("cradle", x - 0.2, x + 0.2, y - 0.07, y + 0.07, zt, zt + 0.22, "M_DarkGrey", bev=0.02, segs=1)) P.append(cy("valve", 0.05, 0.1, (x, 2.28, zt + 0.74), "M_DarkGrey", v=10)) P.append(cy("vwheel", 0.08, 0.025, (x, 2.28, zt + 0.8), "M_PaintRed", v=12)) P.append(pipe("fuel", [(-2.17, 1.7, zt + 0.42), (-2.17, 1.25, zt + 0.42), (-1.5, 0.9, zt + 0.12), (-1.2, 0.75, zt + 0.12)], 0.06, "M_Steel", segs=8, fil=0.3, fn=4)) # front corner warning beacons on the slab for s in (-1, 1): x, y = s * 2.62, -1.42 P.append(cy("wpost", 0.12, 0.3, (x, y, zt + 0.15), "M_PaintOrange", v=14, bev=0.03, segs=2)) P.append(cy("wband", 0.125, 0.08, (x, y, zt + 0.12), "M_DeckEdge", v=14)) P.append(cy("wbase", 0.1, 0.04, (x, y, zt + 0.32), "M_DarkGrey", v=12)) P.append(dome("wlight", 0.09, (x, y, zt + 0.34), "M_LightRed", k=1.2, seg=12, rings=4)) # ---- cargo bay (front, on the deck) P.append(bx("bayfloor", -1.6, 1.6, -2.88, -1.9, 0.0, 0.03, "M_DarkGrey", bev=0.01, segs=1)) for (x0, x1, y0, y1) in ((-1.7, 1.7, -2.98, -2.88), (-1.7, 1.7, -1.9, -1.8), (-1.7, -1.6, -2.88, -1.9), (1.6, 1.7, -2.88, -1.9)): P.append(bx("bayhaz", x0, x1, y0, y1, 0.0, 0.036, "M_DeckEdge")) for yb in (-2.8, -2.53, -2.26): pts = [(-0.6, yb), (0.0, yb + 0.22), (0.6, yb), (0.6, yb + 0.11), (0.0, yb + 0.33), (-0.6, yb + 0.11)] P.append(prism("chev", pts, "XY", 0.025, 0.04, "M_PaintWhite")) for s in (-1, 1): P.append(pill("baycurb", 0.05, 0.9, (s * 1.45, -2.39, 0.06), "M_Rubber", axis="Y", seg=10, cr=2)) # bay pylons with green "ready" lights for s in (-1, 1): x, y = s * 2.0, -2.4 P.append(bx("pylon", x - 0.16, x + 0.16, y - 0.16, y + 0.16, 0.0, 1.05, "M_HullWhite", bev=0.07, segs=2)) P.append(bx("pyhaz", x - 0.168, x + 0.168, y - 0.168, y + 0.168, 0.12, 0.34, "M_DeckEdge", bev=0.03, segs=1)) P.append(bx("pycap", x - 0.18, x + 0.18, y - 0.18, y + 0.18, 1.02, 1.12, "M_PaintOrange", bev=0.04, segs=2)) P.append(cy("pybase", 0.08, 0.04, (x, y, 1.14), "M_DarkGrey", v=12)) P.append(dome("pylight", 0.07, (x, y, 1.16), "M_LightGreen", k=1.2, seg=12, rings=4)) P.append(fit01(bx("pyscr", x - s * 0.17 - 0.01, x - s * 0.17 + 0.01, y - 0.09, y + 0.09, 0.62, 0.8, "M_Screen", bev=0.008, segs=1))) # loading chute in the slab front P.append(bx("chute", -0.7, 0.7, -1.83, -1.75, 0.035, 0.2, "M_Navy", bev=0.03, segs=2)) P.append(bx("chutef", -0.78, 0.78, -1.815, -1.77, 0.02, 0.215, "M_DarkGrey", bev=0.02, segs=1)) fin(P, "Body", uv=1.0, ang=40) empty("RocketMount", (C[0], C[1], PAD_TOP)) empty("Bay", (0.0, -2.39, 0.0)) return dict(elev=26, azim=-38) # ======================================================================= 3. rocket RK_R = 1.18 def rocket(): P = [] R = RK_R def notch(z, d=0.022, w=0.03): return [(R, z - w), (R - d, z - w * 0.4), (R - d, z + w * 0.4), (R, z + w)] prof = [(0.0, 0.98), (0.55, 0.99), (0.82, 1.02), (1.02, 1.08), (1.16, 1.18), (1.235, 1.3), (1.262, 1.42), (1.245, 1.54), (1.21, 1.64), (R, 1.72)] prof += notch(1.85) + [(R, 2.2), (R, 3.0), (R, 3.6)] + notch(4.0) + notch(4.35) + notch(5.0) + [(R, 5.6)] + notch(6.2) # tangent ogive nose (6.2 -> 9.0), truncated at r 0.24 under a round tip cap NZ0, NL = 6.2, 2.8 rho = (R * R + NL * NL) / (2 * R) def ogive(zz): x = NZ0 + NL - zz return math.sqrt(max(0.0, rho * rho - (NL - x) ** 2)) + R - rho ztop = 8.744 zs = [NZ0 + 0.03 + (ztop - NZ0 - 0.03) * (1 - (1 - k / 14) ** 1.5) for k in range(15)] + [6.75, 6.95] zs = sorted(zs) zq = [] for zz in zs: if not zq or zz - zq[-1] > 0.04: zq.append(zz) prof += [(ogive(zz), zz) for zz in zq] hull = revolve("hull", prof, segs=40, m="M_HullWhite", close_top=True) def hull_m(c, n): rr_ = math.hypot(c.x, c.y) if 1.75 < c.z < 6.22 and rr_ < R - 0.006 and abs(n.z) < 0.7: return "M_DarkGrey" if 6.75 < c.z < 6.95: return "M_PaintWhite" if c.z < 1.85 or 4.0 < c.z < 4.35 or c.z > 6.2: return "M_PaintOrange" return "M_HullWhite" mat_by(hull, hull_m) uv_cyl(hull, axis=2, circ_scale=2 * math.pi * R, len_scale=1.0) hull["uvkeep"] = True P.append(hull) # teal pinstripe + skirt rivets on the flare P.append(torus("pin", R, 0.02, loc=(0, 0, 1.95), seg=48, rseg=4, m="M_Teal")) for k in range(16): a = 2 * math.pi * (k + 0.5) / 16 P.append(rivet("riv", (1.262 * math.cos(a), 1.262 * math.sin(a), 1.42), r=0.026)) # vertical panel seams on the upper body for k in range(4): a = 45.0 + 90.0 * k P.append(annulus("seam", R - 0.01, R + 0.006, 4.4, 6.14, "M_DarkGrey", segs=1, a0=a - 0.7, a1=a + 0.7)) # nose tip cap + antenna light P.append(torus("tipring", 0.245, 0.03, loc=(0, 0, 8.745), seg=20, rseg=4, m="M_DarkGrey")) tip = sphere("tip", 0.25, loc=(0, 0, 8.745), seg=20, rings=10, m="M_PaintWhite", scale=(1, 1, 0.95)) P.append(tip) P.append(cy("ant", 0.025, 0.3, (0, 0, 9.1), "M_DarkGrey", v=8)) P.append(sphere("antl", 0.06, loc=(0, 0, 9.28), seg=12, rings=6, m="M_LightRed")) # engine bell (double walled) + lip + mount bell = revolve("bell", [(0.6, 0.32), (0.57, 0.45), (0.48, 0.65), (0.38, 0.84), (0.34, 1.0), (0.29, 1.0), (0.32, 0.84), (0.42, 0.65), (0.51, 0.45), (0.545, 0.33)], segs=28, m="M_Steel", close_top=False) mat_by(bell, lambda c, n: "M_DarkGrey" if (n.x * c.x + n.y * c.y) < 0 else "M_Steel") P.append(bell) P.append(torus("lip", 0.572, 0.032, loc=(0, 0, 0.325), seg=28, rseg=6, m="M_DarkGrey")) for zr in (0.55, 0.75): rr_ = 0.57 - (zr - 0.45) * 0.47 P.append(torus("bellring", rr_ + 0.005, 0.018, loc=(0, 0, zr), seg=28, rseg=4, m="M_DarkGrey")) P.append(cy("mount", 0.42, 0.12, (0, 0, 0.98), "M_DarkGrey", v=24, bev=0.02, segs=1)) # fins fpts = chaikin([(0.98, 3.35), (0.98, 1.3), (1.42, 0.12), (1.92, 0.12), (1.98, 0.85), (1.84, 1.85), (1.36, 3.1)], 2) for k in range(4): a = 45.0 + 90.0 * k Fp = [prism("fin", fpts, "XZ", -0.13, 0.13, "M_PaintOrange", bev=0.08, segs=2, ang=40), bx("foot", 1.38, 1.95, -0.18, 0.18, 0.0, 0.16, "M_Rubber", bev=0.06, segs=2), prism("finstripe", [(1.55, 0.45), (1.965, 0.45), (1.95, 0.62), (1.5, 0.62)], "XZ", -0.136, 0.136, "M_PaintWhite", bev=0.015, segs=1)] xfm(Fp, rot=(0, 0, a)) P += Fp # porthole (front, -Y) pz = 5.15 P.append(torus("pframe", 0.36, 0.075, loc=(0, -(R + 0.02), pz), axis="Y", seg=28, rseg=8, m="M_PaintOrange")) P.append(cy("pback", 0.33, 0.12, (0, -(R - 0.03), pz), "M_Navy", axis="Y", v=24)) P.append(sphere("pglass", 0.33, loc=(0, -(R + 0.0), pz), seg=24, rings=12, m="M_Glass", scale=(1, 0.3, 1))) for k in range(8): a = 2 * math.pi * (k + 0.5) / 8 P.append(rivet("prv", (0.36 * math.cos(a), -(R + 0.095), pz + 0.36 * math.sin(a)), r=0.022)) # GreenHaul decal panels on both sides (-X and +X), 2:1, UV 0..1 for ac in (180.0, 0.0): P.append(annulus("dframe", R - 0.02, R + 0.01, 2.32, 3.43, "M_DarkGrey", segs=18, a0=ac - 49, a1=ac + 49)) P.append(arc_patch("decal", R + 0.014, ac - 46, ac + 46, 2.4, 3.35, "M_RocketDecal", n=18)) for (da, z) in ((-47.5, 2.36), (47.5, 2.36), (-47.5, 3.39), (47.5, 3.39)): aa = DEG(ac + da) P.append(rivet("drv", ((R + 0.012) * math.cos(aa), (R + 0.012) * math.sin(aa), z), r=0.022)) # cargo hatch on the back (+Y) P.append(annulus("hframe", R - 0.02, R + 0.008, 2.25, 3.65, "M_DarkGrey", segs=8, a0=90 - 22, a1=90 + 22)) P.append(annulus("hdoor", R - 0.02, R + 0.016, 2.29, 3.61, "M_HullWhite", segs=8, a0=90 - 20, a1=90 + 20)) P.append(annulus("hstripe", R - 0.02, R + 0.02, 2.85, 2.97, "M_PaintOrange", segs=8, a0=90 - 20, a1=90 + 20)) for z in (2.5, 3.4): P.append(cy("hhinge", 0.035, 0.16, (R * math.cos(DEG(112)), R * math.sin(DEG(112)) + 0.0, z), "M_DarkGrey", v=8)) P.append(pipe("hhandle", [(-0.12, R + 0.0, 2.75), (-0.12, R + 0.06, 2.75), (0.12, R + 0.06, 2.75), (0.12, R + 0.0, 2.75)], 0.018, "M_DarkGrey", segs=6, fil=0.03, fn=2)) # RCS pods near the nose for k in range(4): a = 45.0 + 90.0 * k Rp = [bx("rcs", R - 0.1, R + 0.12, -0.11, 0.11, 5.45, 5.78, "M_DarkGrey", bev=0.05, segs=2), cy("rcsn", 0.035, 0.08, (R + 0.12, 0.0, 5.615), "M_Steel", axis="X", v=8)] for s in (-1, 1): Rp.append(cy("rcsn", 0.03, 0.08, (R + 0.02, s * 0.12, 5.615), "M_Steel", axis="Y", v=8)) xfm(Rp, rot=(0, 0, a)) P += Rp fin(P, "Body", uv=1.0, ang=40) empty("Flame", (0.0, 0.0, 0.32)) return dict(elev=12, azim=-35) # ======================================================================= 4. launch lever def launch_lever(): P = [] base = bx("base", -0.36, 0.36, -0.36, 0.36, 0.0, 0.12, "M_PaintYellow", bev=0.035, segs=2) mat_by(base, lambda c, n: "M_PaintYellow" if n.z > 0.6 else ("M_DarkGrey" if n.z < -0.6 else "M_Hazard")) P.append(base) for (x, y) in ((-0.29, -0.29), (0.29, -0.29), (-0.29, 0.29), (0.29, 0.29)): P.append(bolt("bb", (x, y, 0.125), r=0.025, h=0.02)) P.append(bx("socket", -0.25, 0.25, -0.21, 0.21, 0.1, 0.16, "M_DarkGrey", bev=0.03, segs=2)) # column P.append(bx("col", -0.2, 0.2, -0.16, 0.16, 0.12, 0.92, "M_HullWhite", bev=0.07, segs=3)) P.append(rr_ring("band", 0, 0, 0.4, 0.32, 0.07, 0.24, 0.33, 0.012, 0.02, "M_PaintOrange", n=4)) P.append(rr_ring("tband", 0, 0, 0.4, 0.32, 0.07, 0.37, 0.39, 0.012, 0.02, "M_Teal", n=4)) # front label: red plate with an up arrow P.append(bx("lplate", -0.13, 0.13, -0.175, -0.155, 0.48, 0.74, "M_PaintRed", bev=0.015, segs=2)) P.append(prism("arrow", [(-0.07, 0.56), (0.0, 0.66), (0.07, 0.56), (0.03, 0.56), (0.03, 0.51), (-0.03, 0.51), (-0.03, 0.56)], "XZ", -0.183, -0.17, "M_PaintWhite")) # side vents for s in (-1, 1): for k in range(3): z = 0.55 + k * 0.06 P.append(bx("vent", s * 0.2 - 0.008, s * 0.2 + 0.008, -0.08, 0.08, z, z + 0.03, "M_DarkGrey", bev=0.008, segs=1)) # cable conduit at the back P.append(pipe("cable", [(0.0, 0.15, 0.45), (0.0, 0.24, 0.45), (0.0, 0.26, 0.12)], 0.03, "M_Rubber", segs=8, fil=0.08, fn=4)) # head (tilted toward the player) H = M4((16, 0, 0), (0, 0, 0.99)) Hd = [bx("head", -0.26, 0.26, -0.21, 0.21, -0.08, 0.08, "M_PaintOrange", bev=0.05, segs=3), bx("hhous", -0.085, 0.085, -0.14, 0.14, 0.06, 0.12, "M_DarkGrey", bev=0.03, segs=2), bx("hslot", -0.025, 0.025, -0.115, 0.115, 0.115, 0.125, "M_Navy", bev=0.005, segs=1), bx("sbez", 0.11, 0.24, -0.17, -0.03, 0.065, 0.09, "M_DarkGrey", bev=0.012, segs=1), fit01(bx("screen", 0.122, 0.228, -0.158, -0.042, 0.08, 0.095, "M_Screen", bev=0.006, segs=1))] for (x, y, m) in ((-0.17, -0.11, "M_LightGreen"), (-0.17, 0.0, "M_LightRed"), (-0.17, 0.11, "M_PaintYellow")): Hd.append(cy("btnr", 0.035, 0.02, (x, y, 0.08), "M_DarkGrey", v=12)) Hd.append(cy("btn", 0.026, 0.03, (x, y, 0.09), m, v=12, bev=0.008, segs=1)) for (x, y) in ((-0.22, -0.17), (0.22, -0.17), (-0.22, 0.17), (0.22, 0.17)): Hd.append(bolt("hb", (x, y, 0.08), r=0.016, h=0.012)) for o in Hd: apply_xform(o) o.data.transform(H) P += Hd hinge = H @ Vector((0.0, 0.0, 0.15)) P.append(cy("axle", 0.022, 0.24, tuple(hinge), "M_Steel", axis="X", v=10)) fin(P, "Body", uv=1.0, ang=40, ms={"M_Hazard": 4.0}) # Lever (pivot on the hinge, rest position tilted back toward +Y) tilt = DEG(22) dvec = Vector((0, math.sin(tilt), math.cos(tilt))) h = hinge Lv = [cy("hub", 0.052, 0.13, tuple(h), "M_PaintRed", axis="X", v=16, bev=0.012, segs=2), pipe("arm", [h, h + dvec * 0.36], 0.026, "M_PaintRed", segs=10), pipe("grip", [h + dvec * 0.2, h + dvec * 0.33], 0.036, "M_Rubber", segs=12), sphere("knob", 0.078, loc=tuple(h + dvec * 0.42), seg=20, rings=10, m="M_PaintRed")] for t in (0.22, 0.26, 0.3): Lv.append(torus("gripr", 0.037, 0.006, loc=(0, 0, 0), seg=12, rseg=4, m="M_Rubber")) xf(Lv[-1], rot=(-22, 0, 0), loc=tuple(h + dvec * t)) fin(Lv, "Lever", uv=2.0, ang=45, origin=tuple(h)) return dict(elev=20, azim=-35) # ======================================================================= 5. dock def bollard_parts(x, y, coil=False): prof = [(0.0, 0.0), (0.2, 0.0), (0.2, 0.05), (0.13, 0.075), (0.105, 0.12), (0.1, 0.24), (0.115, 0.3), (0.17, 0.33), (0.175, 0.37), (0.15, 0.41), (0.0, 0.43)] b = revolve("bollard", prof, segs=18, m="M_DarkGrey", loc=(x, y, 0.0), close_top=False) mat_by(b, lambda c, n: "M_PaintOrange" if c.z > 0.31 else "M_DarkGrey") Q = [b] for k in range(4): a = 2 * math.pi * (k + 0.5) / 4 Q.append(bolt("bb", (x + 0.16 * math.cos(a), y + 0.16 * math.sin(a), 0.055), r=0.022, h=0.02)) if coil: for k in range(3): Q.append(torus("rope", 0.13 + 0.01 * k, 0.022, loc=(x, y, 0.15 + k * 0.042), seg=16, rseg=6, m="M_Canvas")) return Q def dock(): P = [] # stringers + end beam (white hull with orange stripe) for s in (-1, 1): x0, x1 = sorted((s * 1.34, s * 1.5)) P.append(bx("stringer", x0, x1, -5.92, -0.0, -0.45, 0.025, "M_HullWhite", bev=0.04, segs=2)) P.append(bx("sstripe", s * 1.5 - 0.008, s * 1.5 + 0.008, -5.8, -0.12, -0.3, -0.2, "M_PaintOrange")) P.append(bx("endbeam", -1.5, 1.5, -5.92, -5.76, -0.45, 0.025, "M_HullWhite", bev=0.04, segs=2)) P.append(bx("estripe", -1.38, 1.38, -5.928, -5.912, -0.3, -0.2, "M_PaintOrange")) # joists for y in (-0.4, -1.75, -3.1, -4.45, -5.6): P.append(bx("joist", -1.36, 1.36, y - 0.07, y + 0.07, -0.32, -0.07, "M_DarkGrey", bev=0.02, segs=1)) # wooden planks y = -5.76 pitch = 0.296 while y - 0.0 < -0.2: y1 = min(y + pitch - 0.028, -0.17) P.append(bx("plank", -1.34, 1.34, y, y1, -0.07, 0.0, "M_WoodDeck", bev=0.014, segs=1)) y += pitch # metal threshold at the deck edge P.append(bx("thresh", -1.5, 1.5, -0.17, 0.0, -0.06, 0.008, "M_DeckEdge", bev=0.012, segs=1)) # piles for (x, y) in ((-1.67, -1.6), (1.67, -1.6), (-1.67, -5.55), (1.67, -5.55)): prof = [(0.0, -2.8), (0.17, -2.78), (0.17, -1.45), (0.17, -1.0), (0.17, 0.3), (0.17, 0.42), (0.155, 0.5), (0.1, 0.545), (0.0, 0.555)] pl = revolve("pile", prof, segs=16, m="M_HullWhite", loc=(x, y, 0), close_top=False) mat_by(pl, lambda c, n: "M_PaintOrange" if c.z > 0.3 else ("M_Seaweed" if -1.45 < c.z < -1.0 else "M_HullWhite")) P.append(pl) P.append(cy("pband", 0.178, 0.1, (x, y, 0.1), "M_DarkGrey", v=16)) s = 1 if x > 0 else -1 x0, x1 = sorted((s * 1.48, s * 1.56)) P.append(bx("pclamp", x0, x1, y - 0.12, y + 0.12, -0.36, -0.16, "M_DarkGrey", bev=0.02, segs=1)) P.append(torus("pring", 0.175, 0.025, loc=(x, y, -0.26), seg=16, rseg=4, m="M_DarkGrey")) # tyre fenders hanging on ropes for s in (-1, 1): for y in (-2.9, -4.3): x = s * 1.62 P.append(torus("tyre", 0.24, 0.1, loc=(x, y, -0.55), axis="X", seg=16, rseg=8, m="M_Rubber")) P.append(pipe("rope", [(x, y, -0.31), (x, y, 0.0), (s * 1.42, y, 0.06)], 0.016, "M_Canvas", segs=6, fil=0.08, fn=3)) P.append(bx("cleat", s * 1.42 - 0.04, s * 1.42 + 0.04, y - 0.09, y + 0.09, 0.02, 0.07, "M_DarkGrey", bev=0.015, segs=1)) # end D-fenders for x in (-0.9, 0.0, 0.9): P.append(pill("dfender", 0.08, 0.42, (x, -5.95, -0.2), "M_Rubber", seg=12, cr=3)) # bollards for (x, y, coil) in ((-1.12, -0.85, False), (1.12, -0.85, False), (-1.12, -4.95, True), (1.12, -4.95, False)): P += bollard_parts(x, y, coil) # boarding light (boat side, -X, near the end) lx, ly = -1.16, -5.5 P.append(cy("lflange", 0.1, 0.04, (lx, ly, 0.02), "M_DarkGrey", v=12, bev=0.01, segs=1)) P.append(cy("lpole", 0.04, 1.45, (lx, ly, 0.75), "M_DarkGrey", v=10)) P.append(cy("lband", 0.046, 0.12, (lx, ly, 0.35), "M_PaintOrange", v=10)) P.append(pipe("larm", [(lx, ly, 1.45), (lx, ly, 1.55), (lx - 0.22, ly, 1.55)], 0.03, "M_DarkGrey", segs=8, fil=0.08, fn=3)) P.append(cy("lhood", 0.11, 0.05, (lx - 0.24, ly, 1.55), "M_PaintOrange", v=14, r2=0.06, bev=0.01, segs=1)) P.append(cy("lcage", 0.07, 0.14, (lx - 0.24, ly, 1.46), "M_DarkGrey", v=8, cap=False)) P.append(pill("lbulb", 0.06, 0.16, (lx - 0.24, ly, 1.45), "M_Emissive", seg=12, cr=3)) # life ring stand (+X side) bx_, by_ = 1.25, -3.6 P.append(bx("lstand", bx_ - 0.04, bx_ + 0.04, by_ - 0.04, by_ + 0.04, 0.0, 1.15, "M_PaintWhite", bev=0.015, segs=1)) P.append(bx("lfoot", bx_ - 0.1, bx_ + 0.1, by_ - 0.1, by_ + 0.1, 0.0, 0.04, "M_DarkGrey", bev=0.01, segs=1)) P.append(bx("lhook", bx_ - 0.12, bx_, by_ - 0.025, by_ + 0.025, 1.0, 1.05, "M_DarkGrey")) lr = torus("lifering", 0.27, 0.075, loc=(bx_ - 0.13, by_, 0.75), axis="X", seg=24, rseg=8, m="M_PaintOrange") mat_by(lr, lambda c, n: "M_PaintOrange" if int((math.degrees(math.atan2(c.z - 0.75, c.y - by_)) + 360 + 22.5) // 45) % 2 == 0 else "M_PaintWhite") P.append(lr) # boarding ladder on the boat side (-X) ly2 = -3.6 for dy in (-0.22, 0.22): P.append(pipe("lrail", [(-1.36, ly2 + dy, 0.02), (-1.36, ly2 + dy, 0.5), (-1.6, ly2 + dy, 0.5), (-1.6, ly2 + dy, -0.15)], 0.032, "M_PaintOrange", segs=8, fil=0.12, fn=4)) P.append(pipe("lrail2", [(-1.6, ly2 + dy, -0.15), (-1.6, ly2 + dy, -1.55)], 0.032, "M_PaintWhite", segs=8)) P.append(bx("lbrk", -1.6, -1.5, ly2 + dy - 0.03, ly2 + dy + 0.03, -0.3, -0.24, "M_DarkGrey")) for z in (-0.35, -0.65, -0.95, -1.25): P.append(bx("lrung", -1.64, -1.56, ly2 - 0.22, ly2 + 0.22, z - 0.022, z + 0.022, "M_DarkGrey", bev=0.012, segs=1)) fin(P, "Body", uv=1.0, ang=40, ms={"M_WoodDeck": 0.5}) empty("Spawn", (-3.4, -3.6, -1.2)) return dict(elev=30, azim=-40) # ======================================================================= 6. ladder def ladder(): P = [] for s in (-1, 1): x = s * 0.26 P.append(pipe("hand", [(x, 0.42, 0.03), (x, 0.42, 0.88), (x, -0.15, 0.88), (x, -0.15, -0.08)], 0.04, "M_PaintOrange", segs=12, fil=0.2, fn=6)) P.append(pipe("rail", [(x, -0.15, -0.08), (x, -0.15, -2.15)], 0.04, "M_PaintWhite", segs=12)) P.append(cy("collar", 0.05, 0.08, (x, -0.15, -0.08), "M_DarkGrey", v=12, bev=0.012, segs=1)) P.append(pill("cap", 0.045, 0.14, (x, -0.15, -2.16), "M_Rubber", seg=12, cr=3)) # foot plate on the deck P.append(bx("foot", x - 0.09, x + 0.09, 0.33, 0.51, 0.0, 0.03, "M_DarkGrey", bev=0.012, segs=1)) for dy in (-0.05, 0.05): P.append(bolt("fb", (x + 0.055, 0.42 + dy, 0.03), r=0.016, h=0.012)) P.append(bolt("fb", (x - 0.055, 0.42 + dy, 0.03), r=0.016, h=0.012)) # J-hooks over the deck edge + standoffs to the slab face P.append(pipe("hook", [(x, 0.16, 0.012), (x, -0.02, 0.012), (x, -0.02, -0.2), (x, -0.15, -0.2)], 0.022, "M_DarkGrey", segs=8, fil=0.04, fn=3)) P.append(bx("hookpad", x - 0.05, x + 0.05, 0.08, 0.2, 0.0, 0.02, "M_Rubber", bev=0.008, segs=1)) for z in (-0.32,): P.append(bx("stand", x - 0.03, x + 0.03, -0.15, 0.0, z - 0.04, z + 0.04, "M_DarkGrey", bev=0.01, segs=1)) # rungs (flat treads with grip ridges) z = -0.4 while z > -2.1: P.append(bx("rung", -0.26, 0.26, -0.19, -0.11, z - 0.025, z + 0.025, "M_DarkGrey", bev=0.018, segs=2)) P.append(bx("ridge", -0.2, 0.2, -0.17, -0.13, z + 0.02, z + 0.035, "M_PaintOrange", bev=0.006, segs=1)) z -= 0.3 # top crossbar on the handrail hoop P.append(pipe("bar", [(-0.26, 0.13, 0.88), (0.26, 0.13, 0.88)], 0.03, "M_PaintOrange", segs=10)) fin(P, "Body", uv=2.0, ang=45) return dict(elev=18, azim=-55) # ======================================================================= 7. crew cabin def crew_cabin(): P = [] BY0, BY1 = -1.45, 1.9 BCY = (BY0 + BY1) / 2 # skid base + corner bumpers P.append(prism("skid", rr(0, 0.125, 6.0, 3.75, 0.28, 3), "XY", 0.0, 0.2, "M_DarkGrey", bev=0.03, segs=2, ang=40)) for sx in (-1, 1): for y0, y1 in ((-1.75, -1.4), (1.65, 2.0)): x0, x1 = sorted((sx * 3.0, sx * 2.65)) P.append(bx("cbump", x0, x1, y0, y1, 0.0, 0.32, "M_PaintOrange", bev=0.08, segs=2)) # body shell P.append(bx("body", -2.9, 2.9, BY0, BY1, 0.2, 3.0, "M_HullWhite", bev=0.35, segs=4)) P.append(rr_ring("band", 0, BCY, 5.8, BY1 - BY0, 0.35, 0.62, 0.8, 0.016, 0.03, "M_PaintOrange", n=4)) P.append(rr_ring("tband", 0, BCY, 5.8, BY1 - BY0, 0.35, 0.86, 0.9, 0.012, 0.03, "M_Teal", n=4)) P.append(rr_ring("gutter", 0, BCY, 5.8, BY1 - BY0, 0.35, 2.6, 2.66, 0.014, 0.03, "M_DarkGrey", n=4)) # panel seams for x in (-1.43, 0.25, 2.2): P.append(bx("seam", x - 0.012, x + 0.012, BY0 - 0.01, BY0 + 0.02, 0.9, 2.6, "M_DarkGrey")) for x in (-1.5, 0.0, 1.5): P.append(bx("seam", x - 0.012, x + 0.012, BY1 - 0.02, BY1 + 0.01, 0.9, 2.6, "M_DarkGrey")) # door: orange surround, white leaf with porthole, threshold dx0, dx1 = 0.6, 1.8 yf = BY0 P.append(bx("jamb", dx0, dx0 + 0.14, yf - 0.13, yf + 0.06, 0.2, 2.48, "M_PaintOrange", bev=0.05, segs=2)) P.append(bx("jamb", dx1 - 0.14, dx1, yf - 0.13, yf + 0.06, 0.2, 2.48, "M_PaintOrange", bev=0.05, segs=2)) P.append(bx("header", dx0, dx1, yf - 0.13, yf + 0.06, 2.34, 2.48, "M_PaintOrange", bev=0.05, segs=2)) P.append(bx("leaf", dx0 + 0.13, dx1 - 0.13, yf - 0.08, yf + 0.02, 0.26, 2.35, "M_HullWhite", bev=0.03, segs=2)) P.append(bx("lstripe", dx0 + 0.14, dx1 - 0.14, yf - 0.086, yf - 0.07, 1.05, 1.15, "M_PaintOrange")) P.append(bx("kick", dx0 + 0.16, dx1 - 0.16, yf - 0.09, yf - 0.07, 0.3, 0.52, "M_Steel", bev=0.01, segs=1)) dcx = (dx0 + dx1) / 2 P.append(torus("dwin", 0.15, 0.04, loc=(dcx, yf - 0.09, 1.82), axis="Y", seg=20, rseg=6, m="M_DarkGrey")) P.append(cy("dwinb", 0.14, 0.04, (dcx, yf - 0.075, 1.82), "M_Navy", axis="Y", v=16)) P.append(sphere("dwing", 0.135, loc=(dcx, yf - 0.085, 1.82), seg=16, rings=8, m="M_Glass", scale=(1, 0.2, 1))) P.append(pipe("dhandle", [(dx1 - 0.25, yf - 0.08, 1.0), (dx1 - 0.25, yf - 0.14, 1.04), (dx1 - 0.25, yf - 0.14, 1.36), (dx1 - 0.25, yf - 0.08, 1.4)], 0.022, "M_DarkGrey", segs=8, fil=0.04, fn=3)) P.append(bx("dthresh", dx0, dx1, yf - 0.15, yf + 0.02, 0.18, 0.24, "M_DeckEdge", bev=0.01, segs=1)) P.append(bx("dlamp", dcx - 0.16, dcx + 0.16, yf - 0.16, yf - 0.02, 2.53, 2.64, "M_DarkGrey", bev=0.03, segs=2)) P.append(bx("dlampl", dcx - 0.12, dcx + 0.12, yf - 0.17, yf - 0.1, 2.535, 2.575, "M_Emissive", bev=0.012, segs=1)) # porch: platform + step + handrails P.append(bx("porch", dx0 - 0.2, dx1 + 0.2, -1.8, yf + 0.02, 0.0, 0.2, "M_Steel", bev=0.025, segs=1)) P.append(bx("step", dx0 - 0.05, dx1 + 0.05, -2.0, -1.78, 0.0, 0.1, "M_Steel", bev=0.02, segs=1)) P.append(bx("stepn", dx0 - 0.05, dx1 + 0.05, -2.0, -1.95, 0.085, 0.105, "M_DeckEdge")) P.append(bx("porchn", dx0 - 0.2, dx1 + 0.2, -1.8, -1.75, 0.185, 0.205, "M_DeckEdge")) for x in (dx0 - 0.14, dx1 + 0.14): P.append(pipe("prail", [(x, -1.9, 0.1), (x, -1.9, 0.95), (x, yf - 0.02, 0.95)], 0.028, "M_PaintOrange", segs=8, fil=0.12, fn=4)) P.append(pipe("prail2", [(x, -1.9, 0.55), (x, yf - 0.02, 0.55)], 0.022, "M_PaintWhite", segs=8)) # round windows for x in (-0.85, -2.0): window_round(P, (x, yf - 0.01, 1.62), "Y", -1, 0.38) window_round(P, (-0.8, BY1 + 0.01, 1.62), "Y", 1, 0.38) window_round(P, (1.4, BY1 + 0.01, 1.62), "Y", 1, 0.38) window_round(P, (-2.91, 0.2, 1.62), "X", -1, 0.36) window_round(P, (2.91, 0.2, 1.62), "X", 1, 0.36) # wall vent (front, right of the door) P.append(bx("ventf", 2.0, 2.45, yf - 0.03, yf + 0.02, 1.55, 2.05, "M_DarkGrey", bev=0.03, segs=2)) for k in range(4): z = 1.62 + k * 0.1 P.append(bx("slat", 2.04, 2.41, yf - 0.06, yf - 0.02, z, z + 0.045, "M_PaintWhite", bev=0.01, segs=1)) # GreenHaul roof sign (square decal, faces -Y) sy = -0.85 for x in (-1.7, -0.7): P.append(pipe("spost", [(x, sy + 0.08, 2.95), (x, sy + 0.08, 3.25)], 0.04, "M_DarkGrey", segs=8)) P.append(pipe("sbrace", [(x, sy + 0.5, 2.98), (x, sy + 0.08, 3.6)], 0.025, "M_DarkGrey", segs=6)) P.append(bx("sfoot", x - 0.08, x + 0.08, sy - 0.0, sy + 0.6, 2.95, 3.0, "M_DarkGrey", bev=0.015, segs=1)) P.append(bx("sboard", -1.9, -0.5, sy - 0.04, sy + 0.08, 3.08, 4.48, "M_PaintOrange", bev=0.05, segs=2)) P.append(bx("scap", -1.94, -0.46, sy - 0.06, sy + 0.1, 4.46, 4.54, "M_Teal", bev=0.03, segs=2)) yl = sy - 0.045 P.append(quad("logo", (-1.82, yl, 3.16), (-0.58, yl, 3.16), (-0.58, yl, 4.4), (-1.82, yl, 4.4), "M_Logo")) for x in (-1.6, -0.8): P.append(pipe("slamp", [(x, sy + 0.06, 4.5), (x, sy + 0.06, 4.66), (x, sy - 0.25, 4.66)], 0.018, "M_DarkGrey", segs=6, fil=0.06, fn=3)) P.append(cy("slampsh", 0.07, 0.07, (x, sy - 0.28, 4.62), "M_DarkGrey", v=10, r2=0.03)) P.append(cy("slampl", 0.06, 0.012, (x, sy - 0.28, 4.585), "M_Emissive", v=10)) # rooftop AC unit + fan ax0, ax1, ay0, ay1 = -2.35, -1.2, 0.45, 1.45 P.append(bx("acfeet", ax0 + 0.05, ax1 - 0.05, ay0 + 0.1, ay1 - 0.1, 2.97, 3.05, "M_DarkGrey")) P.append(bx("ac", ax0, ax1, ay0, ay1, 3.04, 3.58, "M_PaintWhite", bev=0.07, segs=2)) acx, acy = (ax0 + ax1) / 2, (ay0 + ay1) / 2 P.append(annulus("acring", 0.3, 0.37, 3.56, 3.62, "M_DarkGrey", segs=24, c=(acx, acy))) P.append(cy("acfan", 0.3, 0.02, (acx, acy, 3.57), "M_Navy", v=24)) for k in range(4): sp = bx("spoke", -0.3, 0.3, -0.015, 0.015, 3.585, 3.605, "M_DarkGrey") xf(sp, rot=(0, 0, 45 * k), loc=(acx, acy, 0)) P.append(sp) P.append(cy("achub", 0.07, 0.04, (acx, acy, 3.6), "M_PaintOrange", v=12)) for k in range(4): z = 3.15 + k * 0.09 P.append(bx("acslat", ax0 - 0.012, ax0 + 0.02, ay0 + 0.15, ay1 - 0.15, z, z + 0.04, "M_DarkGrey", bev=0.008, segs=1)) P.append(bx("acstripe", ax0 + 0.1, ax1 - 0.1, ay0 - 0.008, ay0 + 0.02, 3.42, 3.48, "M_PaintOrange")) # pipes from the AC down the -X end wall into the cabin for (y, m) in ((0.85, "M_Teal"), (1.02, "M_Brass")): P.append(pipe("acpipe", [(ax0 + 0.05, y, 3.2), (-2.955, y, 3.2), (-2.955, y, 1.15), (-2.86, y, 1.15)], 0.035, m, segs=8, fil=0.14, fn=4)) for z in (2.3, 1.6): P.append(bx("clamp", -2.995, -2.9, 0.78, 1.09, z - 0.03, z + 0.03, "M_DarkGrey", bev=0.01, segs=1)) # satellite dish dprof = [(0.0, 0.0), (0.22, 0.025), (0.42, 0.09), (0.5, 0.14), (0.49, 0.16), (0.41, 0.115), (0.21, 0.05), (0.0, 0.03)] D = [revolve("dish", dprof, segs=24, m="M_PaintWhite", close_top=False)] for k in range(3): a = 2 * math.pi * k / 3 + 0.5 D.append(pipe("strut", [(0.45 * math.cos(a), 0.45 * math.sin(a), 0.13), (0, 0, 0.5)], 0.01, "M_DarkGrey", segs=5)) D.append(cy("horn", 0.045, 0.1, (0, 0, 0.5), "M_PaintOrange", v=10, bev=0.01, segs=1)) D.append(cy("dhub", 0.07, 0.06, (0, 0, -0.01), "M_DarkGrey", v=10)) xfm(D, rot=(25, -35, 0), loc=(0.85, 0.95, 3.48)) P += D P.append(cy("dmount", 0.07, 0.48, (0.85, 0.95, 3.22), "M_DarkGrey", v=10)) P.append(bx("dbase", 0.65, 1.05, 0.75, 1.15, 2.97, 3.04, "M_DarkGrey", bev=0.015, segs=1)) # antenna mast mx, my = 2.25, 1.3 P.append(bx("mbase", mx - 0.13, mx + 0.13, my - 0.13, my + 0.13, 2.97, 3.05, "M_DarkGrey", bev=0.02, segs=1)) P.append(cy("mast", 0.035, 1.55, (mx, my, 3.8), "M_DarkGrey", v=8)) for z in (3.4, 4.0): P.append(cy("mband", 0.042, 0.1, (mx, my, z), "M_PaintOrange", v=8)) for z, w in ((4.15, 0.22), (4.35, 0.15)): P.append(cy("mbar", 0.014, w * 2, (mx, my, z), "M_DarkGrey", axis="X", v=6)) P.append(sphere("mtip", 0.055, loc=(mx, my, 4.6), seg=10, rings=6, m="M_LightRed")) # roof hatch P.append(prism("rhatch", rr(1.75, -0.55, 0.8, 0.8, 0.15, 3), "XY", 2.96, 3.06, "M_DarkGrey", bev=0.02, segs=1, ang=40)) P.append(prism("rhlid", rr(1.75, -0.55, 0.66, 0.66, 0.1, 3), "XY", 3.05, 3.1, "M_HullWhite", bev=0.015, segs=1, ang=40)) P.append(bx("rhh", 1.6, 1.9, -0.84, -0.8, 3.1, 3.13, "M_PaintOrange", bev=0.01, segs=1)) # roof corner lugs for x in (-2.5, 2.5): for y in (BY0 + 0.38, BY1 - 0.38): P.append(bx("lug", x - 0.12, x + 0.12, y - 0.12, y + 0.12, 2.96, 3.06, "M_PaintOrange", bev=0.03, segs=1)) fin(P, "Body", uv=1.0, ang=40) return dict(elev=24, azim=-38) # ======================================================================= 8. terminal def terminal(): P = [] P.append(prism("plinth", rr(0, 0.0, 0.84, 0.66, 0.14, 3), "XY", 0.0, 0.1, "M_DarkGrey", bev=0.025, segs=2, ang=40)) P.append(rr_ring("bumper", 0, 0.0, 0.84, 0.66, 0.14, 0.025, 0.075, 0.018, 0.02, "M_Rubber", n=3)) # column P.append(bx("col", -0.32, 0.32, -0.22, 0.26, 0.08, 1.14, "M_HullWhite", bev=0.08, segs=3)) P.append(rr_ring("band", 0, 0.02, 0.64, 0.48, 0.08, 0.17, 0.27, 0.012, 0.03, "M_PaintOrange", n=3)) P.append(rr_ring("tband", 0, 0.02, 0.64, 0.48, 0.08, 0.3, 0.32, 0.01, 0.03, "M_Teal", n=3)) # +X side stripe and vents, -X side logo decal (2:1) P.append(bx("sstripe", 0.315, 0.33, -0.1, 0.14, 0.38, 1.02, "M_PaintOrange", bev=0.006, segs=1)) xl = -0.326 P.append(bx("logobg", -0.33, -0.31, -0.1, 0.14, 0.52, 0.76, "M_PaintWhite", bev=0.01, segs=1)) P.append(quad("logo", (xl - 0.006, 0.13, 0.53), (xl - 0.006, -0.09, 0.53), (xl - 0.006, -0.09, 0.75), (xl - 0.006, 0.13, 0.75), "M_Logo")) # front: card reader + coin slot + button yf = -0.22 P.append(bx("reader", 0.04, 0.2, yf - 0.03, yf + 0.02, 0.6, 0.76, "M_DarkGrey", bev=0.02, segs=2)) P.append(bx("slot", 0.07, 0.17, yf - 0.035, yf - 0.02, 0.71, 0.725, "M_Navy")) P.append(bx("rled", 0.07, 0.11, yf - 0.035, yf - 0.02, 0.64, 0.66, "M_LightGreen")) P.append(cy("cbtn", 0.045, 0.04, (-0.1, yf - 0.01, 0.68), "M_DarkGrey", axis="Y", v=14)) P.append(cy("cbtnt", 0.035, 0.03, (-0.1, yf - 0.035, 0.68), "M_PaintOrange", axis="Y", v=14, bev=0.008, segs=1)) P.append(bx("hazplate", -0.24, 0.24, yf - 0.012, yf + 0.01, 0.38, 0.46, "M_Hazard")) # back: cable into the floor + vent P.append(pipe("cable", [(0.1, 0.25, 0.4), (0.1, 0.33, 0.4), (0.1, 0.36, 0.06), (0.1, 0.42, 0.03)], 0.03, "M_Rubber", segs=8, fil=0.1, fn=4)) for k in range(4): z = 0.67 + k * 0.07 P.append(bx("bvent", -0.2, 0.2, 0.25, 0.27, z, z + 0.035, "M_DarkGrey", bev=0.008, segs=1)) # neck + head (tilted screen housing) P.append(bx("neck", -0.22, 0.22, -0.12, 0.18, 1.04, 1.22, "M_DarkGrey", bev=0.04, segs=2)) H = M4((-15, 0, 0), (0, -0.02, 1.4)) Hd = [bx("head", -0.41, 0.41, -0.09, 0.09, -0.29, 0.29, "M_HullWhite", bev=0.07, segs=3), bx("bezel", -0.355, 0.355, -0.1, -0.06, -0.235, 0.235, "M_DarkGrey", bev=0.025, segs=2), bx("hcap", -0.42, 0.42, -0.1, 0.1, 0.26, 0.32, "M_PaintOrange", bev=0.03, segs=2), bx("hchin", -0.2, 0.2, -0.105, -0.09, -0.275, -0.245, "M_PaintOrange", bev=0.005, segs=1)] for s in (-1, 1): Hd.append(bx("hside", s * 0.41 - 0.012, s * 0.41 + 0.012, -0.05, 0.05, -0.2, 0.2, "M_PaintOrange", bev=0.008, segs=1)) for k in range(3): z = -0.12 + k * 0.08 Hd.append(bx("hvent", -0.25, 0.25, 0.085, 0.1, z, z + 0.035, "M_DarkGrey", bev=0.008, segs=1)) for o in Hd: apply_xform(o) o.data.transform(H) P += Hd # keyboard shelf K = M4((22, 0, 0), (0, -0.36, 0.92)) Kb = [bx("shelf", -0.31, 0.31, -0.13, 0.13, -0.03, 0.03, "M_HullWhite", bev=0.025, segs=2), bx("shelfl", -0.31, 0.31, -0.135, -0.11, -0.033, 0.033, "M_PaintOrange", bev=0.012, segs=1), bx("kbase", -0.26, 0.26, -0.095, 0.105, 0.02, 0.04, "M_DarkGrey", bev=0.01, segs=1)] for r_ in range(3): for c_ in range(7): x = -0.21 + c_ * 0.07 y = -0.06 + r_ * 0.065 if r_ == 0 and c_ in (2, 3, 4): if c_ == 3: Kb.append(bx("space", -0.1, 0.1, y - 0.024, y + 0.024, 0.035, 0.058, "M_PaintOrange", bev=0.009, segs=1)) continue m = "M_Teal" if (r_ == 2 and c_ == 6) else "M_PaintWhite" Kb.append(bx("key", x - 0.027, x + 0.027, y - 0.024, y + 0.024, 0.035, 0.058, m, bev=0.009, segs=1)) for o in Kb: apply_xform(o) o.data.transform(K) P += Kb for s in (-1, 1): P.append(prism("gusset", [(-0.22, 0.7), (-0.22, 0.9), (-0.44, 0.86)], "YZ", s * 0.2 - 0.02, s * 0.2 + 0.02, "M_DarkGrey", bev=0.01, segs=1)) # beacon on top of the head top = H @ Vector((0.0, 0.03, 0.32)) P.append(cy("bbase", 0.075, 0.06, (top.x, top.y, top.z + 0.02), "M_DarkGrey", v=14, bev=0.012, segs=1)) P.append(dome("beacon", 0.065, (top.x, top.y, top.z + 0.05), "M_LightBlue", k=1.25, seg=14, rings=5)) for k in range(3): a = 2 * math.pi * k / 3 + 0.3 P.append(pipe("bcage", [(top.x + 0.075 * math.cos(a), top.y + 0.075 * math.sin(a), top.z + 0.05), (top.x + 0.075 * math.cos(a), top.y + 0.075 * math.sin(a), top.z + 0.14), (top.x, top.y, top.z + 0.15)], 0.008, "M_DarkGrey", segs=4, fil=0.03, fn=2)) P.append(cy("bcap", 0.03, 0.025, (top.x, top.y, top.z + 0.152), "M_DarkGrey", v=8)) fin(P, "Body", uv=1.0, ang=40, ms={"M_Hazard": 5.0}) # Screen: UV 0..1 exactly over the screen rectangle, faces -Y (tilted up 15 deg) ys = -0.103 corners = [H @ Vector(c) for c in ((-0.32, ys, -0.2), (0.32, ys, -0.2), (0.32, ys, 0.2), (-0.32, ys, 0.2))] sc = quad("Screen", *[tuple(c) for c in corners], "M_Screen") ctr = sum(corners, Vector()) / 4 set_origin(sc, tuple(ctr)) return dict(elev=18, azim=-35) # ======================================================================= main BUILDERS = { "SM_DeckTile": deck_tile, "SM_LaunchPad": launch_pad, "SM_Rocket": rocket, "SM_LaunchLever": launch_lever, "SM_Dock": dock, "SM_Ladder": ladder, "SM_CrewCabin": crew_cabin, "SM_Terminal": terminal, } # preview-only tints for materials whose texture has not been generated yet (never exported / saved) PREVIEW_TINT = {"M_Deck": "#8C98A8", "M_WoodDeck": "#B98556", "M_Logo": "#2D9CDB", "M_RocketDecal": "#2D9CDB"} EXTRA_VIEWS = [("_back", dict(azim=145, elev=25)), ("_top", dict(azim=-20, elev=65))] def tint_missing(): for nm, hx in PREVIEW_TINT.items(): m = bpy.data.materials.get(nm) tex = MATDEFS.get(nm, {}).get("texture") if m and tex and not os.path.exists(os.path.join(TEXTURES, tex)): bsdf = next(n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED") bsdf.inputs["Base Color"].default_value = hex2rgb(hx) + [1.0] def main(): args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] extra = "--extra" in args names = [a for a in args if not a.startswith("--")] or list(BUILDERS) for n in names: reset() random.seed(1234) pv = BUILDERS[n]() or {} print(f"[{n}] tris={tri_count()}") for o in sorted(bpy.context.scene.objects, key=lambda o: o.name): print(f"[{n}] {o.type:6s} {o.name:12s} tris={tri_count([o]) if o.type == 'MESH' else '-'} loc={tuple(round(v, 3) for v in o.location)}") export(n) save_blend(n) tint_missing() preview(n, **pv) if extra: old = common.PREVIEWS common.PREVIEWS = os.environ.get("OS_PREVIEW_EXTRA", os.path.join(os.environ.get("TEMP", "/tmp"), "os_rig_previews")) for tag, kw in EXTRA_VIEWS: preview(n + tag, **{**pv, **kw}) common.PREVIEWS = old print(f"[{n}] done") if __name__ == "__main__": main()