mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2025-09-15 00:29:52 +00:00
hull_shape_type
This commit is contained in:
parent
c7168eae68
commit
8b4b9ae687
8 changed files with 75 additions and 112 deletions
|
@ -8,9 +8,9 @@ include <hulls/hull.scad>
|
|||
// extra_slices is a hack to make inverted dishes still work
|
||||
module shape_hull(thickness_difference, depth_difference, extra_slices = 0){
|
||||
render() {
|
||||
if ($skin_extrude_shape) {
|
||||
if ($hull_shape_type == "skin") {
|
||||
skin_extrude_shape_hull(thickness_difference, depth_difference, extra_slices);
|
||||
} else if ($linear_extrude_shape) {
|
||||
} else if ($hull_shape_type == "linear extrude") {
|
||||
linear_extrude_shape_hull(thickness_difference, depth_difference, extra_slices);
|
||||
} else {
|
||||
hull_shape_hull(thickness_difference, depth_difference, extra_slices);
|
||||
|
|
72
src/key.scad
72
src/key.scad
|
@ -29,9 +29,7 @@ module shape(thickness_difference, depth_difference=0){
|
|||
}
|
||||
}
|
||||
|
||||
// this function is more correct, but takes _forever_
|
||||
// the main difference is minkowski happens after dishing, meaning the dish is
|
||||
// also minkowski'd
|
||||
// Not currently used due to CGAL errors. Rounds the shape via minkowski
|
||||
module rounded_shape() {
|
||||
color($primary_color) minkowski(){
|
||||
// half minkowski in the z direction
|
||||
|
@ -54,7 +52,6 @@ module minkowski_object() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
module envelope(depth_difference=0) {
|
||||
s = 1.5;
|
||||
hull(){
|
||||
|
@ -87,19 +84,6 @@ module _dish(inverted=$inverted_dish) {
|
|||
color($secondary_color) dish(top_total_key_width() + $dish_overdraw_width, top_total_key_height() + $dish_overdraw_height, $dish_depth, inverted);
|
||||
}
|
||||
|
||||
// puts its children at the center of the dishing on the key, including dish height
|
||||
// more user-friendly than top_placement
|
||||
module top_of_key(){
|
||||
// if there is a dish, we need to account for how much it digs into the top
|
||||
dish_depth = ($dish_type == "disable") ? 0 : $dish_depth;
|
||||
// if the dish is inverted, we need to account for that too. in this case we do half, otherwise the children would be floating on top of the dish
|
||||
corrected_dish_depth = ($inverted_dish) ? -dish_depth / 2 : dish_depth;
|
||||
|
||||
top_placement(corrected_dish_depth) {
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
// puts its children at each keystem position provided
|
||||
module keystem_positions(positions) {
|
||||
for (connector_pos = positions) {
|
||||
|
@ -140,6 +124,19 @@ module top_placement(depth_difference=0) {
|
|||
}
|
||||
}
|
||||
|
||||
// puts its children at the center of the dishing on the key, including dish height
|
||||
// more user-friendly than top_placement
|
||||
module top_of_key(){
|
||||
// if there is a dish, we need to account for how much it digs into the top
|
||||
dish_depth = ($dish_type == "disable") ? 0 : $dish_depth;
|
||||
// if the dish is inverted, we need to account for that too. in this case we do half, otherwise the children would be floating on top of the dish
|
||||
corrected_dish_depth = ($inverted_dish) ? -dish_depth / 2 : dish_depth;
|
||||
|
||||
top_placement(corrected_dish_depth) {
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
module front_of_key() {
|
||||
// all this math is to take top skew and tilt into account
|
||||
// we need to find the new effective height and depth of the top, front lip
|
||||
|
@ -164,14 +161,12 @@ module outer_shape() {
|
|||
}
|
||||
|
||||
module inner_shape(extra_wall_thickness = 0, extra_keytop_thickness = 0) {
|
||||
translate([0,0,-SMALLEST_POSSIBLE]) {
|
||||
if ($inner_shape_type == "flat") {
|
||||
/* $key_shape_type="square"; */
|
||||
$height_slices = 1;
|
||||
color($primary_color) shape_hull($wall_thickness + extra_wall_thickness, $keytop_thickness + extra_keytop_thickness, 0);
|
||||
} else {
|
||||
shape($wall_thickness + extra_wall_thickness, $keytop_thickness + extra_keytop_thickness);
|
||||
}
|
||||
if ($inner_shape_type == "flat") {
|
||||
/* $key_shape_type="square"; */
|
||||
$height_slices = 1;
|
||||
color($primary_color) shape_hull($wall_thickness + extra_wall_thickness, $keytop_thickness + extra_keytop_thickness, 0);
|
||||
} else {
|
||||
shape($wall_thickness + extra_wall_thickness, $keytop_thickness + extra_keytop_thickness);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,15 +192,11 @@ module subtractive_features(inset) {
|
|||
if ($clearance_check) %clearance_check();
|
||||
}
|
||||
|
||||
// features inside the key itself (stem, supports, etc)
|
||||
module inside_features() {
|
||||
translate([0, 0, $stem_inset]) {
|
||||
// both stem and support are optional
|
||||
if ($stabilizer_type != "disable") stems_for($stabilizers, $stabilizer_type);
|
||||
if ($stem_type != "disable") stems_for($stem_positions, $stem_type);
|
||||
if ($stabilizer_type != "disable") support_for($stabilizers, $stabilizer_type);
|
||||
// always render stem support even if there isn't a stem.
|
||||
// rendering flat support w/no stem is much more common than a hollow keycap
|
||||
// so if you want a hollow keycap you'll have to turn support off entirely
|
||||
if ($support_type != "disable") support_for($stem_positions, $stem_type);
|
||||
}
|
||||
}
|
||||
|
@ -221,9 +212,13 @@ module key(inset=false) {
|
|||
};
|
||||
}
|
||||
|
||||
if ($inner_shape_type != "disable") difference() {
|
||||
inner_shape();
|
||||
inside_features();
|
||||
if ($inner_shape_type != "disable") {
|
||||
translate([0,0,-SMALLEST_POSSIBLE]) {
|
||||
difference() {
|
||||
inner_shape();
|
||||
inside_features();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subtractive_features(inset) {
|
||||
|
@ -232,17 +227,6 @@ module key(inset=false) {
|
|||
}
|
||||
}
|
||||
|
||||
module display_key(inset=false) {
|
||||
minkowski() {
|
||||
outer_shape();
|
||||
minkowski_object();
|
||||
// minkowski doesn't work with difference
|
||||
additive_features(false) {
|
||||
children();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// actual full key with space carved out and keystem/stabilizer connectors
|
||||
// this is an example key with all the fixins from settings.scad
|
||||
module example_key(){
|
||||
|
|
|
@ -11,7 +11,7 @@ module grid_row(row=3, column = 0) {
|
|||
$dish_skew_x = 0;
|
||||
$dish_skew_y = 0;
|
||||
|
||||
$linear_extrude_shape = true;
|
||||
$hull_shape_type = "linear extrude";
|
||||
|
||||
|
||||
$dish_overdraw_width = -8;
|
||||
|
|
|
@ -46,7 +46,7 @@ module iso_enter() {
|
|||
$top_tilt = 0;
|
||||
$stem_support_type = "disable";
|
||||
$key_shape_type = "iso_enter";
|
||||
/* $linear_extrude_shape = true; */
|
||||
/* $hull_shape_type = "linear extrude"; */
|
||||
$linear_extrude_height_adjustment = 19.05 * 0.5;
|
||||
// this equals (unit_length(1.5) - unit_length(1.25)) / 2
|
||||
$dish_overdraw_width = 2.38125;
|
||||
|
|
|
@ -118,12 +118,10 @@ $font="DejaVu Sans Mono:style=Book";
|
|||
// Whether or not to render fake keyswitches to check clearances
|
||||
$clearance_check = false;
|
||||
// Should be faster, also required for concave shapes
|
||||
// Use linear_extrude instead of hull slices to make the shape of the key
|
||||
$linear_extrude_shape = false;
|
||||
|
||||
// warns in trajectory.scad but it looks benign
|
||||
// brand new, more correct, hopefully faster, lots more work
|
||||
$skin_extrude_shape = false;
|
||||
// what kind of extrusion we use to create the keycap. "hull" is standard, "linear extrude" is legacy, "skin" is new and not well supported.
|
||||
$hull_shape_type = "hull"; // ["hull", "linear extrude", "skin"]
|
||||
|
||||
// This doesn't work very well, but you can try
|
||||
$rounded_key = false;
|
||||
//minkowski radius. radius of sphere used in minkowski sum for minkowski_key function. 1.75 for G20
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue