// ====================================================================== // MC937A/MO603A – Computacao Grafica - 2023-S2 // Trabalho de laboratorio 03 - 2023-08-23 // Refinaria de Quetchupe // // RA108231 - Oscar dos Santos Esgalha Neto // ====================================================================== background{ color rgb < 0.7, 0.7, 0.9 > } #declare roleta = seed(42); #declare tx_toco_cano = texture{ pigment{ color rgb < 0.8, 0.8, 0.8 > } finish{ diffuse 0.8 ambient 0.1 } } #declare tx_cano = texture{ pigment{ color rgb < 0.6, 0.6, 0.6 > } finish{ diffuse 0.8 ambient 0.1 } } #declare tx_tanque1 = texture{ pigment{ color rgb < 0.8, 0.5, 0.5 > } finish{ diffuse 0.8 ambient 0.1 } } #declare tx_tanque2 = texture{ pigment{ color rgb < 0.5, 0.8, 0.8 > } finish{ diffuse 0.8 ambient 0.1 } } #declare tx_tanque3 = texture{ pigment{ color rgb < 0.5, 0.8, 0.5 > } finish{ diffuse 0.8 ambient 0.1 } } #declare tx_bug = texture{ pigment{ color rgb < 1.0, 0.2, 0.1 > } finish{ diffuse 0.5 ambient 0.5 } } #declare tcano = cylinder{ < 0.00, 0.00, 0.00 >, < 0.00, 0.00, 1.0 >, 0.2 texture{ tx_toco_cano } } #declare A = array[1000]; #declare N = 0; #macro tanque1(xx, yy) #local tq = union { cylinder{ < 0.00, 0.00, 0.00 >, < 0.00, 0.00, 4.0 >, 1 } cone{ < 0, 0, 4 >, 0.8, < 0, 0, 5.5 >, 0.2 } object{ tcano translate < 0,0,5.5 > } object{ tcano rotate 90*x rotate 90*z translate < 1,0,2.5 > } object{ tcano rotate 90*x rotate 90*z translate < -2,0,2.5 > } texture { tx_tanque1 } translate < xx, yy, -0.5 > } #declare A[N] = < xx, yy, 5.7 >; #declare N = N + 1; #declare A[N] = < xx+1, yy, 2.7 >; #declare N = N + 1; #declare A[N] = < xx-2, yy, 2.7 >; #declare N = N + 1; tq #end #macro tanque2(xx, yy) #local tq = union { box{ <0,0,0>, <1,3,1> } box{ <2,0,0>, <3,3,1> } box{ <1,0.6,0.3>, <2,1,0.6> } box{ <1,1.8,0.3>, <2,2.2,0.6> } object{ tcano rotate 90*y rotate 90*z translate < 0.5,3,0.5 > } object{ tcano rotate 90*y rotate 90*z translate < 2.5,3,0.5 > } object{ tcano rotate 90*y rotate 90*z translate < 0.5,-1,0.5 > } object{ tcano rotate 90*y rotate 90*z translate < 2.5,-1,0.5 > } texture { tx_tanque2 } translate < xx, yy, -0.5 > } #declare A[N] = < xx+0.5, yy+3, 0.7 >; #declare N = N + 1; #declare A[N] = < xx+2.5, yy+3, 0.7 >; #declare N = N + 1; #declare A[N] = < xx+0.5, yy-1, 0.7 >; #declare N = N + 1; #declare A[N] = < xx+2.5, yy-1, 0.7 >; #declare N = N + 1; tq #end #macro tanque3(xx, yy) #local tq = union { cone{ < 0, 0, 0 >, 1, < 0, 0, 1 >, 0.5 } cylinder{ < 0.00, 0.00, 1 >, < 0.00, 0.00, 3.0 >, 0.5 } cone{ < 0, 0, 3 >, 0.5, < 0, 0, 4 >, 1 } object{ tcano rotate 90*y rotate 120*z translate < 0,0,2 > } object{ tcano rotate 90*y rotate 240*z translate < 0,0,2 > } object{ tcano rotate 90*y translate < 0,0,2 > } texture { tx_tanque3 } translate < xx, yy, -0.5 > } tq #end #macro tubulacao(p, q) #local altura = 10*rand(roleta); #local dist_pontos = sqrt(pow(p.x - q.x, 2) + pow(p.y - q.y, 2)); #local angulo_pontos = 180 + degrees(atan2(p.y - q.y, p.x - q.x)); #local tubo = union { cylinder{ < p.x, p.y, p.z >, < p.x, p.y, altura >, 0.5 } cylinder{ < q.x, q.y, q.z >, < q.x, q.y, altura >, 0.5 } cylinder{ < 0, 0, 0 >, < 0, 0, dist_pontos >, 0.5 rotate 90*y rotate angulo_pontos*z translate < p.x,p.y,altura > } texture { tx_cano } } tubo #end #macro tanque_k(tipo_tanque, posx, posy) #if (tipo_tanque = 0) object { tanque1(posx,posy) } #end #if (tipo_tanque = 1) object { tanque2(posx,posy) } #end #if (tipo_tanque = 2) object { tanque3(posx,posy) } #end #end #declare distancia_tanques = 5; #macro gera_tanques (m, n) union { #local i = 1; #while (i <= m) #local j = 1; #while (j <= n) #local tipo_tanque = int(3*rand(roleta)); object{ tanque_k(tipo_tanque, i * distancia_tanques, j * distancia_tanques) } #local j = j + 1; #end #local i = i + 1; #end } #end #macro liga_tanques() union { #while (N > 0) #local i = int(N*rand(roleta)); #local j = int((N-1)*rand(roleta)); #if (j = i) #local j = j + 1; #end object { tubulacao(A[i], A[j]) } #declare A[i] = A[N-1]; #declare N = N-1; #declare A[j] = A[N-1]; #declare N = N-1; #end } #end #include "eixos.inc" #declare MATRIZ_M = 7; #declare MATRIZ_N = 5; // object { eixos(10) } object { gera_tanques(MATRIZ_M, MATRIZ_N) } object { liga_tanques() } union{ #for (tk,0,2) #declare N = 0; object { tanque_k(tk, 2*distancia_tanques*tk, (MATRIZ_N+2)*distancia_tanques) } #for (k,0,N-1) sphere{ A[k], 0.5 texture{ tx_bug }} #end #end } #local tam_cena = < distancia_tanques*(MATRIZ_M+1), distancia_tanques*(MATRIZ_N+3), 11.0>; #include "camlight.inc" #declare centro_cena = 0.5*tam_cena; #declare raio_cena = 0.6*vlength(tam_cena); #declare dir_camera = < 4.00, 3, 3.00 >; #declare dist_camera = 7*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera, z, intens_luz)