// MC930 - Laboratorio 5 - Parte 2 // Martim Carbone - RA:002193 #include "colors.inc" light_source { <9, 3, -40> color rgb <0.7, 0.7, 0.7>} light_source { <3, 9, -40> color rgb <0.7, 0.7, 0.7>} background{ color rgb < 0.5,0.5, 0.7 > } camera { location <6, 6, -15> look_at <6, 6, 0> sky <0,1,0> } #declare fonte = seed(27118); // qq coisa // Nós da grade #declare yno = 0; #while (yno <= 12) #declare xno = 0; #while (xno <= 12) sphere { , 0.5 texture{pigment{Red}} } #declare xno = xno + 3; #end #declare yno = yno + 3; #end // Arestas horizontais #declare yar = 0; #while (yar <= 12) #declare xar = 0.5; #while (xar <= 10.5) cylinder { , ,0.1 texture{pigment{Green}} } #declare xar = xar + 3; #end #declare yar = yar + 3; #end // Arestas verticais #declare yar = 0.5; #while (yar <= 10.5) #declare xar = 0; #while (xar <= 12) cylinder { , ,0.1 texture{pigment{Green}} } #declare xar = xar + 3; #end #declare yar = yar + 3; #end #declare t1 = clock/0.5; #declare t2 = (clock-0.5)/0.5; // Os pacotes irão "nascer" em regiões aleatórias das arestas e farão uma viajem de ida e volta // em direção ao nó que estiver mais distante. Se por acaso nascerem no ponto médio da aresta, viajarão // para o nó logo acima/a direita // Pacotes nas arestas horizontais #declare yar = 0; #while (yar <= 12) #declare xar = 0.5; #while (xar <= 10.5) #declare pacote_x = xar + 2*rand(fonte); #declare pacote_y = yar; #declare pacote_cor = <0.8*rand(fonte)+0.2,0.8*rand(fonte)+0.2,0.8*rand(fonte)+0.2>; #declare pacote_tipo = rand(fonte); #if (clock<=0.5) #if ((pacote_x-xar)<=1) #declare pacote_x_anim = ((1-t1)*pacote_x)+(t1*(xar+2)); #else #declare pacote_x_anim = ((1-t1)*pacote_x)+(t1*xar); #end #else #if ((pacote_x-xar)<=1) #declare pacote_x_anim = ((1-t2)*(xar+2))+(t2*pacote_x); #else #declare pacote_x_anim = ((1-t2)*xar)+(t2*pacote_x); #end #end #if (pacote_tipo<0.33) // desenha esfera sphere{ , 0.25 texture{pigment{color rgb pacote_cor}} finish { ambient 0.05 diffuse 0.2 reflection pacote_cor specular 0.80 roughness 0.05 metallic } } #else #if ((pacote_tipo>=0.33) & (pacote_tipo<0.66)) // desenha cone cone{ , 0.2, , 0 texture{pigment{color rgb pacote_cor}} finish { ambient 0.05 diffuse 0.2 reflection pacote_cor specular 0.80 roughness 0.05 metallic } } #else // desenha caixa box { , texture{pigment{color rgb pacote_cor}} finish { ambient 0.05 diffuse 0.2 reflection pacote_cor specular 0.80 roughness 0.05 metallic } } #end #end #declare xar = xar + 3; #end #declare yar = yar + 3; #end // Pacotes nas arestas verticais #declare yar = 0.5; #while (yar <= 10.5) #declare xar = 0; #while (xar <= 12) #declare pacote_x = xar; #declare pacote_y = yar + 2*rand(fonte); #declare pacote_cor = <0.4*rand(fonte)+0.4,0.4*rand(fonte)+0.4,0.4*rand(fonte)+0.4>; #declare pacote_tipo = rand(fonte); #if (clock<=0.5) #if ((pacote_y-yar)<=1) #declare pacote_y_anim = ((1-t1)*pacote_y)+(t1*(yar+2)); #else #declare pacote_y_anim = ((1-t1)*pacote_y)+(t1*yar); #end #else #if ((pacote_y-yar)<=1) #declare pacote_y_anim = ((1-t2)*(yar+2))+(t2*pacote_y); #else #declare pacote_y_anim = ((1-t2)*yar)+(t2*pacote_y); #end #end #if (pacote_tipo<0.33) // desenha esfera sphere{ , 0.25 texture{pigment{color rgb pacote_cor}} finish { ambient 0.05 diffuse 0.2 reflection pacote_cor specular 0.80 roughness 0.05 metallic } } #else #if ((pacote_tipo>=0.33) & (pacote_tipo<0.66)) // desenha cone cone{ , 0.2, , 0 texture{pigment{color rgb pacote_cor}} finish { ambient 0.05 diffuse 0.2 reflection pacote_cor specular 0.80 roughness 0.05 metallic } } #else box { , texture{pigment{color rgb pacote_cor}} // desenha caixa finish { ambient 0.05 diffuse 0.2 reflection pacote_cor specular 0.80 roughness 0.05 metallic } } #end #end #declare xar = xar + 3; #end #declare yar = yar + 3; #end