// Felipe Marinho Tavares // R.A.: 265680 // Unicamp - MC937A/MO603A – Computação Gráfica - 2020-S2 - Jorge Stolfi // ====================================================================== // 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 } } // ====================================================================== // DESCRI��O DA CENA #declare node_r = 0.3; #declare edge_size = 0.03; #declare ball = sphere{ < 0,0,0 >, node_r texture { tx_woodish } } #declare start_ball = sphere{ < 0,0,0 >, node_r texture { tx_redish } } #declare roll = seed(47); // random seed #declare starting_dist_x = 10; // half X distance box for initial infected #declare starting_dist_y = 10; // half Y distance box for initial infected #declare dist_x = 1; // half X distance from parent node #declare dist_y = 1; // half Y distance from parent node #macro arvore(P, S, A, B, T) // P: point coord // S: infection ratio // A: min time to infect // B: max time to infect // T: time limit, units in the Z axis union{ #if (P.z < T) #if (P.z = 0) object{start_ball translate } #else object{ball translate } #end #local QQ = S / (S + 1); #while(rand(roll) < QQ) #local time_infected = P.z + rand(roll) * (B - A) + A; #if (time_infected < T) #local coord_x = P.x + (2 * rand(roll) - 1) * dist_x; #local coord_y = P.y + (2 * rand(roll) - 1) * dist_y; object{ cylinder{ < P.x, P.y, P.z >, , edge_size texture{ tx_redish } } } arvore(, S, A, B, T) #end #end #end } #end #macro diagrama(N, S, A, B, T) // N: number of trees // S: infection ratio // A: min time to infect // B: max time to infect // T: time limit, units in the Z axis union{ #local starting_infected = 0; #while(starting_infected < N) #local coord_x = (2 * rand(roll) - 1) * starting_dist_x; #local coord_y = (2 * rand(roll) - 1) * starting_dist_y; arvore(, S, A, B, T) #local starting_infected = starting_infected + 1; #end } #end #include "eixos.inc" // Aqui est� a cena, finalmente: union{ object{ eixos(4.00) translate <0, 0, 0> } object{ diagrama(5, 0.85, 1, 2, 30) translate <0, 0, 0> } } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 5.00 >; #declare raio_cena = 20.0; #declare dir_camera = < 14.00, 7.00, 5.00 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)