// Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2020-09-30 19:57:13 by jstolfi // ====================================================================== // CORES E TEXTURAS #declare semente = seed(43); #declare M = 500; #declare N = 500; #declare A = array[M*N]; #declare num_ponta_tanque = 0; background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_plastico = texture{ pigment{ color rgb < 0.10, 0.80, 1.00 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_fosca = texture{ pigment{ color rgb < 1.00, 0.80, 0.10 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_verde = texture{ pigment{ color rgb < 0.20, 0.99, 0.20 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_vermelho = texture{ pigment{ color rgb < 1.00, 0.01, 0.20 > } finish{ diffuse 0.9 ambient 0.1 } } #declare tx_espelho = texture{ pigment{ color rgb < 1.00, 0.85, 0.30 > } finish{ diffuse 0.2 reflection 0.7*< 1.00, 0.85, 0.30 > ambient 0.1 } } #declare tx_vidro = texture{ pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 } finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 } } #declare tx_xadrez = texture{ pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > } finish{ diffuse 0.9 ambient 0.1 } scale 2.0 } // ====================================================================== // DESCRI��O DA CENA #declare raio = 2.000; // Partes da cena: #declare chao = box{ <-200,-200,-1>, <+200,+200,0> } #include "eixos.inc" #macro gera_tanque1(xx, yy, zz) union { sphere { , 1 // , radius texture {tx_plastico} } cylinder { , <2+xx, yy, zz>, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_verde} } } #end #macro gera_tanques2(xx, yy, zz) union { #local p1 = ; #local q1 = ; #local q2 = <2+xx, yy, zz+0.7>; #local q3 = ; #declare A[num_ponta_tanque] = q1; #declare num_ponta_tanque = num_ponta_tanque + 1; box { , // near lower left corner, far upper right corner texture {tx_plastico} } cone { , 0.25 // , center & radius of one end , 1 // , center & radius of the other end texture {tx_plastico} } cylinder { , q1, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } cylinder { , q2, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } cylinder { , q3, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } } #end #macro gera_tanquesB(xx, yy) union { #local p1 = ; #local q1 = ; #local q2 = <2+xx, yy, 0.7>; #local q3 = ; #declare A[num_ponta_tanque] = q1; #declare num_ponta_tanque = num_ponta_tanque + 1; cylinder { , , 1 // center of one end, center of other end, radius texture {tx_plastico} } box { , // near lower left corner, far upper right corner texture {tx_plastico} } cylinder { , , 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } cylinder { , <2+xx, yy, 0.7>, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } cylinder { , , 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } } #end #macro gera_tanques3(xx, yy, zz) union { #local p1 = ; #local q1 = ; #local q2 = <2+xx, yy, 0.7+zz>; #local q3 = ; #declare A[num_ponta_tanque] = q1; #declare num_ponta_tanque = num_ponta_tanque + 1; box { , // near lower left corner, far upper right corner texture {tx_plastico} } sphere { , 1 // , radius texture {tx_plastico} } cylinder { , , 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } cylinder { , <2+xx, yy, 0.7+zz>, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_verde} } cylinder { , , 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } } #end #macro gera_tanques4(xx, yy, zz) union { #local p1 = ; #local q1 = ; #local q2 = <2+xx, yy, 0.7+zz>; #local q3 = ; #declare A[num_ponta_tanque] = q1; #declare num_ponta_tanque = num_ponta_tanque + 1; box { , // near lower left corner, far upper right corner texture {tx_plastico} } sphere { , 1 // , radius texture {tx_plastico} } cylinder { , , 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } cylinder { , <2+xx, yy, 0.7+zz>, 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_verde} } cylinder { , , 0.1 // center of one end, center of other end, radius open // remove end caps texture {tx_fosca} } } #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(p0, p1, n, raio) union { #local n_atual = 0; #while(n_atual, radius texture {tx_fosca} } #local n_atual = n_atual +1; #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_interpola3(p0, p1, n, raio, v1, v2, ta, tb) union { #local n_atual = 0; #while(n_atual, radius texture {tx_fosca} } #local n_atual = n_atual + 0.01; #end } #end #macro calcula_ponto_medio(pontoA, pontoB) #local ponto_medio = (pontoA + pontoB) / 2; ponto_medio #end #macro interepola3_multi(tt, p_ini, n, p1, p2, p_fim) #local k = int(tt); // #local q3 = #if(k = 0) #local q0 = p_ini; #else #local q0 = (p2[k-1] + p1[k])/2; #end #if(k = (n-1)) #local q3 = p_fim; #else #local q3 = calcula_ponto_medio(p2[k], p1[k+1]); #end #local resultado = interpola3(tt, k, k+1, q0, p1[k], p2[k], q3); resultado #end #macro testa_interpola3_multi() #local p_inicial = <0,0,0>; #local p_final = <5,0,3>; #local n = 3; #local raio = 0.1; #local P1 = array[n]; #local P1[0] = <5,0,0>; #local P1[1] = <3,0,8>; #local P1[2] = <6,0,4>; #local P2 = array[n]; #local P2[0] = <3,0,5>; #local P2[1] = <8,0,5>; #local P2[2] = <5,0,2>; #local t_atual = 0; union { #while(t_atual < n) #local posicao_centro = interepola3_multi(t_atual, p_inicial, n, P1, P2, p_final); sphere { posicao_centro, raio // , radius texture {tx_fosca} } #local t_atual = t_atual+0.001; #end } #end // object{testa_interpola3_multi()} // object{testa_interpola(<0,0,0>, <10,10,10>, 10, 0.5)} #macro gera_conexao_entre_tanques(posicao_tanque_A, posicao_tanque_B, n, curva1, curva2) union { #local ta = 0; #local tb = 10; #local raio = 0.1; gera_tanque1(posicao_tanque_A.x, posicao_tanque_A.y, posicao_tanque_A.z) gera_tanques3(posicao_tanque_B.x, posicao_tanque_B.y, posicao_tanque_B.z) box { , // near lower left corner, far upper right corner } box { , // near lower left corner, far upper right corner } //<2+xx, yy, 0.7+zz> #local ponta_tanque3 = ; //<2+xx, yy, zz> #local ponta_tanque1 = <2+posicao_tanque_A.x, posicao_tanque_A.y, posicao_tanque_A.z>; #local n_atual = 0; #while(n_atual, radius texture {tx_fosca} } #local n_atual = n_atual + 0.01; #end } #end // object{gera_conexao_entre_tanques(<2,5,1>, <0,7,3>, 10, <10,5,1>, <10,0,5>)} // object {testa_interpola3(<0,0,0>, <10,10,10>, 500, 0.05, <10,3,5>, <7,2,9>, 0, 10)} #macro gera_tanques_grade(m, n) #local tipo_tanque = int(3*rand(semente)); #if(tipo_tanque = 0) object {gera_tanquesA(m, n)} #end #if(tipo_tanque = 1) object {gera_tanquesB(m, n)} #end #if(tipo_tanque = 2) object {gera_tanquesC(m, n)} #end #end #macro conector(na, p_inicial, t_inicial, p_fim, t_fim, D, nb) #local P1 = array[na]; #local P2 = array[na]; #local posicao_atual_vetor = 0; #while(posicao_atual_vetor < na) #local P1[posicao_atual_vetor] = ; #local P2[posicao_atual_vetor] = ; #local posicao_atual_vetor = posicao_atual_vetor + 1; #end #local P1[0] = p_inicial; #local P2[na-1] = p_fim; union { //(tt, p_ini, n, p1, p2, p_fim) // interepola3_multi(, ) #local tt = t_inicial; #while(tt < t_fim) #local centro_esfera = interepola3_multi(tt, p_inicial, 3, P1, P2, p_fim); sphere { centro_esfera, 0.5 // , radius texture { tx_vermelho } } #local tt = tt + 0.1; #end } #end #macro conta_grau_vertice(org, dst, tamanho_vetor, vertice_em_analise) #local grau = 0; #local posicao_atual_vetor = 0; #while(posicao_atual_vetor < tamanho_vetor) #if(vertice_em_analise = org[posicao_atual_vetor]) #local grau = grau + 1; #end #if(vertice_em_analise = dst[posicao_atual_vetor]) #local grau = grau + 1; #end #local posicao_atual_vetor = posicao_atual_vetor + 1; #end grau #end #macro gera_grafo(nv, ne, org, dst, D, na, nb) //nv numero de vertices //ne numero de arestas / edges //org no origem //dst no destino //posicao no array e a arresta //D tamanho //na tamanho de arcos //nb quantidade de esferas union { #local vertice_atual = 0; #local xyz_vertice = array[nv]; #while(vertice_atual < nv) #local grau_vertice_atual = conta_grau_vertice(org, dst, nv, vertice_atual); #local x_aleatorio = rand(semente) * D; #local y_aleatorio = rand(semente) * D; #local z_aleatorio = rand(semente) * D; #local xyz_vertice[vertice_atual] = ; #if(grau_vertice_atual = 1) gera_tanque1(x_aleatorio, y_aleatorio, z_aleatorio) #elseif(grau_vertice_atual = 2) gera_tanques2(x_aleatorio, y_aleatorio, z_aleatorio) #elseif(grau_vertice_atual = 3) gera_tanques3(x_aleatorio, y_aleatorio, z_aleatorio) #elseif(grau_vertice_atual = 4) gera_tanques2(x_aleatorio, y_aleatorio, z_aleatorio) #end #local vertice_atual = vertice_atual + 1; #end // #local vertice_atual = 0; // #while(vertice_atual < nv) // conector(4, ) // #local vertice_atual = vertice_atual + 1; // #end //(na, p_inicial, t_inicial, p_fim, t_fim, D, nb) conector(3, <2,2,2>,0, <5,7,8>, 3, D, nb ) } #end // #macro gera_tubulacoes(p, q) // union { // cylinder { // p, , 0.1 // center of one end, center of other end, radius // } // } // #end // Aqui est� a cena, finalmente: // #declare m_atual = 0; // #while(m_atual < M) // #declare n_atual = 0; // #while(n_atual < N) // object {gera_tanques_grade(m_atual, n_atual)} // #declare n_atual = n_atual + 10; // #end // #declare m_atual = m_atual + 10; // #end // #declare ponta_tanque_atual = 0; // #while(ponta_tanque_atual < M*N) // object{gera_tubulacoes(ponta_tanque_atual, ponta_tanque_atual)} // #declare ponta_tanque_atual = ponta_tanque_atual + 1; // #end union{ object{ eixos(3.00) } object{ chao translate < 0,0,-5 > texture{ tx_xadrez } } #local nv = 4; #local ne = 6; #local org = array[ne]{0,2,2,3,1,3}; //0,2,2,3,1,3 #local dst = array[ne]{2,0,1,0,3,3}; //2,0,1,0,3,3 // #local posicao_atual_vetor_fill = 0; // #while(posicao_atual_vetor_fill < nv) // #local org[posicao_atual_vetor_fill] = // #end #local D = 15; #local na = 0; #local nb = 0; object{gera_grafo(nv, ne, org, dst, D, na, nb)} } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 10.00 >; #declare raio_cena = 30.0; #declare dir_camera = < 20.00, 17.00, 4.00 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)