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:
443
ArtSource/Blender/scripts/chars.py
Normal file
443
ArtSource/Blender/scripts/chars.py
Normal file
@ -0,0 +1,443 @@
|
||||
"""Characters, first-person hands, tools, boots, road roller.
|
||||
Blender: front = -Y (Unity +Z). Unity left (-X) == Blender +X.
|
||||
"""
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from common import *
|
||||
from mathutils import Quaternion
|
||||
|
||||
|
||||
def meta(name, elems, res=0.01, thresh=0.6, m=None):
|
||||
"""elems: list of dict(type, co, radius, size=(x,y,z), rot=Quaternion)."""
|
||||
mb = bpy.data.metaballs.new(name)
|
||||
mb.resolution = res
|
||||
mb.render_resolution = res
|
||||
mb.threshold = thresh
|
||||
for e in elems:
|
||||
el = mb.elements.new(type=e.get("type", "BALL"))
|
||||
el.co = e["co"]
|
||||
el.radius = e.get("radius", 0.05)
|
||||
if "size" in e:
|
||||
sz = e["size"]
|
||||
if e.get("type") == "ELLIPSOID":
|
||||
r = max(sz)
|
||||
el.radius = r * 1.25
|
||||
el.size_x, el.size_y, el.size_z = (sz[0] / r, sz[1] / r, sz[2] / r)
|
||||
else:
|
||||
el.size_x, el.size_y, el.size_z = sz
|
||||
if "rot" in e:
|
||||
el.rotation = e["rot"]
|
||||
if "stiff" in e:
|
||||
el.stiffness = e["stiff"]
|
||||
o = link(bpy.data.objects.new(name, mb))
|
||||
bpy.context.view_layer.update()
|
||||
o = to_mesh(o)
|
||||
if m:
|
||||
set_mats(o, m)
|
||||
return o
|
||||
|
||||
|
||||
def q_from_to(a, b):
|
||||
return Vector(a).normalized().rotation_difference(Vector(b).normalized())
|
||||
|
||||
|
||||
def capsule(p0, p1, r):
|
||||
"""metaball capsule element between two points (capsule extends along local X by size_x)."""
|
||||
p0, p1 = Vector(p0), Vector(p1)
|
||||
mid = (p0 + p1) / 2
|
||||
d = p1 - p0
|
||||
return dict(type="CAPSULE", co=mid, radius=r, size=((d.length / 2), r, r), rot=q_from_to((1, 0, 0), d), stiff=2.0)
|
||||
|
||||
|
||||
def decimate(o, ratio):
|
||||
mod(o, "DECIMATE", ratio=ratio)
|
||||
bake(o)
|
||||
return o
|
||||
|
||||
|
||||
# =========================================================== bean
|
||||
|
||||
def bean():
|
||||
prof = [(0.0, 0.0), (0.18, 0.012), (0.29, 0.06), (0.35, 0.18), (0.372, 0.4), (0.368, 0.7), (0.352, 1.0),
|
||||
(0.325, 1.22), (0.27, 1.42), (0.18, 1.54), (0.09, 1.59), (0.0, 1.6)]
|
||||
body = revolve("Body", prof, segs=32, m="M_BeanBody", close_top=False)
|
||||
subsurf(body, 1)
|
||||
smooth(body, 80)
|
||||
uv_cyl(body, axis=2, circ_scale=1, len_scale=0.6)
|
||||
|
||||
def body_r(z):
|
||||
for (r0, z0), (r1, z1) in zip(prof, prof[1:]):
|
||||
if z0 <= z <= z1:
|
||||
return r0 + (r1 - r0) * (z - z0) / (z1 - z0)
|
||||
return 0.0
|
||||
|
||||
ez = 1.2
|
||||
er = 0.115
|
||||
for side, sx in (("L", 1), ("R", -1)):
|
||||
ex = 0.125 * sx
|
||||
surf_y = -math.sqrt(max(body_r(ez) ** 2 - ex ** 2, 0.0))
|
||||
cy = surf_y + er * 0.45
|
||||
eye = sphere(f"Eye_{side}", er, (ex, cy, ez), seg=24, rings=14, m="M_EyeWhite", scale=(1, 0.85, 1.12))
|
||||
smooth(eye, 80)
|
||||
set_origin(eye, (ex, cy, ez))
|
||||
pup = sphere(f"Pupil_{side}", 0.052, (ex, cy - er * 0.85 + 0.008, ez - 0.01), seg=16, rings=8, m="M_Pupil", scale=(1, 0.35, 1.12))
|
||||
# tiny specular highlight dot baked into the pupil mesh
|
||||
hl = sphere("hl", 0.014, (ex + 0.018 * sx * 0 + 0.016, cy - er * 0.85 - 0.004, ez + 0.022), seg=8, rings=4, m="M_EyeWhite", scale=(1, 0.5, 1))
|
||||
pup = join([pup, hl], f"Pupil_{side}")
|
||||
smooth(pup, 80)
|
||||
set_origin(pup, (ex, cy, ez))
|
||||
# mouth (smile)
|
||||
mz = 1.0
|
||||
pts = []
|
||||
for i in range(7):
|
||||
t = -1 + 2 * i / 6
|
||||
x = t * 0.09
|
||||
z = mz - 0.035 * (1 - t * t)
|
||||
y = -math.sqrt(max(body_r(z) ** 2 - x ** 2, 0)) - 0.004
|
||||
pts.append((x, y, z))
|
||||
mouth = tube("Mouth", pts, 0.013, m="M_Pupil", res=4, segs=8)
|
||||
smooth(mouth, 80)
|
||||
# cap
|
||||
crown = revolve("crown", [(0.285, 1.36), (0.29, 1.42), (0.27, 1.5), (0.21, 1.58), (0.12, 1.635), (0.0, 1.65)], segs=32, close_top=False)
|
||||
crown.scale = (1.0, 1.05, 1.0); apply_xform(crown)
|
||||
crown.location = (0, 0.01, 0); apply_xform(crown)
|
||||
bm = bmesh.new(); bm.from_mesh(crown.data)
|
||||
uv = bm.loops.layers.uv.verify()
|
||||
for f in bm.faces:
|
||||
for l in f.loops:
|
||||
p = l.vert.co
|
||||
l[uv].uv = (0.5 + p.x / 0.62, (p.z - 1.36) / 0.3 * 0.7 + 0.15) if p.y < 0 else (0.03 + p.x * 0.02, 0.05)
|
||||
bm.to_mesh(crown.data); bm.free()
|
||||
mod(crown, "SOLIDIFY", thickness=0.012, offset=1)
|
||||
bake(crown)
|
||||
# brim
|
||||
bm = bmesh.new()
|
||||
uvl = bm.loops.layers.uv.verify()
|
||||
N = 16
|
||||
outer = []
|
||||
inner = []
|
||||
for i in range(N + 1):
|
||||
a = math.pi + math.pi * i / N
|
||||
ix, iy = 0.285 * math.cos(a), 0.3 * math.sin(a)
|
||||
ox, oy = 0.27 * math.cos(a), -0.08 + 0.38 * math.sin(a)
|
||||
inner.append(bm.verts.new((ix, iy + 0.01, 1.375)))
|
||||
outer.append(bm.verts.new((ox, oy, 1.375 - 0.035 * (math.sin(a) ** 2))))
|
||||
for i in range(N):
|
||||
f = bm.faces.new((inner[i], inner[i + 1], outer[i + 1], outer[i]))
|
||||
for l in f.loops:
|
||||
l[uvl].uv = (0.04, 0.05)
|
||||
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
||||
brim = mesh_obj("brim", bm)
|
||||
for f in brim.data.polygons:
|
||||
pass
|
||||
mod(brim, "SOLIDIFY", thickness=0.022, offset=0)
|
||||
mod(brim, "BEVEL", width=0.008, segments=2, limit_method="ANGLE")
|
||||
bake(brim)
|
||||
btn = sphere("btn", 0.028, (0, 0.01, 1.655), seg=12, rings=6, scale=(1, 1, 0.5))
|
||||
bm = bmesh.new(); bm.from_mesh(btn.data)
|
||||
uv = bm.loops.layers.uv.verify()
|
||||
for f in bm.faces:
|
||||
for l in f.loops:
|
||||
l[uv].uv = (0.04, 0.05)
|
||||
bm.to_mesh(btn.data); bm.free()
|
||||
cap = join([crown, brim, btn], "Cap")
|
||||
set_mats(cap, "M_CapFabric")
|
||||
smooth(cap, 50)
|
||||
# floating mitten hands
|
||||
for side, sx in (("L", 1), ("R", -1)):
|
||||
palm = sphere("palm", 1.0, (0, 0, 0), seg=20, rings=12, scale=(0.055, 0.065, 0.075))
|
||||
thumb = sphere("thumb", 1.0, (0, 0, 0), seg=14, rings=8, scale=(0.026, 0.026, 0.045))
|
||||
thumb.rotation_euler = (math.radians(35), math.radians(-25 * sx), 0)
|
||||
thumb.location = (-sx * 0.025, -0.045, 0.035)
|
||||
h = join([palm, thumb], f"Hand_{side}")
|
||||
set_mats(h, "M_Glove")
|
||||
smooth(h, 80)
|
||||
h.location = (sx * 0.47, -0.06, 0.72)
|
||||
apply_xform(h)
|
||||
set_origin(h, (sx * 0.47, -0.06, 0.72))
|
||||
# little feet
|
||||
for side, sx in (("L", 1), ("R", -1)):
|
||||
ft = sphere(f"Foot_{side}", 1.0, (0, 0, 0), seg=20, rings=10, scale=(0.085, 0.13, 0.055), m="M_DarkGrey")
|
||||
smooth(ft, 80)
|
||||
ft.location = (sx * 0.15, -0.07, 0.045)
|
||||
apply_xform(ft)
|
||||
set_origin(ft, (sx * 0.15, -0.07, 0.0))
|
||||
return dict(elev=12, azim=-30)
|
||||
|
||||
|
||||
# =========================================================== hands
|
||||
|
||||
def glove_cuff():
|
||||
c = torus("cuff", 0.042, 0.017, loc=(0, 0.035, 0), axis="Y", seg=24, rseg=10, m="M_Glove")
|
||||
c.scale = (1.0, 1.0, 0.82); apply_xform(c)
|
||||
return c
|
||||
|
||||
|
||||
def hand_point():
|
||||
el = [
|
||||
dict(type="ELLIPSOID", co=(0, -0.06, 0), radius=0.07, size=(0.07, 0.075, 0.04)),
|
||||
capsule((0.0, 0.0, 0.0), (0, -0.04, 0), 0.034), # wrist
|
||||
capsule((-0.02, -0.1, 0.003), (-0.022, -0.185, 0.006), 0.017), # index (extended)
|
||||
capsule((0.0, -0.105, -0.004), (0.004, -0.12, -0.035), 0.017), # middle curled
|
||||
capsule((0.004, -0.12, -0.035), (0.004, -0.085, -0.045), 0.015),
|
||||
capsule((0.02, -0.1, -0.006), (0.024, -0.112, -0.034), 0.016), # ring
|
||||
capsule((0.024, -0.112, -0.034), (0.022, -0.082, -0.042), 0.014),
|
||||
capsule((0.038, -0.09, -0.008), (0.042, -0.1, -0.03), 0.014), # pinky
|
||||
capsule((0.042, -0.1, -0.03), (0.038, -0.078, -0.036), 0.012),
|
||||
capsule((-0.04, -0.05, -0.005), (-0.06, -0.09, -0.012), 0.017), # thumb
|
||||
]
|
||||
h = meta("hand", el, res=0.004, thresh=0.6)
|
||||
decimate(h, 0.25)
|
||||
o = join([h, glove_cuff()], "SM_Hand_Point")
|
||||
set_mats(o, "M_Glove")
|
||||
smooth(o, 80)
|
||||
return dict(elev=35, azim=-60)
|
||||
|
||||
|
||||
def hand_grip():
|
||||
el = [
|
||||
dict(type="ELLIPSOID", co=(0.05, 0.015, 0), radius=0.07, size=(0.045, 0.07, 0.07)),
|
||||
capsule((0.04, 0.06, 0), (0.045, 0.02, 0), 0.034),
|
||||
]
|
||||
R = 0.03
|
||||
for i, z in enumerate((0.03, 0.01, -0.012, -0.032)):
|
||||
r = 0.016 if i < 3 else 0.014
|
||||
a0, a1, a2 = math.radians(-10), math.radians(-100), math.radians(-185)
|
||||
p0 = (0.045, -0.005, z)
|
||||
p1 = ((R + 0.012) * math.cos(a1), (R + 0.012) * math.sin(a1), z)
|
||||
p2 = ((R + 0.012) * math.cos(a2), (R + 0.012) * math.sin(a2) - 0.005, z)
|
||||
el.append(capsule(p0, p1, r))
|
||||
el.append(capsule(p1, p2, r * 0.95))
|
||||
el.append(capsule((0.035, -0.03, 0.045), (-0.02, -0.04, 0.05), 0.016)) # thumb over the top
|
||||
h = meta("hand", el, res=0.004, thresh=0.6)
|
||||
decimate(h, 0.25)
|
||||
c = glove_cuff()
|
||||
c.location = (0.04, 0.03, 0); apply_xform(c)
|
||||
o = join([h, c], "SM_Hand_Grip")
|
||||
set_mats(o, "M_Glove")
|
||||
smooth(o, 80)
|
||||
# visual handle for preview only
|
||||
hd = cyl("handle_preview", 0.018, 0.3, verts=16, m="M_Wood")
|
||||
hd["preview_only"] = True
|
||||
return dict(elev=30, azim=-50, frame=["SM_Hand_Grip"])
|
||||
|
||||
|
||||
# =========================================================== tools
|
||||
|
||||
def rolling_pin():
|
||||
barrel = revolve("barrel", [(0.0, -0.15), (0.032, -0.15), (0.04, -0.142), (0.042, -0.12), (0.042, 0.12), (0.04, 0.142), (0.032, 0.15), (0.0, 0.15)],
|
||||
segs=32, axis="X", close_top=False)
|
||||
uv_cyl(barrel, axis=0, circ_scale=1, len_scale=1.5)
|
||||
set_mats(barrel, "M_Wood")
|
||||
parts = [barrel]
|
||||
for s in (-1, 1):
|
||||
h = revolve("handle", [(0.0, 0.15), (0.013, 0.15), (0.016, 0.17), (0.019, 0.2), (0.022, 0.215), (0.012, 0.225), (0.0, 0.226)], segs=20, axis="X", close_top=False)
|
||||
if s < 0:
|
||||
h.scale = (-1, 1, 1); apply_xform(h)
|
||||
bm = bmesh.new(); bm.from_mesh(h.data); bmesh.ops.reverse_faces(bm, faces=bm.faces); bm.to_mesh(h.data); bm.free()
|
||||
set_mats(h, "M_PaintRed")
|
||||
parts.append(h)
|
||||
o = join(parts, "SM_Tool_RollingPin")
|
||||
smooth(o, 50)
|
||||
return dict(elev=30, azim=-25)
|
||||
|
||||
|
||||
def mallet():
|
||||
P = []
|
||||
handle = revolve("handle", [(0.0, -0.07), (0.016, -0.07), (0.02, -0.06), (0.018, 0.0), (0.016, 0.2), (0.018, 0.26), (0.0, 0.27)], segs=16, close_top=False)
|
||||
uv_cyl(handle, axis=2, circ_scale=1, len_scale=2)
|
||||
set_mats(handle, "M_Wood")
|
||||
P.append(handle)
|
||||
grip = revolve("grip", [(0.021, -0.065), (0.023, -0.04), (0.022, 0.07), (0.02, 0.08)], segs=16, close_top=False, close_bottom=False)
|
||||
set_mats(grip, "M_PaintBlue")
|
||||
P.append(grip)
|
||||
head = revolve("head", [(0.0, -0.085), (0.05, -0.085), (0.06, -0.075), (0.065, -0.05), (0.065, 0.05), (0.06, 0.075), (0.05, 0.085), (0.0, 0.085)], segs=28, axis="X", close_top=False)
|
||||
head.location = (0, 0, 0.29); apply_xform(head)
|
||||
set_mats(head, "M_PaintRed")
|
||||
P.append(head)
|
||||
for s in (-1, 1):
|
||||
P.append(torus("band", 0.066, 0.008, loc=(s * 0.055, 0, 0.29), axis="X", seg=28, rseg=6, m="M_Metal"))
|
||||
o = join(P, "SM_Tool_Mallet")
|
||||
smooth(o, 50)
|
||||
return dict(elev=20, azim=-40)
|
||||
|
||||
|
||||
def spike_roller():
|
||||
P = []
|
||||
grip = revolve("grip", [(0.0, 0.07), (0.02, 0.07), (0.024, 0.05), (0.022, -0.05), (0.024, -0.08), (0.012, -0.095)], segs=16, close_top=False)
|
||||
set_mats(grip, "M_PaintBlue")
|
||||
P.append(grip)
|
||||
ax = Vector((0, -0.4, -0.6))
|
||||
rod = tube("rod", [(0, 0, -0.09), (0, -0.04, -0.2), (0, -0.2, -0.36), (0, -0.34, -0.46)], 0.016, m="M_Metal", res=6, segs=8)
|
||||
P.append(rod)
|
||||
for s in (-1, 1):
|
||||
P.append(tube("yoke", [(0, -0.34, -0.46), (s * 0.12, -0.36, -0.48), (s * 0.235, -0.38, -0.52), (s * 0.235, ax.y, ax.z)], 0.014, m="M_Metal", res=6, segs=8))
|
||||
P.append(cyl("cap", 0.022, 0.02, loc=(s * 0.235, ax.y, ax.z), axis="X", verts=12, m="M_DarkGrey"))
|
||||
body = join(P, "Handle")
|
||||
smooth(body, 50)
|
||||
D = [cyl("drum", 0.07, 0.42, axis="X", verts=24, m="M_PaintOrange", bevel=0.01)]
|
||||
for i in range(7):
|
||||
x = -0.18 + i * 0.06
|
||||
for k in range(10):
|
||||
a = k * 2 * math.pi / 10 + (i % 2) * math.pi / 10
|
||||
sp = cyl("spike", 0.016, 0.035, verts=6, m="M_Rubber", r2=0.004)
|
||||
sp.rotation_euler = (a, 0, 0)
|
||||
sp.location = (x, -math.sin(a) * 0.085, math.cos(a) * 0.085)
|
||||
D.append(sp)
|
||||
drum = join(D, "Drum")
|
||||
smooth(drum, 40)
|
||||
drum.location = ax; apply_xform(drum)
|
||||
set_origin(drum, ax)
|
||||
return dict(elev=20, azim=-60)
|
||||
|
||||
|
||||
def boots():
|
||||
P = []
|
||||
for sx in (-1, 1):
|
||||
x = sx * 0.12
|
||||
b = meta("boot", [
|
||||
dict(type="ELLIPSOID", co=(x, -0.03, 0.07), radius=0.1, size=(0.085, 0.15, 0.065)),
|
||||
capsule((x, 0.04, 0.1), (x, 0.05, 0.24), 0.075),
|
||||
dict(type="BALL", co=(x, -0.12, 0.07), radius=0.075),
|
||||
], res=0.012, m="M_PaintOrange")
|
||||
decimate(b, 0.4)
|
||||
P.append(b)
|
||||
sole = rbox("sole", (0.17, 0.33, 0.045), (x, -0.025, 0.0225), bevel=0.02, segs=3, m="M_Rubber")
|
||||
P.append(sole)
|
||||
P.append(torus("cuffb", 0.07, 0.02, loc=(x, 0.05, 0.25), seg=20, rseg=8, m="M_PaintYellow"))
|
||||
for k in range(3):
|
||||
P.append(tube("lace", [(x - 0.04, -0.03 + k * 0.035, 0.135 + k * 0.03), (x + 0.04, -0.03 + k * 0.035, 0.135 + k * 0.03)], 0.007, m="M_PaintWhite", res=1, segs=4))
|
||||
for i in range(3):
|
||||
for j in range(2):
|
||||
P.append(cyl("stud", 0.012, 0.02, loc=(x - 0.04 + j * 0.08, -0.14 + i * 0.11, -0.008), verts=8, m="M_Metal", r2=0.004))
|
||||
o = join(P, "SM_Tool_Boots")
|
||||
o.location = (0, 0, 0.018); apply_xform(o)
|
||||
smooth(o, 50)
|
||||
return dict(elev=25, azim=-40)
|
||||
|
||||
|
||||
# =========================================================== road roller
|
||||
|
||||
def road_roller():
|
||||
Y = 1.0 # yellow
|
||||
P = []
|
||||
# chassis / engine body (rear)
|
||||
P.append(rbox("engine", (1.3, 1.25, 0.7), (0, 0.6, 0.85), bevel=0.14, segs=4, m="M_PaintYellow"))
|
||||
P.append(rbox("hoodtop", (1.1, 1.0, 0.12), (0, 0.66, 1.24), bevel=0.05, segs=3, m="M_PaintYellow"))
|
||||
P.append(rbox("deck", (1.4, 0.95, 0.14), (0, -0.15, 0.82), bevel=0.05, segs=3, m="M_DarkGrey"))
|
||||
P.append(rbox("bumper", (1.36, 0.14, 0.18), (0, 1.25, 0.6), bevel=0.05, segs=3, m="M_DarkGrey"))
|
||||
# grille at rear
|
||||
for k in range(5):
|
||||
P.append(rbox("grl", (0.8, 0.03, 0.035), (0, 1.235, 0.75 + k * 0.07), bevel=0.012, segs=2, m="M_DarkGrey"))
|
||||
# tail lights
|
||||
for s in (-1, 1):
|
||||
P.append(rbox("tl", (0.14, 0.03, 0.08), (s * 0.5, 1.235, 1.05), bevel=0.02, segs=2, m="M_PaintRed"))
|
||||
# exhaust
|
||||
P.append(cyl("exh", 0.05, 0.75, loc=(-0.45, 0.95, 1.45), verts=16, m="M_DarkGrey"))
|
||||
P.append(cyl("exhcap", 0.065, 0.06, loc=(-0.45, 0.95, 1.84), verts=16, m="M_Metal", bevel=0.01))
|
||||
# front yoke around drum
|
||||
for s in (-1, 1):
|
||||
plate = rbox("yplate", (0.09, 0.8, 0.75), (s * 0.79, -0.85, 0.68), bevel=0.06, segs=3, m="M_PaintYellow")
|
||||
P.append(plate)
|
||||
P.append(cyl("axcap", 0.11, 0.05, loc=(s * 0.85, -0.85, 0.45), axis="X", verts=20, m="M_DarkGrey", bevel=0.015))
|
||||
P.append(rbox("ybeam", (1.67, 0.5, 0.18), (0, -0.85, 1.08), bevel=0.06, segs=3, m="M_PaintYellow"))
|
||||
P.append(rbox("neck", (0.7, 0.55, 0.25), (0, -0.48, 0.98), bevel=0.08, segs=3, m="M_PaintYellow"))
|
||||
# hazard stripes on front beam
|
||||
n = 12
|
||||
for k in range(n):
|
||||
x0 = -0.8 + 1.6 * k / n
|
||||
P.append(box_(x0, x0 + 1.6 / n, -1.105, -1.095, 1.02, 1.14, "M_PaintYellow" if k % 2 else "M_DarkGrey"))
|
||||
# headlights
|
||||
for s in (-1, 1):
|
||||
P.append(cyl("hlh", 0.09, 0.08, loc=(s * 0.6, -1.12, 1.24), axis="Y", verts=20, m="M_DarkGrey", bevel=0.015))
|
||||
P.append(cyl("hl", 0.07, 0.02, loc=(s * 0.6, -1.165, 1.24), axis="Y", verts=20, m="M_Emissive"))
|
||||
# seat
|
||||
P.append(rbox("seatbase", (0.55, 0.5, 0.18), (0, 0.05, 0.98), bevel=0.05, segs=3, m="M_DarkGrey"))
|
||||
P.append(rbox("seat", (0.56, 0.5, 0.12), (0, 0.05, 1.12), bevel=0.05, segs=3, m="M_PaintBlue"))
|
||||
back = rbox("seatback", (0.56, 0.12, 0.5), (0, 0.32, 1.38), bevel=0.05, segs=3, m="M_PaintBlue")
|
||||
back.rotation_euler = (math.radians(-10), 0, 0)
|
||||
P.append(back)
|
||||
# dash + steering column
|
||||
P.append(rbox("dash", (0.7, 0.3, 0.4), (0, -0.45, 1.25), bevel=0.08, segs=3, m="M_PaintYellow"))
|
||||
for s in (-1, 0, 1):
|
||||
P.append(cyl("gauge", 0.04, 0.02, loc=(s * 0.16, -0.3, 1.43), axis="Y", verts=16, m="M_PaintWhite"))
|
||||
col = tube("column", [(0, -0.42, 1.4), (0, -0.28, 1.58)], 0.025, m="M_DarkGrey", res=1, segs=8)
|
||||
P.append(col)
|
||||
# canopy posts + roof
|
||||
for sx in (-1, 1):
|
||||
for yy in (-0.38, 0.55):
|
||||
P.append(cyl("post", 0.035, 1.0, loc=(sx * 0.6, yy, 1.65), verts=12, m="M_DarkGrey"))
|
||||
P.append(rbox("roof", (1.45, 1.25, 0.1), (0, 0.08, 2.18), bevel=0.04, segs=3, m="M_PaintYellow"))
|
||||
P.append(rbox("roofrim", (1.5, 1.3, 0.04), (0, 0.08, 2.12), bevel=0.015, segs=2, m="M_DarkGrey"))
|
||||
# beacon
|
||||
P.append(cyl("bcb", 0.08, 0.04, loc=(0.45, 0.4, 2.25), verts=16, m="M_DarkGrey"))
|
||||
P.append(revolve("beacon", [(0.065, 0), (0.065, 0.07), (0.045, 0.11), (0, 0.12)], segs=16, m="M_PaintOrange", loc=(0.45, 0.4, 2.27), close_top=False))
|
||||
# side step
|
||||
for s in (-1, 1):
|
||||
P.append(rbox("step", (0.08, 0.35, 0.04), (s * 0.72, 0.05, 0.55), bevel=0.012, segs=2, m="M_Metal"))
|
||||
body = join(P, "Body")
|
||||
uv_box(body, 1)
|
||||
smooth(body, 40)
|
||||
|
||||
# drum
|
||||
D = [revolve("drum", [(0.0, -0.7), (0.4, -0.7), (0.45, -0.66), (0.45, 0.66), (0.4, 0.7), (0.0, 0.7)], segs=40, axis="X", close_top=False)]
|
||||
set_mats(D[0], "M_Metal")
|
||||
uv_cyl(D[0], axis=0, circ_scale=2, len_scale=1)
|
||||
for s in (-1, 1):
|
||||
D.append(cyl("hub", 0.3, 0.03, loc=(s * 0.7, 0, 0), axis="X", verts=32, m="M_PaintYellow", bevel=0.008))
|
||||
for k in range(6):
|
||||
a = k * math.pi / 3
|
||||
D.append(cyl("bolt", 0.025, 0.04, loc=(s * 0.715, math.cos(a) * 0.2, math.sin(a) * 0.2), axis="X", verts=8, m="M_DarkGrey"))
|
||||
drum = join(D, "Drum")
|
||||
smooth(drum, 40)
|
||||
drum.location = (0, -0.85, 0.45); apply_xform(drum)
|
||||
set_origin(drum, (0, -0.85, 0.45))
|
||||
|
||||
for side, sx in (("L", 1), ("R", -1)):
|
||||
W = []
|
||||
tire = revolve("tire", [(0.2, -0.14), (0.33, -0.14), (0.37, -0.11), (0.38, -0.05), (0.38, 0.05), (0.37, 0.11), (0.33, 0.14), (0.2, 0.14)], segs=32, axis="X", close_top=False)
|
||||
set_mats(tire, "M_Rubber")
|
||||
W.append(tire)
|
||||
for k in range(16): # tread blocks
|
||||
a = k * 2 * math.pi / 16
|
||||
t = rbox("tread", (0.22, 0.07, 0.03), (0, 0, 0), bevel=0.01, segs=1, m="M_Rubber")
|
||||
t.rotation_euler = (a, 0, 0)
|
||||
t.location = (0, -math.sin(a) * 0.385, math.cos(a) * 0.385)
|
||||
W.append(t)
|
||||
W.append(cyl("rim", 0.22, 0.24, axis="X", verts=24, m="M_PaintYellow", bevel=0.02))
|
||||
W.append(cyl("hubc", 0.09, 0.27, axis="X", verts=16, m="M_DarkGrey", bevel=0.015))
|
||||
wh = join(W, f"Wheel_{side}")
|
||||
smooth(wh, 40)
|
||||
wh.location = (sx * 0.74, 0.75, 0.38); apply_xform(wh)
|
||||
set_origin(wh, (sx * 0.74, 0.75, 0.38))
|
||||
|
||||
# steering wheel, tilted towards the driver
|
||||
S = [torus("ring", 0.16, 0.022, seg=28, rseg=8, m="M_DarkGrey"), cyl("hub", 0.04, 0.04, verts=16, m="M_PaintRed", bevel=0.01)]
|
||||
for k in range(3):
|
||||
a = k * 2 * math.pi / 3 + math.pi / 2
|
||||
S.append(tube("spoke", [(0, 0, 0), (math.cos(a) * 0.15, math.sin(a) * 0.15, 0)], 0.012, m="M_DarkGrey", res=1, segs=6))
|
||||
st = join(S, "Steering")
|
||||
smooth(st, 40)
|
||||
st.rotation_euler = (math.radians(-35), 0, 0)
|
||||
st.location = (0, -0.27, 1.6)
|
||||
apply_xform(st)
|
||||
set_origin(st, (0, -0.27, 1.6))
|
||||
empty("SeatPoint", (0, 0.12, 1.8))
|
||||
return dict(elev=18, azim=-40)
|
||||
|
||||
|
||||
def box_(x0, x1, y0, y1, z0, z1, m):
|
||||
return cube("b", (x1 - x0, y1 - y0, z1 - z0), ((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2), m)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run({
|
||||
"SM_Bean": bean,
|
||||
"SM_Hand_Point": hand_point,
|
||||
"SM_Hand_Grip": hand_grip,
|
||||
"SM_Tool_RollingPin": rolling_pin,
|
||||
"SM_Tool_Mallet": mallet,
|
||||
"SM_Tool_SpikeRoller": spike_roller,
|
||||
"SM_Tool_Boots": boots,
|
||||
"SM_RoadRoller": road_roller,
|
||||
})
|
||||
Reference in New Issue
Block a user