// Felipe Marinho Tavares // R.A.: 265680 // Unicamp - MC937A/MO603A – Computação Gráfica - 2020-S2 - Jorge Stolfi // Last edited on 2020-12-08 11:03:37 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_floor = texture{ pigment{ color rgb < 1.000, 0.900, 0.850 > } 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(1249); // random seed #declare raio_x = 10; // half X distance box for initial infected #declare raio_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); #debug concat("!! QQ = ", str(QQ,0,4), "\n") #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) * raio_x; #local coord_y = (2 * rand(roll) - 1) * raio_y; arvore(, S, A, B, T) #local starting_infected = starting_infected + 1; #end box{ < -raio_x, -raio_y, 0 >, < +raio_x, +raio_y, -0.1 > texture{ tx_floor } } } #end #include "eixos.inc" #declare Tmax = 30; union{ // object{ eixos(4.00) translate <0, 0, 0> } object{ diagrama(10, 0.80, 1, 2, Tmax) translate < -1.4*raio_x, +2.4*raio_y, 0 > } object{ diagrama(10, 1.00, 1, 2, Tmax) translate < 0, 0, 0 > } object{ diagrama(10, 1.25, 1, 2, Tmax) translate < +1.4*raio_x, -2.4*raio_y, 0 > } } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, Tmax/2 >; #declare raio_cena = 2*vlength(< 1.4*raio_x, 2.4*raio_y, Tmax/2 >); #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)