mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2024-11-26 14:54:21 +00:00
switch rounded_shape to use half minkowski sum for height and promote connector slop to full special variable
This commit is contained in:
parent
e23dae799b
commit
dcc13b7d35
20
dishes.scad
20
dishes.scad
@ -14,6 +14,9 @@ module dish(width, height, depth, inverted, tilt) {
|
||||
else if ($dish_type == "sideways cylindrical"){
|
||||
sideways_cylindrical_dish(width, height, depth, inverted, tilt);
|
||||
}
|
||||
else if ($dish_type == "old spherical") {
|
||||
old_spherical_dish(width, height, depth, inverted, tilt);
|
||||
}
|
||||
// else no dish, "no dish" is the value
|
||||
}
|
||||
|
||||
@ -68,10 +71,12 @@ module spherical_dish(width, height, depth, inverted, tilt, txt=""){
|
||||
rotate([-tilt,0,0]){
|
||||
translate([0,0,0 * direction]){
|
||||
if (geodesic){
|
||||
$fa=10;
|
||||
geodesic_sphere(r=rad);
|
||||
$fa=20;
|
||||
scale([chord/2/depth, chord/2/depth]) {
|
||||
geodesic_sphere(r=depth);
|
||||
}
|
||||
} else {
|
||||
$fa=1;
|
||||
$fa=7;
|
||||
// rotate 1 because the bottom of the sphere looks like trash.
|
||||
scale([chord/2/depth, chord/2/depth]) {
|
||||
geodesic_sphere(r=depth);
|
||||
@ -102,15 +107,12 @@ module old_spherical_dish(width, height, depth, inverted, tilt, txt=""){
|
||||
rotate([-tilt,0,0]){
|
||||
translate([0,0,chord_length * direction]){
|
||||
if (geodesic){
|
||||
$fa=3;
|
||||
$fa=7;
|
||||
geodesic_sphere(r=rad);
|
||||
} else {
|
||||
$fa=1;
|
||||
// rotate 1 because the bottom of the sphere looks like trash.
|
||||
%difference() {
|
||||
sphere(r=rad);
|
||||
translate([0,0,rad]) cube(rad*2, center=true);
|
||||
}
|
||||
// rotate 1 because the bottom of the sphere looks like trash
|
||||
sphere(r=rad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
48
key.scad
48
key.scad
@ -12,9 +12,9 @@ wall_thickness = 3;
|
||||
//whether stabilizer connectors are enabled
|
||||
stabilizers = false;
|
||||
// font used for text
|
||||
font="Arial";
|
||||
font="DejaVu Sans Mono:style=Book";
|
||||
// font size used for text
|
||||
font_size = 8;
|
||||
font_size = 6;
|
||||
// whether or not to render fake keyswitches to check clearances
|
||||
clearance_check = false;
|
||||
|
||||
@ -71,6 +71,8 @@ text = "";
|
||||
inset_text = false;
|
||||
// radius of corners of keycap
|
||||
corner_radius = 1;
|
||||
// keystem slop - lengthens the cross and thins out the connector
|
||||
slop = 0.3;
|
||||
|
||||
|
||||
|
||||
@ -90,7 +92,7 @@ $fs = .1;
|
||||
//beginning to use unit instead of baked in 19.05
|
||||
unit = 19.05;
|
||||
//minkowski radius. radius of sphere used in minkowski sum for minkowski_key function. 1.75 default for faux G20
|
||||
$minkowski_radius = .75;
|
||||
$minkowski_radius = .33;
|
||||
|
||||
|
||||
|
||||
@ -120,12 +122,15 @@ module shape(thickness_difference, depth_difference){
|
||||
|
||||
// shape of the key but with soft, rounded edges. much more realistic, MUCH more complex. orders of magnitude more complex
|
||||
module rounded_shape() {
|
||||
minkowski(){
|
||||
shape($minkowski_radius*2, $minkowski_radius);
|
||||
difference(){
|
||||
sphere(r=$minkowski_radius, $fn=24);
|
||||
translate([0,0,-$minkowski_radius])
|
||||
render(){
|
||||
minkowski(){
|
||||
// half minkowski. that means the shape is neither circumscribed nor inscribed.
|
||||
shape($minkowski_radius * 2, $minkowski_radius/2);
|
||||
difference(){
|
||||
sphere(r=$minkowski_radius, $fn=24);
|
||||
translate([0,0,-$minkowski_radius])
|
||||
cube([2*$minkowski_radius,2*$minkowski_radius,2*$minkowski_radius], center=true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,14 +141,16 @@ module rounded_shape() {
|
||||
// $height_difference used for keytop thickness
|
||||
// extra_slices is a hack to make inverted dishes still work
|
||||
module shape_hull(thickness_difference, depth_difference, modifier, extra_slices = 0){
|
||||
if ($ISOEnter) {
|
||||
ISOEnterShapeHull(thickness_difference, depth_difference, modifier);
|
||||
} else {
|
||||
slices = 10;
|
||||
for (index = [0:$height_slices - 1 + extra_slices]) {
|
||||
hull() {
|
||||
shape_slice(index, $height_slices, thickness_difference, depth_difference, modifier);
|
||||
shape_slice(index + 1, $height_slices, thickness_difference, depth_difference, modifier);
|
||||
render() {
|
||||
if ($ISOEnter) {
|
||||
ISOEnterShapeHull(thickness_difference, depth_difference, modifier);
|
||||
} else {
|
||||
slices = 10;
|
||||
for (index = [0:$height_slices - 1 + extra_slices]) {
|
||||
hull() {
|
||||
shape_slice(index, $height_slices, thickness_difference, depth_difference, modifier);
|
||||
shape_slice(index + 1, $height_slices, thickness_difference, depth_difference, modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,7 +204,7 @@ module top_of_key(){
|
||||
}
|
||||
|
||||
module keytext() {
|
||||
extra_inset_depth = ($inset_text) ? keytop_thickness/4 : 0;
|
||||
extra_inset_depth = ($inset_text) ? 0.3 : 0;
|
||||
|
||||
translate([0, 0, -extra_inset_depth]){
|
||||
top_of_key(){
|
||||
@ -208,12 +215,12 @@ module keytext() {
|
||||
}
|
||||
}
|
||||
|
||||
module connectors(stem_profile) {
|
||||
module connectors() {
|
||||
intersection() {
|
||||
for (connector_pos = $connectors) {
|
||||
translate([connector_pos[0], connector_pos[1], $stem_inset]) {
|
||||
rotate([0, 0, $stem_rotation]){
|
||||
color([1, .6941, .2]) connector(stem_profile, $has_brim);
|
||||
color([1, .6941, .2]) connector($stem_profile, $has_brim, $slop);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -258,7 +265,7 @@ module key() {
|
||||
difference() {
|
||||
union(){
|
||||
keytop();
|
||||
if($stem_profile != "blank") connectors($stem_profile);
|
||||
if($stem_profile != "blank") connectors();
|
||||
if(!$inset_text) keytext();
|
||||
clearance_check();
|
||||
top_of_key() {
|
||||
@ -298,6 +305,7 @@ module example_key(){
|
||||
$corner_radius = corner_radius;
|
||||
$height_slices = height_slices;
|
||||
$enable_side_sculpting = enable_side_sculpting;
|
||||
$slop = slop;
|
||||
|
||||
key();
|
||||
}
|
||||
|
17
keys.scad
17
keys.scad
@ -6,6 +6,7 @@
|
||||
// special variables, but that's a limitation of SCAD we have to work around
|
||||
|
||||
/* TODO:
|
||||
* add keys.scad function for fudge factor in stem
|
||||
* pull out side sculpting options to let people tweak them?
|
||||
* can now measure keycaps very accurately. need to redo measurements: [x] SA [ ] DCS [X] DSA [X] OEM?
|
||||
* Add inset stem to all profiles that need it. [x] OEM [ ] DCS?
|
||||
@ -43,6 +44,7 @@ $text = "";
|
||||
$inset_text = false;
|
||||
$corner_radius = 1;
|
||||
$height_slices = 1;
|
||||
$slop = 0.3;
|
||||
|
||||
// key profile definitions
|
||||
|
||||
@ -392,17 +394,20 @@ module blank() {
|
||||
children();
|
||||
}
|
||||
|
||||
module cherry() {
|
||||
module cherry(slop = 0.3) {
|
||||
$slop = slop;
|
||||
$stem_profile = "cherry";
|
||||
children();
|
||||
}
|
||||
|
||||
module alps() {
|
||||
module alps(slop = 0.3) {
|
||||
$slop = slop;
|
||||
$stem_profile = "alps";
|
||||
children();
|
||||
}
|
||||
|
||||
module rounded_cherry() {
|
||||
module rounded_cherry(slop = 0.3) {
|
||||
$slop = slop;
|
||||
$stem_profile = "cherry_rounded";
|
||||
children();
|
||||
}
|
||||
@ -413,8 +418,4 @@ module legend(text, inset=false) {
|
||||
children();
|
||||
}
|
||||
|
||||
rows = [4,3,2,1,5];
|
||||
|
||||
|
||||
translate_u(0, 0) dcs_row(1) cherry() key() {
|
||||
};
|
||||
translate_u(0, 0) oem_row(1) cherry() key();
|
||||
|
21
stems.scad
21
stems.scad
@ -11,7 +11,9 @@ module brim(has_brim) {
|
||||
if (has_brim) color([0,1,0]) cube([brim_radius, brim_radius, brim_depth]);
|
||||
}
|
||||
|
||||
module cherry_stem(has_brim, slop = 0.3) {
|
||||
module cherry_stem(has_brim, slop) {
|
||||
|
||||
echo(slop);
|
||||
|
||||
stem_width = 7.2 - slop * 2;
|
||||
stem_height = 5.5 - slop * 2;
|
||||
@ -48,12 +50,12 @@ module cherry_stem(has_brim, slop = 0.3) {
|
||||
}
|
||||
}
|
||||
|
||||
module cherry_stem_rounded(has_brim) {
|
||||
module cherry_stem_rounded(has_brim, slop) {
|
||||
// cross length
|
||||
cross_length = 4.4;
|
||||
//dimensions of connector
|
||||
// outer cross extra length in y
|
||||
extra_outer_cross_height = 1.0;
|
||||
extra_outer_cross_height = 1.1;
|
||||
// dimensions of cross
|
||||
// horizontal cross bar width
|
||||
horizontal_cross_width = 1.4;
|
||||
@ -78,7 +80,7 @@ module cherry_stem_rounded(has_brim) {
|
||||
}
|
||||
}
|
||||
|
||||
module alps_stem(has_brim = false){
|
||||
module alps_stem(has_brim, slop){
|
||||
cross_depth = 40;
|
||||
width = 4.45;
|
||||
height = 2.25;
|
||||
@ -92,7 +94,7 @@ module alps_stem(has_brim = false){
|
||||
}
|
||||
}
|
||||
|
||||
module filled_stem(has_brim=false) {
|
||||
module filled_stem() {
|
||||
// this is mostly for testing. we don't pass the size of the keycp in here
|
||||
// so we can't make this work for all keys
|
||||
cube(100, center=true);
|
||||
@ -100,13 +102,14 @@ module filled_stem(has_brim=false) {
|
||||
|
||||
|
||||
//whole connector, alps or cherry, trimmed to fit
|
||||
module connector(stem_profile, has_brim){
|
||||
module connector(stem_profile, has_brim, slop){
|
||||
echo(slop);
|
||||
if (stem_profile == "alps") {
|
||||
alps_stem(has_brim);
|
||||
alps_stem(has_brim, slop);
|
||||
} else if (stem_profile == "cherry_rounded") {
|
||||
cherry_stem_rounded(has_brim);
|
||||
cherry_stem_rounded(has_brim, slop);
|
||||
} else if (stem_profile == "cherry") {
|
||||
cherry_stem(has_brim);
|
||||
cherry_stem(has_brim, slop);
|
||||
} else if (stem_profile == "filled") {
|
||||
filled_stem();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user