//Tp06 by Carlos Robson // ====================================================================== background{ color rgb < 0.75, 0.80, 0.85 > } #declare Yellow = rgb<255, 255, 0>; #declare Black = rgb < 0.4, 0.4, 0.4 >; #declare tx_plastico = texture{ pigment{ color rgb < 0.10, 0.80, 1.00 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare esfera = sphere { < 0, 0, 0>, 0.25 // Near lower left corner texture{ tx_plastico } } // ====================================================================== // DESCRIÇÃO DA CENA #include "eixos.inc" object{ eixos(3.00) } //matriz com os pontos P #declare P = array[4][4]; //Arco 1 #declare P[0][0] = <0,0,0>; #declare P[0][1] = <0,1,-2>; #declare P[0][2] = <0,3,-2>; #declare P[0][3] = <0,4,0>; //Arco 2 #declare P[1][0] = <0,4,0>; #declare P[1][1] = <0,4,2>; #declare P[1][2] = <1,0,2>; #declare P[1][3] = <1,0,4>; //Arco 3 #declare P[2][0] = <1,0,4>; #declare P[2][1] = <0,1,6>; #declare P[2][2] = <0,3,6>; #declare P[2][3] = <-1,4,4>; //Arco 4 #declare P[3][0] = <-1,4,4>; #declare P[3][1] = <-1,0,2>; #declare P[3][2] = <0,4,2>; #declare P[3][3] = <0,0,0>; //matriz com os pontos Q #declare Q = array[4][4]; //Arco 1 #declare Q[0][0] = <0,0,0>; #declare Q[0][1] = <0,1,-2>; #declare Q[0][2] = <0,3,-2>; #declare Q[0][3] = <0,0,0>; //Arco 2 #declare Q[1][0] = <0,0,0>; #declare Q[1][1] = <0,-1,2>; #declare Q[1][2] = <0,-3,2>; #declare Q[1][3] = <0,0,0>; //Arco 3 #declare Q[2][0] = <0,0,0>; #declare Q[2][1] = <0,2,4>; #declare Q[2][2] = <0,3,6>; #declare Q[2][3] = <0,0,0>; //Arco 4 #declare Q[3][0] = <0,0,0>; #declare Q[3][1] = <0,-2,-4>; #declare Q[3][2] = <0,-3,-6>; #declare Q[3][3] = <0,0,0>; #declare R = array[4][4]; #for(i, 0, 3, 1) #for(j, 0, 3, 1) #declare R[i][j] = <0,0,0>; #end #end #macro interpola(to, vo, t1, v1, tt ) #local r = (tt-to)/(t1-to); #local s = 1-r; #local vv= s*vo+r*v1; vv #end #macro arcobezier(to, t1, a, b, c, d, tt ) #local ab = interpola(to, a, t1, b, tt ); #local bc = interpola(to, b, t1, c, tt ); #local cd = interpola(to, c, t1, d, tt ); #local abc = interpola(to, ab, t1, bc, tt ); #local bcd = interpola(to, bc, t1, cd, tt ); #local abcd = interpola(to, abc, t1, bcd, tt ); abcd #end // N = num de lados, #macro interpolamatriz(PO, QO, N, CO, CI, cc, R) #local i = 0; #while(i < N) #local k = 0; #while(k<3) #declare R[i][k] = interpola(CO,PO[i][k], CI, QO[i][k], cc ); #local k = k+1; #end #local i = i+1; #end #end #macro inmatrizes(P, Q, N) #for(cc, 0, 1, 0.2) interpolamatriz(P, Q, N, 0, 1, cc, R ) object{noh(R, N, 20)} #end #end #macro arco(a0, a1, a2, a3, t0, t1, n) union{ #declare passo = 1/n; #declare j = t0; #while (j <= t1) object { esfera translate arcobezier(t0,t1, a0, a1, a2, a3, j)} #declare j=j+passo; #end } #end //Po = matrix, n = num de arcos, m = num de bolas por arco #macro noh(Po, n, m) union{ #declare lado = m/n; #local i = 0; #while(i < n) object {arco (Po[i][0], Po[i][1], Po[i][2], Po[i][3], i*lado, (i+1)*lado, m) } #local i = i+1; #end } #end //Suaviza 2 junções #macro suaviza(Po, i) #local j = mod(i+1, 4); #local vv = (Po[j][1]-Po[i][2])/2; #declare Po[i][2]= Po[i][3]-vv; #declare Po[j][1]= Po[j][0]+vv; #end //Po= matriz, n numero de arcos #macro suavizamatriz(Po, n) #local i = 0; #while(i < n ) suaviza(Po, i) #local i = i+1; #end #end suavizamatriz(P, 4) //object{noh(P, 4, 20)} //bject{noh(Q, 4, 20)} inmatrizes(P, Q, 4) #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 1.00 >; #declare raio_cena = 7.0; #declare dir_camera = < 14.00, 7.00, 4.00 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)