// Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2020-12-08 10:46:02 by jstolfi #version 3.6; global_settings{ max_trace_level 30 } // ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.85, 0.83, 0.55 > } #declare tx_purple = texture{ pigment{ color rgb < 0.90, 0.40, 0.70 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_silver = texture{ pigment{ color rgb < 0.80, 0.80, 0.80 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_black = texture{ pigment{ color rgb < 0.10, 0.10, 0.10 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_glass = texture{ pigment{ color rgb <1, 1, 1> filter 0.960 } finish{ diffuse 0.005 ambient 0.005 reflection 0.030 specular 0.35 roughness 0.005 } } #declare tx_texto = texture{ pigment{ color rgb <1.000, 0.200, 0.200> } finish{ diffuse 0.00 ambient 1.00} } #declare tx_xadrez = texture{ pigment{ checker color rgb < 0.50, 0.50, 0.50 >, color rgb < 0.90, 0.90, 0.90 > } finish{ diffuse 0.9 ambient 0.1 } scale 1.0 } // ====================================================================== // DESCRIÇÃO DA CENA #declare chao = box{ <-20,-20,-1>, <+20,+20,0> texture { tx_xadrez } rotate 20*z } #declare body = sphere { <0.00, 0.00, 0.00>, 1.00 texture { tx_purple } } #declare jar_outer = cylinder { <0.00, 0.00, 0.00>, <0.00, 0.00, 7.00>, 5.00 } #declare jar_hole = cylinder { <0.00, 0.00, 0.00>, <0.00, 0.00, 6.85>, 4.80 } #declare jar = difference{ object { jar_outer translate <0.00, 0.00, -4.00> } object { jar_hole translate <0.00, 0.00, -3.80> } texture { tx_glass } interior {ior 1.2 fade_color <0.50, 0.95, 0.05> fade_power 1000 fade_distance 2.0} } #declare tampa = cylinder { <0.00, 0.00, 0.00>, <0.00, 0.00, 1.00>, 5.00 texture { tx_silver } } #macro virus(N) union{ object { body } tentaculo_aleatorio(N, 25, <0, 0.85, -0.30>, <0, 3, 0>, 0.3, 0) tentaculo_aleatorio(N, 145, <0, -0.85, -0.30>, <0, -4, 0>, 0.3, 0) tentaculo_aleatorio(N, 151, <0, -0.55, -0.60>, <0, -2, -3>, 0.3, 0) tentaculo_aleatorio(N, 386, <0, 0.55, -0.60>, <0, 2, -3>, 0.3, 0) tentaculo_aleatorio(N, 494, <0, -0.25, -0.90>, <0, -1, -4>, 0.3, 0) tentaculo_aleatorio(N, 777, <0, 0.25, -0.90>, <0, 1, -4>, 0.3, 0) segmento(N, <0, 0.70, 0.70>, <0, 0.85, 0.70>, <0, 0.85, 2>, <0, 0.85, 2>, 0.3, 0) segmento(N, <0, -0.70, 0.60>, <0, -0.85, 0.70>, <0, -0.85, 2>, <0, -0.85, 2>, 0.3, 0) } #end #macro virus_anim(N, tt) union{ object { body } tentaculo_aleatorio_anim(N,tt,0,<0, 0.85, -0.30>, <0, 3, 0>, 0.3, 0) tentaculo_aleatorio_anim(N,tt,1,<0, -0.85, -0.30>, <0, -4, 0>, 0.3, 0) tentaculo_aleatorio_anim(N,tt,2,<0, -0.55, -0.60>, <0, -2, -3>, 0.3, 0) tentaculo_aleatorio_anim(N,tt,3,<0, 0.55, -0.60>, <0, 2, -3>, 0.3, 0) tentaculo_aleatorio_anim(N,tt,4,<0, -0.25, -0.90>, <0, -1, -4>, 0.3, 0) tentaculo_aleatorio_anim(N,tt,5,<0, 0.25, -0.90>, <0, 1, -4>, 0.3, 0) segmento(N, <0, 0.70, 0.70>, <0, 0.85, 0.70>, <0, 0.85, 2>, <0, 0.85, 2>, 0.3, 0) segmento(N, <0, -0.70, 0.60>, <0, -0.85, 0.70>, <0, -0.85, 2>, <0, -0.85, 2>, 0.3, 0) } #end #macro interpola1(tt, tt0, tt1, vv0, vv1) #local rr = (tt - tt0)/(tt1 - tt0); #local vv = (1 - rr)*vv0 + rr*vv1; vv #end #macro interpola3(tt, tt0, tt3, vv0, vv1, vv2, vv3) #local vv01 = interpola1(tt, tt0, tt3, vv0, vv1); #local vv12 = interpola1(tt, tt0, tt3, vv1, vv2); #local vv23 = interpola1(tt, tt0, tt3, vv2, vv3); #local vv012 = interpola1(tt, tt0, tt3, vv01, vv12); #local vv123 = interpola1(tt, tt0, tt3, vv12, vv23); #local vv0123 = interpola1(tt, tt0, tt3, vv012, vv123); vv0123 #end #macro interpola3H(tt, t0, t1, p0, d0, d1, p1) #local rr = (tt - t0)/(t1 - t0); #local ss = 1 - rr; #local ph0 = rr*rr*(2*rr - 3) + 1; #local dh0 = + rr*ss*ss * (t1 - t0); #local dh1 = - ss*rr*rr * (t1 - t0); #local ph1 = ss*ss*(2*ss - 3) + 1; #local pp = ph0*p0 + dh0*d0 + dh1*d1 + ph1*p1; pp #end #macro segmento(N, P0, P1, P2, P3, R0, R3) #local tt = 0.1; #local T1 = N/10; union{ sphere{ P0, R0 texture {tx_purple} } #while (tt < T1) sphere{ interpola3(tt, 0, T1, P0, P1, P2, P3), interpola1(tt, 0, T1, R0, R3) texture {tx_purple} } #local tt = tt + 0.1; #end } #end #macro tentaculo(N, A0, A1, A2, B1, B2, C1, C2, C3, RA0, RC3) #local A3 = (A2 + B1)/2; #local B3 = (B2 + C1)/2; #local RA3 = interpola1(1/3, 0, 1, RA0, RC3); #local RB3 = interpola1(2/3, 0, 1, RA0, RC3); union{ segmento(N, A0, A1, A2, A3, RA0, RA3) segmento(N, A3, B1, B2, B3, RA3, RB3) segmento(N, B3, C1, C2, C3, RB3, RC3) } #end #macro tentaculo_hermite(N, tt,t0,t1, A0, A1H,A2H,B1H,B2H,C1H,C2H,C3H, RA0,RC3) #local A1 = interpola3H(tt, t0, t1, A1H[0], A1H[1], A1H[2], A1H[3]); #local A2 = interpola3H(tt, t0, t1, A2H[0], A2H[1], A2H[2], A2H[3]); #local B1 = interpola3H(tt, t0, t1, B1H[0], B1H[1], B1H[2], B1H[3]); #local B2 = interpola3H(tt, t0, t1, B2H[0], B2H[1], B2H[2], B2H[3]); #local C1 = interpola3H(tt, t0, t1, C1H[0], C1H[1], C1H[2], C1H[3]); #local C2 = interpola3H(tt, t0, t1, C2H[0], C2H[1], C2H[2], C2H[3]); #local C3 = interpola3H(tt, t0, t1, C3H[0], C3H[1], C3H[2], C3H[3]); tentaculo(N, A0, A1, A2, B1, B2, C1, C2, C3, RA0, RC3) #end #macro tentaculo_aleatorio(N, smt, A0, C3, RA0, RC3) #declare roleta = seed(smt); #local A1 = interpola1(1/9, 0, 1, A0, C3) + (-1 + 2*rand(roleta)); #local A2 = interpola1(2/9, 0, 1, A0, C3) + (-1 + 2*rand(roleta)); #local B1 = interpola1(4/9, 0, 1, A0, C3) + (-1 + 2*rand(roleta)); #local B2 = interpola1(5/9, 0, 1, A0, C3) + (-1 + 2*rand(roleta)); #local C1 = interpola1(7/9, 0, 1, A0, C3) + (-1 + 2*rand(roleta)); #local C2 = interpola1(8/9, 0, 1, A0, C3) + (-1 + 2*rand(roleta)); tentaculo(N, A0, A1, A2, B1, B2, C1, C2, C3, RA0, RC3) #end #macro tentaculo_anim(N,tt, A0, NQ,TQ, PA1,DA1, PA2,DA2, PB1,DB1, PB2,DB2, PC1,DC1, PC2,DC2, PC3,DC3, RA0,RC3) // Determina os quadros chave a interpolar k0,k1 e os tempos t0,t1: #local k0 = encontra_intervalo(tt, NQ, TQ); #local k1 = mod(k0 + 1, NQ); #local t0 = TQ[k0]; #local t1 = TQ[k0 + 1]; #debug concat("!! k0 = ", str(k0,0,0), " t0 = ", str(t0,0,4), " k1 = ", str(k1,0,0), " t1 = ", str(t1,0,4), "\n") // Pega posicoes e velocidades nesses dois quadros chave: #local A1H = array[4]; #local A1H[0] = PA1[k0]; #local A1H[1] = DA1[k0]; #local A1H[2] = DA1[k1]; #local A1H[3] = PA1[k1]; #local A2H = array[4]; #local A2H[0] = PA2[k0]; #local A2H[1] = DA2[k0]; #local A2H[2] = DA2[k1]; #local A2H[3] = PA2[k1]; #local B1H = array[4]; #local B1H[0] = PB1[k0]; #local B1H[1] = DB1[k0]; #local B1H[2] = DB1[k1]; #local B1H[3] = PB1[k1]; #local B2H = array[4]; #local B2H[0] = PB2[k0]; #local B2H[1] = DB2[k0]; #local B2H[2] = DB2[k1]; #local B2H[3] = PB2[k1]; #local C1H = array[4]; #local C1H[0] = PC1[k0]; #local C1H[1] = DC1[k0]; #local C1H[2] = DC1[k1]; #local C1H[3] = PC1[k1]; #local C2H = array[4]; #local C2H[0] = PC2[k0]; #local C2H[1] = DC2[k0]; #local C2H[2] = DC2[k1]; #local C2H[3] = PC2[k1]; #local C3H = array[4]; #local C3H[0] = PC3[k0]; #local C3H[1] = DC3[k0]; #local C3H[2] = DC3[k1]; #local C3H[3] = PC3[k1]; // Gera o tentaculo entre esses dois quadros chave: object{tentaculo_hermite(N, tt,t0,t1, A0, A1H,A2H,B1H,B2H,C1H,C2H,C3H, RA0,RC3)} #end #macro tentaculo_hermite_teste(N, tt) #local A0 = < 0, 0, 0 >; #local A1H = parado(< 1, 0, 0 >); #local A2H = parado(< 2, 0, 0 >); #local B1H = parado(< 4, 0, 0 >); #local B2H = parado(< 5, 0, 0 >); #local C1H = parado(< 7, 0, 0 >); #local C2H = parado(< 8, 0, 0 >); #local C3H = array[4]; #local C3H[0] = < 9, 0, -1 >; #local C3H[1] = < 0, +1, 0 >; #local C3H[2] = < 0, -1, 0 >; #local C3H[3] = < 9, 0, +1 >; #local RA0 = 0.2; #local RC3 = 0.02; object{tentaculo_hermite(N, tt,0,1, A0, A1H,A2H,B1H,B2H,C1H,C2H,C3H, RA0,RC3)} #end #macro parado(P) #local PH = array[4]; #local PH[0] = P; #local PH[1] = < 0, 0, 0 >; #local PH[2] = < 0, 0, 0 >; #local PH[3] = P; PH #end #macro tentaculo_aleatorio_anim(N,tt,it,A0,Z3,RA0,RC3) #local smt = 4615 + 418*it; // Semente para este tentaculo. #local NQ = 3; // Quadros-chave excluindo final (= inicial). #local TQ = array[NQ+1]; // Tempos dos quadros-chave #local TQ[0] = 0.0000; // Inicio da animacao. #local TQ[1] = 0.3333; // Fim do primeiro movimento. #local TQ[2] = 0.6667; // Fim do segundo movimento. #local TQ[3] = 1.0000; // Fim da animacao. #local sem = seed(smt); // Gera posicoes e velocidades aleatorias do tentaculo para quadros-chave #local mP = 0.5*vlength(Z3 - A0); // Max perturbacao do ponto. #local mV = 4.0*vlength(Z3 - A0); // Max velocidade. #local PA1 = array[NQ]; #local DA1 = array[NQ]; #local PA2 = array[NQ]; #local DA2 = array[NQ]; #local PB1 = array[NQ]; #local DB1 = array[NQ]; #local PB2 = array[NQ]; #local DB2 = array[NQ]; #local PC1 = array[NQ]; #local DC1 = array[NQ]; #local PC2 = array[NQ]; #local DC2 = array[NQ]; #local PC3 = array[NQ]; #local DC3 = array[NQ]; #local kq = 0; #while (kq < NQ) #local PA1[kq] = interpola1(1/9, 0,1, A0,Z3) + (1/9)*mP*ranvec(sem); #local DA1[kq] = (1/9)*mV*ranvec(sem); #local PA2[kq] = interpola1(2/9, 0,1, A0,Z3) + (2/9)*mP*ranvec(sem); #local DA2[kq] = (2/9)*mV*ranvec(sem); #local PB1[kq] = interpola1(4/9, 0,1, A0,Z3) + (4/9)*mP*ranvec(sem); #local DB1[kq] = (4/9)*mV*ranvec(sem); #local PB2[kq] = interpola1(5/9, 0,1, A0,Z3) + (5/9)*mP*ranvec(sem); #local DB2[kq] = (5/9)*mV*ranvec(sem); #local PC1[kq] = interpola1(7/9, 0,1, A0,Z3) + (7/9)*mP*ranvec(sem); #local DC1[kq] = (7/9)*mV*ranvec(sem); #local PC2[kq] = interpola1(8/9, 0,1, A0,Z3) + (8/9)*mP*ranvec(sem); #local DC2[kq] = (8/9)*mV*ranvec(sem); #local PC3[kq] = Z3 + mP*ranvec(sem); #local DC3[kq] = mV*ranvec(sem); #local kq = kq + 1; #end object{tentaculo_anim(N,tt, A0, NQ,TQ, PA1,DA1, PA2,DA2, PB1,DB1, PB2,DB2, PC1,DC1, PC2,DC2, PC3,DC3, RA0,RC3)} #end #macro ranvec(sem) #local vv = <2*rand(sem)-1, 2*rand(sem)-1, 2*rand(sem)-1>; vv #end #macro encontra_intervalo(tt, NQ,TQ) #local k0 = 0; // Por via das duvidas. #local kq = 0; #while (kq < NQ) #if ((TQ[kq] <= tt) & (tt <= TQ[kq+1])) #local k0 = kq; #end #local kq = kq + 1; #end k0 #end #declare texto1 = text{ ttf "ttf/arial.ttf" "NOVO ANO" 0.001, 0 rotate <90.00, 0.00, 90.00> translate <0.00, -6.30, 2.40> texture{tx_texto} } #declare texto2 = text{ ttf "ttf/arial.ttf" "NOVO VIRUS" 0.001, 0 rotate <90.00, 0.00, 90.00> translate <0.00, 0.30, 1.40> texture{tx_texto} } #declare texto3 = text{ ttf "ttf/arial.ttf" "COVID-21" 0.001, 0 rotate <90.00, 0.00, 90.00> translate <0.00, -2.10, -3.00> texture{tx_texto} } #macro animate_camera(tt) #local dir = < 10.00, 1.00, 4.00 >; #if (tt <= 0.3) #local dir = <10.00, 1.00+9*tt, 4.00-3*tt>; #else #local dir = <10.00, 1.00+15*tt, 4.00-0.9>; #end dir #end #include "eixos.inc" #include "frontal.inc" #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 0.00 >; #declare raio_cena = 12; #declare dir_camera = animate_camera(clock); #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; #declare dist_overlay = 0.67*dist_camera; // Agora eh distancia da camera ao overlay. #macro animate(tt) #if (tt <= 0.3) union{ object{ virus_anim(100, tt) scale 1.0 translate 2.0*z } object{ jar } object {chao translate<0.00, 0.00, -4.01>} object {tampa translate<0.00, 0.00, 3.00 + tt*6>} } #elseif (tt <= 0.5) union{ object{ virus_anim(100, tt) scale 1.0 translate 2.0*z } object{ jar } object {chao translate<0.00, 0.00, -4.01>} object {tampa translate<0.00, 0.00, 3.00 + 0.3*6>} object{frontal(object {texto1}, centro_cena, dir_camera, dist_camera, dist_overlay, z) translate<0.00, -0.5+tt, 0.00>} } #elseif (tt <= 0.7) union{ object{ virus_anim(100, tt) scale 1.0 translate 2.0*z } object{ jar } object {chao translate<0.00, 0.00, -4.01>} object {tampa translate<0.00, 0.00, 3.00 + 0.3*6>} object{frontal(object {texto1}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} object{frontal(object {texto2}, centro_cena, dir_camera, dist_camera, dist_overlay, z) translate<0.00, 0.7-tt, 0.00>} } #elseif (tt <= 0.9) union{ object{ virus_anim(100, tt) scale 1.0 translate 2.0*z } object{ jar } object {chao translate<0.00, 0.00, -4.01>} object {tampa translate<0.00, 0.00, 3.00 + 0.3*6>} object{frontal(object {texto1}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} object{frontal(object {texto2}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} object{frontal(object {texto3}, centro_cena, dir_camera, dist_camera, dist_overlay, z) translate<0.00, 0.00, 0.9-tt>} } #else union{ object{ virus_anim(100, tt) scale 1.0 translate 2.0*z } object{ jar } object {chao translate<0.00, 0.00, -4.01>} object {tampa translate<0.00, 0.00, 3.00 + 0.3*6>} object{frontal(object {texto1}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} object{frontal(object {texto2}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} object{frontal(object {texto3}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} } #end #end camlight(centro_cena, raio_cena, dir_camera, dist_camera, z, intens_luz) // Aqui está a cena, finalmente: union{ //object{ eixos(3.00) } //segmento(100, <0.00, 0.00, 0.00>, <0.00, 0.00, 1.00>, <0.00, 3.00, 2.00>, <0.00, 3.00, 3.00>, 0.30, 0.20) //tentaculo(100, <0, 0, 0>, <0, 0, -1>, <0, -3, -2>, <0, -3, -3>, <0, -4, -3>, <0, -4, -4>, <0, -5, -4>, <0, -5, -5>, 0.3, 0) //tentaculo_aleatorio(100, 25, <0, 0, 0>, <0, -6, -3>, 0.3, 0) //tentaculo_hermite_teste(100, clock) //tentaculo_aleatorio_anim(100,clock,0,<0,0,0>,<5,1,0>,0.3,0) //object {texto1 rotate<90.00, 0.00, 90.00>} animate(clock) //object{frontal(object {texto1}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} //object{frontal(object {texto2}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} //object{frontal(object {texto3}, centro_cena, dir_camera, dist_camera, dist_overlay, z)} }