// ====================================================================== // CORES E TEXTURAS background{ color rgb <0.75, 0.80, 0.85> } #declare tx_tank_silver_body = texture{ pigment { color rgb <0.4, 0.4, 0.4> } finish { diffuse 0.5 reflection 0.1 *<0.8, 0.8, 0.8> ambient 0.2 } } #declare tx_tank_golden_body = texture{ pigment { color rgb < 0.7, 0.7, 0.4 > } finish { diffuse 0.4 reflection 0.2 *< 1.00, 1.00, 1.00 > ambient 0.1 } } #declare tx_green = texture{ pigment { color rgb <0.1, 0.8, 0.2> } finish { diffuse 0.2 ambient 0.2 } } // ====================================================================== // DESCRIÇÃO DA CENA #declare s = seed(360); #declare grid_size = 2.5; #declare vertice_types = array[4]; #declare vertice_types[0] = union { sphere { <0, 0, 2>, 2 } cylinder { <0, 0, 2>, <0, 0, 5>, 0.15 texture { tx_tank_silver_body } } texture { tx_tank_golden_body } } #declare vertice_types[1] = union { box { <-0.5, -2, 0>, <0.5, 2, 4> texture { tx_tank_golden_body } } cylinder { <0, 0, 3>, <2, 0, 3>, 0.15 } cylinder { <0, 0, 2>, <-2, 0, 2>, 0.15 } texture { tx_tank_silver_body } } #declare vertice_types[2] = union { cone { <0, 0, 0>, 1.5 <0, 0, 1.9>, 0.7 texture { tx_tank_golden_body } } cone { <0, 0, 1.9>, 0.7 <0, 0, 3.8>, 1.5 } difference { sphere { <0, 0, 3.8>, 1.8 } box { <-3, -3, 2>, <2, 2, 4.8> } translate <0, 0, -1> texture { tx_tank_golden_body } } cylinder { <0, 0, 3>, <2, 0, 3>, 0.15 } cylinder { <0, 0, 3>, <-2, 0, 3>, 0.15 } cylinder { <0, 0, 3>, <0, 0, 5.5>, 0.15 } texture { tx_tank_silver_body } } #declare vertice_types[3] = union { cylinder { <0, 0, 0>, <0, 0, 1>, 1.2 } cylinder { <0, 0, 1>, <0, 0, 3>, 0.5 texture { tx_tank_silver_body } } cylinder { <0, 0, 3>, <0, 0, 4>, 1.2 } cylinder { <0, 0, 2>, <2, 0, 2>, 0.15 texture { tx_tank_silver_body } } cylinder { <0, 0, 2>, <-2, 0, 2>, 0.15 texture { tx_tank_silver_body } } cylinder { <0, 0, 2>, <0, 2, 2>, 0.15 texture { tx_tank_silver_body } } cylinder { <0, 0, 2>, <0, -2, 2>, 0.15 texture { tx_tank_silver_body } } texture { tx_tank_golden_body } } #macro connect_outputs (connections, pipes, pipe_count, scale_ratio) union { #for (pipe_index, 0, connections - 1) #local socket_1 = floor(pipe_count * rand(s)); #local output_position_1 = pipes[socket_1]; #local pipes[socket_1] = pipes[pipe_count - 1]; #local pipe_count = pipe_count - 1; #local socket_2 = floor(pipe_count * rand(s)); #local output_position_2 = pipes[socket_2]; #local pipes[socket_2] = pipes[pipe_count - 1]; #local pipe_count = pipe_count - 1; #local height = 6 * scale_ratio + 4 * rand(s); union { cylinder { output_position_1, , 0.15 * scale_ratio } cylinder { , , 0.15 * scale_ratio } cylinder { , output_position_2, 0.15 * scale_ratio } texture { tx_tank_silver_body } } #end } #end #macro vertices_grid (vertices_count, connections) #local vertices = array[vertices_count]; #local connectors = array[vertices_count][4]; #local edges = array[connections][2]; #local degree = array[vertices_count]; #local max_x = grid_size * vertices_count; union { #for (i, 0, vertices_count - 1) #local grid_y = -6 + i * grid_size + grid_size / 2; #local vertices[i] = <(rand(s) - 0.5) * max_x, grid_y, 0>; #local degree[i] = 0; #end #for (i, 0, connections - 1) #local vertice1 = floor(rand(s) * vertices_count); #while (degree[vertice1] >= 4) #local vertice1 = floor(rand(s) * vertices_count); #end #local vertice2 = vertice1; #while (vertice2 = vertice1 | degree[vertice2] >= 4) #local vertice2 = floor(rand(s) * vertices_count); #end #local edges[i][0] = vertice1; #local edges[i][1] = vertice2; #local degree[vertice1] = degree[vertice1] + 1; #local degree[vertice2] = degree[vertice2] + 1; #end #for (i, 0 vertices_count - 1) #if (degree[i] != 0) object { vertice_types[degree[i] - 1] scale 0.4 translate vertices[i] } #local connectors[i][0] = ; #end #end #for (i, 0, connections - 1) #local p0 = connectors[edges[i][0]][0]; #local p3 = connectors[edges[i][1]][0]; object { test_interpolate3(p0, , , p3, 150, 0.075) } #end // #switch (type_index) // #case (0) // #local connectors[pipe_count] = ; // #local connectors[pipe_count + 1] = ; // #local connectors[pipe_count + 2] = ; // #local connectors[pipe_count + 3] = ; // #local pipe_count = pipe_count + 4; // #break // #case (1) // #local pipes[pipe_count] = ; // #local pipes[pipe_count + 1] = ; // #local pipes[pipe_count + 2] = ; // #local pipe_count = pipe_count + 3; // #break // #case (2) // #local pipes[pipe_count] = ; // #local pipes[pipe_count + 1] = ; // #local pipes[pipe_count + 2] = ; // #local pipes[pipe_count + 3] = ; // #local pipe_count = pipe_count + 4; // #break // #end // object { connect_outputs(connections, pipes, pipe_count, scale_ratio) } } #end #macro interpolate1 (tt, t0, v0, t1, v1) #local ss = (tt - t0) / (t1 - t0); #local vv = (1 - ss) * v0 + ss * v1; vv #end #macro interpolate3 (ti, ta, tb, v0, v1, v2, v3) #local v01 = interpolate1(ti, ta, v0, tb, v1); #local v12 = interpolate1(ti, ta, v1, tb, v2); #local v23 = interpolate1(ti, ta, v2, tb, v3); #local v012 = interpolate1(ti, ta, v01, tb, v12); #local v123 = interpolate1(ti, ta, v12, tb, v23); #local v0123 = interpolate1(ti, ta, v012, tb, v123); v0123 #end #macro test_interpolate3(p0, p1, p2, p3, n, r) union { #for (k, 0, n - 1) #local center = interpolate3(k, 0, n, p0, p1, p2, p3); sphere { center, r texture { tx_green } } #end } #end #include "eixos.inc" eixos(5) union { object { vertices_grid(2, 1) } } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 0.00 >; #declare raio_cena = 8.0; #declare dir_camera = < 14.00, 7.00, 6.00 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)