// ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_xadrez = texture{ pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > } finish{ diffuse 0.9 ambient 0.1 } scale 2.0 } // ====================================================================== // DESCRIÇÃO DA CENA // Partes da cena: #macro abaco (m,n, valores, prob) #local moldura = difference{ object{ box{ <0,0,0>, <0.2,n+0.4,m+0.4> texture{ pigment{ color rgb <1,0.8,0> }}}} object{ box{ <-0.1,0.2,0.2>, <0.3,n+0.2,m+0.2> }}}; union{ object { moldura } #local i = 0; #while (i < m) object { fileira(n,valores[i],prob) translate <0,0,i+0.15> } #local i = i+1; #end } #end #declare roleta = seed(417); #macro fileira (n, valor, prob) #local i = n-1; union{ object{ divisoria(n) } object{ divisoria(n) translate <0,0,0.6> } #local q = valor; #while (i >= 0) object{ cilindro translate <0.1,1*i+0.7,0.2>} #if (rand(roleta) < prob) #local defeito = 1; #else #local defeito = 0; #end bit(mod(q,2),defeito) #local q = int(q/2); #local i = i-1; #end } #end #macro bit (valor, defeito) #if (defeito = 0) #if (valor = 0) object { bola translate <0.1,1*i+0.7,0.35> } #end #if (valor = 1) object { bola translate <0.1,1*i+0.7,0.65> } #end #end #end #macro divisoria (n) object{ box { <0,0.2,0.2>, <0.2,n+0.2,0.25> texture{ pigment{ color rgb <1,0.8,0> }}}} #end #declare cilindro = object { cylinder{ <0,0,0>, <0,0,0.6>, 0.1 } texture{ pigment{ color rgb <1,0.8,0> }}} #declare bola = sphere {<0,0,0> 0.15 texture{ pigment{ color rgb <1,1,1>}}} #declare chao = box{ <-20,-20,-1>, <+20,+20,0> } #include "eixos.inc" // Aqui está a cena, finalmente: #declare m = 5; #declare n = 7; #declare valores = array[5] {15,5,6,7,8} union{ object{ eixos(3.00) } object{ chao translate < 0,0,-5 > texture{ tx_xadrez } } object{ abaco(m,n,valores,0.1) } } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 1.00 >; #declare raio_cena = 10.0; #declare dir_camera = < 1, 0, 0 >; #declare dist_camera = 10.0; #declare intens_luz = 1; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)