// Felipe Marinho Tavares // R.A.: 265680 // Unicamp - MC937A/MO603A – Computação Gráfica - 2020-S2 - Jorge Stolfi // Last edited on 2020-12-08 11:45:17 by jstolfi #version 3.6; // ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare brown_soft_149_111_82 = color rgb < 149/255, 111/255, 82/255 >; #declare tx_woodish = texture{ pigment{ brown_soft_149_111_82 } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_redish = texture{ pigment{ color rgb < 255/255, 0/255, 0/255 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_gray70 = texture{ pigment{ color rgb <179/255, 179/255, 179/255> } } #declare tx_gray85 = texture{ pigment{ color rgb <217/255, 217/255, 217/255> } } #declare tx_gray90 = texture{ pigment{ color rgb <230/255, 230/255, 230/255> } } // ====================================================================== // DESCRI��O DA CENA #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 segmento(N, P0, P1, P2, P3, R0, R3) #local iter = 0; union{ #while(iter < N) #local tt = iter / (N-1); #local pp = interpola3(tt, 0, 1, P0, P1, P2, P3); #local rr = interpola1(tt, 0, 1, R0, R3); sphere{pp, rr texture{tx_gray85} } #local iter = iter + 1; #end } #end #macro tentaculo(N, A0, A1, A2, B1, B2, C1, C2, C3, RA0, RC3) union{ #local A3 = (A2 + B1) / 2; #local B0 = A3; #local B3 = (B2 + C1) / 2; #local C0 = B3; #local RA3 = interpola1(1/3, 0, 1, RA0, RC3); #local RB0 = RA3; #local RB3 = interpola1(2/3, 0, 1, RA0, RC3); #local RC0 = RB3; segmento(N, A0, A1, A2, A3, RA0, RA3) segmento(N, B0, B1, B2, B3, RB0, RB3) segmento(N, C0, C1, C2, C3, RC0, RC3) } #end #macro tentaculo_aleatorio(N, smt, A0, C3, RA0, RC3) #local roll = seed(smt); #local len = vlength(C3 - A0); #local ps = len/1.5; // pertubation scaler #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local A1 = interpola1(1/9, 0, 1, A0, C3) + pert; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local A2 = interpola1(2/9, 0, 1, A0, C3) + pert; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local B1 = interpola1(4/9, 0, 1, A0, C3) + pert; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local A3 = ((A2 + B1) / 2) + pert; #local B0 = A3; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local B2 = interpola1(5/9, 0, 1, A0, C3) + pert; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local C1 = interpola1(7/9, 0, 1, A0, C3) + pert; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local B3 = ((B2 + C1) / 2) + pert; #local C0 = B3; #local pert = <(rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps, (rand(roll)-0.5)*ps>; #local C2 = interpola1(8/9, 0, 1, A0, C3) + pert; tentaculo(N, A0, A1, A2, B1, B2, C1, C2, C3, RA0, RC3) #end #macro virus() union{ sphere{<0,0,0>, 2 texture{tx_gray85} } tentaculo_aleatorio(100, 8629, <0,2,0>, <0,4,0>, 0.5, 0.01) tentaculo_aleatorio(100, 9011, <0, 2*cos(45), 2*sin(45)>, <0, 2*cos(45)+4, 2*sin(45)+2>, 0.5, 0.01) tentaculo_aleatorio(100, 9283, <0, -2*cos(45), 2*sin(45)>, <0, -2*cos(45)+1, 2*sin(45)+3>, 0.5, 0.01) tentaculo_aleatorio(100, 9479, <0, -2, 0>, <0, -4, 1>, 0.5, 0.01) tentaculo_aleatorio(100, 9533, <0, 2*cos(45), -2*sin(45)>, <-1, 2*cos(45)+2,-2*sin(45)-4>, 0.5, 0.01) tentaculo_aleatorio(100, 9721, <0, -2*cos(45), -2*sin(45)>, <5, -2*cos(45)-1, -2*sin(-45)-4>, 0.5, 0.01) } #end #include "eixos.inc" // Aqui est� a cena, finalmente: union{ //object{ eixos(20.00) translate <0, 0, 0> } object{ virus() } } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 0.00 >; #declare raio_cena = 8.0; #declare dir_camera = < 25.00, -6.00, 12.00 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)