use <mattscad/mirrorcopy.scad>
use <andon.scad>
$fn=$preview?60:240;
$fn=10;
radius = 8;
wall_thickness=3;
magnet_dia=8;
magnet_depth=2;

module turret(){
    translate([0,0,-1])difference(){
        union(){
            translate([0,0,20+50])rotate([0,90,0])andon_reciever();
            // Andon neck
            difference(){
                translate([0,0,50-1.5])cylinder(d=30,h=9); 
                translate([0,0,20+50])rotate([0,90,0])translate([0,0,-16.5])andon_interior_hollow();
            }
        }
        // Hole in andon neck
        translate([0,0,50-1.5-.5])cylinder(h=10, d=17);
        // Clearance for other half
        translate([0,0,50+20])rotate([0,90,0]){
            difference(){
                cylinder(d=40,h=20);
                translate([0,0,-0.5])cylinder(d=25,h=21);
            }
        }
    }
}

color("white",0.3)turret();

module outer_shell(){
    hull(){
        // Lower corners
        translate([0,-10,0.5])
            mirrorCopy([0,1,0],[1,0,0])
                translate([30-radius,50-radius,0])
                    cylinder(h=1,r=radius,center=true);

        // Upper spheres
        mirrorCopy([0,1,0],[1,0,0])
            translate([30-radius-2, 40-radius-2,40])
                sphere(r=radius);
    }
}
module inner_shell(){
    hull(){
        // Lower corners
        translate([0,-10+2,0+wall_thickness])
            mirrorCopy([0,1,0],[1,0,0])
                translate([30-radius-wall_thickness,50-radius-wall_thickness-2,0])
                    cylinder(h=1,r=radius,center=true);

        // Upper spheres
        mirrorCopy([0,1,0],[1,0,0])
            translate([30-radius-2-wall_thickness, 40-radius-2-wall_thickness,40-wall_thickness])
                sphere(r=radius);
    }
}
module bottom_cover(){
    difference(){
        hull(){
            translate([0,-10+2,0.5-0.01])
                mirrorCopy([0,1,0],[1,0,0])
                    translate([30-radius-wall_thickness,50-radius-wall_thickness-2,0])
                        cylinder(h=1,r=radius,center=true);
            translate([0,-10+2,0+wall_thickness])
                mirrorCopy([0,1,0],[1,0,0])
                    translate([30-radius-wall_thickness,50-radius-wall_thickness-2,0])
                        cylinder(h=1,r=radius,center=true);
        }
        translate([0,-10/1.5,0])
            mirrorCopy([0,1,0],[1,0,0])
                translate([30-(wall_thickness*2)-(magnet_dia/2),50-(wall_thickness*2)-(magnet_dia),(magnet_depth/2)-0.02])
                    cylinder(h=magnet_depth,d=magnet_dia, center=true);
    }
}

translate([80,0,0])bottom_cover();
color("white", 0.3)difference(){
    outer_shell();
    inner_shell();
    hull()bottom_cover();
    //translate([50,0,50-5])cube([100,200,100], center=true);
}
//inner_shell();
//color("red")bottom_cover();