//Tp05 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.4, 0.4, 0.4 > } 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 } } #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 #macro desenhaBezier(A,B,C,D) #for (j, 0, 1, 0.001) object { esfera translate arcobezier(0,1,A,B,C,D,j) } #end #end #macro suavizaX(P,N,i) //Suaviza a junta entre o arco //i e o arco = mod(i+1,N) #local j = mod(i+1,N); #local vv = (P[j][i] - P[i][2])/2; #declare P[i][2] = P[i][3]-vv; #declare P[j][1] = P[j][0]+vv; #end #macro curva() #declare P = array[3][4]; #declare P[0][0] = <0,-3,2>; #declare P[0][1] = <-1,2,-3>; #declare P[0][2] = <-3,0,2>; #declare P[0][3] = <1,1,2>; #declare P[1][0] = <1,1,2>; #declare P[1][1] = <2,0,-3>; #declare P[1][2] = <0,-2,0>; #declare P[1][3] = <3,0,2>; #declare P[2][0] = <3,0,2>; #declare P[2][1] = <3,-2,-1>; #declare P[2][2] = <-1,-3,2>; #declare P[2][3] = <0,-3,2>; //[<0,2,-3>,<1,0,-2>,<1,0,2>,<1,0,1>] suavizaX(P,2,0) suavizaX(P,2,1) suavizaX(P,2,2) union { desenhaBezier(P[0][0],P[0][1],P[0][2],P[0][3]) desenhaBezier(P[1][0],P[1][1],P[1][2],P[1][3]) desenhaBezier(P[2][0],P[2][1],P[2][2],P[2][3]) } #end // ====================================================================== // DESCRIÇÃO DA CENA #include "eixos.inc" object{ eixos(3.00) } object{ curva() } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 1.00 >; #declare raio_cena = 4; #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)