#include "retalho-simples.inc" // ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_plastico = texture{ pigment{ color rgb < 0.30, 0.70, 0.70 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_fosca = texture{ pigment{ color rgb < 0.70, 0.70, 0.70 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_pedra = texture{ pigment { color rgb <0.4, 0.2, 0> } finish { diffuse 0.9 ambient 0.1 } } #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 12.0 } // ====================================================================== // DESCRIÇÃO DA CENA #declare P = array[4][4] { {<-5,0,0>,<-4,0,1>,<4,0,1>,<5,0,0>}, {<-5,1,1.5>,<-4,1,2.5>,<4,1,2.5>,<5,1,1.5>}, {<-5,1.5,2>,<-4,1.5,3>,<4,1.5,3>,<5,1.5,2>}, {<-5,3,3>,<-4,3,4>,<4,3,4>,<5,3,3>} } /*#declare ip = 0; #while (ip < 3) #declare jp = 0; #while (jp < 3) #declare P[ip][jp] = P[jp][ip]; #declare jp = jp + 1; #end #declare ip = ip + 1; #end*/ #declare P1 = array[4][4]; #declare P2 = array[4][4]; #declare i0 = 0; #while (i0 < 4) #declare j0 = 0; #while (j0 < 4) #declare P1[i0][j0] = <0,0,0>; #declare j0 = j0 + 1; #end #declare i0 = i0 + 1; #end #declare ip2 = 0; #while (ip2 < 4) #declare jp2 = 0; #while (jp2 < 4) #declare ppt = P[ip2][jp2]; #declare P2[ip2][3-jp2] = ; #declare jp2 = jp2 + 1; #end #declare ip2 = ip2 + 1; #end #declare ip1 = 0; #while (ip1 < 4) #declare P1[ip1][1] = 2*P[ip1][3]-P[ip1][2]; #declare P1[ip1][2] = 2*P2[ip1][0]-P2[ip1][1]; #declare ip1 = ip1 + 1; #end #declare NV = 2; #declare NH = 3; #declare PP = array[NV][NH][4][4]; #macro emenda_retalho(PP, r0, s0, r1, s1) // (r0 = r1 e s0 + 1 = s1) ou (r0+1=r1 e s0=s1) #local i = 0; #while (i < 4) #if (r0 = r1) #declare PP[r0][s0][i][3] = (PP[r0][s0][i][2]+PP[r1][s1][i][1])/2; #declare PP[r1][s1][i][0] = PP[r0][s0][i][3]; #end #if (s0 = s1) #declare PP[r0][s0][3][i] = (PP[r0][s0][2][i]+PP[r1][s1][1][i])/2; #declare PP[r1][s1][0][i] = PP[r0][s0][3][i]; #end #local i = i + 1; #end #end #macro guarda_ret(PP, P, m, n) #local i = 0; #while (i < 4) #local j = 0; #while (j < 4) #declare PP[m][n][i][j] = P[i][j]; #local j = j + 1; #end #local i = i + 1; #end #end #macro extrai_ret(PP, P, m, n) #local i = 0; #while (i < 4) #local j = 0; #while (j < 4) #declare P[i][j] = PP[m][n][i][j]; #local j = j + 1; #end #local i = i + 1; #end #end #macro carroceria(PP, NV, NH) #local PR = array[4][4]; union { #local m = 0; #while (m < NV) #local n = 0; #while (n < NH) extrai_ret(PP, PR, m, n) object { retalho(PR, 0.05, texture{tx_plastico}, texture{tx_fosca}) } #local n = n + 1; #end #local m = m + 1; #end } #end guarda_ret(PP, P, 0, 0) guarda_ret(PP, P1, 0, 1) guarda_ret(PP, P2, 0, 2) #declare i = 0; #while (i < 4) #declare j = 0; #while (j < 4) #declare PP[1][0][i][j] = P[i][j]+<10,0,0>; #declare PP[1][1][i][j] = P1[i][j]+<10,0,0>; #declare PP[1][2][i][j] = P2[i][j]+<10,0,0>; #declare j = j + 1; #end #declare i = i + 1; #end // emenda todos os retalhos #declare nv = 0; #while (nv < NV) #declare nh = 0; #while (nh < NH - 1) emenda_retalho(PP, nv, nh, nv, nh+1) #declare nh = nh + 1; #end #declare nv = nv + 1; #end #declare nh = 0; #while (nh < NH) #declare nv = 0; #while (nv < NV - 1) emenda_retalho(PP, nv, nh, nv+1, nh) #declare nv = nv + 1; #end #declare nh = nh + 1; #end object { carroceria(PP, NV, NH) } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 0.00 >; #declare raio_cena = 20; #declare dir_camera = < 1, 0.00, 0.500 >; #declare dist_camera = 5 * raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)