// Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2017-05-07 20:10:09 by stolfilocal // ====================================================================== // Cores e Texturas background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_plastico_branco = texture{ pigment{ color rgb < 1.0, 1.0, 1.0 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_plastico_preto = texture{ pigment{ color rgb < 0.0, 0.0, 0.0 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_plastico_vermelho = texture{ pigment{ color rgb < 0.90, 0.20, 0.10 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_plastico_azul = texture{ pigment{ color rgb < 0.1, 0.2, 0.9 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } // ====================================================================== // Declaração de Macros // Bola unitária #declare bola_unit = sphere{ <0, 0, 0>, 0.1 texture{ tx_plastico_vermelho } } // Interpolação Linear #macro interplin (p0, p1, t0, t1, tt) #local r = (tt - t0) / (t1 - t0); #local s = 1 - r; #local vv = s * p0 + r * p1; vv #end // end interplin // Interpolação Linear de Matriz #macro interp_matriz (P, N, M, t0, t1, tt, R, k0, k1) #for (j, 0, N - 1) #for (i, 0, M - 1) #declare R[j][i] = interplin(P[k0][j][i], P[k1][j][i], t0, t1, tt); #end // for i #end // for j #end // end interp_matriz // Curva de Bezier #macro bezier (A, B, C, D, t0, t1, tt) #local AB = interplin(A, B, t0, t1, tt); #local BC = interplin(B, C, t0, t1, tt); #local CD = interplin(C, D, t0, t1, tt); #local ABC = interplin(AB, BC, t0, t1, tt); #local BCD = interplin(BC, CD, t0, t1, tt); #local ABCD = interplin(ABC, BCD, t0, t1, tt); ABCD #end // end bezier // Suaviza a junta entre o arco i e o arco j = mod(i + 1, N) #macro suavizaX(P, N, i, k) #local j = mod(i + 1, N); #local vv = (P[k][j][1] - P[k][i][2]) / 2; #declare P[k][i][2] = P[k][i][3] - vv; #declare P[k][j][1] = P[k][j][0] + vv; #end // end suavizaX // Plota um nó dado matriz P, número de arcos Na e número de esferas por arco Ne #macro noh(P, Na, Ne) union { #for (j, 0, Na - 1) #for (i, 0, 1, 1 / Ne) object{ bola_unit translate bezier(P[j][0], P[j][1], P[j][2], P[j][3], 0, 1, i) } #end #end } #end // end no // retorna frame do clock em questão // CK - clock // NK - Número de keyframes // TK - Vetor de tempos #macro busca_frame(CK, NK, TK) #if (CK < TK[0]) 0 #else #if((CK > TK[1]) & (CK <= TK[1])) 1 #end #end #end #include "eixos.inc" // ====================================================================== // Declaração de cena object{ eixos(1.0) } #declare NK = 8; #declare NA = 6; #declare P = array[NK][NA][4]; // Nó 0 // arco 1 #declare P[0][0][0] = <-1, -1, -0.5>; #declare P[0][0][1] = <-0.75, -0.75, -0.2>; #declare P[0][0][2] = <0.3, 0, 0.75>; #declare P[0][0][3] = <0.75, 0.75, 0.5>; // arco 2 #declare P[0][1][0] = <0.75, 0.75, 0.5>; #declare P[0][1][1] = <0.55, 0.55, 0.2>; #declare P[0][1][2] = <0.3, 0.3, -0.5>; #declare P[0][1][3] = <0, 0, -0.75>; // arco 3 #declare P[0][2][0] = <0, 0, -0.75>; #declare P[0][2][1] = <-0.3, -0.3, -0.5>; #declare P[0][2][2] = <-0.55, -0.55, 0.2>; #declare P[0][2][3] = <-0.75, -0.75, 0.5>; // arco 4 #declare P[0][3][0] = <-0.75, -0.75, 0.5>; #declare P[0][3][1] = <-3, 0, 0.75>; #declare P[0][3][2] = <0.75, 0.75, -0.2>; #declare P[0][3][3] = <1, 1, -0.5>; // arco 5 #declare P[0][4][0] = <-1, -1, -0.5>; #declare P[0][4][1] = <-0.85, -0.85, 0.7>; #declare P[0][4][2] = <-0.75, -0.75, 0.9>; #declare P[0][4][3] = <0, 0, 1.0>; // arco 6 #declare P[0][5][0] = <1, 1, -0.5>; #declare P[0][5][1] = <0.85, 0.85, 0.7>; #declare P[0][5][2] = <0.75, 0.75, 0.9>; #declare P[0][5][3] = <0, 0, 1.0>; suavizaX(P, 6, 0, 0) suavizaX(P, 6, 1, 0) suavizaX(P, 6, 2, 0) suavizaX(P, 6, 3, 0) suavizaX(P, 6, 4, 0) suavizaX(P, 6, 5, 0) //noh(P, 6, 40, 0) #declare VT = <0, -2, 0>; #declare ST = 0.02; // Nó 1 // arco 1 #declare P[1][0][0] = VT + (ST * <-2, -3, -0.5>); #declare P[1][0][1] = VT + (ST * <-0.75, -0.75, -0.2>); #declare P[1][0][2] = VT + (ST * <1.3, 0, 0.75>); #declare P[1][0][3] = VT + (ST * <0.75, 0.75, 0.5>); // arco 2 #declare P[1][1][0] = VT + (ST * <0.75, 0.75, 0.5>); #declare P[1][1][1] = VT + (ST * <0.55, 2.55, 2.2>); #declare P[1][1][2] = VT + (ST * <1.3, 0.3, -0.5>); #declare P[1][1][3] = VT + (ST * <0, 0, -0.75>); // arco 3 #declare P[1][2][0] = VT + (ST * <0, 0, -2.75>); #declare P[1][2][1] = VT + (ST * <-2.3, -0.3, -0.5>); #declare P[1][2][2] = VT + (ST * <-0.55, -0.55, 0.2>); #declare P[1][2][3] = VT + (ST * <-0.75, -0.75, 0.5>); // arco 4 #declare P[1][3][0] = VT + (ST * <-0.75, -0.75, 0.5>); #declare P[1][3][1] = VT + (ST * <-3, 0, 2.75>); #declare P[1][3][2] = VT + (ST * <1.75, -2.75, -4.2>); #declare P[1][3][3] = VT + (ST * <1, 1, -0.5>); // arco 5 #declare P[1][4][0] = VT + (ST * <-1, -1, -0.5>); #declare P[1][4][1] = VT + (ST * <-0.85, -0.85, 0.7>); #declare P[1][4][2] = VT + (ST * <-1.75, -5.75, 1.9>); #declare P[1][4][3] = VT + (ST * <0, 0, 1.0>); // arco 6 #declare P[1][5][0] = VT + (ST * <1, 1, -0.5>); #declare P[1][5][1] = VT + (ST * <0.85, 0.85, 0.7>); #declare P[1][5][2] = VT + (ST * <1.75, 0.75, 0.9>); #declare P[1][5][3] = VT + (ST * <0, -4, 1.0>); suavizaX(P, 6, 0, 1) suavizaX(P, 6, 1, 1) suavizaX(P, 6, 2, 1) suavizaX(P, 6, 3, 1) suavizaX(P, 6, 4, 1) suavizaX(P, 6, 5, 1) // inicializa matriz resultante #declare R = array[6][4]; #for (j, 0, 6 - 1) #for (i, 0, 4 - 1) #declare R[j][i] = <0, 0, 0>; #end // for i #end // for j #if (clock <= 0.5) interp_matriz(P, 6, 4, 0, 1, clock, R, 0, 1) #else interp_matriz(P, 6, 4, 0, 1, clock, R, 1, 0) #end /*#local frame = busca_frame(clock) interp_matriz(P, 6, 4, 0, 1, clock, R, frame, frame + 1)*/ object{ noh(R, 6, 40) } // ====================================================================== // Declaração de Câmera #include "camlight.inc" #declare centro_cena = < 0.0, 0.0, 0.0>; #declare raio_cena = 2.0; #declare dir_camera = < 45, 0, 0 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)