// ====================================================================== // CORES E TEXTURAS background { color rgb < 1,1,1 > } #declare tx_corpo = texture { pigment { color rgb < 0.2,0.2,0.2 > } finish { diffuse 1 } } #declare tx_asa = texture { pigment { color rgb < 0.5, 0.5, 0.5 > filter 0.85 } finish { diffuse 0.02 reflection 0.2 ambient 0.02 specular 0.25 roughness 0.005 } } // ====================================================================== // DESCRIÇÃO DA CENA // Partes da cena #macro pe (a1,t1) union { object { sphere { <0,0,0>, 0.05 texture { tx_corpo } } } object { cylinder { <0,0,0>, , 0.05 texture { tx_corpo } } rotate <0,a1,0> } } #end #macro canelaPe (a1,t1, a2,t2) object { union { object { sphere { <0,0,0>, 0.05 texture { tx_corpo } } } object { cylinder { <0,0,0>, , 0.05 texture { tx_corpo } } } object { pe(a1,t1) translate } } rotate <0,a2,0> } #end #macro coxaCanelaPe (a1,t1, a2,t2, a3,t3) object { union { object { sphere { <0,0,0>, 0.05 texture { tx_corpo } } } object { cylinder { <0,0,0>, , 0.05 texture { tx_corpo } } } object { canelaPe(a1,t1, a2,t2) translate } } rotate <0,a3,0> translate <0,0,-0.25> } #end #macro mosquitoDragao (A) #local torax = sphere { <0,0,0>, 0.25 texture{ tx_corpo } } #local cabeca = sphere { <0,0,0>, 0.1 texture{ tx_corpo } } #local proboscide = cylinder { <0,0,0>, <0,0,-0.4>, 0.02 texture{ tx_corpo } } #local abdomen = union { cylinder { <0,0,0>, <0,0,-0.6>, 0.15 texture{ tx_corpo } } sphere { <0,0,-0.6>, 0.15 texture{ tx_corpo } } } #local asa = object { union { box { <0,-0.01,0>, <1,0.01,0.32> texture{ tx_asa } } cylinder { <1,-0.005,0.16>, <1,0.005,0.16> 0.16 texture{ tx_asa } } } translate <0,0,-0.1> } union { // corpo do monstro object { torax } object { abdomen rotate <60,0,90> } object { cabeca translate <0.25,0,-0.1> } object { proboscide translate <0.25,0,-0.2> } // asas object { asa rotate <10,-20,170> } object { asa rotate <-10,-20,190> } // pernas dianteiras object { coxaCanelaPe(A[0][0],0.8, A[0][1],0.7, A[0][2],0.6) rotate z*A[0][3] } object { coxaCanelaPe(A[1][0],0.8, A[1][1],0.7, A[1][2],0.6) rotate z*A[1][3] } // pernas intermediarias object { coxaCanelaPe(A[2][0],0.8, A[2][1],0.6, A[2][2],0.7) rotate z*A[2][3] } object { coxaCanelaPe(A[3][0],0.8, A[3][1],0.6, A[3][2],0.7) rotate z*A[3][3] } // pernas traseiras object { coxaCanelaPe(A[4][0],0.7, A[4][1],0.6, A[4][2],0.8) rotate z*A[4][3] } object { coxaCanelaPe(A[5][0],0.7, A[5][1],0.6, A[5][2],0.8) rotate z*A[5][3] } } #end #macro linearInterpolation(t0,v0, t1,v1, tt) #local r = (tt-t0)/(t1-t0); #local s = 1 - r; #local vv = s*v0 + r*v1; vv #end #macro interpola_quadros(P, k0,k1, t0,t1, tt, A) // Interpola P[k0][i][j] e P[k1][i][j] e coloca em A[i][j] #local R = array[6][4]; #for (i, 0, 5) #for (j, 0, 3) #local R[i][j] = linearInterpolation(t0,P[k0][i][j], t1,P[k1][i][j], tt); #end #end #declare A = R #end #macro busca_tempo(clk, NQ, tk) #local index = NQ; #for (i,0,NQ-1) #if (tk[i] > clk) #local index = i; #break #end #end index #end #macro quadro(clk) #local M = array[7][6][4] { { {-60,140,-70, 45}, {-60,140,-70, -45}, {-60,140,-60, 100}, {-60,140,-60, -100}, {-60,140,-50, 130}, {-60,140,-50, -130} }, { {-60,140,-60, 45}, {-60,140,-60, -45}, {-60,140,-50, 100}, {-60,140,-50, -100}, {-60,140,-40, 130}, {-60,140,-40, -130} }, { {-50,140,-40, 45}, {-50,140,-40, -45}, {-50,140,-30, 100}, {-50,140,-30, -100}, {-50,140,-20, 130}, {-50,140,-20, -130} }, { {-40,140,-30, 45}, {-40,140,-30, -45}, {-40,140,-20, 100}, {-40,140,-20, -100}, {-40,140,-10, 130}, {-40,140,-10, -130} }, { {-50,140,-40, 45}, {-50,140,-40, -45}, {-50,140,-30, 100}, {-50,140,-30, -100}, {-50,140,-20, 130}, {-50,140,-20, -130} }, { {-60,140,-60, 45}, {-60,140,-60, -45}, {-60,140,-50, 100}, {-60,140,-50, -100}, {-60,140,-40, 130}, {-60,140,-40, -130} }, { {-60,140,-70, 45}, {-60,140,-70, -45}, {-60,140,-60, 100}, {-60,140,-60, -100}, {-60,140,-50, 130}, {-60,140,-50, -130} }, }; #local tk = array[7] {0, 0.2, 0.4, 0.6, 0.73, 0.86, 1} #local A = array[6][4]; #local k = busca_tempo(clk, 7, tk); interpola_quadros(M, k-1,k, tk[k-1],tk[k],clk, A); object { mosquitoDragao(A) } #end // Aqui está a cena, finalmente: quadro(clock) #include "camlight.inc" #declare centro_cena = < 0,0,-0.4 >; #declare raio_cena = 2.5; #declare dir_camera = < 90, 90, 90 >; // 0, -1, 90 for XY #declare dist_camera = 4*raio_cena; #declare intens_luz = 1.4; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)