import sand3d as s3d
def wired_controller():
root = s3d.at(housing(), x=-14.59, y=29.54, z=0)
return s3d.assembly(class="tok-string">"wired_controller", root)
def housing(w=52, length=134, thin=16, high=29, cx=12.59, cy=-83.54, cable_d=5, loop_w=65, loop_y=100, loop_l=105, shoulder=39):
case = s3d.body(class="tok-string">"case", plan=[(-length/2,w),(length/2,w)], top=[(-length/2,thin),(length/2-shoulder,high),(length/2,high)], bottom=0, n=6)
case = s3d.fillet(case, r=2)
case = s3d.at(case, x=cx, y=cy)
s3d.material(case, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#45484b")
a = cable_d
t = loop_y
u = loop_w/2
v = loop_l/2
low = 3
pts = [(cx,cy+length/2,3*a),(cx,4*a,thin-a/2),(cx,t/2,low+1),(a,t-3*a,thin-low-1),(a,t+2*a,thin/2),(4*a,t+4*a,a),(u+2*a+low,t-a,low),(u-a/2,t-v/2,2*a),(2*a,t-v/2-2,2*a-1),(-4*a,t,a+2),(-u+2*a,t+u+2,low),(-2*a,t+v-a,low),(4*a,t+u+2,low),(high,t,low+1),(u-a*1.5,t-u+2,3*a),(0,t-v-a/2,2*a-1),(-thin,t/2,a),(-u+a/2,t-u-2,low+1),(-u-a/2,t-thin-a,2*a)]
lead = s3d.wire(class="tok-string">"lead", path=s3d.spline(pts), d=cable_d)
s3d.material(lead, class="tok-string">"rubber", color=class="tok-string">"class="tok-comment">#292b2d")
sleeve = s3d.at(s3d.cone(class="tok-string">"sleeve", d=thin-a, d2=a, h=thin), x=cx, y=cy+length/2-1, z=3*a, rx=-90)
s3d.material(sleeve, class="tok-string">"rubber", color=class="tok-string">"class="tok-comment">#303235")
plug = s3d.at(connector(), x=-u-a/2, y=t-thin-a, z=2*a, rx=-90, rz=6)
groove = s3d.box(class="tok-string">"groove", w=2, d=2, h=thin-a)
grooves = s3d.at(groove, on=s3d.grid(nx=1, ny=4, py=8), x=cx+w/2, y=cy+length/2-thin, z=2)
case = s3d.cut(case, grooves)
b1 = s3d.at(button_01(), on=s3d.local(case, x=5, y=38, z=27))
s3d.joint(class="tok-string">"joint_button_01_joint_00", b1, on=s3d.local(case, x=5, y=38, z=28), kind=class="tok-string">"prismatic", axis=class="tok-string">"+Z", range=(0,0.000001))
b5 = s3d.at(button_05(), on=s3d.local(case, x=-9, y=13, z=25, rx=7))
s3d.joint(class="tok-string">"joint_button_05_joint_00", b5, on=s3d.local(case, x=-9, y=13, z=27, rx=7), kind=class="tok-string">"prismatic", axis=class="tok-string">"normal", range=(-1,0))
b2 = s3d.at(button_02(), on=s3d.local(case, x=-6, y=38, z=27))
s3d.joint(class="tok-string">"joint_button_02_joint_00", b2, on=s3d.local(case, x=-6, y=38, z=28), kind=class="tok-string">"prismatic", axis=class="tok-string">"+Z", range=(0,0.000001))
b6 = s3d.at(button_06(), on=s3d.local(case, x=-9, y=0, z=23, rx=7))
s3d.joint(class="tok-string">"joint_button_06_joint_00", b6, on=s3d.local(case, x=-9, y=0, z=25, rx=7), kind=class="tok-string">"prismatic", axis=class="tok-string">"normal", range=(-1.1,0))
b3 = s3d.at(button_03(), on=s3d.local(case, x=8, y=13, z=25, rx=7))
s3d.joint(class="tok-string">"joint_button_03_joint_00", b3, on=s3d.local(case, x=8, y=13, z=27, rx=7), kind=class="tok-string">"prismatic", axis=class="tok-string">"normal", range=(-1,0))
b4 = s3d.at(button_04(), on=s3d.local(case, x=8, y=0, z=23, rx=7))
s3d.joint(class="tok-string">"joint_button_04_joint_00", b4, on=s3d.local(case, x=8, y=0, z=25, rx=7), kind=class="tok-string">"prismatic", axis=class="tok-string">"normal", range=(-1.1,0))
return s3d.group(class="tok-string">"housing", case, lead, sleeve, plug, b1, b5, b2, b6, b3, b4)
def connector(d=18, h=26, collar=21, tip=7):
ob = s3d.cylinder(class="tok-string">"barrel", d=d, h=h)
for z in (0,h-4):
ob = s3d.join(ob, s3d.at(s3d.cylinder(class="tok-string">"collar", d=collar, h=4), z=z))
ob = s3d.join(ob, s3d.at(s3d.cylinder(class="tok-string">"tip", d=tip, h=6), z=h-1))
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#343638")
return ob
def button_01(w=5, h=2):
ob = s3d.cylinder(class="tok-string">"key", d=w, h=h)
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#a52d30")
return s3d.group(class="tok-string">"button_01", ob)
def button_05(w=11, d=8, h=2):
ob = s3d.extrude(class="tok-string">"key", s3d.rect(w=w,d=d,r=h/4), h=h)
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#474b50")
return s3d.group(class="tok-string">"button_05", ob)
def button_02(w=5, h=2):
ob = s3d.cylinder(class="tok-string">"key", d=w, h=h)
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#3e8054")
return s3d.group(class="tok-string">"button_02", ob)
def button_06(w=11, d=9, h=2):
ob = s3d.extrude(class="tok-string">"key", s3d.rect(w=w,d=d,r=h/4), h=h)
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#474b50")
return s3d.group(class="tok-string">"button_06", ob)
def button_03(w=11, d=8, h=2):
ob = s3d.extrude(class="tok-string">"key", s3d.rect(w=w,d=d,r=h/4), h=h)
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#474b50")
return s3d.group(class="tok-string">"button_03", ob)
def button_04(w=11, d=9, h=2):
ob = s3d.extrude(class="tok-string">"key", s3d.rect(w=w,d=d,r=h/4), h=h)
s3d.material(ob, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#474b50")
return s3d.group(class="tok-string">"button_04", ob)