// Last edited on 2023-12-27 05:33:17 by stolfi background{ color rgb < 0.75, 0.80, 0.85 > } #declare tx_tanque_grande = texture{ pigment{ color rgb < 0.41, 0.41, 0.41 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #macro robo(E11, E12, E13, E14, E15, D11, D12, D13, D14, D15, E21, E22, E23, E24, E25, D21, D22, D23, D24, D25, M1) #local init = <0, 0, 0>; #local final = <0, 10, 5>; #local troncoInit = cylinder { init, final, 2 } #local pernaEsquerda = object { perna(E12, E13, E14, E15) } #local pernaDireita = object { perna(D12, D13, D14, D15) } #local bracoEsquerdo = object { braco(E22, E23, E24, E25) } #local bracoDireito = object { braco(D22, D23, D24, D25) } #local pescocoObj = object { pescoco(M1) } union { object { troncoInit texture{ tx_tanque_grande } } object { pescocoObj rotate M1*y translate final texture{ tx_tanque_grande } } object { pernaEsquerda rotate E11*x translate init + <1.6, 0, 0> texture{ tx_tanque_grande } } object { pernaDireita rotate D11*x translate init - <1.6, 0, 0> texture{ tx_tanque_grande } } object { bracoEsquerdo rotate E21*x translate final + <1.6, 0, 0> texture{ tx_tanque_grande } } object { bracoDireito rotate D21*x translate final - <1.6, 0, 0> texture{ tx_tanque_grande } } } #end #macro braco(E21, E23, E24, E25) #local subbracoObj = object { subbraco(E23, E24, E25) } #local bracoObj = cylinder { <0, 0, 0>, <0, 0, 3>, 0.4 } union { object { bracoObj } object { subbracoObj rotate E12*y translate <0, 0, 3> texture{ tx_tanque_grande } } } #end #macro subbraco(E23, E24, E25) #local dedoObj = cylinder { <0, 0, 0>, <0, 0, 2>, 0.2 } #local subbracoObj = cylinder { <0, 0, 0>, <0, 0, 4>, 0.4 } union { object { subbracoObj } object { dedoObj rotate E23*y translate <0, 0, 4> texture{ tx_tanque_grande } } object { dedoObj rotate E24*y translate <0, 0, 4> texture{ tx_tanque_grande } } object { dedoObj rotate E25*y translate <0, 0, 4> texture{ tx_tanque_grande } } } #end #macro perna(aa, E13, E14, E15) #local subpernaObj = object { subperna(E13, E14, E15) } #local pernaObj = cylinder { <0, 0, 0>, <0, 0, 3>, 0.4 } union { object { pernaObj } object { subpernaObj rotate aa*y translate <0, 0, 3> texture{ tx_tanque_grande } } } #end #macro subperna(E13, E14, E15) #local dedoObj = cylinder { <0, 0, 0>, <0, 0, 2>, 0.2 } #local subpernaObj = cylinder { <0, 0, 0>, <0, 0, 4>, 0.4 } union { object { subpernaObj } object { dedoObj rotate E13*y translate <0, 0, 4> texture{ tx_tanque_grande } } object { dedoObj rotate E14*y translate <0, 0, 4> texture{ tx_tanque_grande } } object { dedoObj rotate E15*y translate <0, 0, 4> texture{ tx_tanque_grande } } } #end #macro pescoco(M1) #local objCabeca = sphere { <0, 0, 0>, 2 } #local objPescoco = cylinder { <0, 0, 0>, <0, 4, 2>, 0.4 } union { object { objPescoco } object { objCabeca rotate M1*y translate <0, 4, 2> texture{ tx_tanque_grande } } } #end #declare NP = 21; #macro empacota(E11, E12, E13, E14, E15, D11, D12, D13, D14, D15, E21, E22, E23, E24, E25, D21, D22, D23, D24, D25, M) #local P = array[NP]; #local P[0] = E11; #local P[1] = E12; #local P[2] = E13; #local P[3] = E14; #local P[4] = E15; #local P[5] = D11; #local P[6] = D12; #local P[7] = D13; #local P[8] = D14; #local P[9] = D15; #local P[10] = E21; #local P[11] = E22; #local P[12] = E23; #local P[13] = E24; #local P[14] = E25; #local P[15] = D21; #local P[16] = D22; #local P[17] = D23; #local P[18] = D24; #local P[19] = D25; #local P[20] = M; P #end #macro acha_quadro(tt) #local k = int(tt * 10); k #end #macro interpola_quadros(tt, ta, Pa, tb, Pb, E11, E12, E13, E14, E15, D11, D12, D13, D14, D15, E21, E22, E23, E24, E25, D21, D22, D23, D24, D25, M) #local s = (tt - ta) / (tb- ta); #declare E11= (1 - s)*Pa[0] + s * Pb[0]; #declare E12 = (1 - s)*Pa[1] + s * Pb[1]; #declare E13= (1 - s)*Pa[2] + s * Pb[2]; #declare E14= (1 - s)*Pa[3] + s * Pb[3]; #declare E15= (1 - s)*Pa[4] + s * Pb[4]; #declare D11= (1 - s)*Pa[5] + s * Pb[5]; #declare D12= (1 - s)*Pa[6] + s * Pb[6]; #declare D13= (1 - s)*Pa[7] + s * Pb[7]; #declare D14= (1 - s)*Pa[8] + s * Pb[8]; #declare D15= (1 - s)*Pa[9] + s * Pb[9]; #declare E21= (1 - s)*Pa[10] + s * Pb[10]; #declare E22= (1 - s)*Pa[11] + s * Pb[11]; #declare E23= (1 - s)*Pa[12] + s * Pb[12]; #declare E24= (1 - s)*Pa[13] + s * Pb[13]; #declare E25= (1 - s)*Pa[14] + s * Pb[14]; #declare D21= (1 - s)*Pa[15] + s * Pb[15]; #declare D22= (1 - s)*Pa[16] + s * Pb[16]; #declare D23= (1 - s)*Pa[17] + s * Pb[17]; #declare D24= (1 - s)*Pa[18] + s * Pb[18]; #declare D25= (1 - s)*Pa[19] + s * Pb[19]; #declare M = (1 - s)*Pa[20] + s * Pb[20]; #end #macro nova_cena(tt) #local NQ = 12; #local TQ = array[NQ + 1]; #local PQ = array[NQ + 1]; #local M = 0; #local index = 0; #while (index <= 110) #local TQ[index / 10] = index / 100; #if (tt <= 0.1) #local PQ[index / 10] = empacota(200 - 200*tt, 45*tt, -45, -90, 45, -200 + 200*tt, -45*tt, 45, 90, -45, 200 + 200*tt, -45, -90, 45, -200 + 200*tt, 200 - 200*tt, -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.2) #local PQ[index / 10] = empacota(200 + 200*(tt - 0.2), 45*tt, -45, -90, 45, -200 - 200*(tt - 0.2), -45*tt, 45, 90, -45, 200 - 200*(tt - 0.2), -45, -90, 45, -200 + 200*tt, 200 + 200*(tt - 0.2), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.3) #local PQ[index / 10] = empacota(200 - 200*(tt - 0.3), 45*tt, -45, -90, 45, -200 + 200*(tt - 0.3), -45*tt, 45, 90, -45, 200 + 200*(tt - 0.3), -45, -90, 45, -200 + 200*tt, 200 - 200*(tt - 0.3), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.4) #local PQ[index / 10] = empacota(200 + 200*(tt - 0.4), 45*tt, -45, -90, 45, -200 - 200*(tt - 0.4), -45*tt, 45, 90, -45, 200 - 200*(tt - 0.4), -45, -90, 45, -200 + 200*tt, 200 + 200*(tt - 0.4), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.5) #local PQ[index / 10] = empacota(200 - 200*(tt - 0.5), 45*tt, -45, -90, 45, -200 + 200*(tt - 0.5), -45*tt, 45, 90, -45, 200 + 200*(tt - 0.5), -45, -90, 45, -200 + 200*tt, 200 - 200*(tt - 0.5), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.6) #local PQ[index / 10] = empacota(200 + 200*(tt - 0.6), 45*tt, -45, -90, 45, -200 - 200*(tt - 0.6), -45*tt, 45, 90, -45, 200 - 200*(tt - 0.6), -45, -90, 45, -200 + 200*tt, 200 + 200*(tt - 0.6), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.7) #local PQ[index / 10] = empacota(200 - 200*(tt - 0.7), 45*tt, -45, -90, 45, -200 + 200*(tt - 0.7), -45*tt, 45, 90, -45, 200 + 200*(tt - 0.7), -45, -90, 45, -200 + 200*tt, 200 - 200*(tt - 0.7), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.8) #local PQ[index / 10] = empacota(200 + 200*(tt - 0.8), 45*tt, -45, -90, 45, -200 - 200*(tt - 0.8), -45*tt, 45, 90, -45, 200 - 200*(tt - 0.8), -45, -90, 45, -200 + 200*tt, 200 + 200*(tt - 0.8), -45, -90, 45, +200 + 200*tt, 0); #else #if (tt <= 0.9) #local PQ[index / 10] = empacota(200 - 200*(tt - 0.9), 45*tt, -45, -90, 45, -200 + 200*(tt - 0.9), -45*tt, 45, 90, -45, 200 + 200*(tt - 0.9), -45, -90, 45, -200 + 200*tt, 200 - 200*(tt - 0.9), -45, -90, 45, +200 + 200*tt, 0); #else #local PQ[index / 10] = empacota(200 + 200*(tt - 1.0), 45*tt, -45, -90, 45, -200 - 200*(tt - 1.0), -45*tt, 45, 90, -45, 200 - 200*(tt - 1.0), -45, -90, 45, -200 + 200*tt, 200 + 200*(tt - 1.0), -45, -90, 45, +200 + 200*tt, 0); #end #end #end #end #end #end #end #end #end #local index = index + 10; #end #local E11= 0; #local E12 = 0; #local E13= 0; #local E14= 0; #local E15= 0; #local D11= 0; #local D12= 0; #local D13= 0; #local D14= 0; #local D15= 0; #local E21= 0; #local E22= 0; #local E23= 0; #local E24= 0; #local E25= 0; #local D21= 0; #local D22= 0; #local D23= 0; #local D24= 0; #local D25= 0; #local k = acha_quadro(tt); interpola_quadros(tt, TQ[k], PQ[k], TQ[k + 1], PQ[k + 1], E11, E12, E13, E14, E15, D11, D12, D13, D14, D15, E21, E22, E23, E24, E25, D21, D22, D23, D24, D25, M) #local rob = object { robo(E11, E12, E13, E14, E15, D11, D12, D13, D14, D15, E21, E22, E23, E24, E25, D21, D22, D23, D24, D25, M) } rob #end object { nova_cena(clock) } #include "eixos.inc" // object{ eixos(20) } #include "galho.inc" #local Lg = 4; // Deslocamento por ciclo -- Prof object{ galho( < 0, -Lg/2, 0 >, < 0, +Lg/2, 0 >, 3, clock) rotate +11*x translate -9*z } // cylinder { <0, 20, -5>, <0, -5, -10>, 3 texture{ tx_tanque_grande } } #include "camlight.inc" #declare centro_cena = < 0.00, 7.00, 0.00 >; #declare raio_cena = 17.0; #declare dir_camera = < 7, 5, 3 >; #declare dist_camera = 7*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera, z, intens_luz)