front.scad 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. include <ATX.scad>
  2. include <functions.scad>
  3. include <angle.scad>
  4. include <addon.scad>
  5. include <switch.scad>
  6. include <../config/global.scad>
  7. include <../config/front.scad>
  8. function front_size() = [
  9. front_motherboard_size.x + front_padding * 2,
  10. front_height + front_padding * 2
  11. ];
  12. module front_shape() {
  13. padding = front_padding;
  14. rounding = front_rounding;
  15. size = front_size();
  16. width = size.x;
  17. height = size.y;
  18. module corner(vector) {
  19. translate(vector) {
  20. circle(r = rounding);
  21. }
  22. }
  23. module base_shape() {
  24. hull() {
  25. for (count = square_vector(width, height, rounding)) {
  26. corner(count);
  27. }
  28. }
  29. }
  30. module mounting_cutoff() {
  31. move_y
  32. = height / 2
  33. - angle_depth / 2
  34. + plywood_thickness / 2;
  35. move_x
  36. = width / 2
  37. - angle_depth / 2
  38. + plywood_thickness / 2;
  39. module right_cutoff() {
  40. translate([move_x, 0]) {
  41. rotate(90) {
  42. angle_cutoff();
  43. }
  44. }
  45. }
  46. translate([0, move_y]) {
  47. angle_cutoff();
  48. }
  49. right_cutoff();
  50. mirror([1, 0]) {
  51. right_cutoff();
  52. }
  53. }
  54. module switch_move_cutoff() {
  55. move_x
  56. = width / 2
  57. - switch_size().x / 2
  58. - angle_depth
  59. + plywood_thickness / 2
  60. - front_switch_margin.x;
  61. move_y
  62. = height / 2
  63. - switch_size().y / 2
  64. - angle_depth
  65. + plywood_thickness / 2
  66. - front_switch_margin.y;
  67. translate([move_x, move_y]) {
  68. switch_cutoff();
  69. }
  70. }
  71. module addon_move_cutoff() {
  72. move_x
  73. = -width / 2
  74. + addon_size().x / 2
  75. + angle_depth
  76. + front_addon_margin.x;
  77. move_y
  78. = -height / 2
  79. + addon_size().y / 2
  80. + front_addon_margin.y;
  81. translate([move_x, move_y]) {
  82. addon_cutoff();
  83. }
  84. }
  85. difference() {
  86. base_shape();
  87. mounting_cutoff();
  88. switch_move_cutoff();
  89. if (front_addon) {
  90. addon_move_cutoff();
  91. }
  92. }
  93. }
  94. module front_object() {
  95. height = plywood_thickness;
  96. color("#AAEEFF") {
  97. render() {
  98. linear_extrude(height = height, center = true) {
  99. front_shape();
  100. }
  101. }
  102. }
  103. }