build the actual case
This commit is contained in:
11
bits.scad
11
bits.scad
@@ -1,3 +1,4 @@
|
|||||||
|
include <defaults.scad>
|
||||||
include <dimensions.scad>
|
include <dimensions.scad>
|
||||||
use <primitives.scad>
|
use <primitives.scad>
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ module Volume_(Depth, Box=false)
|
|||||||
pillX(Depth, VolumeLength, VolumeHeight, center=false);
|
pillX(Depth, VolumeLength, VolumeHeight, center=false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module Volume(Depth, Box=false)
|
module Volume(Depth=2, Box=false)
|
||||||
{
|
{
|
||||||
translate([BodyWidth, VolumeMinY, VolumeMinZ]) Volume_(Depth, Box=Box);
|
translate([BodyWidth, VolumeMinY, VolumeMinZ]) Volume_(Depth, Box=Box);
|
||||||
}
|
}
|
||||||
@@ -22,7 +23,7 @@ module Power_(Depth, Box=false)
|
|||||||
pillX(Depth, PowerLength, PowerHeight, center=false);
|
pillX(Depth, PowerLength, PowerHeight, center=false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module Power(Depth, Box=false)
|
module Power(Depth=2, Box=false)
|
||||||
{
|
{
|
||||||
translate([BodyWidth, PowerMinY, PowerMinZ]) Power_(Depth, Box=Box);
|
translate([BodyWidth, PowerMinY, PowerMinZ]) Power_(Depth, Box=Box);
|
||||||
}
|
}
|
||||||
@@ -35,7 +36,7 @@ module Camera_(Depth, Box=false)
|
|||||||
pillZ(CameraWidth, CameraLength, Depth, center=false);
|
pillZ(CameraWidth, CameraLength, Depth, center=false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module Camera(Depth, Box=false)
|
module Camera(Depth=2, Box=false)
|
||||||
{
|
{
|
||||||
translate([CameraMinX, CameraMinY, BodyHeight]) Camera_(Depth, Box=Box);
|
translate([CameraMinX, CameraMinY, BodyHeight]) Camera_(Depth, Box=Box);
|
||||||
}
|
}
|
||||||
@@ -48,7 +49,7 @@ module Usb_(Depth, Box=false)
|
|||||||
pillY(UsbWidth, Depth, UsbHeight, center=false);
|
pillY(UsbWidth, Depth, UsbHeight, center=false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module Usb(Depth, Box=false)
|
module Usb(Depth=2, Box=false)
|
||||||
{
|
{
|
||||||
translate([BodyWidth/2 - UsbWidth/2, BodyLength-Depth, UsbMinZ]) Usb_(Depth, Box=Box);
|
translate([BodyWidth/2 - UsbWidth/2, BodyLength-Depth, UsbMinZ]) Usb_(Depth, Box=Box);
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ module Aux_(Depth)
|
|||||||
{
|
{
|
||||||
cylinderY(d=3.5, h=Depth, center=false);
|
cylinderY(d=3.5, h=Depth, center=false);
|
||||||
}
|
}
|
||||||
module Aux(Depth)
|
module Aux(Depth=10)
|
||||||
{
|
{
|
||||||
translate([AuxMinX, 0, AuxMinZ]) Aux_(Depth);
|
translate([AuxMinX, 0, AuxMinZ]) Aux_(Depth);
|
||||||
}
|
}
|
||||||
|
148
case.scad
148
case.scad
@@ -1,54 +1,116 @@
|
|||||||
|
include <defaults.scad>
|
||||||
include <dimensions.scad>
|
include <dimensions.scad>
|
||||||
|
use <bits.scad>
|
||||||
use <phone.scad>
|
use <phone.scad>
|
||||||
|
use <primitives.scad>
|
||||||
|
|
||||||
$fs = 1;
|
// thickness of case walls
|
||||||
|
Thickness = 2;
|
||||||
|
// how large of cuts (radial) to make around each component
|
||||||
|
MarginCamera = 2;
|
||||||
|
MarginButtons = 2.5;
|
||||||
|
MarginPorts = 5.5;
|
||||||
|
// how far into the xy plane to extend the part of the case which covers the front of the phone.
|
||||||
|
// the top of the phone contains stuff we don't want to cover (camera); the bottom has more margin
|
||||||
|
FrontOverhangX = 3;
|
||||||
|
FrontOverhangTop = 3;
|
||||||
|
FrontOverhangBot = 6;
|
||||||
|
|
||||||
module plate(Margin, Thick=Height)
|
// gives a 1cm margin around the whole body of the phone, but only in the xy plane.
|
||||||
|
module _PhoneBulkLayer(tol=tol)
|
||||||
{
|
{
|
||||||
translate([0,0,2]) hull() {
|
minkowski() {
|
||||||
translate([(Length-Height-Margin)/2,(Width-Height-Margin)/2,0]) cylinder(d=Height, h=Thick);
|
PhoneBody();
|
||||||
translate([-(Length-Height-Margin)/2,(Width-Height-Margin)/2,0]) cylinder(d=Height, h=Thick);
|
cube([20, 20, tol], center=true);
|
||||||
translate([(Length-Height-Margin)/2,-(Width-Height-Margin)/2,0]) cylinder(d=Height, h=Thick);
|
}
|
||||||
translate([-(Length-Height-Margin)/2,-(Width-Height-Margin)/2,0]) cylinder(d=Height, h=Thick);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
difference() {
|
module _FrontFace(tol=tol) {
|
||||||
union() {
|
color("thistle")
|
||||||
difference() {
|
difference() {
|
||||||
phone(4);
|
translate([0, 0, -Thickness]) PhoneBody();
|
||||||
plate(2);
|
_PhoneBulkLayer(tol=tol);
|
||||||
}
|
};
|
||||||
translate([0,0,Height/2-4]) {
|
|
||||||
minkowski() {
|
|
||||||
difference() {
|
|
||||||
plate(3,1);
|
|
||||||
translate([0,0,-1])plate(3.1,4);
|
|
||||||
}
|
|
||||||
sphere(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
phone(Bits=1);
|
|
||||||
//translate([0,-50,-50])cube([100,100,100]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// we want to cutout a portion of the case to expose the touchscreen.
|
||||||
translate([0,0,Height/2-4]) {
|
/// but we don't want to cut out the entire front face.
|
||||||
minkowski() {
|
/// so, produce a "mask", of just that front-facing portion of the case we want to preserve:
|
||||||
difference() {
|
/// returns a mask which is -Thickness <= z <= 0, within tolerance
|
||||||
plate(3,1);
|
module _FrontKeep(tol=tol) {
|
||||||
translate([0,0,-1])plate(3.1,4);
|
minkowski() {
|
||||||
}
|
// take the outline of the front face of the phone
|
||||||
sphere(2);
|
difference() {
|
||||||
}
|
minkowski() {
|
||||||
|
cylinder(r=2*tol, h=tol, center=true);
|
||||||
|
_FrontFace();
|
||||||
|
};
|
||||||
|
minkowski() {
|
||||||
|
cylinder(r=tol, h=2*tol, center=true);
|
||||||
|
_FrontFace();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
// and expand it
|
||||||
|
// cylinder(r=FrontOverhangX, h=tol, center=false);
|
||||||
|
// translate([0, -0.5*(FrontOverhangBot - FrontOverhangTop), -Thickness])
|
||||||
|
pillZ(2*FrontOverhangX, FrontOverhangBot + FrontOverhangTop, tol, center=true);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
minkowski() {
|
/// returns the region which we want to subtract from the case, in order to keep the front screen accessible.
|
||||||
difference() {
|
/// the returned cutout is strictly z <= 0,
|
||||||
cube([Length+0.2, Width+0.2, 0.2], true);
|
module _FrontCutout() {
|
||||||
cube([Length, Width, 4], true);
|
difference() {
|
||||||
}
|
_FrontFace();
|
||||||
sphere(d=3);
|
_FrontKeep();
|
||||||
}
|
};
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
module Case()
|
||||||
|
{
|
||||||
|
color("DarkSlateGray")
|
||||||
|
difference() {
|
||||||
|
minkowski() {
|
||||||
|
sphere(d=Thickness);
|
||||||
|
// Phone(volume=false, power=false, camera=false);
|
||||||
|
PhoneBody();
|
||||||
|
}
|
||||||
|
union() {
|
||||||
|
minkowski() {
|
||||||
|
sphere(r=MarginCamera);
|
||||||
|
Camera();
|
||||||
|
};
|
||||||
|
// restrict these cutouts to just the phone bulk -- don't let them impact the back of the case
|
||||||
|
intersection() {
|
||||||
|
_PhoneBulkLayer();
|
||||||
|
union() {
|
||||||
|
minkowski() {
|
||||||
|
sphere(r=MarginButtons);
|
||||||
|
union() {
|
||||||
|
Volume();
|
||||||
|
Power();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
minkowski() {
|
||||||
|
sphere(r=MarginPorts);
|
||||||
|
union() {
|
||||||
|
Usb();
|
||||||
|
Aux();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Phone(usb=false, aux=false);
|
||||||
|
translate([0, 0, tol]) _FrontCutout();
|
||||||
|
// _FrontCutout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Case();
|
||||||
|
|
||||||
|
// debugging:
|
||||||
|
// _FrontFace();
|
||||||
|
// _FrontKeep();
|
||||||
|
// _FrontCutout();
|
||||||
|
// Phone();
|
||||||
|
5
defaults.scad
Normal file
5
defaults.scad
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
$fs = 1;
|
||||||
|
|
||||||
|
// tolerance. lining up the extrusions and cuts with zero tolerance causes very thin walls,
|
||||||
|
// so i offset those to make the model actually contiguous.
|
||||||
|
tol = 0.01;
|
47
phone.scad
47
phone.scad
@@ -1,53 +1,48 @@
|
|||||||
|
include <defaults.scad>
|
||||||
include <dimensions.scad>
|
include <dimensions.scad>
|
||||||
use <bits.scad>
|
use <bits.scad>
|
||||||
use <primitives.scad>
|
use <primitives.scad>
|
||||||
|
|
||||||
$fs = 1;
|
|
||||||
|
|
||||||
// tolerance. lining up the extrusions and cuts with zero tolerance causes very thin walls,
|
|
||||||
// so i offset those to make the model actually contiguous.
|
|
||||||
Tol = 0.1;
|
|
||||||
|
|
||||||
// simple box-shaped body; preserve for easier debugging
|
|
||||||
module BodyBox() {
|
|
||||||
cube([BodyWidth, BodyLength, BodyHeight], center=false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the kernel which can be convolved with the box body to produce the actual body
|
// return the kernel which can be convolved with the box body to produce the actual body
|
||||||
module BodyConvolve(Tol=Tol) {
|
module _BodyConvolve(tol=tol) {
|
||||||
minkowski() {
|
minkowski() {
|
||||||
// cylinder rounds the four corners of the phone
|
// cylinder rounds the four corners of the phone
|
||||||
cylinder(r=BodyRadXY-BodyRadFrontZ, h=Tol, center=true);
|
cylinder(r=BodyRadXY-BodyRadFrontZ, h=tol, center=true);
|
||||||
// sphere rounds the thickness of the phone
|
// sphere rounds the thickness of the phone
|
||||||
// in actuality this shouldn't be symmetric (the screen and back cover have different radii),
|
// in actuality this shouldn't be symmetric (the screen and back cover have different radii),
|
||||||
// but using a single radius is Good Enough
|
// but using a single radius is Good Enough
|
||||||
sphere(r=BodyRadFrontZ);
|
sphere(r=BodyRadFrontZ);
|
||||||
// cylinderY(r=BodyRadFrontZ, h=Tol, center=true);
|
// cylinderY(r=BodyRadFrontZ, h=tol, center=true);
|
||||||
// cylinderX(r=BodyRadFrontZ, h=Tol, center=true);
|
// cylinderX(r=BodyRadFrontZ, h=tol, center=true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module Body()
|
module PhoneBody(Box=false)
|
||||||
{
|
{
|
||||||
translate([BodyRadXY, BodyRadXY, BodyRadFrontZ])
|
if (Box) {
|
||||||
minkowski() {
|
cube([BodyWidth, BodyLength, BodyHeight], center=false);
|
||||||
cube([BodyWidth-2*BodyRadXY, BodyLength-2*BodyRadXY, BodyHeight-2*BodyRadFrontZ], center=false);
|
} else {
|
||||||
BodyConvolve();
|
translate([BodyRadXY, BodyRadXY, BodyRadFrontZ])
|
||||||
|
minkowski() {
|
||||||
|
cube([BodyWidth-2*BodyRadXY, BodyLength-2*BodyRadXY, BodyHeight-2*BodyRadFrontZ], center=false);
|
||||||
|
_BodyConvolve();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module Phone(Box=false)
|
module Phone(Box=false, volume=true, power=true, camera=true, usb=true, aux=true)
|
||||||
{
|
{
|
||||||
difference() {
|
difference() {
|
||||||
union() {
|
union() {
|
||||||
if (Box) { BodyBox(); } else { Body(); }
|
PhoneBody(Box=Box);
|
||||||
Volume(2, Box=Box);
|
if (volume) { Volume(Box=Box); }
|
||||||
Power(2, Box=Box);
|
if (power) { Power(Box=Box); }
|
||||||
Camera(2, Box=Box);
|
if (camera) { Camera(Box=Box); }
|
||||||
}
|
}
|
||||||
union() {
|
union() {
|
||||||
translate([0, Tol, 0])Usb(2, Box=Box);
|
if (usb) { translate([0, tol, 0]) Usb(Box=Box); }
|
||||||
translate([0, -Tol, 0])Aux(2);
|
if (aux) { translate([0, -tol, 0]) Aux(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
//! general-purpose "primitives" lacking from the OpenSCAD builtins
|
//! general-purpose "primitives" lacking from the OpenSCAD builtins
|
||||||
|
|
||||||
|
include <defaults.scad>
|
||||||
|
|
||||||
/// cylinder() but with the axis on the x axis instead of the z axis.
|
/// cylinder() but with the axis on the x axis instead of the z axis.
|
||||||
/// and where `center=false` behaves like for `cube(center=false)`,
|
/// and where `center=false` behaves like for `cube(center=false)`,
|
||||||
/// i.e. circle center is not at (0, 0) but (r, r)
|
/// i.e. circle center is not at (0, 0) but (r, r)
|
||||||
@@ -27,7 +29,7 @@ module cylinderZ(d=undef, r=undef, h=undef, center=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// a 2d-cylinder extruded along the x-axis
|
// a 2d-cylinder extruded along the x-axis
|
||||||
module pillX(dimX, dimY, dimZ, tol=0.01, center=false) {
|
module pillX(dimX, dimY, dimZ, tol=tol, center=false) {
|
||||||
diam = min(dimY, dimZ) - tol;
|
diam = min(dimY, dimZ) - tol;
|
||||||
minkowski() {
|
minkowski() {
|
||||||
cube([dimX/2, dimY-diam, dimZ-diam], center=center);
|
cube([dimX/2, dimY-diam, dimZ-diam], center=center);
|
||||||
@@ -36,7 +38,7 @@ module pillX(dimX, dimY, dimZ, tol=0.01, center=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// a 2d-cylinder extruded along the x-axis
|
// a 2d-cylinder extruded along the x-axis
|
||||||
module pillY(dimX, dimY, dimZ, tol=0.01, center=false) {
|
module pillY(dimX, dimY, dimZ, tol=tol, center=false) {
|
||||||
diam = min(dimX, dimZ) - tol;
|
diam = min(dimX, dimZ) - tol;
|
||||||
minkowski() {
|
minkowski() {
|
||||||
cube([dimX-diam, dimY/2, dimZ-diam], center=center);
|
cube([dimX-diam, dimY/2, dimZ-diam], center=center);
|
||||||
@@ -45,7 +47,7 @@ module pillY(dimX, dimY, dimZ, tol=0.01, center=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// a 2d-cylinder extruded along the z-axis
|
// a 2d-cylinder extruded along the z-axis
|
||||||
module pillZ(dimX, dimY, dimZ, tol=0.01, center=false) {
|
module pillZ(dimX, dimY, dimZ, tol=tol, center=false) {
|
||||||
diam = min(dimX, dimY) - tol;
|
diam = min(dimX, dimY) - tol;
|
||||||
minkowski() {
|
minkowski() {
|
||||||
cube([dimX-diam, dimY-diam, dimZ/2], center=center);
|
cube([dimX-diam, dimY-diam, dimZ/2], center=center);
|
||||||
|
Reference in New Issue
Block a user