Files
grass-cutters/ArtSource/Blender/scripts/gc_phone_hand.py
NiemandKG d1c3761e58 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>
2026-11-06 18:44:40 +06:00

81 lines
3.5 KiB
Python

"""GRASS CUTTER - the left hand round the phone: SM_PhoneHand, the work glove opened up and closed on the slate.
The palm lies against the back, the thumb runs up the left edge, and the four fingers cross the back and come round the
right edge, so their tips show on the front. It is built where it goes, in the phone's own frame: same origin as SM_Phone.
Run: blender -b --factory-startup --python gc_phone_hand.py"""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import gc_farm_tools as FT
from gc_farm_tools import * # noqa: F401,F403
import gc_phone as GP
# bare, like the right hand: ViewModel paints the skin and the sleeve in the colours of whoever the player is
SKIN, SLEEVE = "M_CrewSkin", "M_PaintRed"
BACK = -GP.D / 2
FRONT = GP.D / 2
EDGE = GP.W / 2
def at(u, v, w):
"""As you look at the display: right, up, toward you. To Blender."""
return Vector((-u, w, v))
def finger(v, r, ln):
"""Across the back from the knuckle, round the right edge, and the tip over the front."""
behind = BACK - r * 1.05
ahead = FRONT + r * 0.95
out = EDGE + r * 1.02
pts = [(-0.014, v - 0.005, behind - 0.009), (0.016, v - 0.003, behind - 0.003), (0.04, v - 0.001, behind), (out - 0.004, v, behind + 0.004),
(out + 0.001, v + 0.001, -0.002), (out - 0.003, v + 0.002, ahead - 0.005), (out - 0.004 - 0.008 * ln, v + 0.003, ahead)]
return FT.digit("finger", [at(*p) for p in pts], r, (0.04, 0.44, 0.74), m=SKIN)
def thumb():
r = 0.0128
pts = [(-0.05, -0.098, BACK - 0.016), (-0.062, -0.078, BACK - 0.008), (-EDGE - r * 0.9, -0.056, -0.002), (-EDGE - r * 0.45, -0.036, FRONT + 0.004), (-EDGE - 0.001, -0.02, FRONT + r * 0.8)]
return FT.digit("thumb", [at(*p) for p in pts], r, (0.34, 0.68), m=SKIN)
def arm(P):
"""Wrist, bare forearm and shirt sleeve, off under the phone and back toward the shoulder."""
root = Vector((-0.05, -0.124, BACK - 0.024))
way = Vector((-0.34, -0.8, 0.5)).normalized()
p = lambda s: at(*(root + way * s))
def part(name, s0, s1, r0, r1, m):
P.append(sweep_circle(name, [p(s0), p((s0 + s1) / 2), p(s1)], lambda t, l: r0 + (r1 - r0) * t, segs=12, m=m, cap=True, smooth_ang=60))
part("forearm", -0.012, 0.26, 0.031, 0.042, SKIN)
part("cuff", 0.25, 0.272, 0.05, 0.05, SLEEVE)
part("sleeve", 0.266, 0.5, 0.048, 0.058, SLEEVE)
def hand():
P = []
# the palm on the back of the phone: the mass under the fingers, the heel below it
P.append(sphere("palm", 1.0, tuple(at(-0.025, -0.05, BACK - 0.024)), seg=12, rings=8, m=SKIN, scale=(0.045, 0.021, 0.058)))
P.append(sphere("heel", 1.0, tuple(at(-0.044, -0.098, BACK - 0.026)), seg=12, rings=8, m=SKIN, scale=(0.033, 0.022, 0.036)))
P.append(sphere("thenar", 1.0, tuple(at(-0.056, -0.082, BACK - 0.014)), seg=10, rings=6, m=SKIN, scale=(0.02, 0.016, 0.036)))
for v, r, ln in ((-0.012, 0.0122, 0.9), (-0.0365, 0.0126, 1.0), (-0.0615, 0.0122, 0.95), (-0.0845, 0.0108, 0.8)):
P.append(finger(v, r, ln))
P.append(thumb())
arm(P)
return FT.done(P, "SM_PhoneHand", uv=6.0, ang=60)
def main():
reset()
o = hand()
print("SM_PhoneHand", len(o.data.polygons), "faces")
export("SM_PhoneHand")
# only for the picture: the phone in the hand
a = GP.body()
s = GP.screen(a)
a["preview_only"] = s["preview_only"] = 1
preview("SM_PhoneHand_front", elev=6, azim=168, res=800, bg=(0.2, 0.24, 0.22), radius=0.3)
preview("SM_PhoneHand_back", elev=10, azim=-20, res=800, bg=(0.62, 0.7, 0.66), radius=0.3)
if __name__ == "__main__":
main()