// Last edited on 2019-11-22 00:40:40 by jstolfi #macro painted_box(bdim, xlop,xhip, ylop,yhip, zlop,zhip, tx0, tx1) // A box that is painted {tx0} some sides and {tx1} on others. // The origin is at the back left bottom corner of the nominal dimensions. // {bdim} is the nominal dimensions of the box. // {xlop,ylop,zlop} are booleans that say how the low X,Y,Z sides are painted. // {xhip,yhip,zhip} are booleans that say how the high X,Y,Z sides are painted. // In each case, if the boolean is false (0) the side is painted with {tx0}; // if it is true (1) it is paiinted with {tx1} #local eps = 0.001; // Perturbation to avoid coincident surfaces. #local eps3 = < eps, eps, eps >; #local tad = 1.0; // Perturbation to scrape away the paint. // Corners of the painted box: #local lo1 = < 0, 0, 0 > - tad * < 1-xlop, 1-ylop, 1-zlop >; #local hi1 = bdim + tad * < 1-xhip, 1-yhip, 1-zhip >; // Corners of the bare wood box: #local lo0 = < 0, 0, 0 > - tad * < xlop, ylop, zlop >; #local hi0 = bdim + tad * < xhip, yhip, zhip >; #local pbox = intersection{ box{ lo1 + eps3, hi1 - eps3 texture{ tx1 } } box{ lo0 + eps3, hi0 - eps3 texture{ tx0 } } } object{ pbox } #end