// Last edited on 2023-12-23 01:27:53 by stolfi // Textures background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_objetos = texture{ pigment{ color rgb < 0.80, 0.75, 0.70 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_arestas = texture{ pigment{ color rgb < 0.70, 0.75, 0.80 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_conectores = texture{ pigment{ color rgb < 1.0, 1.0, 1.0 > } finish{ diffuse 0.9 ambient 0.1 } } // Objetos #declare raio_esferas = 3.0; #declare tamanho_conectores = 1; #declare raio_conectores = raio_esferas / 5; #declare prof_fix_size = false; #declare prof_fix_pos = false; #declare grau_1 = union { sphere { < 0.00, 0.00, 0.00 >, raio_esferas } // conector cylinder { < 0.00, raio_esferas, 0.00 >, < 0.00, raio_esferas + tamanho_conectores, 0.00 >, raio_conectores texture {tx_conectores} } #if (prof_fix_size) scale 0.333 #end } #declare grau_2 = union { cylinder{ < 0.00, 0.00, 0.00 >, < 0.00, 0.00, 6.00 >, raio_esferas } // conectores cylinder { < 0.00, 0.00, 0.00 >, < 0.00, 0.00, -(tamanho_conectores) >, raio_conectores texture {tx_conectores} } cylinder { < 0.00, 0.00, 6.00 >, < 0.00, 0.00, 6.00 + tamanho_conectores >, raio_conectores texture {tx_conectores} } #if (prof_fix_size) translate -3*z scale 0.333 translate 3*z #end #if (prof_fix_pos) translate -3*z #end } #declare grau_3 = union { box { < 0.00, 0.00, 0.00 >, < 6.00, 6.00, 6.00 > // near lower left corner, far upper right corner } cylinder { < 0.00, 3.00, 3.00 >, < -(tamanho_conectores), 3.00, 3.00>, raio_conectores texture {tx_conectores} } cylinder { < 3.00, 3.00, 6.00 >, < 3.00, 3.00, 6.00 + tamanho_conectores >, raio_conectores texture {tx_conectores} } cylinder { < 3.00, 6.00, 3.00 >, < 3.00, 6.00 + tamanho_conectores, 3.00 >, raio_conectores texture {tx_conectores} } #if (prof_fix_size) translate <-3,-3,-3> scale 0.333 translate <3,3,3> #end #if (prof_fix_pos) translate <-3,-3,-3> #end } #declare grau_4 = union { sphere { < 3.00, 3.00, 6.00 >, 4 } box { < 0.00, 0.00, 0.00 >, < 6.00, 6.00, 6.00 > // near lower left corner, far upper right corner } cylinder { < 3.00, 0.00, 3.00 >, < 3.00, -(tamanho_conectores), 3.00 >, raio_conectores texture {tx_conectores} } cylinder { < 3.00, 3.00, 0.00 >, < 3.00, 3.00, -(tamanho_conectores) >, raio_conectores texture {tx_conectores} } cylinder { < 3.00, 6.00, 3.00 >, < 3.00, 6.00 + tamanho_conectores, 3.00 >, raio_conectores texture {tx_conectores} } cylinder { < 3.00, 3.00, 10.00 >, < 3.00, 3.00, 10.00 + tamanho_conectores >, raio_conectores texture {tx_conectores} } #if (prof_fix_size) translate <-3,-3,-6> scale 0.333 translate <3,3,6> #end #if (prof_fix_pos) translate <-3,-3,-6> #end } #declare chao = box{ <-100,-100,-1>, <+100,+100,0> } // Macros #macro interpola1(ti, t0, v0, t1, v1) #local ss = (ti - t0)/(t1 - t0); #local vv = ((1 - ss) * v0) + (ss * v1); vv #end #macro interpola3(ti, ta, tb, v0, v1, v2, v3) #local v01 = interpola1(ti, ta, v0, tb, v1); #local v02 = interpola1(ti, ta, v1, tb, v2); #local v03 = interpola1(ti, ta, v2, tb, v3); #local v012 = interpola1(ti, ta, v01, tb, v02); #local v123 = interpola1(ti, ta, v02, tb, v03); #local v0123 = interpola1(ti, ta, v012, tb, v123); v0123 #end #macro test_interpola(p0, p1, p2, p3, n, raio) union{ #local k = 0; #while (k < n) #local centro = interpola3(k, 0, n, p0, p1, p2, p3); sphere{ centro, raio texture{ tx_arestas } } #local k = k + 1; #end } #end #macro interpola3_multi(tt, pini, n, p1, p2, pfim) #local raio = 0.15; // 0.5 Raio devia ser parâmetro. union{ #local q0 = pini; #local k = 0; #while (k; #local p2_x = tini.x*rand(my_seed); #local p2_y = tini.y*rand(my_seed); #local p2_z = tini.z*rand(my_seed); #local p2[i] = ; #end #for(i, div(na,2), na-1) #local p1_x = tfin.x*rand(my_seed); // Devia ser {D} ou {pfin} não {tfin}! --prof #local p1_y = tfin.y*rand(my_seed); #local p1_z = tfin.z*rand(my_seed); #local p1[i] = ; #local p2_x = tfin.x*rand(my_seed); #local p2_y = tfin.y*rand(my_seed); #local p2_z = tfin.z*rand(my_seed); #local p2[i] = ; #end interpola3_multi(nb, tini, na, p1, p2, tfin) #end #macro gera_grafo(nv, ne, org, dst, D, na, nb) union{ #local my_seed = seed(1773); // -- GERANDO VERTICES -- #local vertices = array[nv] #local vert_pos = array[nv] // calcula os graus de cada vertice #for(ie, 0, ne-1) #ifndef(vertices[dst[ie]]) #local vertices[dst[ie]] = 0; #end #ifndef(vertices[org[ie]]) #local vertices[org[ie]] = 0; #end #local vertices[org[ie]] = vertices[org[ie]] + 1; #local vertices[dst[ie]] = vertices[dst[ie]] + 1; #end // #debug concat("!!array = ", str(vertices[0], 0, 4), "\n") #for(i, 0, nv-1) #local vert_x = D*rand(my_seed); #local vert_y = D*rand(my_seed); #local vert_z = D*rand(my_seed); #local new_pos = ; #local vert_pos[i] = new_pos; #switch(vertices[i]) #case (0) sphere{ , raio_esferas texture {tx_objetos} } #break #case(1) object{ grau_1 texture {tx_objetos} translate new_pos // } #break #case(2) object{ grau_2 texture {tx_objetos} translate new_pos // } #break #case(3) object{ grau_3 texture {tx_objetos} rotate <0, 90, 0> // translate new_pos // } #break #case(4) object{ grau_4 texture {tx_objetos} rotate <0, 0, 45> // translate new_pos // } #break #end #end #for(ie, 0, ne-1) conector(3, 500, <0, 0, 0>, vert_pos[org[ie]], <0, 0, 0>, vert_pos[dst[ie]]) #end } #end #include "eixos.inc" // Cena #declare nv_grafo = 3; #declare ne_grafo = 4; #declare org = array[ne_grafo] {0, 0, 0, 1}; #declare dest = array[ne_grafo] {1, 2, 0, 1}; #declare D = 20; union{ // object{ eixos(25.00) } gera_grafo(nv_grafo, ne_grafo, org, dest, D, 1, 1) // object{ grau_1 texture {tx_objetos} } // object{ grau_2 texture {tx_objetos} translate < D, 0, 0> } // object{ grau_3 texture {tx_objetos} translate < 0, D, 0> } // object{ grau_4 texture {tx_objetos} translate < 0, 0, D> } } #declare cmin = < 0, 0, 0 >; #declare cmax = < D, D, D > + < 3, 3, 3 >; #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 = < 7.00, 3.00, 2.00 >; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)