// Last edited on 2023-12-23 04:01:29 by stolfi background{ color rgb < 0.910, 0.830, 0.800 > } // ====================================================================== // CORES E TEXTURAS #declare tx_fosca = texture{ pigment{ color rgb < 0.00, 0.50, 0.90 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_tubo = texture{ pigment{ color rgb < 0.3, 0.3, 0.3 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_base = texture{ pigment{ color rgb < 1.00, 1.0, 1.0 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_base_preta = texture{ pigment{ color rgb < 0, 0, 0 > } finish{ diffuse 0.9 ambient 0.1 } } // ====================================================================== // DESCRI��O DA CENA #declare tamanho_tanques = 2.0; #declare esp_cano = 0.1; #declare tam_cano = 0.25 * tamanho_tanques; #macro cano(comprimento) cylinder { <0, 0, 0> esp_cano texture{tx_tubo} } #end // tanque 1 #declare base_tanque1 = difference { sphere { <0, 0, 0>, tamanho_tanques * 0.5 } box{ <-5 * tamanho_tanques, -5 * tamanho_tanques,0>, <5 * tamanho_tanques, 5 * tamanho_tanques, -5 * tamanho_tanques> } } # declare tam_topo_t1 = 0.25 * tamanho_tanques; #declare topo_tanque1 = box{ <0,0,0>, } #declare v_grau1 = union { sphere { <0, 0, 0>, tamanho_tanques * 0.5 texture{tx_fosca} } object{cano(tam_cano) translate} } // tanque 2 # declare quina_t2 = tamanho_tanques * 0.3; # declare base_tanque2 = difference { box{ <0,0,0>, } union { box{ } box{ <-5, tamanho_tanques + 5, tamanho_tanques + 5> } box{ <-5, -5, tamanho_tanques + 5> } box{ } } } #declare v_grau2 = union { cone { <0, 0, 0>, tamanho_tanques * 0.5 // Center and radius of one end <0, 0, 0.5 * tamanho_tanques >, 0.3 * tamanho_tanques // Center and radius of other end texture{ tx_fosca } } cone { <0, 0, 0.5 * tamanho_tanques>, 0.3 * tamanho_tanques // Center and radius of one end <0, 0, tamanho_tanques >, 0.5 * tamanho_tanques // Center and radius of other end texture{ tx_fosca } } object{cano(tam_cano) translate<0.4 * tamanho_tanques, 0, 0.25 * tamanho_tanques>} object{cano(tam_cano) translate<0.4 * tamanho_tanques, 0, 0.75 * tamanho_tanques> rotate <0, 0, 180>} } #declare v_grau3 = union { object{base_tanque1 texture{tx_fosca}} object{topo_tanque1 texture{tx_fosca} translate <- 0.5 * tam_topo_t1,- 0.5 * tam_topo_t1, tamanho_tanques * 0.4>} #for (ncount, 0, 1) object{cano(tam_cano) translate<0.4 * tamanho_tanques, 0, 0.2 * tamanho_tanques> rotate <0, 0, (360 / 2) * ncount>} #end object{cano(tam_cano) translate rotate<0, 0, 90>} } #declare v_grau4 = union { object{base_tanque2 texture{tx_fosca}} cylinder{ quina_t2 texture{tx_fosca} } cylinder{ quina_t2 texture{tx_fosca} } cylinder{ quina_t2 texture{tx_fosca} } cylinder{ quina_t2 texture{tx_fosca} } #for (ncount, 0, 3) object{cano(tam_cano) translate<0.5 * tamanho_tanques, 0, 0.5 * tamanho_tanques> rotate <0, 0, (360 / 4) * ncount> translate<0.5 * tamanho_tanques, 0.5 * tamanho_tanques>} #end } #macro interpola1(tt, t0, v0, t1, v1) #local ss = (tt - t0)/(t1 - t0); #local vv = (1 - ss) * v0 + ss * v1; vv #end #macro testa_interpola_1(p0, p1, n, raio_) union { #for (k, 0, n) #local centro = interpola1(k, 0, p0, n, p1); object{sphere{ centro raio_ } texture{tx_fosca}} #end } #end #macro interpola3(tt, ta, tb, v0, v1, v2, v3) #local v01 = interpola1(tt, ta, v0, tb, v1); #local v12 = interpola1(tt, ta, v1, tb, v2); #local v23 = interpola1(tt, ta, v2, tb, v3); #local v012 = interpola1(tt, ta, v01, tb, v12); #local v123 = interpola1(tt, ta, v12, tb, v23); #local v0123 = interpola1(tt, ta, v012, tb, v123); v0123 #end #macro testa_interpola_3(p0, p1, p2, p3, n, raio_) union { #for (k, 0, n) #local centro = interpola3(k, 0, n, p0, p1, p2, p3); object{sphere{ centro raio_ } texture{tx_tubo}} #end } #end #macro interpola3_multi(tt, pini, n, p1, p2, pfim) #local k = int(tt); #if (k = 0) #local q0 = pini; #else #local q0 = (p2[k - 1] + p1[k]) / 2; #end #if (k = (n - 1)) #local q3 = pfim; #else #local q3 = (p2[k] + p1[k + 1]) / 2; #end #local q1 = p1[k]; #local q2 = p2[k]; interpola3(tt, k, k + 1, q0, q1, q2, q3) #end #macro testa_interpola_3_multi(p_ini, p_fim, p1, p2, n, nb) union { #for (i, 0, n - 1) #local centro = interpola3_multi((i / (nb/n)), p_ini, n, p1, p2, p_fim); object{sphere{ centro 0.1 } texture{tx_tubo}} #end } #end #macro gera_vertice(deg, pos) #if (deg = 1) object {v_grau1 translate pos} #end #if (deg = 2) object {v_grau2 translate pos} #end #if (deg = 3) object {v_grau3 translate pos} #end #if (deg = 4) object {v_grau4 translate pos} #end #end #declare roleta1 = seed(3); #macro conetor(na, p_ini, t_ini, p_fim, t_fim, D, nb) #local p1 = array[na]; #local p2 = array[na]; #local p1[0] = t_ini; #local p2[na - 1] = t_fim; #for (j, 1, na - 1) #local p1[j] = ; #end #for (j, 0, na - 2) #local p2[j] = ; #end union { #for (i, 0, nb - 1) #local centro = interpola3_multi((i / (nb/na)), p_ini, na, p1, p2, p_fim); object{sphere{ centro 0.1 } texture{tx_tubo}} #end } #end #macro gera_grafo(nv, ne, org, dst, D, na, nb) #local deg = array[nv] #local pos = array[nv] #for (i, 0, nv - 1) #local deg[i] = 0; #end // calcula os graus #for (i, 0, ne - 1) #local deg[org[i]] = deg[org[i]] + 1; #local deg[dst[i]] = deg[dst[i]] + 1; #end union { #for (j, 0, nv - 1) #local pos[j] = ; gera_vertice(deg[j], pos[j]) #end conetor(na, <-10, -10, -10>, <-9, -10, -10>, < 10, 10, 10>, <9, 10, 10>, D, nb) } #end #declare nv_grafo = 6; #declare ne_grafo = 7; #declare D = 15; #macro testa_gera_grafo() #local org = array[ne_grafo]; #local org[0] = 0; #local org[1] = 1; #local org[2] = 1; #local org[3] = 2; #local org[4] = 2; #local org[5] = 3; #local org[6] = 4; #local dst = array[ne_grafo]; #local dst[0] = 1; #local dst[1] = 2; #local dst[2] = 4; #local dst[3] = 4; #local dst[4] = 3; #local dst[5] = 4; #local dst[6] = 5; gera_grafo(nv_grafo, ne_grafo, org, dst, D, 7, 1000) #end // Cena union { object{testa_gera_grafo()} } #declare cmin = < 0, 0, 0 >; #declare cmax = < D, D, D >; #include "gaiola.inc" // object{ gaiola(cmin,cmax) } #declare centro_cena = (cmin + cmax)/2; #declare raio_cena = 0.65*vlength(cmax-cmin); #declare dist_camera = 7*raio_cena; #include "camlight.inc" #declare dir_camera = < 10.00, 7.00, 4 >; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)