// CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_green = texture{ pigment{ color rgb < 0.30, 1.00, 0.30 > } finish{ diffuse 0.8 ambient 0.1 specular 1.0 roughness 0.005 } } #declare tx_red = texture{ pigment{ color rgb < 1.00, 0.20, 0.20 > } finish{ diffuse 0.6 ambient 0.1 specular 1.0 roughness 0.005 } } #declare tx_blue = texture{ pigment{ color rgb < 0.30, 0.30, 1.00 > } finish{ diffuse 0.5 ambient 0.1 specular 1.0 roughness 0.005 } } #declare tx_white = texture{ pigment{ color rgb < 1.00, 1.00, 1.00 > } finish{ diffuse 0.5 ambient 0.8 specular 1.0 roughness 0.005 } } #macro retalho_val (PP) #local P = PP // Col1 #declare P[4][0][0][0] = P[4][0][0][0] + <0, 0, -0.2>; #declare P[4][0][0][3] = P[4][0][0][3] + <0, 0, +0.2>; #declare P[4][0][1][1] = P[4][0][1][1] + <0, 0, 0>; #declare P[4][0][1][2] = P[4][0][1][2] + <0, 0, 0>; #declare P[4][0][2][1] = P[4][0][2][1] + <0, 0, 0>; #declare P[4][0][2][2] = P[4][0][2][2] + <0, 0, 0>; #declare P[4][0][1][0] = P[4][0][1][0] + <0, 0, -0.3>; #declare P[4][0][2][0] = P[4][0][2][0] + <0, 0, -0.3>; #declare P[4][0][3][0] = P[4][0][3][0] + <0, 0, -0.2>; #declare P[4][0][0][3] = P[4][0][0][3] + <0, -0.5, -0.6>; #declare P[4][1][1][1] = P[4][1][1][1] + <0, -2, -0.2>; #declare P[4][1][1][2] = P[4][1][1][2] + <0, -2, -0.1>; #declare P[4][1][2][1] = P[4][1][2][1] + <0, -2, -0.4>; #declare P[4][1][2][2] = P[4][1][2][2] + <0, -2, -0.2>; #declare P[4][1][0][3] = P[4][1][0][3] + <0, -2, 0>; #declare P[4][1][1][3] = P[4][1][1][3] + <-1, -2, -0.5>; #declare P[4][1][2][3] = P[4][1][2][3] + <-1, -2, -0.8>; #declare P[4][1][3][3] = P[4][1][3][3] + <0, -2, -1>; #declare P[4][1][3][2] = P[4][1][3][2] + <0.3, -2, -0.4>; #declare P[4][1][3][1] = P[4][1][3][1] + <-0.3, -2, -0.3>; #declare P[4][1][3][0] = P[4][1][3][0] + <0, -2, -1>; // Col2 #declare P[3][0][1][1] = P[3][0][1][1] + <0, 0, 3>; #declare P[3][0][1][2] = P[3][0][1][2] + <0, 0, -1>; #declare P[3][0][2][1] = P[3][0][2][1] + <0, 0, 3>; #declare P[3][0][2][2] = P[3][0][2][2] + <0, 0, -1>; #declare P[3][1][1][1] = P[3][1][1][1] + <0, -2, -1>; #declare P[3][1][1][2] = P[3][1][1][2] + <0, -2, -1>; #declare P[3][1][2][1] = P[3][1][2][1] + <0, -2, -2>; #declare P[3][1][2][2] = P[3][1][2][2] + <0, -2, -2>; // Col3 #declare P[2][0][1][1] = P[2][0][1][1] + <2, 0, 3>; #declare P[2][0][1][2] = P[2][0][1][2] + <2, 0, 3>; #declare P[2][0][2][1] = P[2][0][2][1] + <-2, 0, 3>; #declare P[2][0][2][2] = P[2][0][2][2] + <-2, 0, 3>; #declare P[2][1][1][1] = P[2][1][1][1] + <0, -2, 1>; #declare P[2][1][1][2] = P[2][1][1][2] + <0, -2, 1>; #declare P[2][1][2][1] = P[2][1][2][1] + <0, -2, -1>; #declare P[2][1][2][2] = P[2][1][2][2] + <0, -2, -1>; // Col4 #declare P[1][0][1][1] = P[1][0][1][1] + <0, 0, 0>; #declare P[1][0][1][2] = P[1][0][1][2] + <0, 0, 0>; #declare P[1][0][2][1] = P[1][0][2][1] + <0, 0, 0>; #declare P[1][0][2][2] = P[1][0][2][2] + <0, 0, 0>; #declare P[1][1][1][1] = P[1][1][1][1] + <0, -2, 0>; #declare P[1][1][1][2] = P[1][1][1][2] + <0, -2, 0>; #declare P[1][1][2][1] = P[1][1][2][1] + <0, -2, 0>; #declare P[1][1][2][2] = P[1][1][2][2] + <0, -2, 0>; // Col3 #declare P[0][0][1][1] = P[0][0][1][1] + <0, -2, 0>; #declare P[0][0][1][2] = P[0][0][1][2] + <0, -2, 0>; #declare P[0][0][2][1] = P[0][0][2][1] + <0, -2, 0>; #declare P[0][0][2][2] = P[0][0][2][2] + <0, -2, 0>; #declare P[0][1][1][1] = P[0][1][1][1] + <0, -2, 0>; #declare P[0][1][1][2] = P[0][1][1][2] + <0, -2, 0>; #declare P[0][1][2][1] = P[0][1][2][1] + <0, -2, 0>; #declare P[0][1][2][2] = P[0][1][2][2] + <0, -2, 0>; P #end #macro retalho_suaves (PP, r0, s0, r1, s1) #local i = 0; #while (i < 4) //Col #if (r0 = r1) #local PP[r0][s0][3][i] = ( PP[r1][s1][1][i] + PP[r0][s0][2][i] )/2; #local PP[r1][s1][0][i] = PP[r0][s0][3][i]; #end //Lin #if (s0 = s1) #local PP[r0][s0][i][3] = ( PP[r1][s1][i][1] + PP[r0][s0][i][2] )/2; #local PP[r1][s1][i][0] = PP[r0][s0][i][3]; #end #local i = i + 1; #end PP #end #macro emenda_retalho_col (PP, NV, NA) #local i = 0; #while (i < NV) #local j = 0; #while (j < NA) #if (i < NV-1) #local PP = retalho_suaves (PP, i, j, i+1, j); #end #local j = j+1; #end #local i = i+1; #end PP #end #macro emenda_retalho_lin (PP, NV, NA) #local i = 0; #while (i < NV) #local j = 0; #while (j < NA) #if (j < NA-1) #local PP = retalho_suaves (PP, i, j, i, j+1); #end #local j = j+1; #end #local i = i+1; #end PP #end #macro retalho_base (PP, NV , NA, P, move) #local i = 0; #while (i < 4) #local j = 0; #while (j < 4) #local PP[NV][NA][i][j] = P[i][j] + move; #local j = j+1; #end #local i = i+1; #end PP #end #macro retalho_mat (P, NV, NA) #local PP = array[NV][NA][4][4]; #local i = 0; #while (i < NV) #local j = 0; #while (j < NA) #local move = <3*i, 3*j, 0>; #local PP = retalho_base (PP, i , j, P, move); #local j = j+1; #end #local i = i+1; #end PP #end #macro copy_mat (PP, NV, NA) #local P = array[4][4]; #local i = 0; #while (i < 4) #local j = 0; #while (j < 4) #local P[i][j] = PP[NV][NA][i][j]; #local j = j+1; #end #local i = i+1; #end P #end // ====================================================================== // DESCRIÇÃO DA CENA #include "retalho-simples.inc" #local P = array[4][4] { {<0, 0, 0>, <1, 0, 0>, <2, 0, 0>, <3, 0, 0>} {<0, 1, 0>, <1, 1, 0>, <2, 1, 0>, <3, 1, 0>} {<0, 2, 0>, <1, 2, 0>, <2, 2, 0>, <3, 2, 0>} {<0, 3, 0>, <1, 3, 0>, <2, 3, 0>, <3, 3, 0>} } // Cria a matriz dos retalhos #local NV = 5; #local NA = 2; #local PP = retalho_mat (P, NV, NA); #local PP = retalho_val (PP); #local PP = emenda_retalho_col (PP, NV, NA); #local PP = emenda_retalho_lin (PP, NV, NA); // Cria o retalho #local i = 0; #while (i < NV) #local j = 0; #while (j < NA) #declare P = copy_mat (PP, i, j); object{ retalho(P, 0.00, tx_white, tx_red) } #local j = j+1; #end #local i = i+1; #end #include "camlight.inc" #declare centro_cena = < 20, 20, 10 >; #declare raio_cena = 10.0; #declare dir_camera = < 3, 4, 2>; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)