background{ color rgb < 0.75, 0.80, 0.85 > } #macro pe(rc) union { // pé cylinder { <0,0,0> <0,0,-0.2> 0.3 texture { pigment { color rgb <1,1,1>} } } sphere { <0,0,0> 0.2 texture { pigment { color rgb <1,1,1>} } } rotate rc } #end #macro perna2(rb, rc) #local cb = 0.6; union { // perna 2 union { // pé pe(rc) translate <0,0,-cb> } cylinder { <0,0,0> <0,0,-cb> 0.2 texture { pigment { color rgb <0,0,1>} } } sphere { <0,0,0> 0.2 texture { pigment { color rgb <0,0,1>} } } rotate rb } #end #macro perna(ra, rb, rc) #local ca = 0.7; union { // perna 1 union { perna2(rb,rc) translate <0,0,-ca> } cylinder { <0,0,0> <0,0,-ca> 0.2 texture { pigment { color rgb <1,1,0>} } } sphere { <0,0,0> 0.2 texture { pigment { color rgb <1,1,0>} } } rotate ra } #end #macro mandibula(p3) union { box { <0,-0.3,0> <0.5,0.3,-0.1> texture { pigment { color rgb <1,1,1>} } } rotate p3 } #end #macro cabeca(p2,p3) union { union { mandibula(p3) translate <0.1,0,-0.3> } box { <0,-0.3,-0.3> <0.6,0.3,0.3> texture { pigment { color rgb <0,0,1>} } } sphere { <0,0,0> 0.2 texture { pigment { color rgb <0,0,1>} } } rotate p2 } #end #macro pescoco(p1,p2,p3) union { union { cabeca(p2,p3) translate <0.5,0,0> } cylinder { <0,0,0> <0.5,0,0> 0.2 pigment { color rgb <1,1,0>} } sphere { <0,0,0> 0.2 texture { pigment { color rgb <1,1,0>} } } rotate p1 } #end #macro torax(p1,p2,p3,e1,e2,e3,d1,d2,d3) union { sphere { <0,0,0> 0.8 texture { pigment { color rgb <0,1,0>} } } union { pescoco(p1,p2,p3) translate <0.8,0,0> } union { perna(e1,e2,e3) translate <0,0.8,0> } union { perna(d1,d2,d3) translate <0,-0.8,0> } } #end #macro rabo(r1) union { cylinder { <0,0,0> <-0.5,0,0> 0.15 texture { pigment { color rgb <1,1,0>} } } sphere { <0,0,0> 0.15 texture { pigment { color rgb <1,1,0>} } } sphere { <-0.5,0,0> 0.15 texture { pigment { color rgb <1,1,0>} } } rotate r1 } #end #macro abdomen(e1,e2,e3,d1,d2,d3,r1) union { sphere { <0,0,0> 0.8 texture { pigment { color rgb <0,1,0>} } } union { perna(e1,e2,e3) translate <0,0.8,0> } union { perna(d1,d2,d3) translate <0,-0.8,0> } union { rabo(r1) translate <-0.8,0,0> } translate <-0.8,0,0> } #end #macro robo(p1,p2,p3,e11,e12,e13,e21,e22,e23,d11,d12,d13,d21,d22,d23,r1,c1) union { torax(p1,p2,p3,e11,e12,e13,d11,d12,d13) union { abdomen(e21,e22,e23,d21,d22,d23,r1) rotate c1 translate <-0.8,0,0> } } #end #declare e = <0,0,0>; // pos p1 p2 p3 e11 e12 e13 e21 e22 e23 d11 d12 d13 d21 d22 d23 r1 c1 #declare frame0 = array[18] {< 3* 0.000, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0,-40, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 40, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 20, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0,-20, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame1 = array[18] {< 3* 0.125, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0,-25, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 45, 0>,<-45, 0, 0>,< 0, 0, 0>,<-20,-20, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, -5, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame2 = array[18] {< 3* 0.250, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0,-10, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 50, 0>,<-40, 0, 0>,< 0, 0, 0>,< 0,-55, 15>,< 40, 0, 0>,< 0, 0, 0>,< 0, 10, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame3 = array[18] {< 3* 0.375, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 5, 0>,<-50, 0, 0>,< 0, 0, 0>,< 20, 10, 0>,<-35, 0, 0>,< 0, 0, 0>,< 0,-47, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 25, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame4 = array[18] {< 3* 0.500, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 20, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0,-20, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0,-40, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 40, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame5 = array[18] {< 3* 0.625, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 20,-20, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, -5, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0,-25, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 45, 0>,< 45, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame6 = array[18] {< 3* 0.750, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0,-55, 15>,<-40, 0, 0>,< 0, 0, 0>,< 0, 10, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0,-10, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 50, 0>,< 40, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame7 = array[18] {< 3* 0.875, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0,-47, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 25, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 5, 0>,< 50, 0, 0>,< 0, 0, 0>,<-20, 10, 0>,< 35, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare frame8 = array[18] {< 3* 1.000, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0,-40, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 40, 0>,<-50, 0, 0>,< 0, 0, 0>,< 0, 20, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0,-20, 0>,< 50, 0, 0>,< 0, 0, 0>,< 0, 0, 0>,< 0, 0, 0>} #declare keyFrames = array[9] {frame0,frame1,frame2,frame3,frame4,frame5,frame6,frame7,frame8} #macro periodic(clk) #if (clk >= 0.5) #local time = 1.0-clk; #else #local time = clk; #end time #end #macro interpola(ti,t0,v0,t1,v1) #local ss = (ti-t0)/(t1-t0); #local vv = (1-ss)*v0+ss*v1; vv #end #macro interpolateFrames (clk) #local total = clk*8; #local frameBase = int(total); #local prog = total-frameBase; #if (frameBase >= 8) #local frameBase = 7; #end #local f0 = keyFrames[frameBase]; #local f1 = keyFrames[frameBase+1]; #local res = array[18]; #local i = 0; #while (i < 18) #local res[i] = interpola(prog,0,f0[i],1,f1[i]); #local i = i+1; #end res #end #macro byFrame(index) #local frame = keyFrames[index] union{ robo(frame[1],frame[2],frame[3],frame[4],frame[5],frame[6],frame[7],frame[8],frame[9],frame[10],frame[11],frame[12],frame[13],frame[14],frame[15],frame[16],frame[17]) rotate 180*x translate frame[0] } #end #macro byClock(clk) #local frame = interpolateFrames(clk) union{ robo(frame[1],frame[2],frame[3],frame[4],frame[5],frame[6],frame[7],frame[8],frame[9],frame[10],frame[11],frame[12],frame[13],frame[14],frame[15],frame[16],frame[17]) rotate 180*x translate frame[0] } #end union { box{ <-1000,-1000,0> <1000,1000,-0.1> texture{ pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > } finish{ diffuse 0.9 ambient 0.1 } scale 0.5 } translate <0,0,-1.4> } cylinder { <-1000,0,1> <1000,0,1> 0.2 texture { pigment { color rgb <1,0.5,0.5>} } } union { // pesc cab boca omb esq brac esq mao esq per esq joe esq pe esq omb dir brac dir mao dir per dir joe dir pe dir rabo corpo //robo(<0,45,0>,<0,45,0>,<0,30,0>,<180,90,0>,<0,0,0>,<0,0,0>,<90,90,0>,<0,0,0>,<0,0,0>,<-180,90,0>,<0,0,0>,<0,0,0>,<-90,90,0>,<0,0,0>,<0,0,0>,<0,0,0>,<0,0,0>) //byClock(clock) // p1 p2 p3 e11 e12 e13 e21 e22 e23 d11 d12 d13 d21 d22 d23 r1 c1 //byFrame(7) byClock(clock) } //union { // robo(e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e) // rotate 90*z // translate <-20, -2, 4> //} } #include "camlight.inc" #declare centro_cena = < 3*clock, 0, 0>; #declare raio_cena = 5; #declare dir_camera = < 0, 0.01, 1.2 >; #declare dist_camera = raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)