"""v4: helper robots + their stations (sweeper bot / dock, cargo drone / pad, spring launcher, poke bot, gold plater). Authored in UNITY coordinates through v2.B(): Unity (x, y, z) == Blender (-x, -z, y) (front +Z == Blender -Y). Run: blender -b --factory-startup --python v4_robots.py -- [names] """ import sys, os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from v2 import * from v3_belts import u_transform, uv_box_m, fin, prism_y # ======================================================================= helpers def uprism(name, pts, plane, d0, d1, m): """Polygon (may be concave) extruded. plane 'XZ': pts (x, z) along Y; 'XY': pts (x, y) along Z; 'ZY': pts (z, y) along X.""" def P(a, b, d): return {"XZ": B(a, d, b), "XY": B(a, b, d), "ZY": B(d, b, a)}[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] caps = [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])) if n > 4: bmesh.ops.triangulate(bm, faces=caps) bmesh.ops.recalc_face_normals(bm, faces=bm.faces) o = mesh_obj(name, bm) set_mats(o, m) return o def arc_band(name, r0, r1, y0, y1, a0, a1, m, segs=16, c=(0.0, 0.0)): """Annular sector solid around Unity Y. Angles in degrees, measured from +Z toward +X. c = centre (x, z).""" full = abs(a1 - a0) >= 359.9 n = segs if full else segs + 1 bm = bmesh.new() rows = [] for i in range(n): a = math.radians(a0 + (a1 - a0) * i / segs) sx, cz = math.sin(a), math.cos(a) rows.append([bm.verts.new(B(c[0] + r * sx, y, c[1] + r * cz)) for (r, y) in ((r0, y0), (r1, y0), (r1, y1), (r0, y1))]) for i in range(n if full else n - 1): a, b = rows[i], rows[(i + 1) % n] for k in range(4): bm.faces.new((a[k], b[k], b[(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 star_pts(n, ro, ri, cx=0.0, cy=0.0, rot=90.0): pts = [] for i in range(n * 2): a = math.radians(rot + i * 180.0 / n) r = ro if i % 2 == 0 else ri pts.append((cx + r * math.cos(a), cy + r * math.sin(a))) return pts def chevron_z(P, cx, zb, w, h, t, y0, y1, m="M_PaintWhite"): """Flat chevron on a horizontal surface pointing +Z: back corners at z=zb, x=cx+-w, apex at zb+h, stroke t.""" for s in (-1, 1): pts = [(cx + s * w, zb), (cx, zb + h), (cx, zb + h + t), (cx + s * w, zb + t)] P.append(prism_y("chev", pts, y0, y1, m)) def dome(name, r, c, m, k=0.5, seg=20, rings=10): """Upper half of a sphere squashed to k*r in height, base at c.""" o = usphere(name, r, c, m, seg=seg, rings=rings, scale=(1, k, 1)) bm = bmesh.new(); bm.from_mesh(o.data) bmesh.ops.delete(bm, geom=[v for v in bm.verts if v.co.z < c[1] - 1e-4], context="VERTS") bm.to_mesh(o.data); bm.free() smooth(o, 80) return o def lamp(P, x, y, z): """Beacon like v2.lamp_parts (same size), but the dome has an equator ring so it sits flush on its base. Dark base joins Body via P; the 'Lamp' dome stays a separate object (origin at its base centre).""" P.append(ucyl("lbase", 0.08, 0.05, (x, y + 0.025, z), "Y", verts=14, m="M_DarkGrey", bevel=0.012)) lo = dome("Lamp", 0.07, (x, y + 0.05, z), "M_Emissive", k=1.1, seg=14, rings=8) lo.name = "Lamp" set_origin(lo, B(x, y + 0.05, z)) return lo def part(objs, name, origin, uv=1.0, ang=40, haz=4.0): """Join a moving part, box-UV it, put its origin (pivot) at the given Unity point.""" o = fin(objs, name, uv=uv, ang=ang, haz=haz) set_origin(o, B(*origin)) return o def place_y(o, ang, t): """Rotate about Unity Y (radians, +Z toward -X ... see u_transform) and translate (Unity).""" return u_transform(o, ang, t) def rot_x(o, ang): """Rotate about the Unity X axis through the origin (positive turns +Y toward +Z).""" apply_xform(o) o.rotation_euler = (ang, 0, 0) # blender X == -unity X ; blender (y,z) == (-z, y): +ang turns +Y(unity) toward +Z(unity) apply_xform(o) return o def bolt_ring(P, n, R, y, r=0.02, h=0.025, m="M_Metal", c=(0.0, 0.0), a0=0.0): for k in range(n): a = math.radians(a0 + 360.0 * k / n) P.append(ucyl("bolt", r, h, (c[0] + R * math.sin(a), y + h / 2, c[1] + R * math.cos(a)), "Y", verts=6, m=m)) def spring(P, c, R, y0, y1, turns, wire, m="M_Metal", per_turn=8): n = int(turns * per_turn) pts = [(c[0] + R * math.cos(2 * math.pi * i / per_turn), y0 + (y1 - y0) * i / n, c[1] + R * math.sin(2 * math.pi * i / per_turn)) for i in range(n + 1)] P.append(utube("spring", pts, wire, m, res=1, segs=4)) # flat end coils (seats) P.append(torus("seat", R, wire * 1.1, loc=B(c[0], y0 + wire, c[1]), axis="Z", seg=12, rseg=4, m=m)) P.append(torus("seat", R, wire * 1.1, loc=B(c[0], y1 - wire, c[1]), axis="Z", seg=12, rseg=4, m=m)) # ======================================================================= 1. sweeper bot def sweeper_bot(): P = [] # chassis (underside) + wheels + caster P.append(revolve("chassis", [(0.0, 0.032), (0.262, 0.032), (0.28, 0.042), (0.284, 0.062)], segs=40, m="M_DarkGrey", close_top=True)) for s in (-1, 1): P.append(ucyl("wheel", 0.03, 0.03, (s * 0.205, 0.03, -0.02), "X", verts=14, m="M_Rubber", bevel=0.008)) P.append(usphere("caster", 0.016, (0, 0.016, 0.2), "M_Metal", seg=10, rings=5)) P.append(usphere("caster", 0.016, (0, 0.016, -0.2), "M_Metal", seg=10, rings=5)) # bumper ring P.append(revolve("bumper", [(0.275, 0.036), (0.296, 0.04), (0.306, 0.055), (0.306, 0.07), (0.296, 0.084), (0.275, 0.088)], segs=40, m="M_DarkGrey", close_top=False)) # teal shell (dome) + white lid P.append(revolve("shell", [(0.282, 0.084), (0.29, 0.094), (0.284, 0.108), (0.268, 0.118), (0.235, 0.124), (0.0, 0.126)], segs=40, m="M_PaintTeal", close_top=False)) P.append(revolve("lid", [(0.0, 0.12), (0.2, 0.12), (0.205, 0.124), (0.2, 0.13), (0.19, 0.132), (0.0, 0.132)], segs=36, m="M_PaintWhite", close_top=False)) # white racing stripe on the shell sides (back half) P.append(arc_band("stripe", 0.284, 0.293, 0.092, 0.1, 110, 250, "M_PaintWhite", segs=14)) # button ring around the lamp P.append(ucyl("btnring", 0.088, 0.012, (0, 0.136, 0.0), "Y", verts=28, m="M_DarkGrey", bevel=0.004)) # face: googly eyes peeking over the front rim for s in (-1, 1): ex, ey, ez = s * 0.075, 0.125, 0.232 P.append(usphere("eye", 0.046, (ex, ey, ez), "M_EyeWhite", seg=18, rings=10)) d = Vector((0.0, 0.25, 1.0)).normalized() px = ex + s * 0.008 pp = (px + d.x * 0.0, ey + d.y * 0.04, ez + d.z * 0.04) pu = usphere("pupil", 0.021, pp, "M_Pupil", seg=12, rings=6, scale=(1, 1, 0.5)) P.append(pu) P.append(usphere("glint", 0.006, (pp[0] - 0.007, pp[1] + 0.008, pp[2] + 0.01), "M_EyeWhite", seg=6, rings=3)) # antenna at the back P.append(utube("antenna", [(0.0, 0.126, -0.17), (0.0, 0.17, -0.19), (0.0, 0.2, -0.225)], 0.006, "M_DarkGrey", res=4, segs=4)) P.append(usphere("antball", 0.016, (0.0, 0.2, -0.228), "M_PaintRed", seg=10, rings=6)) # side vents for s in (-1, 1): for k in range(3): a = 90 * s + (k - 1) * 9 P.append(arc_band("vent", 0.287, 0.292, 0.096, 0.101 + 0.0, a - 2.5, a + 2.5, "M_DarkGrey", segs=1)) lo = dome("Lamp", 0.07, (0, 0.14, 0), "M_Emissive", k=0.45, seg=24, rings=12) set_origin(lo, B(0, 0.14, 0)) fin(P, "Body", uv=2.0, ang=45) # side brushes (spin about Y), origins at their centres for nm, s in (("BrushL", -1), ("BrushR", 1)): cx, cy, cz = s * 0.2, 0.02, 0.18 Bp = [ucyl("hub", 0.024, 0.014, (cx, cy, cz), "Y", verts=12, m="M_DarkGrey", bevel=0.004), ucyl("stub", 0.012, 0.01, (cx, cy + 0.011, cz), "Y", verts=8, m="M_Metal")] for k in range(3): a = math.radians(k * 120 + (20 if s > 0 else -20)) pts = [] for i in range(4): t = i / 3 rr = 0.02 + t * 0.09 aa = a + s * t * 0.45 # swept bristles, mirrored left/right pts.append((cx + rr * math.sin(aa), cy - t * 0.01, cz + rr * math.cos(aa))) Bp.append(utube("bristle", pts, 0.0085, "M_PaintYellow", res=3, segs=4)) e = pts[-1] Bp.append(usphere("tipb", 0.011, e, "M_PaintYellow", seg=8, rings=4)) part(Bp, nm, (cx, cy, cz), uv=4.0) return dict(elev=28, azim=-35) # ======================================================================= 2. sweeper dock def sweeper_dock(): P = [] plate = uprism("plate", [(-0.45, 0.0), (0.45, 0.0), (0.45, 0.006), (0.29, 0.045), (-0.45, 0.045)], "ZY", -0.45, 0.45, "M_DarkGrey") puff(plate, 0.008, segs=2, angle=20) P.append(plate) # teal guide curbs for s in (-1, 1): P.append(ubox("curb", s * 0.43 - 0.025, s * 0.43 + 0.025, 0.04, 0.07, -0.42, 0.26, "M_PaintTeal", bevel=0.012, segs=2)) # dashed parking ring for k in range(14): a = 42 + k * (276 / 13) P.append(arc_band("dash", 0.305, 0.335, 0.044, 0.05, a - 7, a + 7, "M_PaintWhite", segs=2)) # floor charging strips for s in (-1, 1): P.append(ubox("strip", s * 0.12 - 0.025, s * 0.12 + 0.025, 0.044, 0.052, -0.26, -0.08, "M_Metal", bevel=0.004, segs=1)) # ramp grip lines for k in range(3): z = 0.33 + k * 0.04 y = 0.045 - (z - 0.29) * (0.039 / 0.16) o = ubox("grip", -0.36, 0.36, -0.004, 0.004, -0.008, 0.008, "M_PaintTeal") rot_x(o, math.atan2(0.039, 0.16)) u_transform(o, 0.0, (0, y + 0.001, z)) P.append(o) # tower P.append(ubox("tower", -0.33, 0.33, 0.04, 0.62, -0.49, -0.3, "M_PaintTeal", bevel=0.06, segs=3)) P.append(ubox("cap", -0.355, 0.355, 0.6, 0.7, -0.5, -0.285, "M_PaintWhite", bevel=0.045, segs=3)) P.append(ubox("panel", -0.26, 0.26, 0.2, 0.57, -0.31, -0.292, "M_PaintWhite", bevel=0.02, segs=2)) # docking mouth + contacts P.append(ubox("mouth", -0.21, 0.21, 0.05, 0.17, -0.31, -0.29, "M_DarkGrey", bevel=0.02, segs=2)) for s in (-1, 1): P.append(ubox("contact", s * 0.12 - 0.025, s * 0.12 + 0.025, 0.09, 0.12, -0.3, -0.255, "M_Metal", bevel=0.01, segs=2)) # charge bars for k in range(3): x = -0.09 + k * 0.09 P.append(ubox("bar", x - 0.032, x + 0.032, 0.235, 0.265, -0.296, -0.284, "M_Screen", bevel=0.006, segs=1)) recycle_badge(P, (0, 0.43, -0.291), "+Z", 0.48) # side bin windows with a few bits inside for s in (-1, 1): P.append(ubox("win", s * 0.33 - 0.012, s * 0.33 + 0.012, 0.18, 0.46, -0.45, -0.34, "M_Glass", bevel=0.01, segs=1)) P.append(ubox("winframe", s * 0.33 - 0.008, s * 0.33 + 0.008, 0.16, 0.48, -0.47, -0.32, "M_DarkGrey", bevel=0.01, segs=1)) # back vents for k in range(4): y = 0.3 + k * 0.05 P.append(ubox("bvent", -0.18, 0.18, y, y + 0.022, -0.497, -0.485, "M_DarkGrey", bevel=0.006, segs=1)) # cable at the back P.append(utube("cable", [(0.22, 0.12, -0.49), (0.26, 0.04, -0.495), (0.36, 0.012, -0.49), (0.44, 0.012, -0.47)], 0.014, "M_Rubber", res=4, segs=4)) lamp(P, 0.0, 0.7, -0.39) fin(P, "Body", uv=1.0, ang=40) return dict(elev=26, azim=-35) # ======================================================================= 3. drone DRONE_M = [(1, 1), (-1, 1), (-1, -1), (1, -1)] # Rotor0 front-right, 1 front-left, 2 back-left, 3 back-right DM = 0.3 # motor offset (x and z) RY = 0.125 # rotor hub plane def drone(): P = [] P.append(ubox("body", -0.2, 0.2, -0.11, 0.1, -0.23, 0.23, "M_PaintOrange", bevel=0.08, segs=3)) P.append(ubox("lid", -0.135, 0.135, 0.07, 0.125, -0.17, 0.13, "M_PaintYellow", bevel=0.04, segs=2)) P.append(ubox("belly", -0.15, 0.15, -0.125, -0.09, -0.18, 0.18, "M_DarkGrey", bevel=0.015, segs=1)) # hazard side panels for s in (-1, 1): P.append(ubox("haz", s * 0.2 - 0.008, s * 0.2 + 0.008, -0.065, 0.025, -0.13, 0.13, "M_Hazard", bevel=0.006, segs=1)) # face P.append(ubox("visor", -0.13, 0.13, -0.045, 0.055, 0.2, 0.238, "M_DarkGrey", bevel=0.03, segs=2)) for s in (-1, 1): P.append(ucyl("eye", 0.026, 0.012, (s * 0.058, 0.005, 0.239), "Z", verts=16, m="M_Emissive", bevel=0.004)) # back vents for k in range(3): y = -0.04 + k * 0.03 P.append(ubox("vent", -0.1, 0.1, y, y + 0.012, -0.24, -0.225, "M_DarkGrey")) # arms + motor pods for (sx, sz) in DRONE_M: mx, mz = sx * DM, sz * DM P.append(utube("arm", [(sx * 0.12, 0.0, sz * 0.12), (mx, 0.03, mz)], 0.032, "M_DarkGrey", res=1, segs=8)) P.append(ucyl("pod", 0.06, 0.09, (mx, 0.045, mz), "Y", verts=14, m="M_PaintOrange", bevel=0.018)) P.append(ucyl("podband", 0.062, 0.022, (mx, 0.035, mz), "Y", verts=16, m="M_Hazard", cap=False)) P.append(ucyl("podcap", 0.038, 0.02, (mx, 0.098, mz), "Y", verts=14, m="M_DarkGrey", bevel=0.005)) P.append(ucyl("shaft", 0.012, 0.03, (mx, 0.113, mz), "Y", verts=8, m="M_Metal")) P.append(usphere("podbot", 0.055, (mx, 0.0, mz), "M_DarkGrey", seg=12, rings=4, scale=(1, 0.45, 1))) # skids (two bent rails) for s in (-1, 1): x = s * 0.15 P.append(utube("skid", [(s * 0.1, -0.1, -0.1), (x, -0.19, -0.15), (x, -0.19, 0.13), (s * 0.1, -0.1, 0.09)], 0.016, "M_DarkGrey", res=5, segs=4)) # winch under the belly (claw attaches at y -0.13) P.append(ucyl("winch", 0.045, 0.02, (0, -0.13, 0), "Y", verts=16, m="M_Metal", bevel=0.005)) lamp(P, 0.0, 0.125, -0.06) fin(P, "Body", uv=2.0, ang=40, haz=3.0) # rotors for i, (sx, sz) in enumerate(DRONE_M): mx, mz = sx * DM, sz * DM R = [ucyl("hub", 0.032, 0.024, (0, 0, 0), "Y", verts=14, m="M_DarkGrey", bevel=0.006), dome("spinner", 0.026, (0, 0.012, 0), "M_PaintYellow", k=0.8, seg=12, rings=6)] for s in (-1, 1): bl = ubox("blade", 0.02, 0.165, -0.006, 0.006, -0.027, 0.027, "M_DarkGrey", bevel=0.005, segs=1) tip = ubox("tip", 0.13, 0.168, -0.0065, 0.0065, -0.0275, 0.0275, "M_PaintYellow", bevel=0.005, segs=1) for o in (bl, tip): o.rotation_euler = (math.radians(12), 0, 0) # blade pitch apply_xform(o) u_transform(o, (0 if s > 0 else math.pi) + i * math.pi / 4, (0, 0, 0)) R.append(o) ro = fin(R, "Rotor%d" % i, uv=4.0, ang=40) u_transform(ro, 0.0, (mx, RY, mz)) set_origin(ro, B(mx, RY, mz)) # claw: origin at the top attach point C = [ucyl("cable", 0.012, 0.08, (0, -0.18, 0), "Y", verts=8, m="M_Metal"), ucyl("swivel", 0.022, 0.025, (0, -0.1425, 0), "Y", verts=10, m="M_DarkGrey"), ucyl("hub", 0.05, 0.045, (0, -0.235, 0), "Y", verts=16, m="M_PaintYellow", bevel=0.012), ucyl("hubcap", 0.036, 0.012, (0, -0.262, 0), "Y", verts=14, m="M_DarkGrey")] for k in range(3): a = math.radians(k * 120 + 60) sa, ca = math.sin(a), math.cos(a) pts = [(0.038 * sa, -0.245, 0.038 * ca), (0.078 * sa, -0.285, 0.078 * ca), (0.066 * sa, -0.33, 0.066 * ca), (0.034 * sa, -0.35, 0.034 * ca)] C.append(utube("prong", pts, 0.012, "M_DarkGrey", res=4, segs=4)) C.append(usphere("knuckle", 0.018, pts[0], "M_Metal", seg=8, rings=4)) C.append(usphere("ptip", 0.014, pts[-1], "M_PaintYellow", seg=8, rings=4)) part(C, "Claw", (0, -0.13, 0), uv=4.0) return dict(elev=30, azim=-35) # ======================================================================= 4. drone pad def drone_pad(): P = [] P.append(ubox("base", -0.475, 0.475, 0.0, 0.12, -0.475, 0.475, "M_DarkGrey", bevel=0.03, segs=2)) P.append(ubox("deck", -0.42, 0.42, 0.11, 0.124, -0.42, 0.42, "M_PaintOrange", bevel=0.006, segs=1)) # hazard trim for s in (-1, 1): P.append(ubox("trim", -0.47, 0.47, 0.1, 0.123, s * 0.445 - 0.025, s * 0.445 + 0.025, "M_Hazard")) P.append(ubox("trim", s * 0.445 - 0.025, s * 0.445 + 0.025, 0.1, 0.1225, -0.42, 0.42, "M_Hazard")) # landing circle + H cz = -0.05 P.append(arc_band("ring", 0.245, 0.29, 0.12, 0.129, 0, 360, "M_PaintWhite", segs=40, c=(0, cz))) for s in (-1, 1): P.append(ubox("Hleg", s * 0.115 - 0.026, s * 0.115 + 0.026, 0.12, 0.129, cz - 0.135, cz + 0.135, "M_PaintWhite", bevel=0.003, segs=1)) P.append(ubox("Hbar", -0.09, 0.09, 0.12, 0.129, cz - 0.026, cz + 0.026, "M_PaintWhite", bevel=0.003, segs=1)) # drop chevrons toward +Z chevron_z(P, 0.0, 0.265, 0.13, 0.045, 0.035, 0.12, 0.129, "M_PaintWhite") chevron_z(P, 0.0, 0.335, 0.13, 0.045, 0.035, 0.12, 0.129, "M_PaintWhite") # front face chevrons (vertical, pointing down/out) -> small white arrow on the +Z side for s in (-1, 1): pts = [(s * 0.06, 0.1), (0.0, 0.03), (0.0, 0.055), (s * 0.06, 0.125)] o = extrude_poly("fchev", [(x, y - 0.02) for (x, y) in pts], "XY", 0.47, 0.48, "M_PaintWhite") P.append(o) # corner lights for (sx, sz) in ((1, 1), (-1, 1), (1, -1), (-1, -1)): x, z = sx * 0.35, sz * 0.35 P.append(ucyl("lring", 0.036, 0.012, (x, 0.13, z), "Y", verts=14, m="M_DarkGrey", bevel=0.004)) P.append(dome("light", 0.027, (x, 0.135, z), "M_Emissive", k=0.7, seg=12, rings=6)) # side handles / vents on the base for s in (-1, 1): P.append(ubox("slot", -0.25, 0.25, 0.045, 0.07, s * 0.475 - 0.006, s * 0.475 + 0.006, "M_Rubber", bevel=0.005, segs=1)) P.append(ubox("slot", s * 0.475 - 0.006, s * 0.475 + 0.006, 0.045, 0.07, -0.25, 0.25, "M_Rubber", bevel=0.005, segs=1)) # pole with windsock at the back-left corner px, pz = -0.42, -0.42 P.append(ubox("flange", px - 0.03, px + 0.03, 0.12, 0.14, pz - 0.03, pz + 0.03, "M_DarkGrey", bevel=0.008, segs=1)) P.append(ucyl("pole", 0.02, 0.96, (px, 0.14 + 0.48, pz), "Y", verts=10, m="M_DarkGrey")) for y in (0.3, 0.55): P.append(ucyl("pband", 0.023, 0.08, (px, y, pz), "Y", verts=10, m="M_PaintOrange")) P.append(ucyl("arm", 0.01, 0.06, (px + 0.04, 0.98, pz), "X", verts=6, m="M_DarkGrey")) P.append(torus("sockring", 0.05, 0.007, loc=B(px + 0.075, 0.97, pz), axis="X", seg=14, rseg=4, m="M_DarkGrey")) xs = [px + 0.075, px + 0.15, px + 0.225, px + 0.3] rs = [0.05, 0.043, 0.036, 0.029] ys = [0.97, 0.955, 0.935, 0.91] for k in range(3): L = math.dist((xs[k], ys[k]), (xs[k + 1], ys[k + 1])) o = cyl("sock", rs[k], L, axis="X", verts=12, cap=False, r2=rs[k + 1]) # cyl axis X: radius1 at -X (Blender) == +X unity; flip so the wide end is toward the pole o.rotation_euler = (0, 0, math.pi) apply_xform(o) ang = math.atan2(ys[k] - ys[k + 1], xs[k + 1] - xs[k]) o.rotation_euler = (0, -ang, 0) o.location = B((xs[k] + xs[k + 1]) / 2, (ys[k] + ys[k + 1]) / 2, pz) apply_xform(o) set_mats(o, "M_PaintOrange" if k % 2 == 0 else "M_PaintWhite") mod(o, "SOLIDIFY", thickness=0.004, offset=0) bake(o) P.append(o) lamp(P, px, 1.1, pz) fin(P, "Body", uv=1.0, ang=40, haz=2.5) return dict(elev=30, azim=-35) # ======================================================================= 5. launcher def launcher(): P = [] P.append(ubox("base", -0.5, 0.5, 0.0, 0.13, -0.5, 0.5, "M_PaintYellow", bevel=0.035, segs=3)) for s in (-1, 1): P.append(ubox("haz", -0.46, 0.46, 0.025, 0.1, s * 0.5 - 0.006, s * 0.5 + 0.006, "M_Hazard")) P.append(ubox("haz", s * 0.5 - 0.006, s * 0.5 + 0.006, 0.025, 0.1, -0.46, 0.46, "M_Hazard")) P.append(ubox("tray", -0.44, 0.44, 0.12, 0.14, -0.44, 0.44, "M_DarkGrey", bevel=0.01, segs=1)) # springs for (x, z) in ((-0.25, -0.1), (0.25, -0.1), (-0.25, 0.25), (0.25, 0.25)): P.append(ucyl("sseat", 0.105, 0.015, (x, 0.145, z), "Y", verts=16, m="M_PaintRed", bevel=0.004)) spring(P, (x, z), 0.085, 0.152, 0.298, 4, 0.016, "M_Metal") # scissor lift on both sides for s in (-1, 1): x = s * 0.4 P.append(utube("sc", [(x, 0.15, -0.38), (x, 0.285, 0.36)], 0.016, "M_PaintYellow", res=1, segs=6)) P.append(utube("sc", [(x, 0.285, -0.38), (x, 0.15, 0.36)], 0.016, "M_PaintYellow", res=1, segs=6)) P.append(ucyl("pin", 0.024, 0.05, (x, 0.2175, -0.01), "X", verts=10, m="M_Metal")) P.append(ucyl("foot", 0.024, 0.05, (x, 0.15, 0.36), "X", verts=10, m="M_Metal")) # front rubber stops the plate rests on for s in (-1, 1): P.append(ubox("stop", s * 0.435 - 0.025, s * 0.435 + 0.025, 0.13, 0.3, 0.41, 0.46, "M_Rubber", bevel=0.012, segs=2)) # hinge blocks + body knuckles + pin for s in (-1, 1): P.append(ubox("hblock", s * 0.385 - 0.06, s * 0.385 + 0.06, 0.12, 0.27, -0.5, -0.42, "M_PaintRed", bevel=0.02, segs=2)) P.append(ucyl("knuckle", 0.034, 0.11, (s * 0.385, 0.3, -0.46), "X", verts=14, m="M_PaintRed", bevel=0.006)) P.append(ucyl("knuckle", 0.034, 0.1, (s * 0.0 + s * 0.1, 0.3, -0.46), "X", verts=14, m="M_PaintRed", bevel=0.006)) P.append(ubox("hblock", s * 0.1 - 0.05, s * 0.1 + 0.05, 0.12, 0.27, -0.49, -0.43, "M_PaintRed", bevel=0.02, segs=2)) P.append(ucyl("hpin", 0.014, 0.92, (0, 0.3, -0.46), "X", verts=10, m="M_Metal")) fin(P, "Body", uv=1.0, ang=40, haz=2.5) # Plate (pivot at the back hinge) Q = [ubox("plate", -0.46, 0.46, 0.3, 0.36, -0.424, 0.46, "M_PaintRed", bevel=0.025, segs=3)] for s in (-1, 1): Q.append(ucyl("knuckle", 0.034, 0.17, (s * 0.24, 0.3, -0.46), "X", verts=14, m="M_PaintRed", bevel=0.006)) Q.append(ubox("rim", -0.43, 0.43, 0.355, 0.364, -0.4, 0.43, "M_DarkGrey", bevel=0.004, segs=1)) Q.append(ubox("pad", -0.405, 0.405, 0.36, 0.368, -0.38, 0.405, "M_PaintRed", bevel=0.004, segs=1)) for zb in (-0.33, -0.09, 0.15): chevron_z(Q, 0.0, zb, 0.29, 0.13, 0.075, 0.362, 0.372, "M_PaintWhite") part(Q, "Plate", (0, 0.3, -0.46), uv=1.0) return dict(elev=22, azim=-35) # ======================================================================= 6. poke bot YB = 1.05 # boom centre height def poke_bot(): P = [] P.append(ucyl("flange", 0.37, 0.06, (0, 0.03, 0), "Y", verts=32, m="M_DarkGrey", bevel=0.018)) bolt_ring(P, 8, 0.32, 0.06, r=0.022, h=0.022, a0=22.5) P.append(revolve("column", [(0.3, 0.055), (0.29, 0.1), (0.255, 0.19), (0.245, 0.45), (0.27, 0.5)], segs=32, m="M_PaintBlue", close_top=True)) P.append(ucyl("band", 0.252, 0.06, (0, 0.3, 0), "Y", verts=32, m="M_Hazard", cap=False)) P.append(ucyl("bearing", 0.29, 0.05, (0, 0.525, 0), "Y", verts=32, m="M_PaintWhite", bevel=0.014)) # little control panel on the front P.append(arc_band("panel", 0.24, 0.258, 0.13, 0.24, -28, 28, "M_PaintWhite", segs=6)) P.append(arc_band("screen", 0.25, 0.262, 0.15, 0.22, -20, 20, "M_Screen", segs=6)) # lamp on a side bracket (+X) P.append(ubox("bracket", 0.24, 0.37, 0.37, 0.4, -0.06, 0.06, "M_DarkGrey", bevel=0.01, segs=1)) lamp(P, 0.32, 0.4, 0.0) fin(P, "Body", uv=1.0, ang=40, haz=3.0) # Yaw turret (pivot (0, 0.55, 0)) Y = [ucyl("turntable", 0.25, 0.05, (0, 0.575, 0), "Y", verts=32, m="M_DarkGrey", bevel=0.012)] Y.append(ubox("housing", -0.15, 0.15, 0.6, 1.0, -0.17, 0.17, "M_PaintWhite", bevel=0.07, segs=3)) Y.append(ucyl("joint", 0.13, 0.33, (0, 0.82, 0), "X", verts=24, m="M_PaintBlue", bevel=0.02)) for s in (-1, 1): Y.append(ucyl("jcap", 0.085, 0.02, (s * 0.17, 0.82, 0), "X", verts=20, m="M_DarkGrey", bevel=0.005)) Y.append(ucyl("jbolt", 0.03, 0.02, (s * 0.185, 0.82, 0), "X", verts=10, m="M_Metal")) Y.append(ubox("boom", -0.07, 0.07, YB - 0.05, YB + 0.05, -0.25, 1.3, "M_PaintBlue", bevel=0.02, segs=2)) Y.append(ubox("saddle", -0.12, 0.12, 0.98, YB + 0.08, -0.14, 0.14, "M_PaintWhite", bevel=0.035, segs=2)) for s in (-1, 1): Y.append(ubox("rail", s * 0.072 - 0.006, s * 0.072 + 0.006, YB - 0.022, YB + 0.022, 0.15, 1.25, "M_Metal", bevel=0.004, segs=1)) Y.append(ubox("stop", -0.085, 0.085, YB - 0.065, YB + 0.065, 1.25, 1.32, "M_PaintRed", bevel=0.02, segs=2)) Y.append(ubox("cw", -0.13, 0.13, 0.9, YB + 0.08, -0.28, -0.14, "M_DarkGrey", bevel=0.035, segs=2)) Y.append(ubox("cwhaz", -0.11, 0.11, 0.93, 1.1, -0.286, -0.27, "M_Hazard")) # hose loop from housing to boom Y.append(utube("hose", [(0.1, 0.9, -0.12), (0.13, 1.0, -0.2), (0.08, YB + 0.06, -0.18)], 0.016, "M_Rubber", res=4, segs=4)) part(Y, "Yaw", (0, 0.55, 0), uv=1.0, haz=3.0) # Carriage (pivot = slider centre on the boom) cz = 0.9 C = [ubox("slider", -0.11, 0.11, YB - 0.08, YB + 0.095, cz - 0.1, cz + 0.1, "M_PaintWhite", bevel=0.035, segs=3)] C.append(ubox("sstripe", -0.112, 0.112, YB + 0.02, YB + 0.045, cz - 0.08, cz + 0.08, "M_PaintBlue")) for s in (-1, 1): for dz in (-0.05, 0.05): C.append(ucyl("roller", 0.024, 0.016, (s * 0.118, YB - 0.03, cz + dz), "X", verts=10, m="M_DarkGrey")) C.append(ucyl("cyl", 0.048, 0.1, (0, YB - 0.12, cz), "Y", verts=18, m="M_PaintBlue", bevel=0.01)) C.append(ucyl("collar", 0.054, 0.02, (0, YB - 0.175, cz), "Y", verts=18, m="M_DarkGrey", bevel=0.005)) C.append(ucyl("rod", 0.026, 0.09, (0, YB - 0.225, cz), "Y", verts=12, m="M_Metal")) C.append(ucyl("tcollar", 0.06, 0.02, (0, 0.8, cz), "Y", verts=20, m="M_PaintWhite", bevel=0.006)) tip = revolve("tip", [(0.0, 0.7), (0.025, 0.703), (0.044, 0.716), (0.055, 0.737), (0.058, 0.762), (0.056, 0.79)], segs=20, m="M_PaintRed", close_top=True, loc=B(0, 0, cz)) C.append(tip) part(C, "Carriage", (0, YB, cz), uv=1.0) return dict(elev=22, azim=-55) # ======================================================================= 7. gold plater def gold_plater(): b, half, r = belt_loop(2.0) P = belt_frame_parts(2.0, half, r, legs_at=(-0.85, 0.85)) D = 0.42 for s in (-1, 1): xa, xb = (0.5, 0.64) if s > 0 else (-0.64, -0.5) P.append(ubox("pillar", xa, xb, 0.0, 1.2, -D, D, "M_PaintWhite", bevel=0.05, segs=3)) P.append(ubox("pfoot", xa - 0.03, xb + 0.03, 0.0, 0.08, -D - 0.03, D + 0.03, "M_DarkGrey", bevel=0.02, segs=2)) P.append(ubox("haz", xa - 0.005, xb + 0.005, 0.08, 0.2, -D - 0.005, D + 0.005, "M_Hazard")) P.append(ubox("gtrim", xa - 0.006, xb + 0.006, 0.2, 0.235, -D - 0.006, D + 0.006, "M_Gold", bevel=0.008, segs=1)) # brush bearing (stays outside |x| < 0.45) P.append(ubox("bearing", s * 0.475 - 0.025, s * 0.475 + 0.025, 0.5, 0.74, -0.12, 0.12, "M_DarkGrey", bevel=0.015, segs=2)) P.append(ucyl("bcap", 0.06, 0.02, (s * 0.65, 0.62, 0), "X", verts=16, m="M_Gold", bevel=0.005)) # gold sparkle decals on the outer side faces for (zz, yy, rr) in ((-0.15, 0.85, 0.11), (0.17, 0.58, 0.075), (0.2, 0.98, 0.055)): P.append(uprism("spark", star_pts(4, rr, rr * 0.3, zz, yy, 90), "ZY", min(s * 0.636, s * 0.648), max(s * 0.636, s * 0.648), "M_Gold")) P.append(ubox("beam", -0.64, 0.64, 1.0, 1.28, -D, D, "M_PaintWhite", bevel=0.06, segs=3)) for f in (1, -1): P.append(ubox("gband", -0.6, 0.6, 1.2, 1.235, f * D - 0.01, f * D + 0.01, "M_Gold", bevel=0.005, segs=1)) # front (+Z) sparkles on the beam and pillar faces for (x, y, rr) in ((0.0, 1.1, 0.075), (-0.22, 1.12, 0.045), (0.22, 1.12, 0.045)): P.append(uprism("spark", star_pts(4, rr, rr * 0.3, x, y, 90), "XY", D - 0.004, D + 0.008, "M_Gold")) P.append(uprism("spark", star_pts(4, rr, rr * 0.3, x, y, 90), "XY", -D - 0.008, -D + 0.004, "M_Gold")) for s in (-1, 1): P.append(uprism("spark", star_pts(4, 0.06, 0.018, s * 0.57, 0.7, 90), "XY", D - 0.004, D + 0.008, "M_Gold")) # spray manifold + nozzles (upstream of the brush) zn = -0.3 P.append(ucyl("manifold", 0.03, 0.86, (0, 0.965, zn), "X", verts=12, m="M_Gold")) for x in (-0.3, -0.1, 0.1, 0.3): P.append(ucyl("nozzle", 0.016, 0.06, (x, 0.915, zn), "Y", verts=12, m="M_Metal", r2=0.03)) P.append(ucyl("ntip", 0.01, 0.01, (x, 0.882, zn), "Y", verts=8, m="M_DarkGrey")) # gold paint tank on the roof + feed pipe P.append(ucyl("tank", 0.14, 0.2, (0.3, 1.38, -0.05), "Y", verts=20, m="M_Gold", bevel=0.03)) P.append(ucyl("tband", 0.145, 0.03, (0.3, 1.38, -0.05), "Y", verts=20, m="M_PaintWhite", cap=False)) P.append(ucyl("tcap", 0.06, 0.04, (0.3, 1.49, -0.05), "Y", verts=16, m="M_PaintWhite", bevel=0.01)) P.append(utube("feed", [(0.3, 1.3, -0.2), (0.3, 1.3, -0.36), (0.3, 1.2, -0.45), (0.45, 1.0, -0.45)], 0.022, "M_Metal", res=4, segs=4)) lamp(P, -0.38, 1.28, 0.0) fin(P, "Body", uv=1.0, ang=40, haz=1.0) # Brush drum along X, pivot (0, 0.62, 0) yc = 0.62 Rb = [ucyl("shaft", 0.03, 0.9, (0, yc, 0), "X", verts=10, m="M_Metal"), ucyl("core", 0.095, 0.8, (0, yc, 0), "X", verts=20, m="M_PaintWhite")] for s in (-1, 1): Rb.append(ucyl("end", 0.13, 0.03, (s * 0.405, yc, 0), "X", verts=20, m="M_PaintWhite", bevel=0.008)) nr, nt = 6, 12 for i in range(nr): x = -0.33 + i * 0.132 for k in range(nt): th = 2 * math.pi * (k + (0.5 if i % 2 else 0.0)) / nt t = cyl("tuft", 0.022, 0.105, (0, 0, 0.1425), axis="Z", verts=5, r2=0.034) # tip corners stay inside r 0.2 t.rotation_euler = (th, 0, 0) apply_xform(t) t.location = B(x, yc, 0) apply_xform(t) set_mats(t, "M_Gold") Rb.append(t) part(Rb, "Brush", (0, yc, 0), uv=1.0, ang=50) return dict(elev=25, azim=-40) if __name__ == "__main__": run({ "SM_SweeperBot": sweeper_bot, "SM_SweeperDock": sweeper_dock, "SM_Drone": drone, "SM_DronePad": drone_pad, "SM_Launcher": launcher, "SM_PokeBot": poke_bot, "SM_GoldPlater": gold_plater, })