extends RefCounted var g var wood=Color("573927") var iron=Color("343730") var brass=Color("8e8066") func beam(root,a,b,r=0.09,c=Color("573927")): g.line(root,a,b,r,c) func rim(root,radius,width,color): var mesh=TorusMesh.new();mesh.inner_radius=radius-width;mesh.outer_radius=radius+width;mesh.rings=128;mesh.ring_segments=20 var n=g.mesh_node(root,mesh,Vector3.ZERO,color);n.rotation.x=PI/2 return n func wheel(root,radius): var n=Node3D.new();root.add_child(n) rim(n,radius,0.10,wood);rim(n,radius+0.08,0.025,iron) for i in range(12): var a=i*TAU/12 beam(n,Vector3.ZERO,Vector3(cos(a),sin(a),0)*radius,0.065) g.ball(n,Vector3(cos(a),sin(a),0.105)*radius,Vector3.ONE*0.065,brass) var hub=g.cylinder(n,Vector3.ZERO,0.18,0.35,iron);hub.rotation.x=PI/2 return n func build(game,d): g=game if d.selected>=4: preload("res://new_equipment.gd").new().build(g,d) return var root=d.device if d.selected==3: preload("res://iron_maiden.gd").new().build(g,d) return if d.selected==0: preload("res://pillory.gd").new().build(g,d) return if d.selected==1: # Long timber bed, end rollers, iron straps and a separate winding crank. for x in [-0.70,0.70]: g.box(root,Vector3(x,0.84,0),Vector3(0.18,0.28,3.15),wood) for z in [-1.3,1.3]: g.box(root,Vector3(x,0.4,z),Vector3(0.23,0.8,0.25),wood) g.box(root,Vector3(x,0.68,z),Vector3(0.25,0.14,0.27),iron) for j in range(10):g.box(root,Vector3(0,0.86,-1.17+j*0.26),Vector3(1.3,0.14,0.23),wood.lightened((j%3)*0.04)) for z in [-1.4,1.4]: var roller=g.cylinder(root,Vector3(0,1.08,z),0.16,1.75,wood);roller.rotation.z=PI/2 for x in [-0.48,0.48]: beam(root,Vector3(x,1.16,z),Vector3(x,1.12,sign(z)*0.72),0.022,Color("bda27a")) for x in [-0.72,0.72]: for z in [-1.35,-0.5,0.5,1.35]: g.box(root,Vector3(x,0.87,z),Vector3(0.2,0.31,0.07),iron) g.ball(root,Vector3(x,1.04,z),Vector3.ONE*0.07,brass) d.crank=wheel(root,0.36);d.crank.position=Vector3(1.0,1.1,1.4);d.crank.rotation.y=PI/2 beam(d.crank,Vector3(0.36,0,0),Vector3(0.36,0,0.3),0.055,iron) elif d.selected==2: for x in [-0.55,0.55]: beam(root,Vector3(x,0,-0.7),Vector3(0,1.6,-0.45),0.14) beam(root,Vector3(x,0,0.6),Vector3(0,1.6,-0.45),0.14) g.box(root,Vector3(0,0.12,0),Vector3(1.7,0.22,1.5),wood) d.crank=wheel(root,1.28);d.crank.position=Vector3(0,1.62,0) for x in [-0.72,0.72]: for y in [-0.62,0.62]: pass # Bone-following leather cuffs are supplied by apparatus_motion. else: # Body-shaped iron shell with rounded shoulders, face and two hinged leaves. root.scale=Vector3(1.25,1.12,1.2) var sculpt=preload("res://hero.gd").new();sculpt.g=g g.cylinder(root,Vector3(0,0.13,0),0.95,0.26,iron) var profile=[[0.25,0.56],[0.8,0.67],[1.5,0.74],[2.1,0.64],[2.4,0.40],[2.65,0.28]] for j in range(profile.size()-1): var y=(profile[j][0]+profile[j+1][0])/2.0 var h=profile[j+1][0]-profile[j][0] var w=(profile[j][1]+profile[j+1][1])/2.0 for i in range(9): var a=PI+i*PI/8 var n=g.box(root,Vector3(cos(a)*w,y,sin(a)*0.52),Vector3(0.30,h+0.02,0.12),iron);n.rotation.y=-a+PI/2 d.door=Node3D.new();root.add_child(d.door);d.door.position=Vector3(-0.69,0,0.10) d.second_door=Node3D.new();root.add_child(d.second_door);d.second_door.position=Vector3(0.69,0,0.10) for side in [-1,1]: var leaf=d.door if side<0 else d.second_door for j in range(profile.size()-1): var y=(profile[j][0]+profile[j+1][0])/2.0;var h=profile[j+1][0]-profile[j][0] var w=(profile[j][1]+profile[j+1][1])/2.0 g.box(leaf,Vector3(-side*(0.69-w/2),y,0.44),Vector3(w,h+0.01,0.14),iron.lightened(0.07)) for y in [0.5,1.2,1.9]: g.box(leaf,Vector3(-side*0.34,y,0.54),Vector3(0.62,0.06,0.06),brass) for x in [0.13,0.55]:g.ball(leaf,Vector3(-side*x,y,0.59),Vector3.ONE*0.065,brass) sculpt.loft(leaf,Vector3(-side*0.55,0,0.43),[[2.35,0.15,0.08,0],[2.5,0.2,0.16,0],[2.73,0.15,0.13,0],[2.83,0.01,0.04,0]],brass) g.ball(leaf,Vector3(-side*0.55,2.58,0.58),Vector3(0.09,0.035,0.03),Color("19151b")) d.crank=wheel(root,0.32);d.crank.position=Vector3(1.0,1.05,0.1) beam(root,Vector3(0.7,0.2,0),Vector3(1,0.2,0),0.10,iron) beam(root,Vector3(1,0.2,0),Vector3(1,1,0),0.10,iron) d.flame=g.ball(root,Vector3(0,0.3,0),Vector3(1,0.5,0.9),Color("ff8735"));d.flame.material_override=g.mat(Color("ff8735"),true);d.flame.hide() d.door.rotation.y=-1.8;d.second_door.rotation.y=1.8 add_detail(root,d) var queue=[root] while not queue.is_empty(): var n=queue.pop_back() for child in n.get_children():queue.append(child) if n is MeshInstance3D and n.material_override is StandardMaterial3D and n!=d.flame: var color=n.material_override.albedo_color var mat=ShaderMaterial.new() mat.shader=preload("res://timber.gdshader") if color.r>color.g*1.25 and color.r<0.5 else preload("res://forged.gdshader") mat.set_shader_parameter("tint",color) n.material_override=mat func add_detail(root,d): if d.selected==1: for z in [-1.4,1.4]: # Actual helical rope wound around both rollers. for i in range(100): var a=i*.65;var b=(i+1)*.65 var x=-.62+i*.0124 beam(root,Vector3(x,1.08+cos(a)*.175,z+sin(a)*.175),Vector3(x+.0124,1.08+cos(b)*.175,z+sin(b)*.175),.009,Color("918066")) for x in [-.82,.82]: var cap=g.cylinder(root,Vector3(x,1.08,z),.21,.06,iron);cap.rotation.z=PI/2 for j in range(8): var a=j*TAU/8;g.ball(root,Vector3(x,1.08+sin(a)*.17,z+cos(a)*.17),Vector3.ONE*.037,brass) for x in [-.7,.7]: for z in [-1.25,1.25]: beam(root,Vector3(x,.15,z),Vector3(x,.72,z-sign(z)*.55),.045,iron) for y in [.15,.35,.65]:g.ball(root,Vector3(x+sign(x)*.12,y,z),Vector3.ONE*.045,brass) elif d.selected==2: for j in range(36): var a=j*TAU/36 g.ball(d.crank,Vector3(cos(a)*1.28,sin(a)*1.28,.12),Vector3.ONE*.05,brass) if j%3==0: var plate=g.box(d.crank,Vector3(cos(a)*1.20,sin(a)*1.20,.11),Vector3(.09,.21,.03),iron);plate.rotation.z=a-PI/2 for j in range(24): var a=j*TAU/24 var tooth=g.box(d.crank,Vector3(cos(a)*.30,sin(a)*.30,-.12),Vector3(.07,.09,.08),iron);tooth.rotation.z=a elif d.selected==3: for side in [-1,1]: var leaf=d.door if side<0 else d.second_door for y in [.35,.75,1.15,1.55,1.95,2.25]: g.cylinder(leaf,Vector3(0,y,.1),.055,.16,brass) for x in [.08,.59]:g.ball(leaf,Vector3(-side*x,y,.56),Vector3.ONE*.045,brass) for j in range(7):g.box(leaf,Vector3(-side*(.15+j*.055),.32,.56),Vector3(.018,.13,.025),Color("111411")) var handle=g.torus(leaf,Vector3(-side*.48,1.3,.62),.075,iron);handle.rotation.x=PI/2;handle.material_override=g.mat(iron) for j in range(24): var a=j*TAU/24;g.ball(root,Vector3(cos(a)*.85,.2,sin(a)*.85),Vector3.ONE*.06,brass)