// Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2010-03-04 15:44:01 by stolfi // ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_plastico = texture{ pigment{ color rgb < 0.10, 0.80, 1.00 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_fosca = texture{ pigment{ color rgb < 1.00, 0.80, 0.10 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_espelho = texture{ pigment{ color rgb < 1.00, 0.85, 0.30 > } finish{ diffuse 0.2 reflection 0.7*< 1.00, 0.85, 0.30 > ambient 0.1 } } #declare tx_vidro = texture{ pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 } finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 } } #declare tx_head = texture{ pigment{ color rgb < 0.90, 0.15, 0.10 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_red = texture{ pigment{ color rgb < 1, 0, 0 > filter 0.70 } finish{ diffuse 0.8 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 } } #declare tx_blue = texture{ pigment{ color rgb < 0.30, 0.5, 0.90 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_brown = texture{ pigment{ color rgb < 0.55, 0.15, 0.45 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_yellow = texture{ pigment{ color rgb < 1, 1, 0 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_green = texture{ pigment{ color rgb < 0.30, 0.9, 0.20 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #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 } #macro bit (valor,defeito) #local pos = 1.2 + 2.6*valor; union { cylinder { <0,0,0>, <0,0,5> 0.2 texture {tx_head} } difference { sphere {<0,0,pos>, 1 texture {tx_yellow}} cylinder { <0,0,0>, <0,0,5> 0.25} #if (defeito) sphere {<0,0,pos>, 1 texture {tx_yellow} translate <0,0.7,0.3>} #end } } #end #macro quadro(n) difference { box {<-1,-2,0>,<1,n*2,5> texture {tx_blue} } box {<-1.1,-1.8,0.1>,<1.1,n*2-0.2,4.9> } } #end #declare roleta = seed (417); #macro defeito(prob) #if (rand(roleta) < prob) #local retorno = 1; #else #local retorno = 0; #end retorno #end #macro fileira(n,valor,prob) union { object {quadro(n)} #local r = int(valor); #local f = valor - r; #local k = 0; #while (k < n) #local vu = mod(r,2); #if (vu=0) #local bitk = f; #local f = 0; #else #local bitk= 1-f; #end #local r = int(r/2); #local k = k+1; object { bit(bitk,defeito(prob)) translate<0,(n-k)*2,0> } #end } #end //m fileiras //n tamanho #macro abaco(m,n,inicial,final,prob) union { difference { box {<-1,-3,-1>,<1,n*2+1,5*m+1> texture {tx_blue}} box {<-1.1,-1.8,0.1>,<1.1,n*2-0.2,5*m-0.1>} } #local i = 0; #while (i < m) object{fileira(n,(1-clock)*inicial[i]+clock*final[i],prob) translate<0,0,5*i>} #local i = i +1; #end } #end // Aqui está a cena, finalmente: #include "eixos.inc" union{ object{ eixos(3.00) } //object{ bit(1)} //object{ bit(0) translate <0,2,0>} //object {fileira(7,12)} #declare m = 7; #declare valores = array[m]; #declare valores[0] = 27; #declare valores[1] = 3; #declare valores[2] = 0; #declare valores[3] = 7; #declare valores[4] = 37; #declare valores[5] = 40; #declare valores[6] = 26; #declare final = array[m]; #declare final[0] = 28; #declare final[1] = 4; #declare final[2] = 1; #declare final[3] = 8; #declare final[4] = 38; #declare final[5] = 41; #declare final[6] = 27; object {abaco (m,6,valores,final,0.5) translate <-10,5,-5*m/2>} #declare m2 = 10; #declare valores2 = array[m2]; #declare valores2[0] = 150; #declare valores2[1] = 225; #declare valores2[2] = 511; #declare valores2[3] = 0; #declare valores2[4] = 327; #declare valores2[5] = 418; #declare valores2[6] = 92; #declare valores2[7] = 13; #declare valores2[8] = 450; #declare valores2[9] = 199; // object {abaco (m2,9,valores2,0.5) translate <-10,-30,-5*m2/2> } } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 0.00 >; #declare raio_cena = 40.0; #declare dir_camera = < 2*sin((pi/2)*clock), 2.00*cos((pi/2)*clock), 0.00 >; #declare dist_camera = 45.0; #declare intens_luz = 1.00; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)