// ====================================================================== // CORES E TEXTURAS background { color rgb < 1,1,1 > } #declare tx_esfera = texture { pigment { color rgb < 1,0,1 > } finish{ diffuse 1 } } // ====================================================================== // DESCRIÇÃO DA CENA // Partes da cena #include "eixos.inc" #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 bezierCurve(t0,t1, A,B,C,D, tt) #local AB = linearInterpolation(t0,A, t1,B, tt); #local BC = linearInterpolation(t0,B, t1,C, tt); #local CD = linearInterpolation(t0,C, t1,D, tt); #local ABC = linearInterpolation(t0,AB, t1,BC, tt); #local BCD = linearInterpolation(t0,BC, t1,CD, tt); #local ABCD = linearInterpolation(t0,ABC, t1,BCD, tt); ABCD #end #macro smoothenCurves(P, n, i) #local j = mod(i+1,n); #local vv = (P[j][1]-P[i][2])/2; #local P[i][2] = P[i][3]-vv; #local P[j][1] = P[j][0]+vv; #end #macro drawBezier(A,B,C,D) #for (i, 0, 1, 0.001) object { esfera translate bezierCurve(0,1, A,B,C,D, i) } #end #end #macro drawCurve() #local P = array[3][4] { {<0.3,-0.5,1>, <-1,0.5,0.66>, <-1,0.5,0.33>, <0.8,0,0>}, {<0.8,0,0>, <0.66,0.5,0.5>, <0.33,-1,0.9>, <0.3,0,0.5>}, {<0.3,0,0.5>, <0,0.8,-0.8>, <-0.5,-1,-1>, <0.3,-0.5,1>} }; #local Q = array[3][4] { {<-0.3,-0.5,1>, <-1,0.5,0.66>, <-1,0.5,0.33>, <-0.8,0,0>}, {<-0.8,0,0>, <0.66,0.5,0.5>, <0.33,-1,0.9>, <-0.3,0,0.5>}, {<-0.3,0,0.5>, <0,0.8,-0.8>, <-0.5,-1,-1>, <-0.3,-0.5,1>} }; #for (i, 0, 2) smoothenCurves(P, 3, i) smoothenCurves(Q, 3, i) #end #local R = array[2][3][4]; #for (i, 0, 1, 0.01) #local R = matrixInterpolation(R,0,1,2, 0,1,i); #end #for (i, 0, 2) smoothenCurves(R, 3, i) #end union { drawBezier(R[0][0], R[0][1], R[0][2], R[0][3]) drawBezier(R[1][0], R[1][1], R[1][2], R[1][3]) drawBezier(R[2][0], R[2][1], R[2][2], R[2][3]) } #end #macro matrixInterpolation(P, k0,k1, NA, t0,t1, tt) // Interpola P[k0][i][j] e P[k1][i][j] e coloca em R[i][j] #local R = array[NA][4]; #for (i, 0, NA-1) #for (j, 0, 3) #local R[i][j] = linearInterpolation(t0,t1, P[k0][i][j],P[k1][i][j], tt); #end #end R #end #macro func(i) i*i #end #declare esfera = sphere { < func(clock-0.5), func(clock-0.5)*2, func(clock-0.5)/4 >, 0.2 texture{ tx_esfera } } // Aqui está a cena, finalmente: object { eixos(1) } object { esfera } #include "camlight.inc" #declare centro_cena = < 0,0,0 >; #declare raio_cena = 2; #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)