// Trabalho prático 09 // ====================================================================== //Includes #include "eixos.inc" #include "dados.inc" // CORES E TEXTURAS background{ color rgb < 0.75, 0.80, 0.85 > } #declare tex = texture{ pigment{ color rgb < 1.00, 0.80, 0.10 > } finish{ diffuse 0.9 ambient 0.1 } } // ====================================================================== // DESCRIÇÃO DA CENA #declare body = difference{ cylinder{ <-2,0,0>, <2,0,0>, 0.5 texture {tex} } box{ <-2.1,-0.5,0>, <2.1,0.5,-0.5> texture {tex} } } // ====================================================================== // ====================================================================== // ====================================================================== // Claw #declare Claw = union{ sphere{ <0,0,0>, legRadio texture {tex} } cylinder{ <0,legRadio,0>, <0,clawLen,0>, legRadio texture {tex} } } // ====================================================================== // Tarsus #macro Tarsus(angClaw) union{ sphere{ <0,0,0>, legRadio texture {tex} } cylinder{ <0,legRadio,0>, <0,tarsusLen,0>, legRadio texture {tex} } object{Claw rotate translate <0,legRadio+tarsusLen,0>} } #end // ====================================================================== // Tibia #macro Tibia(angTarsus,angClaw) union{ sphere{ <0,0,0>, legRadio texture {tex} } cylinder{ <0,legRadio,0>, <0,tibiaLen,0>, legRadio texture {tex} } object{Tarsus(angClaw) rotate translate <0,legRadio+tibiaLen,0>} } #end // ====================================================================== // Femur #macro Femur(angTibia,angTarsus,angClaw) union{ sphere{ <0,0,0>, legRadio texture {tex} } cylinder{ <0,legRadio,0>, <0,femurLen,0>, legRadio texture {tex} } object{Tibia(angTarsus,angClaw) rotate translate <0,legRadio+femurLen,0>} } #end // ====================================================================== // Coxa #macro Coxa(angFemur,angTibia,angTarsus,angClaw) union{ sphere{ <0,0,0>, legRadio texture {tex} } cylinder{ <0,legRadio,0>, <0,coxaLen,0>, legRadio texture {tex} } object{Femur(angTibia,angTarsus,angClaw) rotate translate <0,legRadio+coxaLen,0>} } #end // ====================================================================== // Leg #macro Leg(angCoxa,angFemur,angTibia,angTarsus,angClaw,transl,reflect) object{Coxa(angFemur,angTibia,angTarsus,angClaw) rotate<0,0,angCoxa> translate < transl,0,0 > scale<1,reflect,1>} #end // ====================================================================== // macro Dragon #macro Dragon(dragon) #local f=0; #for(l,0,nLegs-1) object{body translate <0,0,0.1>} object{Leg( dragon[l][0], dragon[l][1], dragon[l][2], dragon[l][3], dragon[l][4], dragon[l][5], dragon[l][6])} #end #end // ====================================================================== // ====================================================================== // ====================================================================== //macro interp1 KeyFrame //Numero de Pernas //Numero de Angulos //matriz Q[frame][perna][angulo] #macro interp1KeyFrame (NP,NA,Q,k0,t0,t1,tt,R) #for (i, 0, NP-1, 1) #for (k, 0, NA-1, 1) #declare R[i][k] = interp1(Q[k0][i][k], Q[k0+1][i][k], t0, t1, tt); #end #end #end // ====================================================================== // macro interp1 #macro interp1 (v0, v1, t0, t1, tt) #local rr = (tt - t0) / (t1 - t0); #local ss = 1 - rr; #local vv = ss * v0 + rr * v1; vv #end // ====================================================================== // macro busca tempo #macro busca_tempo(clk, nk, tk) //devolve k tal que //tk[k] <= clk <= tk[k+1] #local result = -1; #for (k, 0, nk-2, 1) #if ((tk[k] <= clk) & (clk < tk[k+1])) #local result = k; #end #end #if (result = -1) #local result = nk-1; #end result #end // ====================================================================== // ====================================================================== // ====================================================================== //#declare frame = busca_tempo(0.100, nFrames, tk); // CENA object{ eixos(3.00) translate < 0,0,0 > } object{ eixos(1.0) } #declare frame = busca_tempo(clock, nFrames, tk); interp1KeyFrame(nLegs,nParam,Q,frame,0,1,clock,R) Dragon(R) // ILUMINACAO E CAMERA #include "camlight.inc" #declare centro_cena = < 0, 3, 0>; #declare raio_cena = 7.0; #declare dir_camera = < 10, -5, 5 >; #declare dist_camera = 5*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)