// CORES E TEXTURAS #declare tx_fosca = texture{ pigment{ color rgb < 1, 1, 1 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_fosca2 = texture{ pigment{ color rgb < 1, 0, 1 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_fosca3 = texture{ pigment{ color rgb < 0.3, 0.6, 0.154 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_fosca4 = texture{ pigment{ color rgb < 1, 0, 0 > } finish{ diffuse 0.9 ambient 0.1 } } // ====================================================================== // DESCRIÇÃO DA CENA #macro pe(tamanho, textura) union{ sphere { <0,0,0>, tamanho } cylinder { <0, tamanho, 0>, <0, tamanho + 2*tamanho, 0> tamanho } texture{textura} } #end #macro canela(tamanho, textura, alfa) union{ union{ sphere { <0,0,0>, tamanho } cylinder { <0, tamanho, 0>, <0, tamanho + 10, 0> tamanho } texture{textura} } object{ pe(tamanho, textura) rotate<0,0,alfa> translate<0,2*tamanho+10,0> } } #end #macro perna(tamanho, textura, alfa, beta) union{ union{ sphere { <0,0,0>, tamanho } cylinder { <0, tamanho, 0>, <0, tamanho + 7, 0> tamanho } texture{textura} } object{ canela(tamanho, textura,alfa) rotate<0,0,beta> translate<0,2*tamanho+7,0> } } #end #macro bixo_doido(textura,A) union{ box { <-16,-6,-6>, <16,6,0> texture { textura } } object{ perna(1,textura, A[0][0], A[0][1]) rotate <-90,-90,90> translate<0,6,0> } object{ perna(1,textura, A[1][0], A[1][1]) rotate <90,-90,90> translate<0,-6,0> } object{ perna(1,textura, A[2][0], A[2][1]) rotate <-90,-90,90> translate<10,6,0> } object{ perna(1,textura, A[3][0], A[3][1]) rotate <90,-90,90> translate<10,-6,0> } object{ perna(1,textura, A[4][0], A[4][1]) rotate <-90,-90,90> translate<-10,6,0> } object{ perna(1,textura, A[5][0], A[5][1]) rotate <90,-90,90> translate<-10,-6,0> } } #end #macro matrizinterpola(P, k0, k1, N, c0, c1, cc, R) #for(i, 0, N - 1, 1) #for(j, 0, 4 - 1, 1) #local R[i][j] = interpol(c0, P[k0][i][j], c1, P[k1][i][j], cc); #end #end #end #macro interpola_quadros(NP, NA, Q, k0, t0, k1, t1, tt, A) #for(i, 0, NP - 1, 1) #for(j, 0, NA - 1, 1) #local A[i][j] = interpolaNumeros(t0, Q[k0][i][j], t1, Q[k1][i][j], tt); #end #end #end #macro interpolaNumeros(t0, v0, t1, v1, tt) #local r = (tt - t0) / (t1 - t0); #local s = 1 - r; #local vv = s * v0 + r * v1; vv #end #macro buscaTempo(clk, NQ, tk) #local retorno = 0; #for(i, 0, NQ -1, 1) #if(clk > tk[i]) #local retorno = i; #end #end retorno #end // Partes da cena: #include "eixos.inc" #declare NQ = 6; #declare NP = 6; #declare NA = 2; #declare tk = array[NQ] { 0, 0.2, 0.4, 0.6, 0.8, 1 }; #declare Q = array[NQ][NP][NA] { { { 10, 10 }, { 40, 40 }, { 60, 60 }, { -30, -30 }, { 90, 90 }, { -30, -30 } }, { { 20, 10 }, { 90, 10 }, { 11, 22 }, { 90, 12 }, { -90, -90 }, { 12, 61 } }, { { -14, -67 }, { -14, 90 }, { 40, 51 }, { 10, -15 }, { -90, 151 }, { 191, 232 } }, { { -120, 110 }, { 40, 40 }, { 60, 60 }, { -30, -30 }, { 90, 90 }, { -30, -30 } }, { { 110, 110 }, { 140, 140 }, { 260, 260 }, { -310, -310 }, { 490, 290 }, { -130, -310 } }, { { -10, 10 }, { 40, 410 }, { 260, 60 }, { 11, -130 }, { 3, 21 }, { -111, -99 } } }; #declare A = array[NP][NA]; #for(i,0,NP-1,1) #for(j,0,NA-1,1) #declare A[i][j] = 0; #end #end object{eixos(10)} union{ #declare bt = buscaTempo(clock, NQ, tk); interpola_quadros(NP, NA, Q, bt, tk[bt], bt+1, tk[bt+1], clock, A) object{ bixo_doido(tx_fosca, A)} } #include "camlight.inc" #declare centro_cena = < 0,0,0>; #declare raio_cena = 30; #declare dir_camera = < 4,1,3 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)