// Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2020-09-30 19:57:13 by jstolfi // ====================================================================== // CORES E TEXTURAS 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 } } // ====================================================================== // BASIC #declare roleta = seed(27); #declare M = 4; #declare N = 3; // ====================================================================== // TANQUES #declare TANK_SIZE = 2; #declare TANK_OFFSET = 1; #declare cylinder_tank = union { box{ <-TANK_SIZE / 2, -TANK_SIZE / 2, 0>, } cylinder { <0, 0, 0>, <0, 0, TANK_SIZE>, TANK_SIZE / 4 } texture { tx_plastico } } #declare cone_tank = union { box{ <-TANK_SIZE / 2, -TANK_SIZE / 2, 0>, } cone { <0, 0, 0>, TANK_SIZE / 2 <0, 0, TANK_SIZE>, 0.1 } texture { tx_plastico } } #declare sphere_tank = union { box{ <-TANK_SIZE / 2, -TANK_SIZE / 2, 0>, } difference { sphere { <0, 0, 0.5>, TANK_SIZE / 2 } box { <-TANK_SIZE / 2, -TANK_SIZE / 2, 0>, } } texture { tx_plastico } } // ====================================================================== // PINS #declare NUMBER_OF_PINS = 3 * M * N; #declare PINS = array[NUMBER_OF_PINS]; #declare CURRENT_PIN = 0; #declare PIN_SIZE = 0.2; #declare PIN_LENGTH = 0.5; #macro tube_IO(from, to) object { cylinder { from, to, PIN_SIZE } texture { tx_plastico } } #declare PINS[CURRENT_PIN] = to; #declare CURRENT_PIN = CURRENT_PIN + 1; #end #macro full_cylinder_tank(position) union { object { cylinder_tank translate position } #local tube_center = position + <0, 0, TANK_SIZE / 2>; tube_IO(tube_center, tube_center + ) tube_IO(tube_center, tube_center + ) tube_IO(tube_center, tube_center + <0, -(PIN_LENGTH + TANK_SIZE / 4), 0>) } #end #macro full_cone_tank(position) union { object { cone_tank translate position } #local tube_center = position + <0, 0, TANK_SIZE / 2>; tube_IO(tube_center, tube_center + ) tube_IO(tube_center, tube_center + ) tube_IO(tube_center, tube_center + <0, -(PIN_LENGTH + TANK_SIZE / 4), 0>) } #end #macro full_sphere_tank(position) union { object { sphere_tank translate position } #local tube_center = position + <0, 0, TANK_SIZE / 2>; tube_IO(tube_center, tube_center + ) tube_IO(tube_center, tube_center + ) tube_IO(tube_center, tube_center + <0, -(PIN_LENGTH + TANK_SIZE / 4), 0>) } #end // ====================================================================== // GRID #macro calculate_xy(M_VALUE, N_VALUE) #local resultadoX = (M_VALUE - 1) * (TANK_OFFSET + TANK_SIZE) + TANK_SIZE / 2; #local resultadoY = (N_VALUE - 1) * (TANK_OFFSET + TANK_SIZE) + TANK_SIZE / 2; #end #macro gera_tanques(M_VALUE, N_VALUE) union { #declare CURRENT_M = 1; #while (CURRENT_M <= M_VALUE) #declare CURRENT_N = 1; #while (CURRENT_N <= N_VALUE) #local random = rand(roleta); #if (random < 0.33) full_cone_tank(calculate_xy(CURRENT_M, CURRENT_N)) #else #if (random < 0.66) full_cylinder_tank(calculate_xy(CURRENT_M, CURRENT_N)) #else full_sphere_tank(calculate_xy(CURRENT_M, CURRENT_N)) #end #end #declare CURRENT_N = CURRENT_N + 1; #end #declare CURRENT_M = CURRENT_M + 1; #end } #end // ====================================================================== // TUBES #declare MIN_TUBE_HEIGHT = 2.5; #declare DELTA_TUBE_HEIGHT = 1.5; #macro build_tube(fromIndex, toIndex) #local height = MIN_TUBE_HEIGHT + DELTA_TUBE_HEIGHT * rand(roleta); #local from = PINS[fromIndex]; #local to = PINS[toIndex]; union { sphere { from, PIN_SIZE } cylinder { from, from + <0, 0, height>, PIN_SIZE } sphere { from + <0, 0, height>, PIN_SIZE } cylinder { to, to + <0, 0, height>, PIN_SIZE } sphere { to + <0, 0, height>, PIN_SIZE } cylinder { from + <0, 0, height>, to + <0, 0, height>, PIN_SIZE } sphere { to, PIN_SIZE } texture { tx_plastico } } #end #macro tubulation() union { #local AVAILABLE_PINS = NUMBER_OF_PINS; #while (AVAILABLE_PINS >= 2) #local LHS_PIN_INDEX = int(AVAILABLE_PINS * rand(roleta)); #local RHS_PIN_INDEX = int((AVAILABLE_PINS - 1) * rand(roleta)); #if (RHS_PIN_INDEX = LHS_PIN_INDEX) #local RHS_PIN_INDEX = RHS_PIN_INDEX + 1; #end build_tube(LHS_PIN_INDEX, RHS_PIN_INDEX) #if (RHS_PIN_INDEX > LHS_PIN_INDEX) #declare PINS[RHS_PIN_INDEX] = PINS[AVAILABLE_PINS - 1]; #local AVAILABLE_PINS = AVAILABLE_PINS - 1; #declare PINS[LHS_PIN_INDEX] = PINS[AVAILABLE_PINS - 1]; #local AVAILABLE_PINS = AVAILABLE_PINS - 1; #else #declare PINS[LHS_PIN_INDEX] = PINS[AVAILABLE_PINS - 1]; #local AVAILABLE_PINS = AVAILABLE_PINS - 1; #declare PINS[RHS_PIN_INDEX] = PINS[AVAILABLE_PINS - 1]; #local AVAILABLE_PINS = AVAILABLE_PINS - 1; #end #end } #end // ====================================================================== // DESCRI��O DA CENA #declare raio = 2.000; #include "eixos.inc" union{ object{ eixos(3.00) } // cylinder_tank gera_tanques(M, N) // build_tube(0, 1) tubulation() } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 1.00 >; #declare raio_cena = 10.0; #declare dir_camera = < 14.00, 7.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)