Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date. Images, audio, models and binaries go through Git LFS (.gitattributes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
915
ArtSource/Blender/scripts/v2.py
Normal file
915
ArtSource/Blender/scripts/v2.py
Normal file
@ -0,0 +1,915 @@
|
||||
"""v2 assets: modular warehouse kit, racks, wrapped pallet, big/giant rolls, build pieces, gadgets, icon props.
|
||||
Authored in UNITY coordinates through B(): Unity (x, y, z) == Blender (-x, -z, y) (front +Z == Blender -Y).
|
||||
Run: blender -b --factory-startup --python v2.py -- [names]
|
||||
"""
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from common import *
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- unity-space helpers
|
||||
|
||||
def B(x, y, z):
|
||||
return (-x, -z, y)
|
||||
|
||||
|
||||
UAX = {"X": "X", "Y": "Z", "Z": "Y"}
|
||||
|
||||
|
||||
def ubox(name, x0, x1, y0, y1, z0, z1, m, bevel=0.0, segs=2):
|
||||
size = (x1 - x0, z1 - z0, y1 - y0)
|
||||
c = B((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2)
|
||||
return rbox(name, size, c, bevel=bevel, segs=segs, m=m) if bevel > 0 else cube(name, size, c, m)
|
||||
|
||||
|
||||
def ucyl(name, r, depth, c, axis="Y", **kw):
|
||||
return cyl(name, r, depth, loc=B(*c), axis=UAX[axis], **kw)
|
||||
|
||||
|
||||
def utube(name, pts, radius, m, **kw):
|
||||
return tube(name, [B(*p) for p in pts], radius, m=m, **kw)
|
||||
|
||||
|
||||
def usphere(name, r, c, m, seg=16, rings=8, scale=(1, 1, 1)):
|
||||
return sphere(name, r, loc=B(*c), seg=seg, rings=rings, m=m, scale=(scale[0], scale[2], scale[1]))
|
||||
|
||||
|
||||
def extrude_poly(name, pts2d, plane, d0, d1, m):
|
||||
"""plane 'XY': pts (x, y) extruded along Unity Z d0..d1; plane 'ZY': pts (z, y) extruded along Unity X."""
|
||||
bm = bmesh.new()
|
||||
|
||||
def P(a, b, d):
|
||||
return B(a, b, d) if plane == "XY" else B(d, b, a)
|
||||
f0 = [bm.verts.new(P(a, b, d0)) for a, b in pts2d]
|
||||
f1 = [bm.verts.new(P(a, b, d1)) for a, b in pts2d]
|
||||
bm.faces.new(f0)
|
||||
bm.faces.new(list(reversed(f1)))
|
||||
n = len(pts2d)
|
||||
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)
|
||||
return o
|
||||
|
||||
|
||||
def puff(o, w, segs=3, angle=30):
|
||||
b = o.modifiers.new("bev", "BEVEL")
|
||||
b.width = w
|
||||
b.segments = segs
|
||||
b.limit_method = "ANGLE"
|
||||
b.angle_limit = math.radians(angle)
|
||||
bake(o)
|
||||
return o
|
||||
|
||||
|
||||
def quad(name, corners, uvs, m):
|
||||
"""corners in unity space (4 points, CCW seen from the visible side is fixed below by normal hint)."""
|
||||
bm = bmesh.new()
|
||||
uvl = bm.loops.layers.uv.verify()
|
||||
vs = [bm.verts.new(B(*c)) for c in corners]
|
||||
f = bm.faces.new(vs)
|
||||
for l, uv in zip(f.loops, uvs):
|
||||
l[uvl].uv = uv
|
||||
o = mesh_obj(name, bm)
|
||||
set_mats(o, m)
|
||||
return o
|
||||
|
||||
|
||||
def face_toward(o, unity_dir):
|
||||
"""Flip every face of o so its normal points along unity_dir."""
|
||||
d = Vector(B(*unity_dir))
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(o.data)
|
||||
for f in bm.faces:
|
||||
if f.normal.dot(d) < 0:
|
||||
f.normal_flip()
|
||||
bm.to_mesh(o.data)
|
||||
bm.free()
|
||||
|
||||
|
||||
def finalize(parts, name, uv=1.0, ang=40):
|
||||
o = join(parts, name)
|
||||
if uv:
|
||||
uv_box(o, uv)
|
||||
smooth(o, ang)
|
||||
return o
|
||||
|
||||
|
||||
# ======================================================================= warehouse kit
|
||||
|
||||
WT = 0.15 # wall half thickness
|
||||
H = 8.0
|
||||
|
||||
|
||||
def wall_dressing(P, x0, x1, faces=(1,), seams=(-1.5, 1.5), y_ranges=((0.95, 7.85),)):
|
||||
"""concrete kick, yellow stripe, seams, top cap on the given faces (+1 = +Z inner, -1 = outer)."""
|
||||
P.append(ubox("kick", x0, x1, 0.0, 0.8, -WT - 0.04, WT + 0.04, "M_Concrete", bevel=0.03, segs=2))
|
||||
P.append(ubox("cap", x0, x1, 7.85, H, -WT - 0.04, WT + 0.04, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
for s in faces:
|
||||
za, zb = (WT, WT + 0.035) if s > 0 else (-WT - 0.035, -WT)
|
||||
P.append(ubox("stripe", x0, x1, 0.8, 0.95, za, zb, "M_PaintYellow", bevel=0.012, segs=2))
|
||||
for sx in seams:
|
||||
for (ya, yb) in y_ranges:
|
||||
P.append(ubox("seam", sx - 0.04, sx + 0.04, ya, yb, za, zb + 0.01 * s, "M_PaintWhite", bevel=0.015, segs=2))
|
||||
|
||||
|
||||
def wh_wall(inner_only=True):
|
||||
P = [ubox("panel", -3, 3, 0.8, 7.85, -WT, WT, "M_WallPanel")]
|
||||
wall_dressing(P, -3, 3, faces=(1,) if inner_only else (1, -1))
|
||||
finalize(P, "Wall")
|
||||
return dict(elev=15, azim=-25)
|
||||
|
||||
|
||||
def wh_partition():
|
||||
return wh_wall(inner_only=False)
|
||||
|
||||
|
||||
def wh_wall_window():
|
||||
P = []
|
||||
P.append(ubox("panel", -3, 3, 0.8, 3.0, -WT, WT, "M_WallPanel"))
|
||||
P.append(ubox("panel", -3, 3, 5.5, 7.85, -WT, WT, "M_WallPanel"))
|
||||
for s in (-1, 1):
|
||||
P.append(ubox("post", min(s * 2.6, s * 3), max(s * 2.6, s * 3), 3.0, 5.5, -WT, WT, "M_WallPanel"))
|
||||
wall_dressing(P, -3, 3, faces=(1,), y_ranges=((0.95, 3.0), (5.5, 7.85)))
|
||||
# frames
|
||||
P.append(ubox("sill", -2.7, 2.7, 2.9, 3.02, -0.26, 0.26, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
P.append(ubox("head", -2.65, 2.65, 5.47, 5.57, -0.2, 0.2, "M_PaintWhite", bevel=0.02, segs=2))
|
||||
for x in (-2.6, -1.3, 0.0, 1.3, 2.6):
|
||||
P.append(ubox("mull", x - 0.05, x + 0.05, 3.0, 5.5, -0.08, 0.08, "M_PaintWhite", bevel=0.015, segs=2))
|
||||
P.append(ubox("tran", -2.6, 2.6, 4.55, 4.65, -0.08, 0.08, "M_PaintWhite", bevel=0.015, segs=2))
|
||||
finalize(P, "Wall")
|
||||
g = ubox("glass", -2.6, 2.6, 3.0, 5.5, -0.012, 0.012, "M_Glass")
|
||||
uv_box(g, 1)
|
||||
g.name = "Windows"
|
||||
return dict(elev=12, azim=-25)
|
||||
|
||||
|
||||
def wh_pillar():
|
||||
P = []
|
||||
P.append(ubox("flange", -0.2, 0.2, 0, H, 0.15, 0.2, "M_PaintBlue", bevel=0.012, segs=1))
|
||||
P.append(ubox("flange", -0.2, 0.2, 0, H, -0.2, -0.15, "M_PaintBlue", bevel=0.012, segs=1))
|
||||
P.append(ubox("web", -0.025, 0.025, 0, H, -0.16, 0.16, "M_PaintBlue"))
|
||||
P.append(ubox("plate", -0.29, 0.29, 0, 0.04, -0.29, 0.29, "M_DarkGrey", bevel=0.012, segs=1))
|
||||
for (x, z) in ((-0.22, -0.22), (0.22, -0.22), (-0.22, 0.22), (0.22, 0.22)):
|
||||
P.append(ucyl("bolt", 0.022, 0.03, (x, 0.05, z), "Y", verts=8, m="M_Metal"))
|
||||
P.append(ubox("guard", -0.29, 0.29, 0.04, 1.0, -0.29, 0.29, "M_PaintYellow", bevel=0.07, segs=3))
|
||||
for y in (0.35, 0.7):
|
||||
P.append(ubox("band", -0.295, 0.295, y, y + 0.09, -0.295, 0.295, "M_DarkGrey", bevel=0.03, segs=2))
|
||||
P.append(ubox("top", -0.24, 0.24, H - 0.06, H, -0.24, 0.24, "M_DarkGrey", bevel=0.01, segs=1))
|
||||
finalize(P, "SM_WH_Pillar")
|
||||
return dict(elev=15)
|
||||
|
||||
|
||||
def wh_roof():
|
||||
P = []
|
||||
y0, y1 = 8.5, 8.7
|
||||
P.append(ubox("slab", -3, 3, y0, y1, -3, -1, "M_Roof"))
|
||||
P.append(ubox("slab", -3, 3, y0, y1, 1, 3, "M_Roof"))
|
||||
P.append(ubox("slab", -3, -2, y0, y1, -1, 1, "M_Roof"))
|
||||
P.append(ubox("slab", 2, 3, y0, y1, -1, 1, "M_Roof"))
|
||||
# skylight curb
|
||||
P.append(ubox("curb", -2.12, 2.12, 8.45, 8.85, -1.12, -1.0, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
P.append(ubox("curb", -2.12, 2.12, 8.45, 8.85, 1.0, 1.12, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
P.append(ubox("curb", -2.12, -2.0, 8.45, 8.85, -1.0, 1.0, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
P.append(ubox("curb", 2.0, 2.12, 8.45, 8.85, -1.0, 1.0, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
# purlins (along Z, sit on the truss)
|
||||
for x in (-2.5, 2.5):
|
||||
P.append(ubox("purlin", x - 0.07, x + 0.07, 8.35, y0, -3, 3, "M_DarkGrey"))
|
||||
# truss along X at the tile edge z = -3
|
||||
zt = -3.0
|
||||
P.append(ubox("chordT", -3, 3, 8.2, 8.35, zt - 0.08, zt + 0.08, "M_PaintBlue", bevel=0.02, segs=1))
|
||||
P.append(ubox("chordB", -3, 3, 7.55, 7.67, zt - 0.07, zt + 0.07, "M_PaintBlue", bevel=0.02, segs=1))
|
||||
xs = [-3.0, -1.5, 0.0, 1.5, 3.0]
|
||||
for i, x in enumerate(xs):
|
||||
if -3 < x < 3:
|
||||
P.append(utube("vert", [(x, 7.67, zt), (x, 8.2, zt)], 0.035, "M_PaintBlue", segs=4, res=1))
|
||||
if i < len(xs) - 1:
|
||||
xb = xs[i + 1]
|
||||
pts = [(x, 7.67, zt), (xb, 8.2, zt)] if i % 2 == 0 else [(x, 8.2, zt), (xb, 7.67, zt)]
|
||||
P.append(utube("diag", pts, 0.03, "M_PaintBlue", segs=4, res=1))
|
||||
finalize(P, "Roof")
|
||||
g = ubox("glass", -2.0, 2.0, 8.78, 8.8, -1.0, 1.0, "M_Glass")
|
||||
uv_box(g, 1)
|
||||
g.name = "Skylight"
|
||||
return dict(elev=-30, azim=-30)
|
||||
|
||||
|
||||
def wh_gate_wall():
|
||||
P = []
|
||||
for s in (-1, 1):
|
||||
xa, xb = (2, 3) if s > 0 else (-3, -2)
|
||||
P.append(ubox("panel", xa, xb, 0.8, 7.85, -WT, WT, "M_WallPanel"))
|
||||
P.append(ubox("kick", xa, xb, 0.0, 0.8, -WT - 0.04, WT + 0.04, "M_Concrete", bevel=0.03, segs=2))
|
||||
for f in (1, -1):
|
||||
za, zb = (WT, WT + 0.035) if f > 0 else (-WT - 0.035, -WT)
|
||||
P.append(ubox("stripe", xa, xb, 0.8, 0.95, za, zb, "M_PaintYellow", bevel=0.012, segs=2))
|
||||
P.append(ubox("panel", -2, 2, 4.6, 7.85, -WT, WT, "M_WallPanel"))
|
||||
P.append(ubox("cap", -3, 3, 7.85, H, -WT - 0.04, WT + 0.04, "M_PaintWhite", bevel=0.03, segs=2))
|
||||
# roller drum housing on the +Z side
|
||||
drum = ucyl("drum", 0.3, 4.3, (0, 5.2, WT + 0.33), "X", verts=20, m="M_Metal", bevel=0.03)
|
||||
P.append(drum)
|
||||
P.append(ubox("hood", -2.25, 2.25, 5.5, 5.62, WT, WT + 0.72, "M_PaintBlue", bevel=0.03, segs=2))
|
||||
for s in (-1, 1):
|
||||
P.append(ubox("brk", s * 2.18 - 0.07, s * 2.18 + 0.07, 4.85, 5.55, WT, WT + 0.66, "M_PaintBlue", bevel=0.02, segs=2))
|
||||
finalize(P, "Wall")
|
||||
F = []
|
||||
for s in (-1, 1):
|
||||
xa, xb = (2.0, 2.25) if s > 0 else (-2.25, -2.0)
|
||||
F.append(ubox("jamb", xa, xb, 0.0, 4.85, -WT - 0.06, WT + 0.06, "M_Hazard", bevel=0.03, segs=2))
|
||||
F.append(ubox("header", -2.25, 2.25, 4.6, 4.85, -WT - 0.06, WT + 0.06, "M_Hazard", bevel=0.03, segs=2))
|
||||
fr = finalize(F, "Frame", uv=0.5)
|
||||
return dict(elev=12, azim=-30)
|
||||
|
||||
|
||||
def wh_shutter():
|
||||
Hs, Wd = 4.6, 4.0
|
||||
N = 30
|
||||
y0 = 0.12
|
||||
front, back = [], []
|
||||
steps = N * 4
|
||||
for i in range(steps + 1):
|
||||
y = y0 + (Hs - y0) * i / steps
|
||||
k = (i % 4) / 4.0
|
||||
bump = 0.014 * math.sin(math.pi * k)
|
||||
front.append((0.026 + bump, y))
|
||||
back.append((-0.026 - bump, y))
|
||||
prof = front + list(reversed(back))
|
||||
sl = extrude_poly("slats", prof, "ZY", -Wd / 2 + 0.02, Wd / 2 - 0.02, "M_PaintBlue")
|
||||
P = [sl]
|
||||
P.append(ubox("bar", -Wd / 2 + 0.02, Wd / 2 - 0.02, 0.0, y0, -0.055, 0.055, "M_DarkGrey", bevel=0.025, segs=2))
|
||||
for f in (1, -1):
|
||||
P.append(ubox("handle", -0.25, 0.25, 0.05, 0.09, f * 0.055, f * 0.085, "M_Metal", bevel=0.012, segs=2))
|
||||
sh = finalize(P, "Shutter", ang=35)
|
||||
set_origin(sh, B(0, Hs, 0))
|
||||
G = []
|
||||
for s in (-1, 1):
|
||||
G.append(ubox("guide", s * 2.0 - 0.04, s * 2.0 + 0.04, 0, Hs, -0.06, 0.06, "M_DarkGrey", bevel=0.01, segs=1))
|
||||
finalize(G, "Guides")
|
||||
return dict(elev=10, azim=-25)
|
||||
|
||||
|
||||
def hanging_sign():
|
||||
P = []
|
||||
P.append(ubox("board", -1.5, 1.5, -2.5, -1.5, -0.045, 0.045, "M_PaintBlue", bevel=0.035, segs=2))
|
||||
for s in (-1, 1):
|
||||
x = s * 1.2
|
||||
P.append(ucyl("eye", 0.03, 0.05, (x, -1.48, 0), "Z", verts=10, m="M_Metal"))
|
||||
n = 10
|
||||
for i in range(n):
|
||||
y = -1.5 + (i + 0.5) * 1.5 / n
|
||||
t = torus("link", 0.045, 0.009, loc=B(x, y, 0), axis="X" if i % 2 == 0 else "Y", seg=10, rseg=4, m="M_Metal")
|
||||
t.scale = (1, 1, 1.75) if True else (1, 1, 1)
|
||||
apply_xform(t)
|
||||
P.append(t)
|
||||
P.append(ucyl("hook", 0.06, 0.03, (x, 0.0, 0), "Y", verts=12, m="M_DarkGrey"))
|
||||
finalize(P, "Board")
|
||||
xa, xb, ya, yb, z = -1.4, 1.4, -2.42, -1.58, 0.047
|
||||
# viewer at +Z looks toward -Z: their right is -X, so U grows toward -X
|
||||
f = quad("Face", [(xb, ya, z), (xa, ya, z), (xa, yb, z), (xb, yb, z)], [(0, 0), (1, 0), (1, 1), (0, 1)], "M_PaintWhite")
|
||||
face_toward(f, (0, 0, 1))
|
||||
return dict(elev=10, azim=-20)
|
||||
|
||||
|
||||
# ======================================================================= racks / pallets
|
||||
|
||||
def pallet_rack():
|
||||
P = []
|
||||
W, D, HH = 2.8, 1.1, 4.3
|
||||
decks = (1.45, 2.85, 4.25)
|
||||
for sx in (-1, 1):
|
||||
for sz in (-1, 1):
|
||||
x, z = sx * W / 2, sz * D / 2
|
||||
P.append(ubox("up", x - 0.045, x + 0.045, 0, HH, z - 0.045, z + 0.045, "M_PaintOrange", bevel=0.012, segs=1))
|
||||
P.append(ubox("foot", x - 0.08, x + 0.08, 0, 0.02, z - 0.08, z + 0.08, "M_DarkGrey"))
|
||||
zs = [0.25 + i * 0.6 for i in range(7)]
|
||||
for i in range(len(zs) - 1):
|
||||
a = (sx * W / 2, zs[i], -D / 2 if i % 2 == 0 else D / 2)
|
||||
b = (sx * W / 2, zs[i + 1], D / 2 if i % 2 == 0 else -D / 2)
|
||||
P.append(utube("br", [a, b], 0.018, "M_PaintOrange", res=1, segs=4))
|
||||
for y in (0.25, HH - 0.12):
|
||||
P.append(utube("hb", [(sx * W / 2, y, -D / 2), (sx * W / 2, y, D / 2)], 0.02, "M_PaintOrange", res=1, segs=4))
|
||||
for sz in (-1, 1):
|
||||
P.append(ubox("beam0", -W / 2, W / 2, 0.1, 0.2, sz * D / 2 - 0.035, sz * D / 2 + 0.035, "M_PaintBlue", bevel=0.015, segs=1))
|
||||
for d in decks:
|
||||
top = d
|
||||
for sz in (-1, 1):
|
||||
P.append(ubox("beam", -W / 2, W / 2, top - 0.15, top - 0.03, sz * D / 2 - 0.035, sz * D / 2 + 0.035, "M_PaintBlue", bevel=0.015, segs=1))
|
||||
n = 6
|
||||
for k in range(n):
|
||||
pw = (D + 0.02) / n
|
||||
z0 = -D / 2 - 0.01 + k * pw + 0.012
|
||||
P.append(ubox("plank", -W / 2 + 0.03, W / 2 - 0.03, top - 0.03, top, z0, z0 + pw - 0.024, "M_Wood", bevel=0.008, segs=1))
|
||||
finalize(P, "SM_PalletRack")
|
||||
return dict(elev=18, azim=-30)
|
||||
|
||||
|
||||
def pallet_wrapped():
|
||||
import decor
|
||||
decor.pallet()
|
||||
pal = bpy.data.objects["SM_Pallet"]
|
||||
pal.name = "Pallet"
|
||||
P = []
|
||||
rnd = random.Random(7)
|
||||
top0 = 0.144
|
||||
bw, bd, bh = 0.58, 0.48, 0.36
|
||||
for layer in range(3):
|
||||
for ix in (-1, 1):
|
||||
for iz in (-1, 1):
|
||||
cx = ix * (bw / 2 + 0.005) + rnd.uniform(-0.01, 0.01)
|
||||
cz = iz * (bd / 2 + 0.005) + rnd.uniform(-0.01, 0.01)
|
||||
y0 = top0 + layer * bh
|
||||
P.append(ubox("box", cx - bw / 2, cx + bw / 2, y0, y0 + bh - 0.004, cz - bd / 2, cz + bd / 2, "M_Cardboard", bevel=0.02, segs=1))
|
||||
if layer == 2:
|
||||
P.append(ubox("tape", cx - 0.04, cx + 0.04, y0 + bh - 0.006, y0 + bh + 0.002, cz - bd / 2 - 0.002, cz + bd / 2 + 0.002, "M_Tape"))
|
||||
finalize(P, "Boxes", uv=1.0)
|
||||
F = [ubox("film", -0.605, 0.605, 0.16, 1.25, -0.505, 0.505, "M_StretchFilm", bevel=0.07, segs=2)]
|
||||
for y in (0.3, 0.68, 1.02):
|
||||
F.append(ubox("wrap", -0.615, 0.615, y, y + 0.16, -0.515, 0.515, "M_StretchFilm", bevel=0.05, segs=2))
|
||||
finalize(F, "Film", ang=60)
|
||||
return dict(elev=22, azim=-35)
|
||||
|
||||
|
||||
# ======================================================================= rolls
|
||||
|
||||
def make_roll(name, R, L, core_in, core_out, circ_density=3.6, len_density=3.3, label=False):
|
||||
outer = cyl("outer", R, L - 0.04, axis="X", verts=48, cap=False)
|
||||
uv_cyl(outer, axis=0, circ_scale=2 * math.pi * R * circ_density, len_scale=len_density)
|
||||
set_mats(outer, "M_WrapRoll")
|
||||
parts = [outer]
|
||||
for s in (-1, 1):
|
||||
prof = []
|
||||
n = 9
|
||||
for i in range(n + 1):
|
||||
r = core_out + (R - core_out) * i / n
|
||||
x = (L / 2 - 0.02) + (0.008 if i % 2 else 0.0)
|
||||
prof.append((r, x))
|
||||
prof[-1] = (R, L / 2 - 0.02)
|
||||
end = revolve("end", [(r, x * s) for r, x in prof], segs=48, axis="X", close_top=False)
|
||||
bm = bmesh.new(); bm.from_mesh(end.data)
|
||||
for f in bm.faces:
|
||||
if f.normal.x * s < 0:
|
||||
f.normal_flip()
|
||||
bm.to_mesh(end.data); bm.free()
|
||||
uv_box(end, len_density)
|
||||
set_mats(end, "M_WrapRoll")
|
||||
parts.append(end)
|
||||
ext = 0.02 + R * 0.04
|
||||
core = revolve("core", [(core_in, -L / 2 - ext), (core_out, -L / 2 - ext), (core_out, L / 2 + ext), (core_in, L / 2 + ext), (core_in, -L / 2 - ext)],
|
||||
segs=32, axis="X", close_top=False)
|
||||
uv_cyl(core, axis=0, circ_scale=1, len_scale=2)
|
||||
set_mats(core, "M_Cardboard")
|
||||
parts.append(core)
|
||||
if label:
|
||||
bw = 0.34
|
||||
lab = cyl("label", R + 0.006, bw, axis="X", verts=48, cap=False)
|
||||
set_mats(lab, "M_PaintWhite")
|
||||
parts.append(lab)
|
||||
for s in (-1, 1):
|
||||
st = cyl("lstripe", R + 0.009, 0.05, loc=(s * (bw / 2 - 0.045), 0, 0), axis="X", verts=48, cap=False)
|
||||
set_mats(st, "M_PaintRed")
|
||||
parts.append(st)
|
||||
# hazard tape wrap near one end
|
||||
ht = cyl("htape", R + 0.007, 0.08, loc=(-(L / 2 - 0.22), 0, 0), axis="X", verts=48, cap=False)
|
||||
uv_cyl(ht, axis=0, circ_scale=2 * math.pi * R * 2, len_scale=2)
|
||||
set_mats(ht, "M_Hazard")
|
||||
parts.append(ht)
|
||||
# loose tail of wrap on the floor towards -Y (Unity +Z / front)
|
||||
bm = bmesh.new()
|
||||
uvl = bm.loops.layers.uv.verify()
|
||||
pts = []
|
||||
for i in range(5):
|
||||
a = math.radians(-35 + i * 8.75)
|
||||
pts.append((R * 1.02 * math.sin(a) * -1, -R * 1.02 * math.cos(a)))
|
||||
for i in range(1, 6):
|
||||
pts.append((-i * R * 0.3, -R - 0.002))
|
||||
rows = [(bm.verts.new((-L / 2 + 0.03, y, z)), bm.verts.new((L / 2 - 0.03, y, z))) for (y, z) in pts]
|
||||
for i in range(len(rows) - 1):
|
||||
a, b = rows[i], rows[i + 1]
|
||||
f = bm.faces.new((a[0], a[1], b[1], b[0]))
|
||||
for l in f.loops:
|
||||
j = i if l.vert in a else i + 1
|
||||
l[uvl].uv = (l.vert.co.x * len_density, j * 0.04 * len_density)
|
||||
tail = mesh_obj("tail", bm)
|
||||
set_mats(tail, "M_WrapRoll")
|
||||
mod(tail, "SOLIDIFY", thickness=0.005, offset=0)
|
||||
bake(tail)
|
||||
parts.append(tail)
|
||||
o = join(parts, name)
|
||||
smooth(o, 50)
|
||||
return o
|
||||
|
||||
|
||||
def roll_big():
|
||||
make_roll("SM_RollBig", 0.3, 1.2, 0.06, 0.08)
|
||||
return dict(elev=25, azim=-50)
|
||||
|
||||
|
||||
def roll_giant():
|
||||
make_roll("SM_RollGiant", 0.65, 2.0, 0.13, 0.17, circ_density=1.8, len_density=1.65, label=True)
|
||||
return dict(elev=25, azim=-50)
|
||||
|
||||
|
||||
# ======================================================================= build pieces
|
||||
|
||||
BELT_Y = 0.35
|
||||
BW = 0.84
|
||||
|
||||
|
||||
def belt_loop(L, W=BW, ZT=BELT_Y, r=0.05):
|
||||
"""Belt loop along Unity Z (Blender Y), same construction/UVs as SM_Conveyor (V = -metres along flow)."""
|
||||
half = L / 2 - r - 0.005
|
||||
prof = []
|
||||
for i in range(10):
|
||||
a = -math.pi / 2 + math.pi * i / 9
|
||||
prof.append((half + r * math.cos(a), ZT - r + r * math.sin(a)))
|
||||
for i in range(10):
|
||||
a = math.pi / 2 + math.pi * i / 9
|
||||
prof.append((-half + r * math.cos(a), ZT - r + r * math.sin(a)))
|
||||
bm = bmesh.new()
|
||||
uvl = bm.loops.layers.uv.verify()
|
||||
rows = [(bm.verts.new((-W / 2, y, z)), bm.verts.new((W / 2, y, z))) for (y, z) in prof]
|
||||
acc = [0.0]
|
||||
for i in range(1, len(prof) + 1):
|
||||
acc.append(acc[-1] + math.dist(prof[i % len(prof)], prof[i - 1]))
|
||||
n = len(rows)
|
||||
for i in range(n):
|
||||
a, b = rows[i], rows[(i + 1) % n]
|
||||
fc = bm.faces.new((a[0], b[0], b[1], a[1]))
|
||||
for l in fc.loops:
|
||||
j = i if l.vert in a else i + 1
|
||||
u = 0.0 if l.vert in (a[0], b[0]) else 1.0
|
||||
l[uvl].uv = (u, -acc[j])
|
||||
belt = mesh_obj("Belt", bm)
|
||||
tb = bmesh.new(); tb.from_mesh(belt.data)
|
||||
for f in tb.faces:
|
||||
c = f.calc_center_median()
|
||||
if f.normal.dot(Vector((0, c.y * 0.3, c.z - (ZT - r)))) < 0:
|
||||
f.normal_flip()
|
||||
tb.to_mesh(belt.data); tb.free()
|
||||
set_mats(belt, "M_ConveyorBelt")
|
||||
mod(belt, "SOLIDIFY", thickness=0.01, offset=-1)
|
||||
bake(belt)
|
||||
smooth(belt, 40)
|
||||
return belt, half, r
|
||||
|
||||
|
||||
def belt_frame_parts(L, half, r, rails=True, legs_at=None):
|
||||
P = []
|
||||
W = BW
|
||||
for s in (-1, 1):
|
||||
P.append(ucyl("roll", r - 0.01, W + 0.05, (0, BELT_Y - r, s * half), "X", verts=14, m="M_Metal"))
|
||||
x = s * (W / 2 + 0.035)
|
||||
# skirt under the belt
|
||||
P.append(ubox("skirt", x - 0.025, x + 0.025, 0.06, BELT_Y - 0.02, -L / 2 + 0.01, L / 2 - 0.01, "M_PaintYellow", bevel=0.012, segs=1))
|
||||
if rails:
|
||||
P.append(ubox("rail", x - 0.03, x + 0.03, BELT_Y - 0.05, BELT_Y + 0.15, -L / 2 + 0.01, L / 2 - 0.01, "M_PaintYellow", bevel=0.022, segs=2))
|
||||
P.append(ubox("lip", x - 0.045 - 0.005 * s, x + 0.045 - 0.005 * s, BELT_Y + 0.12, BELT_Y + 0.16, -L / 2 + 0.01, L / 2 - 0.01, "M_PaintYellow", bevel=0.015, segs=2))
|
||||
for zz in (-half, half):
|
||||
P.append(ucyl("cap", 0.03, 0.025, (s * (W / 2 + 0.075), BELT_Y - r, zz), "X", verts=12, m="M_DarkGrey"))
|
||||
for zz in (legs_at or (-L / 2 + 0.12, L / 2 - 0.12)):
|
||||
P.append(ubox("foot", x - 0.06, x + 0.06, 0, 0.06, zz - 0.06, zz + 0.06, "M_Rubber", bevel=0.015, segs=1))
|
||||
P.append(ubox("tray", -W / 2, W / 2, 0.1, 0.13, -L / 2 + 0.04, L / 2 - 0.04, "M_DarkGrey"))
|
||||
return P
|
||||
|
||||
|
||||
def belt():
|
||||
b, half, r = belt_loop(1.0)
|
||||
P = belt_frame_parts(1.0, half, r)
|
||||
finalize(P, "Frame")
|
||||
return dict(elev=35, azim=-40)
|
||||
|
||||
|
||||
def belt_turn():
|
||||
cx, cz = 0.5, -0.5
|
||||
ri, ro = 0.08, 0.92
|
||||
nA, nR = 16, 2
|
||||
arc_c = 0.5 * math.pi / 2
|
||||
|
||||
def pt(rad, t, y):
|
||||
th = math.pi - (math.pi / 2) * t
|
||||
return (cx + rad * math.cos(th), y, cz + rad * math.sin(th))
|
||||
# belt slab (top + bottom + sides + ends)
|
||||
bm = bmesh.new()
|
||||
uvl = bm.loops.layers.uv.verify()
|
||||
top = [[bm.verts.new(B(*pt(ri + (ro - ri) * j / nR, i / nA, BELT_Y))) for j in range(nR + 1)] for i in range(nA + 1)]
|
||||
bot = [[bm.verts.new(B(*pt(ri + (ro - ri) * j / nR, i / nA, BELT_Y - 0.035))) for j in range(nR + 1)] for i in range(nA + 1)]
|
||||
for i in range(nA):
|
||||
for j in range(nR):
|
||||
f = bm.faces.new((top[i][j], top[i + 1][j], top[i + 1][j + 1], top[i][j + 1]))
|
||||
for l in f.loops:
|
||||
ii = i if l.vert in (top[i][j], top[i][j + 1]) else i + 1
|
||||
jj = j if l.vert in (top[i][j], top[i + 1][j]) else j + 1
|
||||
l[uvl].uv = (jj / nR, -arc_c * ii / nA)
|
||||
bm.faces.new((bot[i][j + 1], bot[i + 1][j + 1], bot[i + 1][j], bot[i][j]))
|
||||
bm.faces.new((top[i][0], bot[i][0], bot[i + 1][0], top[i + 1][0]))
|
||||
bm.faces.new((top[i + 1][nR], bot[i + 1][nR], bot[i][nR], top[i][nR]))
|
||||
for i in (0, nA):
|
||||
for j in range(nR):
|
||||
bm.faces.new((top[i][j], top[i][j + 1], bot[i][j + 1], bot[i][j]))
|
||||
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
||||
bt = mesh_obj("Belt", bm)
|
||||
set_mats(bt, "M_ConveyorBelt")
|
||||
smooth(bt, 40)
|
||||
# frame
|
||||
P = []
|
||||
n = 12
|
||||
outer = [pt(0.965, i / n, 0) for i in range(n + 1)]
|
||||
for i in range(n):
|
||||
a, b = outer[i], outer[i + 1]
|
||||
mx, mz = (a[0] + b[0]) / 2, (a[2] + b[2]) / 2
|
||||
ln = math.dist((a[0], a[2]), (b[0], b[2])) + 0.03
|
||||
ang = math.atan2(b[0] - a[0], b[2] - a[2])
|
||||
sk = ubox("skirt", -0.025, 0.025, 0.06, BELT_Y - 0.02, -ln / 2, ln / 2, "M_PaintYellow", bevel=0.01, segs=1)
|
||||
rl = ubox("rail", -0.03, 0.03, BELT_Y - 0.05, BELT_Y + 0.15, -ln / 2, ln / 2, "M_PaintYellow", bevel=0.02, segs=2)
|
||||
for o in (sk, rl):
|
||||
o.rotation_euler = (0, 0, -ang)
|
||||
o.location = B(mx, 0, mz)
|
||||
apply_xform(o)
|
||||
P.append(o)
|
||||
lip = utube("lip", [pt(0.965, i / n, BELT_Y + 0.14) for i in range(n + 1)], 0.03, "M_PaintYellow", res=2, segs=6)
|
||||
P.append(lip)
|
||||
P.append(ucyl("post", 0.055, BELT_Y + 0.15, (cx, (BELT_Y + 0.15) / 2, cz), "Y", verts=14, m="M_PaintYellow", bevel=0.015))
|
||||
P.append(ucyl("postcap", 0.07, 0.04, (cx, BELT_Y + 0.15, cz), "Y", verts=14, m="M_DarkGrey", bevel=0.012))
|
||||
for t in (0.15, 0.85):
|
||||
x, _, z = pt(0.9, t, 0)
|
||||
P.append(ubox("foot", x - 0.06, x + 0.06, 0, 0.06, z - 0.06, z + 0.06, "M_Rubber", bevel=0.015, segs=1))
|
||||
P.append(ubox("leg", x - 0.03, x + 0.03, 0.06, BELT_Y - 0.04, z - 0.03, z + 0.03, "M_DarkGrey"))
|
||||
# under tray wedge
|
||||
tr = [pt(0.1, i / 8, 0.1) for i in range(9)] + [pt(0.9, (8 - i) / 8, 0.1) for i in range(9)]
|
||||
bm = bmesh.new()
|
||||
vs0 = [bm.verts.new(B(*p)) for p in tr]
|
||||
vs1 = [bm.verts.new(B(p[0], 0.13, p[2])) for p in tr]
|
||||
bm.faces.new(vs0); bm.faces.new(list(reversed(vs1)))
|
||||
for i in range(len(tr)):
|
||||
j = (i + 1) % len(tr)
|
||||
bm.faces.new((vs0[i], vs0[j], vs1[j], vs1[i]))
|
||||
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
||||
tro = mesh_obj("tray", bm)
|
||||
set_mats(tro, "M_DarkGrey")
|
||||
P.append(tro)
|
||||
finalize(P, "Frame")
|
||||
return dict(elev=45, azim=-30)
|
||||
|
||||
|
||||
def lamp_parts(P, x, y, z):
|
||||
P.append(ucyl("lbase", 0.08, 0.05, (x, y + 0.025, z), "Y", verts=14, m="M_DarkGrey", bevel=0.012))
|
||||
lamp = usphere("Lamp", 0.07, (x, y + 0.05, z), "M_Emissive", seg=14, rings=7, scale=(1, 1.1, 1))
|
||||
bm = bmesh.new(); bm.from_mesh(lamp.data)
|
||||
bmesh.ops.delete(bm, geom=[v for v in bm.verts if v.co.z < y + 0.05 - 1e-4], context="VERTS")
|
||||
bm.to_mesh(lamp.data); bm.free()
|
||||
smooth(lamp, 80)
|
||||
lamp.name = "Lamp"
|
||||
return lamp
|
||||
|
||||
|
||||
def machine_opener():
|
||||
b, half, r = belt_loop(2.0)
|
||||
P = belt_frame_parts(2.0, half, r, legs_at=(-0.85, 0.85))
|
||||
D = 0.35
|
||||
for s in (-1, 1):
|
||||
xa, xb = (0.475, 0.64) if s > 0 else (-0.64, -0.475)
|
||||
P.append(ubox("pillar", xa, xb, 0.0, 1.8, -D, D, "M_PaintYellow", bevel=0.05, segs=3))
|
||||
P.append(ubox("pfoot", xa - 0.03, xb + 0.03, 0.0, 0.08, -D - 0.04, D + 0.04, "M_DarkGrey", bevel=0.02, segs=2))
|
||||
P.append(ubox("beam", -0.64, 0.64, 1.25, 1.8, -D, D, "M_PaintYellow", bevel=0.06, segs=3))
|
||||
for f in (1, -1):
|
||||
P.append(ubox("haz", -0.6, 0.6, 1.33, 1.5, f * D - 0.012 if f > 0 else -D - 0.012, f * D + 0.012 if f > 0 else -D + 0.012, "M_Hazard"))
|
||||
# blade guard + motor
|
||||
P.append(ubox("slot", -0.03, 0.03, 1.2, 1.26, -0.34, 0.34, "M_DarkGrey"))
|
||||
P.append(ubox("motor", 0.64, 0.86, 1.3, 1.66, -0.2, 0.2, "M_PaintRed", bevel=0.05, segs=2))
|
||||
for k in range(4):
|
||||
P.append(ubox("vent", 0.855, 0.875, 1.36 + k * 0.07, 1.39 + k * 0.07, -0.15, 0.15, "M_DarkGrey"))
|
||||
P.append(ucyl("shaft", 0.04, 0.3, (0.6, 1.3, 0), "X", verts=10, m="M_Metal"))
|
||||
lamp = lamp_parts(P, -0.4, 1.8, 0)
|
||||
finalize(P, "Body")
|
||||
# saw blade (spins about X), centre (0, 1.3, 0)
|
||||
pts = []
|
||||
teeth = 20
|
||||
for i in range(teeth * 2):
|
||||
a = 2 * math.pi * i / (teeth * 2)
|
||||
rr = 0.3 if i % 2 == 0 else 0.255
|
||||
a2 = a + (0.06 if i % 2 == 0 else 0)
|
||||
pts.append((rr * math.cos(a2), 1.3 + rr * math.sin(a2)))
|
||||
bl = extrude_poly("disc", pts, "ZY", -0.012, 0.012, "M_Metal")
|
||||
hub = ucyl("hub", 0.075, 0.06, (0, 1.3, 0), "X", verts=16, m="M_PaintRed", bevel=0.012)
|
||||
blade = join([bl, hub], "Blade")
|
||||
smooth(blade, 30)
|
||||
uv_box(blade, 1)
|
||||
set_origin(blade, B(0, 1.3, 0))
|
||||
return dict(elev=25, azim=-40)
|
||||
|
||||
|
||||
def machine_press():
|
||||
b, half, r = belt_loop(2.0)
|
||||
P = belt_frame_parts(2.0, half, r, legs_at=(-0.85, 0.85))
|
||||
for s in (-1, 1):
|
||||
xa, xb = (0.5, 0.62) if s > 0 else (-0.62, -0.5)
|
||||
P.append(ubox("plate", xa, xb, 0.0, 1.2, -0.45, 0.45, "M_PaintBlue", bevel=0.04, segs=2))
|
||||
P.append(ubox("haz", xa - 0.005, xb + 0.005, 0.02, 0.17, -0.455, 0.455, "M_Hazard"))
|
||||
P.append(ubox("bearing", s * 0.47 - 0.05, s * 0.47 + 0.05, 0.53, 0.77, -0.13, 0.13, "M_DarkGrey", bevel=0.02, segs=2))
|
||||
# hydraulic piston
|
||||
P.append(ucyl("piston", 0.055, 0.32, (s * 0.38, 0.98, 0), "Y", verts=14, m="M_Metal", bevel=0.01))
|
||||
P.append(ucyl("rod", 0.025, 0.2, (s * 0.38, 0.77, 0), "Y", verts=10, m="M_Metal"))
|
||||
P.append(ubox("top", -0.62, 0.62, 1.1, 1.3, -0.25, 0.25, "M_PaintBlue", bevel=0.05, segs=3))
|
||||
P.append(ubox("warn", -0.3, 0.3, 1.16, 1.25, 0.245, 0.265, "M_PaintYellow", bevel=0.01, segs=1))
|
||||
lamp_parts(P, 0.35, 1.3, 0)
|
||||
finalize(P, "Body")
|
||||
R = []
|
||||
R.append(ucyl("drum", 0.25, 0.86, (0, 0.65, 0), "X", verts=28, m="M_Metal", bevel=0.02))
|
||||
for k in range(5):
|
||||
x = -0.32 + k * 0.16
|
||||
R.append(ucyl("ring", 0.262, 0.035, (x, 0.65, 0), "X", verts=28, m="M_DarkGrey"))
|
||||
for s in (-1, 1):
|
||||
R.append(ucyl("end", 0.12, 0.06, (s * 0.45, 0.65, 0), "X", verts=16, m="M_PaintRed", bevel=0.012))
|
||||
ro = join(R, "Roller")
|
||||
uv_box(ro, 1)
|
||||
smooth(ro, 40)
|
||||
set_origin(ro, B(0, 0.65, 0))
|
||||
return dict(elev=25, azim=-40)
|
||||
|
||||
|
||||
def recycle_badge(P, c, normal_axis, scale=1.0):
|
||||
"""White disc with three chunky arrows; c = centre on the face, normal_axis = '+Z' / '+X' / '-X'."""
|
||||
def place(o):
|
||||
rot = {"+Z": 0.0, "+X": math.pi / 2, "-X": -math.pi / 2}[normal_axis]
|
||||
# parts are built facing +Z around origin; rotate about Unity Y (Blender Z) then move
|
||||
o.rotation_euler = (0, 0, -rot)
|
||||
o.location = B(*c)
|
||||
apply_xform(o)
|
||||
P.append(o)
|
||||
place(ucyl("disc", 0.26 * scale, 0.02, (0, 0, 0.0), "Z", verts=28, m="M_PaintWhite", bevel=0.008))
|
||||
for k in range(3):
|
||||
a0 = math.radians(90 + k * 120 + 15)
|
||||
a1 = math.radians(90 + k * 120 + 95)
|
||||
pts = []
|
||||
for i in range(5):
|
||||
a = a0 + (a1 - a0) * i / 4
|
||||
pts.append((0.16 * scale * math.cos(a), 0.16 * scale * math.sin(a), 0.02))
|
||||
place(utube("arc", pts, 0.032 * scale, "M_PaintGreen", res=3, segs=6))
|
||||
ah = a1 + math.radians(4)
|
||||
tip = (0.16 * scale * math.cos(ah), 0.16 * scale * math.sin(ah))
|
||||
tang = (-math.sin(ah), math.cos(ah))
|
||||
nrm = (math.cos(ah), math.sin(ah))
|
||||
w = 0.075 * scale
|
||||
tri = [(tip[0] + tang[0] * 0.08 * scale, tip[1] + tang[1] * 0.08 * scale),
|
||||
(tip[0] + nrm[0] * w, tip[1] + nrm[1] * w),
|
||||
(tip[0] - nrm[0] * w, tip[1] - nrm[1] * w)]
|
||||
place(extrude_poly("head", tri, "XY", 0.0, 0.05, "M_PaintGreen"))
|
||||
|
||||
|
||||
def machine_compactor():
|
||||
P = []
|
||||
body = ubox("bin", -1.0, 1.0, 0.1, 1.6, -1.0, 1.0, "M_PaintGreen", bevel=0.1, segs=3)
|
||||
cut = cube("cut", (1.0, 1.9, 0.85), B(0, 0.775, -1.0))
|
||||
mod(body, "BOOLEAN", operation="DIFFERENCE", object=cut, solver="EXACT")
|
||||
bake(body)
|
||||
bpy.data.objects.remove(cut)
|
||||
P.append(body)
|
||||
# dark cavity lining (open toward -Z)
|
||||
bm = bmesh.new()
|
||||
bmesh.ops.create_cube(bm, size=1.0)
|
||||
bmesh.ops.scale(bm, vec=(0.98, 0.93, 0.84), verts=bm.verts)
|
||||
bmesh.ops.translate(bm, vec=B(0, 0.775, -0.525), verts=bm.verts)
|
||||
bmesh.ops.delete(bm, geom=[f for f in bm.faces if f.normal.y > 0.9], context="FACES_ONLY")
|
||||
bmesh.ops.reverse_faces(bm, faces=bm.faces)
|
||||
lin = mesh_obj("lining", bm)
|
||||
set_mats(lin, "M_DarkGrey")
|
||||
P.append(lin)
|
||||
P.append(ubox("base", -1.04, 1.04, 0.0, 0.14, -1.04, 1.04, "M_DarkGrey", bevel=0.05, segs=2))
|
||||
# intake hazard frame
|
||||
P.append(ubox("hz", -0.62, -0.5, 0.3, 1.32, -1.03, -0.97, "M_Hazard", bevel=0.015, segs=1))
|
||||
P.append(ubox("hz", 0.5, 0.62, 0.3, 1.32, -1.03, -0.97, "M_Hazard", bevel=0.015, segs=1))
|
||||
P.append(ubox("hz", -0.62, 0.62, 1.2, 1.32, -1.03, -0.97, "M_Hazard", bevel=0.015, segs=1))
|
||||
P.append(ubox("lip", -0.5, 0.5, 0.3, 0.35, -1.06, -0.6, "M_Metal", bevel=0.01, segs=1))
|
||||
# hydraulic tower + exhaust
|
||||
P.append(ubox("tower", -0.35, 0.35, 1.6, 1.85, -0.75, -0.15, "M_DarkGrey", bevel=0.05, segs=2))
|
||||
P.append(ucyl("cylinder", 0.12, 0.35, (0, 1.95, -0.45), "Y", verts=16, m="M_Metal", bevel=0.015))
|
||||
P.append(ucyl("stack", 0.08, 0.7, (0.7, 1.95, 0.7), "Y", verts=14, m="M_DarkGrey", bevel=0.01))
|
||||
P.append(ucyl("stackcap", 0.11, 0.05, (0.7, 2.32, 0.7), "Y", verts=14, m="M_Metal", bevel=0.012))
|
||||
for s in (-1, 1):
|
||||
P.append(ubox("rib", s * 1.0 - 0.04, s * 1.0 + 0.04, 0.2, 1.5, -0.6, 0.6, "M_PaintGreen", bevel=0.02, segs=1))
|
||||
lamp_parts(P, -0.65, 1.6, 0.65)
|
||||
recycle_badge(P, (0, 0.85, 1.0), "+Z", 1.15)
|
||||
recycle_badge(P, (1.04, 0.85, 0.15), "-X" if False else "+X", 0.9)
|
||||
recycle_badge(P, (-1.04, 0.85, 0.15), "-X", 0.9)
|
||||
finalize(P, "Body", ang=35)
|
||||
C = [ubox("plate", -0.46, 0.46, 1.08, 1.17, -0.97, -0.2, "M_Metal", bevel=0.02, segs=2),
|
||||
ucyl("rod", 0.045, 0.45, (0, 1.38, -0.55), "Y", verts=12, m="M_Metal")]
|
||||
for k in range(4):
|
||||
x = -0.33 + k * 0.22
|
||||
C.append(ubox("tooth", x - 0.05, x + 0.05, 1.03, 1.08, -0.95, -0.25, "M_DarkGrey", bevel=0.012, segs=1))
|
||||
cr = join(C, "Crusher")
|
||||
uv_box(cr, 1)
|
||||
smooth(cr, 35)
|
||||
set_origin(cr, B(0, 1.12, -0.58))
|
||||
return dict(elev=28, azim=-140)
|
||||
|
||||
|
||||
# ======================================================================= gadgets
|
||||
|
||||
def grip(P, m="M_Rubber"):
|
||||
P.append(ucyl("grip", 0.027, 0.15, (0, 0, 0), "Y", verts=14, m=m, bevel=0.012))
|
||||
P.append(ucyl("gripcap", 0.032, 0.02, (0, -0.08, 0), "Y", verts=14, m="M_DarkGrey", bevel=0.008))
|
||||
|
||||
|
||||
def gadget_blower():
|
||||
P = []
|
||||
grip(P)
|
||||
P.append(ubox("trigger", -0.01, 0.01, 0.03, 0.07, 0.025, 0.05, "M_PaintRed", bevel=0.006, segs=1))
|
||||
P.append(ubox("engine", -0.08, 0.08, 0.07, 0.24, -0.2, 0.06, "M_PaintOrange", bevel=0.05, segs=3))
|
||||
P.append(usphere("fan", 0.105, (0.0, 0.17, 0.05), "M_PaintOrange", seg=18, rings=9, scale=(0.85, 1, 1)))
|
||||
P.append(ucyl("starter", 0.06, 0.03, (0.09, 0.16, -0.08), "X", verts=16, m="M_DarkGrey", bevel=0.008))
|
||||
P.append(ucyl("pull", 0.012, 0.05, (0.12, 0.16, -0.08), "X", verts=8, m="M_PaintRed"))
|
||||
P.append(ucyl("fuel", 0.025, 0.03, (-0.03, 0.255, -0.12), "Y", verts=10, m="M_DarkGrey", bevel=0.006))
|
||||
P.append(ubox("vent", -0.082, 0.082, 0.1, 0.13, -0.18, -0.05, "M_DarkGrey"))
|
||||
P.append(utube("tube", [(0, 0.15, 0.1), (0, 0.12, 0.25), (0, 0.09, 0.43)], 0.038, "M_PaintOrange", res=4, segs=8))
|
||||
P.append(ucyl("nozzle", 0.05, 0.08, (0, 0.087, 0.46), "Z", verts=16, m="M_DarkGrey", r2=0.04, bevel=0.008))
|
||||
P.append(ucyl("band", 0.043, 0.025, (0, 0.11, 0.3), "Z", verts=14, m="M_DarkGrey"))
|
||||
finalize(P, "SM_Gadget_Blower", uv=4)
|
||||
return dict(elev=20, azim=-60)
|
||||
|
||||
|
||||
def gadget_vac():
|
||||
P = []
|
||||
grip(P)
|
||||
P.append(ubox("trigger", -0.01, 0.01, 0.03, 0.07, 0.025, 0.05, "M_PaintYellow", bevel=0.006, segs=1))
|
||||
P.append(ubox("body", -0.065, 0.065, 0.06, 0.17, -0.22, 0.08, "M_PaintBlue", bevel=0.04, segs=3))
|
||||
P.append(ucyl("canister", 0.07, 0.24, (0, 0.22, -0.03), "Z", verts=20, m="M_Glass"))
|
||||
for z in (-0.15, 0.09):
|
||||
P.append(torus("ring", 0.072, 0.012, loc=B(0, 0.22, z), axis="Y", seg=20, rseg=6, m="M_PaintWhite"))
|
||||
rnd = random.Random(3)
|
||||
for k in range(9):
|
||||
c = (rnd.uniform(-0.035, 0.035), 0.2 + rnd.uniform(-0.035, 0.03), rnd.uniform(-0.1, 0.06))
|
||||
P.append(usphere("bit", rnd.uniform(0.012, 0.022), c, rnd.choice(["M_PaintRed", "M_PaintYellow", "M_PaintGreen", "M_Cardboard", "M_PaintWhite"]), seg=8, rings=5))
|
||||
P.append(ucyl("neck", 0.04, 0.08, (0, 0.13, 0.12), "Z", verts=14, m="M_DarkGrey"))
|
||||
P.append(ucyl("funnel", 0.04, 0.24, (0, 0.13, 0.28), "Z", verts=20, m="M_PaintBlue", r2=0.085, cap=False))
|
||||
P.append(torus("lipring", 0.085, 0.012, loc=B(0, 0.13, 0.4), axis="Y", seg=20, rseg=6, m="M_PaintYellow"))
|
||||
for k in range(3):
|
||||
P.append(ubox("fin", -0.075, 0.075, 0.08 + k * 0.03, 0.095 + k * 0.03, -0.235, -0.2, "M_DarkGrey"))
|
||||
P.append(ucyl("tank", 0.035, 0.14, (0.08, 0.11, -0.12), "Z", verts=12, m="M_PaintYellow", bevel=0.01))
|
||||
finalize(P, "SM_Gadget_Vac", uv=4)
|
||||
return dict(elev=20, azim=-60)
|
||||
|
||||
|
||||
def gadget_bomb():
|
||||
P = [usphere("core", 0.068, (0, 0, 0), "M_PaintRed", seg=20, rings=10)]
|
||||
P.append(usphere("shell", 0.074, (0, 0, 0), "M_BubblePlastic", seg=20, rings=10))
|
||||
bm = bmesh.new()
|
||||
bmesh.ops.create_icosphere(bm, subdivisions=2, radius=1.0)
|
||||
dirs = [v.co.copy() for v in bm.verts]
|
||||
bm.free()
|
||||
for d in dirs:
|
||||
if d.z > 0.8:
|
||||
continue # leave room for the cap (Blender +Z is up)
|
||||
dm = usphere("dome", 0.018, (0, 0, 0), "M_BubblePlastic", seg=8, rings=4)
|
||||
apply_xform(dm)
|
||||
q = Vector((0, 0, 1)).rotation_difference(d)
|
||||
dm.rotation_mode = "QUATERNION"
|
||||
dm.rotation_quaternion = q
|
||||
dm.location = d * 0.072
|
||||
apply_xform(dm)
|
||||
P.append(dm)
|
||||
P.append(ucyl("cap", 0.03, 0.035, (0, 0.085, 0), "Y", verts=14, m="M_Metal", bevel=0.008))
|
||||
P.append(ubox("lever", -0.012, 0.012, 0.03, 0.1, 0.02, 0.035, "M_Metal", bevel=0.005, segs=1))
|
||||
P.append(torus("ring", 0.022, 0.005, loc=B(0.04, 0.095, 0), axis="Y", seg=16, rseg=6, m="M_PaintYellow"))
|
||||
finalize(P, "SM_Gadget_Bomb", uv=6, ang=60)
|
||||
return dict(elev=20)
|
||||
|
||||
|
||||
def gadget_tablet():
|
||||
P = [ubox("body", -0.15, 0.15, 0.0, 0.22, -0.016, 0.016, "M_DarkGrey", bevel=0.012, segs=2)]
|
||||
for (x, y) in ((-0.15, 0.0), (0.15, 0.0), (-0.15, 0.22), (0.15, 0.22)):
|
||||
P.append(ubox("bumper", x - 0.028, x + 0.028, y - 0.028, y + 0.028, -0.022, 0.022, "M_PaintYellow", bevel=0.014, segs=2))
|
||||
P.append(ubox("handle", -0.08, 0.08, -0.03, 0.005, -0.012, 0.012, "M_PaintYellow", bevel=0.01, segs=2))
|
||||
P.append(ubox("logo", -0.03, 0.03, 0.09, 0.13, 0.016, 0.019, "M_PaintYellow", bevel=0.004, segs=1))
|
||||
finalize(P, "Body", uv=4)
|
||||
xa, xb, ya, yb, z = -0.125, 0.125, 0.025, 0.195, -0.0175
|
||||
# viewer behind the tablet (at -Z, looking +Z): their right is +X
|
||||
sc = quad("Screen", [(xa, ya, z), (xb, ya, z), (xb, yb, z), (xa, yb, z)], [(0, 0), (1, 0), (1, 1), (0, 1)], "M_Screen")
|
||||
face_toward(sc, (0, 0, -1))
|
||||
return dict(elev=10, azim=-160)
|
||||
|
||||
|
||||
# ======================================================================= icon props
|
||||
|
||||
def icon_coin():
|
||||
prof = [(0.0, 0.026), (0.19, 0.026), (0.205, 0.038), (0.235, 0.038), (0.25, 0.022), (0.25, -0.022), (0.235, -0.038), (0.205, -0.038), (0.19, -0.026), (0.0, -0.026)]
|
||||
c = revolve("coin", prof, segs=40, m="M_Gold", axis="Y", close_top=False)
|
||||
P = [c]
|
||||
for f in (1, -1):
|
||||
zf = f * 0.04
|
||||
s = [(0.075, 0.08), (0.0, 0.11), (-0.075, 0.075), (-0.05, 0.015), (0.05, -0.015), (0.075, -0.075), (0.0, -0.11), (-0.075, -0.08)]
|
||||
s = [(x * f, y, zf) for (x, y) in s]
|
||||
P.append(utube("S", s, 0.028, "M_PaintYellow", res=6, segs=8))
|
||||
P.append(utube("bar", [(0, 0.15, zf), (0, -0.15, zf)], 0.02, "M_PaintYellow", res=1, segs=8))
|
||||
finalize(P, "SM_IconCoin", uv=0, ang=50)
|
||||
return dict(elev=5, azim=-15)
|
||||
|
||||
|
||||
def icon_flat(name, pts, m, t=0.1, bev=0.03):
|
||||
o = extrude_poly(name, pts, "XY", -t / 2, t / 2, m)
|
||||
puff(o, bev, segs=3, angle=30)
|
||||
smooth(o, 50)
|
||||
return o
|
||||
|
||||
|
||||
def icon_arrow():
|
||||
pts = [(-0.09, -0.26), (0.09, -0.26), (0.09, 0.02), (0.22, 0.02), (0.0, 0.27), (-0.22, 0.02), (-0.09, 0.02)]
|
||||
icon_flat("SM_IconArrow", pts, "M_PaintGreen")
|
||||
return dict(elev=5, azim=-15)
|
||||
|
||||
|
||||
def icon_bolt():
|
||||
pts = [(0.06, 0.3), (-0.16, -0.02), (-0.02, -0.02), (-0.08, -0.3), (0.17, 0.05), (0.03, 0.05), (0.12, 0.3)]
|
||||
icon_flat("SM_IconBolt", pts, "M_PaintYellow", bev=0.025)
|
||||
return dict(elev=5, azim=-15)
|
||||
|
||||
|
||||
def icon_star():
|
||||
pts = []
|
||||
for i in range(10):
|
||||
a = math.pi / 2 + i * math.pi / 5
|
||||
r = 0.28 if i % 2 == 0 else 0.13
|
||||
pts.append((r * math.cos(a), r * math.sin(a)))
|
||||
icon_flat("SM_IconStar", pts, "M_Gold", t=0.11, bev=0.035)
|
||||
return dict(elev=5, azim=-15)
|
||||
|
||||
|
||||
def icon_gear():
|
||||
pts = []
|
||||
teeth = 8
|
||||
for i in range(teeth):
|
||||
a0 = 2 * math.pi * i / teeth
|
||||
for (da, r) in ((-0.2, 0.19), (-0.13, 0.26), (0.13, 0.26), (0.2, 0.19)):
|
||||
a = a0 + da
|
||||
pts.append((r * math.cos(a), r * math.sin(a)))
|
||||
a = a0 + math.pi / teeth
|
||||
pts.append((0.19 * math.cos(a), 0.19 * math.sin(a)))
|
||||
o = extrude_poly("SM_IconGear", pts, "XY", -0.05, 0.05, "M_Metal")
|
||||
puff(o, 0.02, segs=2, angle=30)
|
||||
hole = ucyl("hole", 0.075, 0.3, (0, 0, 0), "Z", verts=24)
|
||||
mod(o, "BOOLEAN", operation="DIFFERENCE", object=hole, solver="EXACT")
|
||||
bake(o)
|
||||
bpy.data.objects.remove(hole)
|
||||
smooth(o, 40)
|
||||
return dict(elev=5, azim=-15)
|
||||
|
||||
|
||||
def icon_clock():
|
||||
prof = [(0.0, -0.04), (0.18, -0.04), (0.2, -0.05), (0.225, -0.045), (0.24, -0.02), (0.24, 0.02), (0.225, 0.045), (0.0, 0.045)]
|
||||
P = [revolve("case", prof, segs=40, m="M_PaintRed", axis="Y", close_top=False)]
|
||||
P.append(ucyl("face", 0.185, 0.012, (0, 0, 0.042), "Z", verts=36, m="M_PaintWhite"))
|
||||
for k in range(12):
|
||||
a = 2 * math.pi * k / 12
|
||||
L = 0.04 if k % 3 == 0 else 0.022
|
||||
x, y = 0.15 * math.sin(a), 0.15 * math.cos(a)
|
||||
o = ubox("tick", -0.008, 0.008, -L / 2, L / 2, 0.045, 0.054, "M_DarkGrey")
|
||||
o.rotation_euler = (0, a, 0) if False else (0, -a, 0)
|
||||
o.location = B(x, y, 0)
|
||||
apply_xform(o)
|
||||
P.append(o)
|
||||
P.append(utube("hand", [(0, 0, 0.056), (0, 0.12, 0.056)], 0.012, "M_DarkGrey", res=1, segs=6))
|
||||
P.append(utube("hand", [(0, 0, 0.056), (0.08, -0.03, 0.056)], 0.012, "M_PaintRed", res=1, segs=6))
|
||||
P.append(ucyl("pin", 0.02, 0.02, (0, 0, 0.06), "Z", verts=12, m="M_DarkGrey"))
|
||||
P.append(ucyl("stem", 0.03, 0.05, (0, 0.26, 0), "Y", verts=12, m="M_Metal"))
|
||||
P.append(ucyl("button", 0.045, 0.04, (0, 0.3, 0), "Y", verts=14, m="M_PaintRed", bevel=0.01))
|
||||
side = ucyl("side", 0.025, 0.05, (0, 0, 0), "Y", verts=10, m="M_Metal", bevel=0.006)
|
||||
side.rotation_euler = (0, -math.radians(-40), 0)
|
||||
side.location = B(0.17, 0.2, 0)
|
||||
apply_xform(side)
|
||||
P.append(side)
|
||||
finalize(P, "SM_IconClock", uv=0, ang=50)
|
||||
return dict(elev=5, azim=-15)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run({
|
||||
"SM_WH_Wall": wh_wall,
|
||||
"SM_WH_WallWindow": wh_wall_window,
|
||||
"SM_WH_Pillar": wh_pillar,
|
||||
"SM_WH_Roof": wh_roof,
|
||||
"SM_WH_Partition": wh_partition,
|
||||
"SM_WH_GateWall": wh_gate_wall,
|
||||
"SM_WH_Shutter": wh_shutter,
|
||||
"SM_HangingSign": hanging_sign,
|
||||
"SM_PalletRack": pallet_rack,
|
||||
"SM_PalletWrapped": pallet_wrapped,
|
||||
"SM_RollBig": roll_big,
|
||||
"SM_RollGiant": roll_giant,
|
||||
"SM_Belt": belt,
|
||||
"SM_BeltTurn": belt_turn,
|
||||
"SM_MachineOpener": machine_opener,
|
||||
"SM_MachinePress": machine_press,
|
||||
"SM_MachineCompactor": machine_compactor,
|
||||
"SM_Gadget_Blower": gadget_blower,
|
||||
"SM_Gadget_Vac": gadget_vac,
|
||||
"SM_Gadget_Bomb": gadget_bomb,
|
||||
"SM_Gadget_Tablet": gadget_tablet,
|
||||
"SM_IconCoin": icon_coin,
|
||||
"SM_IconArrow": icon_arrow,
|
||||
"SM_IconBolt": icon_bolt,
|
||||
"SM_IconClock": icon_clock,
|
||||
"SM_IconStar": icon_star,
|
||||
"SM_IconGear": icon_gear,
|
||||
})
|
||||
Reference in New Issue
Block a user