// Last edited on 2023-12-27 04:16:03 by stolfi background{ color rgb <0.75, 0.80, 0.85> } #declare tx_brown = texture{ pigment { color rgb <0.700, 0.500, 0.000 > } finish { diffuse 0.8 ambient 0.2 } } #declare s = seed(360); #macro robot( p1b1, p1b2, p1b3, p1b4, p2b1, p2b2, p2b3, p2b4, p3b1, p3b2, p3b3, p3b4, p4b1, p4b2, p4b3, p4b4, a1, a2, a3 ) union { box { <-2, -1.25, -0.4>, <2, 1.25, 0.4> } union { object { leg(p1b2, p1b3, p1b4) rotate scale 6 translate <1.75, -1, 0> } object { leg(p2b2, p2b3, p2b4) rotate scale 6 translate <1.75, 1, 0> } object { leg(p3b2, p3b3, p3b4) rotate scale 6 translate <-1.75, -1, 0> } object { leg(p4b2, p4b3, p4b4) rotate scale 6 translate <-1.75, 1, 0> } } object { neck(a2, a3) rotate <0, a1, 0> scale 3 translate <2, 0, 0> } texture { tx_brown } } #end #macro leg(b2, b3, b4) #local leg_base = cylinder { <0, 0, 0>, <0, 0, -0.25>, 0.04 } union { object { leg_base } object { shin(b3, b4) rotate <0, b2 - 90, 0> translate <0, 0, -0.25> } } #end #macro shin(b3, b4) #local shin_base = cylinder { <0, 0, 0>, <0, 0, -0.25>, 0.04 } union { object { shin_base } object { metatarsus(b4) rotate <0, 90 - b3, 0> translate <0, 0, -0.25> } } #end #macro metatarsus(b4) #local metatarsus_base = cylinder { <0, 0, 0>, <0, 0, -0.25>, 0.04 } union { object { metatarsus_base } object { paw() rotate <0, b4 - 90, 0> translate <0, 0, -0.25> } } #end #macro paw() box { <-0.01, -0.05, -0.025>, <0.19, 0.05, 0.025> } #end #macro neck(a2, a3) #local neck_base = cylinder { <0, 0, 0>, <0, 0, 0.75>, 0.10 } union { object { neck_base } object { metaneck(a3) rotate <0, 90 - a2, 0> translate <0, 0, 0.75> } } #end #macro metaneck(a3) #local metaneck_base = cylinder { <0, 0, 0>, <0, 0, 0.4>, 0.075 } union { object { metaneck_base } object { head() rotate <0, a3 - 90, 0> translate <0, 0, 0.4> } } #end #macro head() sphere { <0, 0, 0.25>, 0.25 } #end #declare NQ = 6; #declare PQ = array[19][NQ] { // frente-esquerda {0, 0, 0, 45, 45, 45}, {0, -45, -45, -45, -45, 0}, {0, -20, -20, -20, -20, 0}, {90, 90, 90, 90, 90, 90}, // frente-direita {0, 0, 0, -45, -45, -45}, {0, -45, -45, -45, -45, 0}, {0, -20, -20, -20, -20, 0}, {90, 90, 90, 90, 90, 90}, // trás-esquerda {0, 0, 0, 0, 45, 45}, {0, 0, -45, -45, -45, 0}, {0, 0, -20, -20, -20, 0}, {90, 90, 90, 90, 90, 90}, // trás-direita {0, 0, 0, 0, -45, -45}, {0, 0, -45, -45, -45, 0}, {0, 0, -20, -20, -20, 0}, {90, 90, 90, 90, 90, 90}, // cabeça {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {90, 90, 90, 90, 90, 90} } #declare TQ = array[NQ + 1] { 0, 0.166, 0.333, 0.5, 0.666, 0.833, 1 } #macro acha_quadro(tt) #local i = 0; #while (tt > TQ[i]) #local i = i + 1; #end max(i - 1, 0) #end #macro interpol(p, tt) #local k = acha_quadro(tt); #debug concat( "!! tt = ", str(tt,0,4), " k = ", str(k,0,0), "\n" ) #local current = PQ[p][k]; #local next = PQ[p][mod(k + 1, NQ)]; #local ta = TQ[k]; #local tb = TQ[mod(k + 1, NQ)]; // Prof #local s = (mod(tt, 1) - ta) / (tb - ta); current + ((next - current) * s) #end #include "eixos.inc" #include "galho.inc" #local Lg = 0.68; // Deslocamento pro ciclo -- Prof #macro cena(tt) union { object{ robot( interpol(0, tt), interpol(1, tt), interpol(2, tt), interpol(3, tt), interpol(4, tt), interpol(5, tt), interpol(6, tt), interpol(7, tt), interpol(8, tt), interpol(9, tt), interpol(10, tt), interpol(11, tt), interpol(12, tt), interpol(13, tt), interpol(14, tt), interpol(15, tt), interpol(16, tt), interpol(17, tt), interpol(18, tt) ) } object{ galho( < -Lg/2, 0, 0 >, < +Lg/2, 0, 0 >, 0.25, tt) translate -1.5*z } rotate -90*y } #end // object{ eixos(5) } object { cena(clock) } #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 1.50 >; #declare raio_cena = 7.0; #declare dir_camera = < 7, 5, 3 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)