"""Prepare five Meshy props for Godot. Blender 5.0+, no paid API calls. Source GLBs remain intact. Coordinates below come from inspected source rays; the playable contact surfaces use the existing soul pose in metres. Blender -Y exports as Godot +Z, which is the station's approach/occupant-facing side. """ import bpy,bmesh,json,math,hashlib from pathlib import Path from mathutils import Vector ROOT=Path(__file__).resolve().parents[1] SOURCE=ROOT/'tools/model_sources/equipment_meshy_v01' OUT=ROOT/'Demon_v0.19/art/equipment/meshy_v01' OUT.mkdir(parents=True,exist_ok=True) def interp(value,knots): for (a,b),(c,d) in zip(knots,knots[1:]): if value<=c:return b+(value-a)*(d-b)/(c-a) a,b=knots[-2];c,d=knots[-1] return b+(value-a)*(d-b)/(c-a) def symmetric(value,knots):return math.copysign(interp(abs(value),knots),value) def part(name,c): x,y,z=c if name=='pillory': return 'UpperYoke' if abs(x)<.335 and z>.131 and z<.26 else 'Body' if name=='rack': # Remove the source's empty cuffs/ropes. Runtime follows actual bones. if .13.044:return None if abs(y)<.077 and z>.032: if -.440.398 and z>.005:return None # replaced by functional crank return 'Body' if name=='wheel_vat': # Cuffs are re-created on actual hands/feet rather than baked empty. if .075-.149 and (abs(y)<.020 or radius<.100 and abs(y)<.060):return 'Wheel' # Fixed side bearing ornament in the source intersects the rotor. # Remove its ragged cut caps; clean authored frame caps replace it. if .22.355 and z>-.02:return None # functional side handle added locally return 'Body' return 'Body' def point(name,p,group): x,y,z=p if name=='pillory': return Vector((interp(x,[(-.480,-.99),(-.360,-.85),(-.185,-.59),(.015,0),(.195,.59),(.360,.85),(.480,.99)]),y*3.5,interp(z,[(-.397,0),(-.315,.10),(.131,1.70),(.395,2.48)]))) if name=='rack': return Vector((-y*4.45,(x+.038)*3.62,interp(z,[(-.114,0),(-.090,.07),(.01,.82),(.037,.94),(.113,1.31)]))) if name=='wheel_vat': if group=='Wheel':return Vector((x*5.04,y*3.5+.07,1.62+(z-.114)*5.04)) rear_clearance=min(1,max(0,(z+.16)/.20))*.20 return Vector((symmetric(x,[(0,0),(.26,1.30),(.31,1.43),(.478,1.87)]),y*3.4+rear_clearance,interp(z,[(-.365,0),(-.319,.10),(-.160,.99),(.114,1.62),(.17,1.80),(.369,2.9)]))) if name=='musical_chair': depth=interp(y,[(-.262,-.90),(-.170,-.36),(-.020,.10),(.125,.48),(.261,.65)]) # Shorten only the cushion/apron, not the arms, legs or speaker cabinets. # The front edge clears the seated thigh/knee sweep for all ten souls. if abs(x)<.19 and -.2352048: factor=2048/max(image.size);image.scale(round(image.size[0]*factor),round(image.size[1]*factor)) points=[o.matrix_world@v.co for o in output for v in o.data.vertices] bpy.context.view_layer.update() points=[o.matrix_world@v.co for o in output for v in o.data.vertices] lo=[min(v[i] for v in points) for i in range(3)];hi=[max(v[i] for v in points) for i in range(3)] triangles=sum(len(f.vertices)-2 for o in output for f in o.data.polygons) path=OUT/(name+'.glb') bpy.ops.export_scene.gltf(filepath=str(path),export_format='GLB',export_yup=True,export_animations=False) report[name]={'source_sha256':hashlib.sha256(source.read_bytes()).hexdigest(),'game_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),'triangles':triangles,'blender_bounds':[lo,hi],'parts':[o.name for o in output]} (OUT/'manifest.json').write_text(json.dumps(report,indent=2)+'\n') print('EQUIPMENT_BUILD',json.dumps(report))