// ====================================================================== // CORES E TEXTURAS #include "textures.inc" #include "debug.inc" 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 1.0 } // ====================================================================== // DESCRIÇÃO DA CENA #declare tam_bit =<2,1,2>; #declare tam_borda = 0.3; #declare random_seed = seed (1153); #macro random() rand(random_seed) #end #macro make_bit(frac, errado) cylinder { < 0, 0, 0> 0.1*tam_bit.y texture { Chrome_Metal } } #if ( errado ) #local frac = (1-frac)*0.8 + 0.1; #end sphere { <(.25+0.5*frac)*tam_bit.x,0,0> 0.45*tam_bit.y #if ( errado ) texture { Rusty_Iron } #else texture { Jade } #end } #end #macro make_col(nrows, number, prob_erro_bit) #local row=0; #local _number=int(number); #local frac = number - _number; #while (row } #local _number=int(_number/2); #local row=row+1; #end #end #macro make_cols(ncols, nrows, numbers, prob_erro_bit) #local col=0; #while (col } #local col=col+1; #end #end #macro abaco(numbers, prob_defeito_bit) #local ncols = dimension_size(numbers, 1); #local maxNum=0; #local i=0; #while (i 0) #local nrows=nrows+1; #local maxNum=int(maxNum/2); #end #local largura_total = ncols *tam_bit.x + (ncols+1)*tam_borda; #local altura_total = nrows*tam_bit.y + 2*tam_borda; union { //Ábaco //Cria a borda, com os "furos" em cada fileira =================================== difference { //Caixa principal box { < 0, 0, -tam_bit.z/2> texture { Cherry_Wood } } //Buracos #local col=0; #while (col texture { Cherry_Wood } translate } #local col=col+1; #end } //Cria as bolinhas =================================== union { make_cols( ncols, nrows, numbers, prob_defeito_bit ) translate } translate <-largura_total/2, -altura_total/2, 0> scale<-1,1,1> } #end #declare time = 10*clock; #declare time_int = int(time); #declare time_frac = time-time_int; //Usa interpolação de cosseno (Não ficou legal =( ////#declare time_frac = (1-cos(time_frac*pi))/2; //#declare time = time+time_frac; #declare Digits = array[6] {18+time,27+time,16+time,37+time,0+time,31+time}; object { abaco(Digits, 0.05) rotate <-90, 0, 0> } //Chão xadrez box{ <-20,-20,-1>, <+20,+20,0> texture{ tx_xadrez } translate <0,0,-3.5> } #declare camera_ang = pi/4 + pi/3*clock; #include "camlight.inc" #declare centro_cena = <-2+2*clock,0,0>; #declare raio_cena = 12 - 4*clock; #declare dir_camera = < cos(camera_ang), sin(camera_ang), 0.3*clock>; #declare dist_camera = 50.0 - 40*clock; #declare intens_luz = 1.00; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)