// CORES E TEXTURAS // background{ color rgb < 0.75, 0.80, 0.85 > } background{ color rgb < 0.90, 0.20, 0.85 > } #declare tx_tanque = texture{ pigment{ color rgb < 0.7, 0.50, 0.40 > } //finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_pecas = texture{ pigment{ color rgb < 1.00, 0.80, 0.10 > } 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 } finish{ diffuse 0.2 reflection 1.0*< 1.00, 1.00, 1.00 > 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 } ///////////////////////////////////////////////////////////////////////////////////////////// // DESCRICAO DA CENA #include "eixos.inc" #declare vertice2 = union{ cylinder{ < +1.00, +1.00, +0.00 >, < +1.00, +1.00, +2.00 >, 1.0 texture{ tx_tanque } } cone{ < +1.00, +1.00, +2.00 >, 1.0, < +1.00, +1.00, +4.00 >, 0.5 texture{ tx_tanque } } cylinder{ < +1.00, +1.90, +1.00 >, < +1.00, +2.25, +1.00 >, 0.1 texture{ tx_tanque } } cylinder{ < +1.00, +0.10, +1.00 >, < +1.00, -0.25, +1.00 >, 0.1 texture{ tx_tanque } } } #declare vertice3 = union{ cylinder{ < +1.00, +1.00, +0.00 >, < +1.00, +1.00, +2.00 >, 1.0 texture{ tx_tanque } } cone{ < +1.00, +1.00, +2.00 >, 1.0, < +1.00, +1.00, +4.00 >, 0.5 texture{ tx_tanque } } cylinder{ < +1.00, +1.90, +1.00 >, < +1.00, +2.25, +1.00 >, 0.1 texture{ tx_tanque } } cylinder{ < +1.00, +0.10, +1.00 >, < +1.00, -0.25, +1.00 >, 0.1 texture{ tx_tanque } } cylinder{ < +1.90, +1.00, +1.00 >, < +2.25, +1.00, +1.00 >, 0.1 texture{ tx_tanque } } } #declare vertice4 = union{ cylinder{ < +1.00, +1.00, +0.00 >, < +1.00, +1.00, +2.00 >, 1.0 texture{ tx_tanque } } cone{ < +1.00, +1.00, +2.00 >, 1.0, < +1.00, +1.00, +4.00 >, 0.5 texture{ tx_tanque } } cylinder{ < +1.00, +1.90, +1.00 >, < +1.00, +2.25, +1.00 >, 0.1 texture{ tx_tanque } } cylinder{ < +1.00, +0.10, +1.00 >, < +1.00, -0.25, +1.00 >, 0.1 texture{ tx_tanque } } cylinder{ < +1.90, +1.00, +1.00 >, < +2.25, +1.00, +1.00 >, 0.1 texture{ tx_tanque } } cylinder{ < +0.10, +1.00, +1.00 >, < -0.25, +1.00, +1.00 >, 0.1 texture{ tx_tanque } } } ////////////////////////////////////////////////////////////////////////////////////////////////// // Aqui esta a cena, finalmente: //object{ tanque1 // translate < 0.0, -5.0, 0.0 > // } //object{ tanque2 // translate < 0.0, +5.0, 0.0 > // } //object{ tanque3 // translate < 5.0, 0.0, 0.0 > // } #macro interpola1(tt, t0, t1, p0, p1) #local ss = (tt - t0) / (t1 - t0); #local xx = (1 - ss) * p0.x + (ss * p1.x); #local yy = (1 - ss) * p0.y + (ss * p1.y); #local zz = (1 - ss) * p0.z + (ss * p1.z); #local ponto = < xx, yy, zz >; ponto #end #macro testa_interpola1(p0, p1, n, raio) #local tt = 0; #while (tt < n) #local ponto = interpola1(tt, 0, n-1, p0, p1); sphere{ ponto, raio texture { tx_tanque } } #local tt = tt + 1; #end #end //testa_interpola1(<0, 0, 0>, <30, 0, 0>, 5, 1) #macro interpola3(tt, t0, t1, v0, v1, v2, v3) #local v01 = interpola1(tt, t0, t1, v0, v1); #local v12 = interpola1(tt, t0, t1, v1, v2); #local v23 = interpola1(tt, t0, t1, v2, v3); #local v012 = interpola1(tt, t0, t1, v01, v12); #local v123 = interpola1(tt, t0, t1, v12, v23); #local v0123 = interpola1(tt, t0, t1, v012, v123); v0123 #end #macro testa_interpola3() #local tt = 0; #while (tt < 1) #local ponto = interpola3(tt, 0, 1, < 0, 0, 0 >, < 0, 5, 0 >, < -5, 5, 0 >, < -5, 5, 5 >); sphere{ ponto, 1 texture { tx_tanque } } #local tt = tt + 0.001; #end #end //testa_interpola3() #macro interpola3_multi(tt, n, p_ini, p_fin, p1, p2) #local k = int(tt); #local v1 = p1[k]; #local v2 = p2[k]; #if (k = 0) #local v0 = p_ini; #local v3 = (p2[0] + p1[1]) / 2; #end #if (k = n - 1) #local v0 = (p2[k-1] + p1[k]) / 2; #local v3 = p_fin; #end #if (k > 0 & k < n-1) #local v0 = (p2[k-1] + p1[k]) / 2; #local v3 = (p2[k] + p1[k+1]) / 2; #end #local ponto = interpola3(tt, k, k+1, v0, v1, v2, v3); ponto #end #macro testa_interpola3_multi() #local p_ini = < 0, 0, 0 >; #local p_fin = < 10, 5, 10 >; #local n = 3; #local p1 = array[n]; #local p2 = array[n]; #local p1[0] = < 3, 3, 5 >; #local p2[0] = < 4, 4, 5 >; #local p1[1] = < 7, 4, 5 >; #local p2[1] = < 7, 0, 5 >; #local p1[2] = < 10, 0, 10 >; #local p2[2] = < 9, 3, 8 >; union{ #local tt = 0; #local delta_tt = 0.001; #local raio = 1; #while (tt < n) #local ponto = interpola3_multi(tt, n, p_ini, p_fin, p1, p2); sphere{ ponto, raio texture { tx_tanque } } #local tt = tt + delta_tt; #end } #end //testa_interpola3_multi() #macro gera_grafo(nv, ne, org, dst, D, na, nb) #local roleta = seed( 31159 ); #local deg = array[nv] // Calcula o grau deg[i] de cada vertice #for (i, 0, nv-1) #local deg[i] = 0; #end #for (i, 0, ne-1) #local deg[org[i]] = deg[org[i]] + 1; #local deg[dst[i]] = deg[dst[i]] + 1; #end // Cria os vertices #local C = array[nv] #for (i, 0, nv-1) #local i_vert = 1 + int(nv*rand(roleta)); #local j_vert = 1 + int(nv*rand(roleta)); #local k_vert = 1 + int(nv*rand(roleta)); #local x_vert = i_vert * D / (nv+1); #local y_vert = j_vert * D / (nv+1); #local z_vert = k_vert * D / (nv+1); #local C[i] = < x_vert, y_vert, z_vert>; #end // Cria os objetos nos respectivos vertices #for (i, 0, nv-1) #if (deg[i] = 2) object{ vertice2 translate C[i] } #end #if (deg[i] = 3) object{ vertice3 translate C[i] } #end #if (deg[i] = 4) object{ vertice4 translate C[i] } #end #end #end #macro testa_gera_grafo () #local nv = 4; #local ne = 6; #local org = array[6]{0, 2, 2, 3, 1, 3} #local dst = array[6]{2, 0, 1, 0, 3, 3} #local D = 30; #local na = 4; #local nb = 100; gera_grafo(nv, ne, org, dst, D, na, nb) #end testa_gera_grafo () //#local m = 6; //#local n = 6; //#declare roleta = seed( 31159 ); //#declare ponta_cano = array[3000] //#declare N = 0; //#macro gera_tanques(m, n) // #local i = 0; // #local j = 0; // #local n_tanque = 1; // #while (i < m) // #local j = 0; // #while (j < n) // #local n_tanque = 1 + int(3.0*rand(roleta)); // #if (n_tanque = 1) // object{ tanque1 // translate < 5.0*i, 5.0*j, 0.0 > // } // #declare ponta_cano[N] = < (5.0*i + 1.00), (5.0*j + 1.75), +3.00 >; // #declare ponta_cano[N+1] = < (5.0*i + 1.00), (5.0*j + 0.25), +3.00 >; // #declare ponta_cano[N+2] = < (5.0*i + 1.00), (5.0*j + 1.00), +4.25 >; // #declare N = N + 3; // #end // #if (n_tanque = 2) // object{ tanque2 // translate < 5.0*i, 5.0*j, 0.0 > // } // #declare ponta_cano[N] = < (5.0*i + 1.00), (5.0*j + 2.00), +3.00 >; // #declare ponta_cano[N+1] = < (5.0*i + 1.00), (5.0*j + 1.50), +4.25 >; // #declare ponta_cano[N+2] = < (5.0*i + 1.00), (5.0*j + 0.50), +4.25 >; // #declare N = N + 3; // #end // #if (n_tanque = 3) // object{ tanque3 // translate < 5.0*i, 5.0*j, 0.0 > // } // #declare ponta_cano[N] = < (5.0*i + 1.00), (5.0*j + 2.25), +1.50 >; // #declare ponta_cano[N+1] = < (5.0*i + 1.00), (5.0*j - 0.25), +1.50 >; // #declare ponta_cano[N+2] = < (5.0*i + 1.00), (5.0*j + 1.00), +4.25 >; // #declare N = N + 3; // #end // #local j = j + 1; // #end // #local i = i + 1; // #end //#end //gera_tanques(m, n) //#local pos_x = 0.0; //#local pos_y = 0.0; //#macro desenhar_circulo(raio) // #local i = 0; // #while (i < n) // #local pos_x = raio * cos(i * theta); // #local pos_y = raio * sin(i * theta); // #if (mod(i, 4) = 0) // object { rainha // translate < pos_x, pos_y, 0 > // } // #else // object { peao // translate < pos_x, pos_y, 0 > // } // #end // #local i = i + 1; // #end //#end //#macro desenhar_tudo(m, n) // desenhar_circulo(raio_tabuleiro - 5.0) // desenhar_circulo((raio_tabuleiro - 5.0) * (m - 1) / m) //#end //desenhar_tudo(m, n) object{ eixos(20.0) } #include "camlight.inc" #declare centro_cena = < 0.00, 5.00, 7.00 >; #declare raio_cena = 25.0; #declare dir_camera = < 7.00, 2.00, 1.00 >; #declare dist_camera = 2*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)