Glasses for the Masses by @creativethumbs is a fully customizable pair of glasses made with OpenScad.
Essentially it’s a program that allows the user to specify the parameters of a pair of glasses–such as height, width, roundness, and lens tint–and creates a model of the pair of glasses with the desired specifications. I would like to think that people find this project beautiful and useful.
This project was not inspired by anything in particular; it was more of a personal experiment because I am incredibly picky about the things I wear / what I put on my body. Because of that, when I have to go shopping for articles such as glasses I often leave the store empty-handed because I am not satisfied with their selections. Sometimes I would feel that an aspect of a certain design fits better with that of another, but there is no design that meets my expectations. Alternatively, I would find a pair of glasses that look exactly the way I want them to, but end up not fitting well. I was hoping to use this program as a way to address this conflict between consumer desires and product availability, and I also was interested in creating something that was practical as well as aesthetic. The program works mostly the way I wanted it to–it has a lot of variables that the user can change and the glasses actually look like glasses. While changing the parameters in the code can give very varied and interesting results, the program still has a fair share of errors (such as scaling issues and proportions) that I would need to fix if I wanted to put it to use. With regard to that, I would have to add details, such as leg joints, to the model if it needed to be used as reference for an actual physical object.
One of the many challenges of this project was getting the lens to scale properly when the ’roundedness’ value changed. Because the square lens are constructed using a minkowski transformation, greater ’roundedness’ values mean larger cylinders are being wrapped around the quadrangle–which means the lens after the transformation will become larger than the rectangle they were formed by. Even after hours of scratching my head, I was not able to derive a mathematical relationship between the size of the lens before and after the minkowski transformation–I ended up using an arbitrary inverse-square-root equation that seemed to work well for smaller inputs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | /* Parametric glasses by Ticha Sethapakdi */ //----USER DEFINED VARIABLES----- //the style of the glasses can either be 'squared' or 'oval' frame = "oval"; //value from 1-6; can technically be larger, but some parts may look awkward... roundedness = 6; //1 for regular glasses; 2 for sunglasses style = 2; width = 10; height = 5; length = 14; //for "oval" mode only: radius = 7; //see the SVG color list (http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#color) //for all possible color selections //e.g. Crimson, Coral, Fuchsia, Chocolate, Navy... frame_color = "Crimson"; //if the style is "sunglasses", the user may customize the color of the lens //again, consult the SVG color list for a range of selections lens_color = "Aqua"; //------------------------------- /* The glasses are created here */ eyegap = 5; if(frame == "squared") { rotate([90,0,0]) { translate([sqrt(roundedness), -sqrt(roundedness), 0]){ scale([1/sqrt(roundedness), 1/sqrt(roundedness), 0.5]){ translate([width/2+eyegap/2-1.5/roundedness, 0,0]) { //draws one side of the frame color(frame_color) { difference() { minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); } translate([0,-0.8,0]){ scale([0.8,0.8,2]){ minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); }}} } } //draws the lens if(style == 2) { color(lens_color, 0.7) { translate([0,-0.8,0]){ scale([0.8,0.8,0.5]){ minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); }}} } } else { color("white", 0.4) { translate([0,-0.8,0]){ scale([0.8,0.8,0.5]){ minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); }}} } } //leg color(frame_color) { hull() { translate([width/2 + roundedness, (height/2)*0.6-2,-1.5]){ cube([1, 2.5, 5], center = true); } translate([width/2 + roundedness, (height/2)*0.6-2,-23.5]){ cube([1, 1.5, 3], center = true); } } hull() { translate([width/2 + roundedness, (height/2)*0.6-2,-24.5]){ cube([1, 1.5, 1.5], center = true); } translate([width/2 + roundedness, (height/2)*0.6-5,-32.5]){ cube([1, 1.5, 1.5], center = true); } } } }}} //bridge color(frame_color) { hull() { translate([0.25, -1.8, 0.25]){ cube([0.5, 1, 1], center = true); } translate([eyegap/3, -1.8, 0.25]){ cube([0.2, 1.5, 1], center = true); } } } } mirror([1,0,0]) {rotate([90,0,0]) { translate([sqrt(roundedness), -sqrt(roundedness), 0]){ scale([1/sqrt(roundedness), 1/sqrt(roundedness), 0.5]){ translate([width/2+eyegap/2-1.5/roundedness, 0,0]) { //draws one side of the frame color(frame_color) { difference() { minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); } translate([0,-0.8,0]){ scale([0.8,0.8,2]){ minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); }}} } } //draws the lens if(style == 2) { color(lens_color, 0.7) { translate([0,-0.8,0]){ scale([0.8,0.8,0.5]){ minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); }}} } } else { color("white", 0.4) { translate([0,-0.8,0]){ scale([0.8,0.8,0.5]){ minkowski() { hull() { cube([width, 1, 1], center = true); translate([0,-height+1,0]){cube([3*width/4, 3*height/4, 1], center = true);} } cylinder(r=roundedness, h=1); }}} } } //leg color(frame_color) { hull() { translate([width/2 + roundedness, (height/2)*0.6-2,-1.5]){ cube([1, 2.5, 5], center = true); } translate([width/2 + roundedness, (height/2)*0.6-2,-23.5]){ cube([1, 1.5, 3], center = true); } } hull() { translate([width/2 + roundedness, (height/2)*0.6-2,-24.5]){ cube([1, 1.5, 1.5], center = true); } translate([width/2 + roundedness, (height/2)*0.6-5,-32.5]){ cube([1, 1.5, 1.5], center = true); } } } }}} //bridge color(frame_color) { hull() { translate([0.25, -1.8, 0.25]){ cube([0.5, 1, 1], center = true); } translate([eyegap/3, -1.8, 0.25]){ cube([0.2, 1.5, 1], center = true); } } } }} } //ROUNDED FRAME else if (frame == "oval") { rotate([90,0,0]) { translate([6.5*radius/8+eyegap/2, 0,0]) { //draws one side of the frame color(frame_color) { difference() { cylinder(1,radius,radius, center = true); scale([0.8,0.8,2]){ cylinder(1,radius,radius, center = true); } } } //draws the lens if(style == 2) { color(lens_color, 0.7) { scale([0.8,0.8,0.5]){ cylinder(1,radius,radius, center = true); } } } else { color("white", 0.4) { scale([0.8,0.8,0.5]){ cylinder(1,radius,radius, center = true); } } } //leg color(frame_color) { hull() { translate([radius, 0, -2]){ cube([1, 2.5, 5], center = true); } translate([radius, 0,-23.5]){ cube([1, 1.5, 3], center = true); } } hull() { translate([radius, 0 ,-24.5]){ cube([1, 1.5, 1.5], center = true); } translate([radius, -2,-32.5]){ cube([1, 1.5, 1.5], center = true); } } } } //bridge color(frame_color) { hull() { translate([0.25, 1.5, 0]){ cube([0.5, 1, 1], center = true); } translate([eyegap/3, 1.5, 0]){ cube([0.2, 1.5, 1], center = true); } } } } mirror([1,0,0]) {rotate([90,0,0]) { translate([6.5*radius/8+eyegap/2, 0,0]) { //draws one side of the frame color(frame_color) { difference() { cylinder(1,radius,radius, center = true); scale([0.8,0.8,2]){ cylinder(1,radius,radius, center = true); } } } //draws the lens if(style == 2) { color(lens_color, 0.7) { scale([0.8,0.8,0.5]){ cylinder(1,radius,radius, center = true); } } } else { color("white", 0.4) { scale([0.8,0.8,0.5]){ cylinder(1,radius,radius, center = true); } } } //leg color(frame_color) { hull() { translate([radius, 0, -2]){ cube([1, 2.5, 5], center = true); } translate([radius, 0,-23.5]){ cube([1, 1.5, 3], center = true); } } hull() { translate([radius, 0 ,-24.5]){ cube([1, 1.5, 1.5], center = true); } translate([radius, -2,-32.5]){ cube([1, 1.5, 1.5], center = true); } } } } //bridge color(frame_color) { hull() { translate([0.25, 1.5, 0]){ cube([0.5, 1, 1], center = true); } translate([eyegap/3, 1.5, 0]){ cube([0.2, 1.5, 1], center = true); } } } }} } else { echo("Undefined frame style!"); } |