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>
302 lines
14 KiB
Python
302 lines
14 KiB
Python
"""Decor: shelf rack, pallet, pop table, lamp, plant, sign, truck, forklift."""
|
|
import sys, os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
from common import *
|
|
|
|
|
|
def bx(x0, x1, y0, y1, z0, z1, m, bevel=0.0, segs=2, name="b"):
|
|
size = (x1 - x0, y1 - y0, z1 - z0)
|
|
loc = ((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2)
|
|
return rbox(name, size, loc, bevel=bevel, segs=segs, m=m) if bevel > 0 else cube(name, size, loc, m)
|
|
|
|
|
|
def wheel(name, r, w, loc, rim_m="M_PaintWhite", segs=24):
|
|
W = []
|
|
t = revolve("tire", [(r * 0.55, -w / 2), (r * 0.88, -w / 2), (r, -w / 2 + w * 0.2), (r, w / 2 - w * 0.2), (r * 0.88, w / 2), (r * 0.55, w / 2)], segs=segs, axis="X", close_top=False)
|
|
set_mats(t, "M_Rubber")
|
|
W.append(t)
|
|
W.append(cyl("rim", r * 0.58, w * 0.9, axis="X", verts=segs, m=rim_m, bevel=0.01))
|
|
W.append(cyl("hub", r * 0.22, w, axis="X", verts=12, m="M_DarkGrey"))
|
|
o = join(W, name)
|
|
o.location = loc
|
|
apply_xform(o)
|
|
return o
|
|
|
|
|
|
# ------------------------------------------------------------------------------------------------
|
|
|
|
def shelf_rack():
|
|
P = []
|
|
W, D, H = 3.0, 1.0, 3.0
|
|
for sx in (-1, 1):
|
|
for sy in (-1, 1):
|
|
P.append(bx(sx * W / 2 - 0.045, sx * W / 2 + 0.045, sy * (D / 2) - 0.045, sy * (D / 2) + 0.045, 0, H, "M_PaintOrange", bevel=0.012))
|
|
P.append(bx(sx * W / 2 - 0.08, sx * W / 2 + 0.08, sy * (D / 2) - 0.08, sy * (D / 2) + 0.08, 0, 0.02, "M_DarkGrey"))
|
|
# side bracing (zig-zag)
|
|
zs = [0.2 + i * 0.55 for i in range(6)]
|
|
for i in range(len(zs) - 1):
|
|
a = (sx * W / 2, -D / 2 if i % 2 == 0 else D / 2, zs[i])
|
|
b = (sx * W / 2, D / 2 if i % 2 == 0 else -D / 2, zs[i + 1])
|
|
P.append(tube("br", [a, b], 0.018, m="M_PaintOrange", res=1, segs=4))
|
|
for z in (0.2, H - 0.1):
|
|
P.append(tube("hb", [(sx * W / 2, -D / 2, z), (sx * W / 2, D / 2, z)], 0.02, m="M_PaintOrange", res=1, segs=4))
|
|
for z in (0.15, 1.5, 2.85):
|
|
for sy in (-1, 1):
|
|
P.append(bx(-W / 2, W / 2, sy * D / 2 - 0.035, sy * D / 2 + 0.035, z - 0.06, z + 0.06, "M_PaintBlue", bevel=0.015))
|
|
# wire deck
|
|
for k in range(13):
|
|
x = -W / 2 + 0.1 + k * (W - 0.2) / 12
|
|
P.append(tube("w", [(x, -D / 2, z + 0.065), (x, D / 2, z + 0.065)], 0.007, m="M_Metal", res=1, segs=4))
|
|
for yy in (-0.3, 0.0, 0.3):
|
|
P.append(tube("w", [(-W / 2, yy, z + 0.055), (W / 2, yy, z + 0.055)], 0.008, m="M_Metal", res=1, segs=4))
|
|
o = join(P, "SM_ShelfRack")
|
|
uv_box(o, 1)
|
|
smooth(o, 40)
|
|
return dict(elev=20, azim=-30)
|
|
|
|
|
|
def pallet():
|
|
P = []
|
|
L, W = 1.2, 1.0
|
|
for i in range(7):
|
|
x = -L / 2 + 0.07 + i * (L - 0.14) / 6
|
|
P.append(bx(x - 0.065, x + 0.065, -W / 2, W / 2, 0.122, 0.144, "M_Wood", bevel=0.006))
|
|
for y in (-W / 2 + 0.05, 0, W / 2 - 0.05):
|
|
for x in (-L / 2 + 0.05, 0, L / 2 - 0.05):
|
|
P.append(bx(x - 0.05, x + 0.05, y - 0.05, y + 0.05, 0.022, 0.1, "M_Wood", bevel=0.006))
|
|
P.append(bx(-L / 2, L / 2, y - 0.05, y + 0.05, 0.1, 0.122, "M_Wood", bevel=0.006))
|
|
for x in (-L / 2 + 0.05, 0, L / 2 - 0.05):
|
|
P.append(bx(x - 0.06, x + 0.06, -W / 2, W / 2, 0.0, 0.022, "M_Wood", bevel=0.006))
|
|
o = join(P, "SM_Pallet")
|
|
for i, poly in enumerate(o.data.polygons):
|
|
pass
|
|
# rotate UVs so grain runs along each board: box projection is enough here
|
|
uv_box(o, 1.2)
|
|
smooth(o, 40)
|
|
return dict(elev=30)
|
|
|
|
|
|
def pop_table():
|
|
P = []
|
|
L, W, T = 2.4, 1.2, 0.85
|
|
P.append(bx(-L / 2, L / 2, -W / 2, W / 2, T - 0.07, T, "M_Wood", bevel=0.025, segs=3))
|
|
for sx in (-1, 1):
|
|
for sy in (-1, 1):
|
|
x, y = sx * (L / 2 - 0.12), sy * (W / 2 - 0.12)
|
|
P.append(bx(x - 0.055, x + 0.055, y - 0.055, y + 0.055, 0.04, T - 0.07, "M_PaintBlue", bevel=0.02))
|
|
P.append(cyl("foot", 0.07, 0.04, loc=(x, y, 0.02), verts=16, m="M_Rubber", bevel=0.01))
|
|
for sy in (-1, 1):
|
|
P.append(bx(-L / 2 + 0.12, L / 2 - 0.12, sy * (W / 2 - 0.12) - 0.03, sy * (W / 2 - 0.12) + 0.03, T - 0.2, T - 0.07, "M_PaintYellow", bevel=0.015))
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * (L / 2 - 0.12) - 0.03, sx * (L / 2 - 0.12) + 0.03, -W / 2 + 0.12, W / 2 - 0.12, T - 0.2, T - 0.07, "M_PaintYellow", bevel=0.015))
|
|
P.append(bx(-L / 2 + 0.1, L / 2 - 0.1, -W / 2 + 0.1, W / 2 - 0.1, 0.22, 0.26, "M_Wood", bevel=0.015))
|
|
o = join(P, "SM_PopTable")
|
|
uv_box(o, 1)
|
|
smooth(o, 40)
|
|
return dict(elev=30)
|
|
|
|
|
|
def lamp():
|
|
P = []
|
|
P.append(cyl("mount", 0.06, 0.03, loc=(0, 0, -0.015), verts=16, m="M_DarkGrey"))
|
|
P.append(cyl("cable", 0.008, 1.2, loc=(0, 0, -0.62), verts=8, m="M_Rubber"))
|
|
P.append(cyl("neck", 0.05, 0.12, loc=(0, 0, -1.26), verts=16, m="M_DarkGrey", bevel=0.01))
|
|
shade = revolve("shade", [(0.06, -1.3), (0.12, -1.33), (0.22, -1.42), (0.29, -1.53), (0.32, -1.6), (0.33, -1.62)], segs=32, m="M_PaintYellow", close_top=True)
|
|
bm = bmesh.new(); bm.from_mesh(shade.data)
|
|
bmesh.ops.delete(bm, geom=[f for f in bm.faces if len(f.verts) > 4], context="FACES_ONLY")
|
|
bm.to_mesh(shade.data); bm.free()
|
|
mod(shade, "SOLIDIFY", thickness=0.012, offset=1, material_offset=1, material_offset_rim=0)
|
|
shade.data.materials.append(mat("M_PaintWhite"))
|
|
bake(shade)
|
|
P.append(shade)
|
|
P.append(torus("lip", 0.33, 0.012, loc=(0, 0, -1.62), seg=32, rseg=6, m="M_PaintYellow"))
|
|
body = join(P, "Body")
|
|
smooth(body, 40)
|
|
bulb = sphere("Bulb", 0.07, (0, 0, -1.43), seg=16, rings=10, m="M_Emissive", scale=(1, 1, 1.2))
|
|
smooth(bulb, 80)
|
|
return dict(elev=10)
|
|
|
|
|
|
def leaf(name, length, width, loc, yaw, pitch, curl=0.25):
|
|
bm = bmesh.new()
|
|
nu, nv = 8, 4
|
|
grid = []
|
|
for i in range(nu + 1):
|
|
t = i / nu
|
|
w = width * math.sin(math.pi * min(1.0, t * 1.05)) * (1 - 0.3 * t)
|
|
row = []
|
|
for j in range(nv + 1):
|
|
s = -1 + 2 * j / nv
|
|
x = s * w / 2
|
|
y = t * length
|
|
z = -curl * length * t * t + abs(s) * w * 0.25
|
|
row.append(bm.verts.new((x, y, z)))
|
|
grid.append(row)
|
|
for i in range(nu):
|
|
for j in range(nv):
|
|
bm.faces.new((grid[i][j], grid[i][j + 1], grid[i + 1][j + 1], grid[i + 1][j]))
|
|
o = mesh_obj(name, bm)
|
|
mod(o, "SOLIDIFY", thickness=0.006, offset=0)
|
|
bake(o)
|
|
o.rotation_euler = (pitch, 0, yaw)
|
|
o.location = loc
|
|
apply_xform(o)
|
|
return o
|
|
|
|
|
|
def plant():
|
|
P = []
|
|
pot = revolve("pot", [(0.0, 0.0), (0.17, 0.0), (0.19, 0.03), (0.24, 0.38), (0.27, 0.4), (0.27, 0.46), (0.24, 0.46), (0.22, 0.42)], segs=32, m="M_Pot", close_top=True)
|
|
P.append(pot)
|
|
P.append(cyl("soil", 0.225, 0.02, loc=(0, 0, 0.42), verts=32, m="M_DarkGrey"))
|
|
rnd = random.Random(3)
|
|
for k in range(10):
|
|
yaw = k * 2 * math.pi / 10 + rnd.uniform(-0.2, 0.2)
|
|
h = rnd.uniform(0.45, 0.85)
|
|
lean = rnd.uniform(0.12, 0.3)
|
|
top = (math.sin(yaw) * -lean, math.cos(yaw) * lean, 0.42 + h)
|
|
P.append(tube("stem", [(0, 0, 0.42), (top[0] * 0.4, top[1] * 0.4, 0.42 + h * 0.6), top], 0.012, m="M_Plant", res=4, segs=6))
|
|
lf = leaf("leaf", rnd.uniform(0.3, 0.4), rnd.uniform(0.2, 0.27), top, yaw, math.radians(rnd.uniform(15, 40)), curl=0.45)
|
|
set_mats(lf, "M_Plant")
|
|
P.append(lf)
|
|
o = join(P, "SM_Plant")
|
|
smooth(o, 50)
|
|
uv_box(o, 1)
|
|
return dict(elev=20)
|
|
|
|
|
|
def sign():
|
|
W, H = 4.8, 3.2
|
|
P = [bx(-W / 2, W / 2, -0.1, 0.0, 0, H, "M_PaintBlue", bevel=0.06, segs=3)]
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * (W / 2 - 0.5) - 0.06, sx * (W / 2 - 0.5) + 0.06, 0.0, 0.1, H * 0.2, H * 0.8, "M_DarkGrey", bevel=0.015))
|
|
frame = join(P, "Frame")
|
|
uv_box(frame, 1)
|
|
smooth(frame, 40)
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
m = 0.1
|
|
v = [bm.verts.new(p) for p in ((W / 2 - m, -0.105, m), (-W / 2 + m, -0.105, m), (-W / 2 + m, -0.105, H - m), (W / 2 - m, -0.105, H - m))]
|
|
f = bm.faces.new(v)
|
|
for l, uv in zip(f.loops, ((1, 0), (0, 0), (0, 1), (1, 1))):
|
|
l[uvl].uv = uv
|
|
if f.normal.y > 0:
|
|
f.normal_flip()
|
|
face = mesh_obj("Face", bm)
|
|
set_mats(face, "M_Sign")
|
|
return dict(elev=5, azim=-15)
|
|
|
|
|
|
def truck():
|
|
P = []
|
|
# chassis
|
|
P.append(bx(-1.0, 1.0, -3.3, 3.4, 0.55, 0.8, "M_DarkGrey", bevel=0.04))
|
|
# cab
|
|
cab = bx(-1.2, 1.2, -3.6, -1.75, 0.75, 2.9, "M_PaintRed", bevel=0.25, segs=4, name="cab")
|
|
P.append(cab)
|
|
P.append(bx(-1.1, 1.1, -3.68, -2.9, 1.85, 2.65, "M_Glass", bevel=0.08, name="windshield"))
|
|
P.append(bx(-1.05, 1.05, -3.4, -2.0, 1.6, 2.6, "M_DarkGrey", name="interior"))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * 1.21 - 0.02, s * 1.21 + 0.02, -3.1, -2.2, 1.7, 2.5, "M_Glass", bevel=0.05, name="sidewin"))
|
|
P.append(bx(s * 1.22 - 0.03, s * 1.22 + 0.03, -2.9, -2.86, 0.9, 2.55, "M_DarkGrey", name="doorline"))
|
|
P.append(cyl("hl", 0.18, 0.08, loc=(s * 0.82, -3.63, 1.25), axis="Y", verts=20, m="M_Emissive"))
|
|
P.append(torus("hlr", 0.18, 0.03, loc=(s * 0.82, -3.63, 1.25), axis="Y", seg=20, rseg=6, m="M_Metal"))
|
|
P.append(bx(s * 1.24, s * 1.38, -3.25, -3.1, 2.0, 2.45, "M_DarkGrey", bevel=0.03, name="mirror"))
|
|
for k in range(4):
|
|
P.append(bx(-0.5, 0.5, -3.64, -3.58, 0.95 + k * 0.1, 1.0 + k * 0.1, "M_Metal", bevel=0.015, name="grille"))
|
|
P.append(bx(-1.25, 1.25, -3.75, -3.55, 0.6, 0.85, "M_Metal", bevel=0.06, name="bumper"))
|
|
# cargo box (open at +Y end)
|
|
x0, x1, y0, y1, z0, z1 = -1.25, 1.25, -1.6, 3.5, 0.85, 3.5
|
|
t = 0.08
|
|
P.append(bx(x0, x1, y0, y0 + t, z0, z1, "M_PaintWhite", bevel=0.04, name="front"))
|
|
P.append(bx(x0, x0 + t, y0, y1, z0, z1, "M_PaintWhite", bevel=0.04, name="left"))
|
|
P.append(bx(x1 - t, x1, y0, y1, z0, z1, "M_PaintWhite", bevel=0.04, name="right"))
|
|
P.append(bx(x0, x1, y0, y1, z1 - t, z1, "M_PaintWhite", bevel=0.04, name="roof"))
|
|
P.append(bx(x0, x1, y0, y1, z0, z0 + t, "M_Wood", bevel=0.02, name="floor"))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * 1.25 - 0.01, s * 1.25 + 0.01, y0 + 0.1, y1 - 0.1, 1.05, 1.25, "M_PaintBlue", name="stripe"))
|
|
P.append(bx(s * 1.25 - 0.01, s * 1.25 + 0.01, y0 + 0.1, y1 - 0.1, 1.3, 1.37, "M_PaintYellow", name="stripe2"))
|
|
# rear frame + open doors
|
|
P.append(bx(x0 - 0.04, x1 + 0.04, y1 - 0.06, y1 + 0.04, z1 - 0.15, z1 + 0.02, "M_DarkGrey", bevel=0.02, name="rearframe"))
|
|
for s in (-1, 1):
|
|
P.append(bx(s * 1.25 - 0.06, s * 1.25 + 0.06, y1 - 0.06, y1 + 0.04, z0, z1, "M_DarkGrey", bevel=0.02, name="post"))
|
|
door = bx(-1.22, -0.02, -0.04, 0.04, z0 + 0.05, z1 - 0.08, "M_PaintWhite", bevel=0.03, name="door") if s > 0 else bx(0.02, 1.22, -0.04, 0.04, z0 + 0.05, z1 - 0.08, "M_PaintWhite", bevel=0.03, name="door")
|
|
door.rotation_euler = (0, 0, math.radians(-160 * s))
|
|
door.location = (s * 1.32, y1 + 0.02, 0)
|
|
apply_xform(door)
|
|
P.append(door)
|
|
P.append(bx(-0.9, 0.9, y1 - 0.05, y1 + 0.3, 0.6, 0.72, "M_DarkGrey", bevel=0.03, name="step"))
|
|
# wheels
|
|
for s in (-1, 1):
|
|
P.append(wheel("w", 0.5, 0.36, (s * 1.0, -2.6, 0.5)))
|
|
P.append(wheel("w", 0.5, 0.36, (s * 1.0, 1.6, 0.5)))
|
|
P.append(wheel("w", 0.5, 0.36, (s * 1.0, 2.75, 0.5)))
|
|
for yy in (-2.6, 2.17):
|
|
P.append(bx(s * 1.18 - 0.05, s * 1.18 + 0.05, yy - (0.65 if yy < 0 else 1.2), yy + (0.65 if yy < 0 else 1.2), 1.0, 1.08, "M_DarkGrey", bevel=0.02, name="fender"))
|
|
body = join(P, "Body")
|
|
uv_box(body, 1)
|
|
smooth(body, 40)
|
|
# branded side panels (sign texture)
|
|
for s, nm in ((-1, "LogoR"), (1, "LogoL")):
|
|
bm = bmesh.new()
|
|
uvl = bm.loops.layers.uv.verify()
|
|
xx = s * 1.262
|
|
w, h, cy, cz = 3.3, 2.2, 1.0, 2.35
|
|
pts = [(xx, cy - w / 2, cz - h / 2), (xx, cy + w / 2, cz - h / 2), (xx, cy + w / 2, cz + h / 2), (xx, cy - w / 2, cz + h / 2)]
|
|
uvs = [(0, 0), (1, 0), (1, 1), (0, 1)] if s > 0 else [(1, 0), (0, 0), (0, 1), (1, 1)]
|
|
f = bm.faces.new([bm.verts.new(p) for p in pts])
|
|
for l, uv in zip(f.loops, uvs):
|
|
l[uvl].uv = uv
|
|
if f.normal.x * s < 0:
|
|
f.normal_flip()
|
|
for l, uv in zip(f.loops, uvs):
|
|
pass
|
|
lg = mesh_obj(nm, bm)
|
|
set_mats(lg, "M_Sign")
|
|
logos = join([o for o in bpy.context.scene.objects if o.name.startswith("Logo")], "Decals")
|
|
return dict(elev=20, azim=-150)
|
|
|
|
|
|
def forklift():
|
|
P = []
|
|
P.append(bx(-0.6, 0.6, -0.5, 1.0, 0.25, 0.9, "M_PaintOrange", bevel=0.12, segs=3, name="body"))
|
|
P.append(bx(-0.62, 0.62, 0.65, 1.15, 0.3, 1.15, "M_DarkGrey", bevel=0.15, segs=3, name="counterweight"))
|
|
P.append(bx(-0.35, 0.35, 0.1, 0.55, 0.9, 1.05, "M_DarkGrey", bevel=0.04, name="seatb"))
|
|
P.append(bx(-0.3, 0.3, 0.15, 0.5, 1.05, 1.15, "M_PaintBlue", bevel=0.04, name="seat"))
|
|
P.append(bx(-0.3, 0.3, 0.45, 0.55, 1.1, 1.5, "M_PaintBlue", bevel=0.04, name="back"))
|
|
for sx in (-1, 1):
|
|
for yy in (-0.45, 0.85):
|
|
P.append(cyl("post", 0.035, 1.3, loc=(sx * 0.55, yy, 1.55), verts=10, m="M_DarkGrey"))
|
|
P.append(bx(-0.62, 0.62, -0.52, 0.92, 2.18, 2.26, "M_DarkGrey", bevel=0.03, name="cage"))
|
|
for k in range(4):
|
|
x = -0.45 + k * 0.3
|
|
P.append(bx(x - 0.03, x + 0.03, -0.5, 0.9, 2.2, 2.28, "M_PaintOrange", bevel=0.01, name="bar"))
|
|
# mast and forks at the front (-Y)
|
|
for sx in (-1, 1):
|
|
P.append(bx(sx * 0.35 - 0.05, sx * 0.35 + 0.05, -0.75, -0.62, 0.15, 2.2, "M_DarkGrey", bevel=0.015, name="mast"))
|
|
P.append(bx(sx * 0.25 - 0.06, sx * 0.25 + 0.06, -1.85, -0.78, 0.12, 0.17, "M_Metal", bevel=0.01, name="fork"))
|
|
P.append(bx(sx * 0.25 - 0.06, sx * 0.25 + 0.06, -0.82, -0.76, 0.12, 0.7, "M_Metal", bevel=0.01, name="forkup"))
|
|
P.append(bx(-0.42, 0.42, -0.8, -0.74, 0.45, 0.7, "M_DarkGrey", bevel=0.015, name="carriage"))
|
|
P.append(cyl("wheel_s", 0.12, 0.05, loc=(0, -0.25, 1.25), axis="Y", verts=16, m="M_DarkGrey"))
|
|
for sx in (-1, 1):
|
|
P.append(wheel("w", 0.28, 0.24, (sx * 0.55, -0.35, 0.28), rim_m="M_PaintYellow"))
|
|
P.append(wheel("w", 0.24, 0.2, (sx * 0.55, 0.85, 0.24), rim_m="M_PaintYellow"))
|
|
P.append(cyl("beacon", 0.06, 0.1, loc=(0, 0.6, 2.33), verts=12, m="M_PaintOrange"))
|
|
o = join(P, "SM_Forklift")
|
|
uv_box(o, 1)
|
|
smooth(o, 40)
|
|
return dict(elev=20, azim=-40)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run({
|
|
"SM_ShelfRack": shelf_rack,
|
|
"SM_Pallet": pallet,
|
|
"SM_PopTable": pop_table,
|
|
"SM_Lamp": lamp,
|
|
"SM_Plant": plant,
|
|
"SM_Sign": sign,
|
|
"SM_Truck": truck,
|
|
"SM_Forklift": forklift,
|
|
})
|