// Desenho do vírus com tentáculos // Last edited on 2020-12-08 11:45:04 by jstolfi #version 3.6; // ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_roxo = texture{ pigment{ color rgb < 0.80, 0.20, 0.80 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_verde = texture{ pigment{ color rgb < 0.20, 0.70, 0.20 > } finish{ diffuse 0.9 ambient 0.1 } } // ====================================================================== // DESCRICAO // Partes 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(p0, p1, p2, p3, n, r0, rn) union{ #local tt = 0; #while(tt < n) #local r = interpola1(tt, 0, n-1, r0, rn); #local px = interpola3(tt, 0, n-1, p0.x, p1.x, p2.x, p3.x); #local py = interpola3(tt, 0, n-1, p0.y, p1.y, p2.y, p3.y); #local pz = interpola3(tt, 0, n-1, p0.z, p1.z, p2.z, p3.z); sphere{, r texture{tx_verde} } #local tt = tt+1; #end } #end #macro tentaculo(p0, p1, p2, p4, p5, p7, p8, p9) union{ #local p3 = <(p2.x+p4.x)/2.0, (p2.y+p4.y)/2.0, (p2.z+p4.z)/2.0>; #local p6 = <(p5.x+p7.x)/2.0, (p5.y+p7.y)/2.0, (p5.z+p7.z)/2.0>; object{segmento(p0,p1,p2,p3,90,1.0,0.66)} object{segmento(p3,p4,p5,p6,90,0.66,0.33)} object{segmento(p6,p7,p8,p9,90,0.33,0.01)} } #end #macro tentaculo_rand(a0, c3, ss) union{ #declare roleta = seed(ss); #local tx = array[10]; #local ty = array[10]; #local tz = array[10]; #local j = 1; #while(j < 9) #local tx[j] = a0.x + (c3.x - a0.x)*j/9.0 + (rand(roleta)-0.5)*10.0; #local ty[j] = a0.y + (c3.y - a0.y)*j/9.0 + (rand(roleta)-0.5)*10.0; #local tz[j] = a0.z + (c3.z - a0.z)*j/9.0 + (rand(roleta)-0.5)*10.0; #local j = j+1; #end object{tentaculo(a0,,,,,,,c3)} } #end #macro virus() union{ box{ <0,0,0>, <6,6,6> texture{tx_roxo} } object{tentaculo_rand(<3, 3, 0>, <3, 3, -24>, 125)} object{tentaculo_rand(<3, 3, 6>, <3, 3, 30>, 123)} object{tentaculo_rand(<3, 0, 3>, <3, -24, 3>, 127)} object{tentaculo_rand(<3, 6, 3>, <3, 30, 3>, 129)} object{tentaculo_rand(<0, 3, 3>, <-24, 3, 3>, 131)} object{tentaculo_rand(<6, 3, 3>, <30, 3, 3>, 133)} } #end #include "eixos.inc" // Aqui esta a cena, finalmente: union{ object{virus()} } #include "camlight.inc" #declare centro_cena = < 3.00, 3.00, 3.00 >; #declare raio_cena = 35.0; #declare dir_camera = < 2.00, 2.00, 1.50 >; #declare dist_camera = 15*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)