Advertisement
KeithFromCanada

Game Piece (OpenSCAD)

Aug 17th, 2022
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.52 KB | Gaming | 0 0
  1. //--------------------------------
  2. // Game Piece
  3. // Keith Olson
  4. // CC 2020
  5. // OpenSCAD
  6. //--------------------------------
  7.  
  8. // OpenSCAD uses millimeters (mm) for units.
  9. // Distance functions are both for conversion and to state plainly that a number is a
  10. //    measurement, not just a value.
  11. // Fractions are interpreted as formulas: '1 3/4' = '1+3/4' = 1.75
  12. function mm(x = 1) = x;
  13. function cm(x = 1) = x * 10;
  14. function inches(x = 1) = x * 25.40000;  
  15. function feet(x = 1) = x * 25.40000 * 12;  
  16.  
  17. $fn=120; // (Circles are divided in $fn line segments.)
  18.  
  19. height    = mm(25.40); // inches( 1   );
  20. head_dia  = mm( 6.40); // inches( 1/ 4);
  21. neck_dia  = mm( 3.40); // inches( 5/32);
  22. neck_len  = mm(15.80); // inches( 5/ 8);
  23. neck_top  = mm(19.52); // inches( 3/ 4);
  24. shldr_dia = mm( 7.60); // inches( 1/ 4);
  25. base_dia  = mm(15.80); // inches( 5/ 8);
  26. base_ht   = mm( 3.80); // inches( 5/32);
  27. edge_rad  = mm( 1.00); // inches( 1/16);
  28.  
  29. head_pos = height - head_dia/2;
  30.  
  31. shoulder_rad_pos = ((shldr_dia - neck_dia) * edge_rad) / neck_len;
  32. echo(inches(1/16));
  33. echo(neck_len);
  34. echo(shoulder_rad_pos,edge_rad);
  35. game_piece();
  36.    
  37. module game_piece(piece_style = "std", scale = 1/1)
  38. {
  39.     rotate_extrude()
  40.     union()
  41.     {
  42.         difference()
  43.         {
  44.             union()
  45.             {
  46.                 polygon([[  0,            0],
  47.                          [  base_dia/2,   0],
  48.                          [  base_dia/2,   base_ht],
  49.                          [  shldr_dia/2,  base_ht],
  50.                          [  neck_dia/2,   neck_top],
  51.                          [  0,            neck_top]]);
  52.        
  53.                 translate([0, head_pos, 0])// color("green")
  54.                     circle(d = head_dia);
  55.                
  56.                 translate([shldr_dia/2,  base_ht, 0])// color("yellow")
  57.                     square(edge_rad * 2 - shoulder_rad_pos, center = true);
  58.             }
  59.             union()
  60.             {
  61.                 translate([-base_dia, -height, 0])
  62.                 square([base_dia, height * 2]);
  63.                
  64.             translate([base_dia/2 - edge_rad, base_ht - edge_rad, 0]) // 1.5]) color("blue")
  65.                 square(edge_rad+5);
  66.            
  67.             translate([shldr_dia/2 + edge_rad - shoulder_rad_pos/2 + 0.01,  base_ht + edge_rad, 0]) // 0.5]) color("blue",0.5)
  68.                 circle(edge_rad);
  69.             }
  70.            
  71.         }  
  72.         translate([base_dia/2 - edge_rad, base_ht - edge_rad, 0]) // 0.5]) color("orange")
  73.             circle(edge_rad);
  74.     }    
  75.        
  76. }
  77. //*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement