// Test tube macro. February 2000, Paul Daniel Jones // This macro is for the generation of an array of testtubes, // each filled with a liquid at various heights. // This macro needs a few variables, liquid_color, liquid_height // and dotest. #macro test_tubes( liquid_height, dotest,row,col) #declare l1=seed(45681); #declare empty_tube= difference{ merge { sphere {<0,1,0> 1.0} cylinder {<0,1,0> <0,15,0> 1.0} torus {1.0,0.15 translate <0,14.9,0>} } merge { sphere {<0,1,0>0.96} cylinder {<0,1,0> <0,16,0> 0.96} }} #declare liquid= merge { sphere {<0,1,0> 0.989999999990} cylinder {<0,1,0> <0,liquid_height*rand(l1),0> 0.959999999990} } #declare hole = union { sphere {<0,1,0>1.1} cylinder {<0,1,0><0,5,0> 1.1} torus {1.1,.2 translate <0,3,0>}} #declare wooden_rack = difference{ superellipsoid {<0.1, 0.1> scale translate <0,2,0> } #declare counter=0; #while (counter } #declare counter2=counter2+1 ; #end #declare counter=counter+1; #end} union{ object { wooden_rack texture{ T_Wood5 rotate <45,45,45> scale 6} normal{dents 6 scale 2}} #declare counter3=0; #while (counter3 } finish {phong 1}} #else texture{ pigment {color rgbt<1,1,1,1>} finish {ambient 0 diffuse 0.4 reflection 0.05 phong 0.9 phong_size 100}} interior {ior 1.6 fade_distance 1 fade_power 4 caustics 4} #end } object { #if (dotest=on) merge { sphere {<0,1,0> 0.989999999990} cylinder {<0,1,0> <0,liquid_height+rand(l1),0> 0.959999999990}} texture {pigment {color rgbf <.9,rand(l1),1-rand(l1),1>} finish {phong 1}} #else merge { sphere {<0,1,0> 0.989999999990} cylinder {<0,1,0> <0,liquid_height*rand(l1),0> 0.959999999990}} texture{ pigment {color rgbf } finish {ambient 0.1 diffuse 0.6 reflection 0.1 phong 0.9 phong_size 100}} interior {ior 1.33 caustics 4} #end } translate <(col*1.7)-3*counter4-2,0,(row*1.7)-3*counter3-2 >} #declare counter4=counter4+1 ; #end #declare counter3=counter3+1; #end } #end