use <fonts/CasualStencil.ttf>

rotate([180, 0, 0]) translate([-112, -243, -3]) {
    //import("Crossfire_2/C2BottomPlate.stl");
}

module arm_preview(angle) {
    rotate([180, 0, 90 + angle])
        translate([-735, -186.4, 0]) {
            import("Crossfire_2/ArmTall4H.stl");
        }
}

$fn=30;

module bumper_hole() {
    translate([0, 0, 1.5]) union() {
        cylinder(d =  8.5, center = true, h = 3.1);
        translate([0, 0, 0.76])
            cylinder(d = 14.5, center = true, h = 1.5);
    }
}

module band_hole() {
    translate([0, 0, 1.5]) union() {
        translate([  9, 0, 0]) cylinder(d =  2, center = true, h = 4);
        translate([- 9, 0, 0]) cylinder(d =  2, center = true, h = 4);
        cube([18, 2, 4], center = true);
    }
}

module arm_hole(angle) {
    rotate([0, 0, angle]) {
        translate([-12.5, -14, 0]) cylinder(d = 3, center = true, h = 4);
        translate([ 13  , -14, 0]) cylinder(d = 3, center = true, h = 4);
        translate([-12.5,  11.5, 0]) cylinder(d = 3, center = true, h = 4);
        translate([ 13  ,  11.5, 0]) cylinder(d = 3, center = true, h = 4);
    }
}

/*
color("DarkViolet") {
    translate([ 24,  24, 29]) arm_preview(- 45 + 180);
    translate([-24,  24, 29]) arm_preview(  45 + 180);
    translate([ 24, -24, 29]) arm_preview(  45);
    translate([-24, -24, 29]) arm_preview(- 45);
}
*/

intersection() {
    difference() {
        union() {
            translate([0, 0, 1.5]) rotate([0, 0, -45])
                cube(size=[105, 105, 3], center = true);

            translate([   0,  21, 3.5]) cylinder(d = 5, center = true, h = 7);
            translate([   0,- 21, 3.5]) cylinder(d = 5, center = true, h = 7);
        }
        union() {
            // Rounded corners are removed
            translate([   0, -90, 1.9])
                cylinder(d = 90, center = true, h = 4);
            translate([   0,  90, 1.9])
                cylinder(d = 90, center = true, h = 4);
            translate([ 90,    0, 1.9])
                cylinder(d = 90, center = true, h = 4);
            translate([-90,    0, 1.9])
                cylinder(d = 90, center = true, h = 4);
            
            // Arm holes are removed            
            translate([ 24,  24, 1.9]) arm_hole(- 45 + 180);
            translate([-24,  24, 1.9]) arm_hole(  45 + 180);
            translate([ 24, -24, 1.9]) arm_hole(  45);
            translate([-24, -24, 1.9]) arm_hole(- 45);

            // bumper holes are removed
            translate([  0,  32, 0]) bumper_hole();
            translate([  0,- 32, 0]) bumper_hole();
            translate([ 32,   0, 0]) bumper_hole();
            translate([-32,   0, 0]) bumper_hole();
            
            translate([ 20,  32, 0]) band_hole();
            translate([ 20,- 32, 0]) band_hole();
            translate([-20,  32, 0]) band_hole();
            translate([-20,- 32, 0]) band_hole();
            
            // Through holes are removed
            translate([0, 0, 1.9])
                cylinder(d = 20, center = true, h = 4);
                
                
            //rotate([0, 0, 0])
            //    translate([0, 0, -15]) cube(size=[150, 49, 29], center = true);
            
            translate([   0,  21, 3.5]) cylinder(d = 3, center = true, h = 7.2);
            translate([   0,- 21, 3.5]) cylinder(d = 3, center = true, h = 7.2);
            translate([  21,   0, 3.5]) cylinder(d = 3, center = true, h = 7.2);
            translate([- 21,   0, 3.5]) cylinder(d = 3, center = true, h = 7.2);
            
        }
    }
}