// Exemplo de arquivo de descricao de cena para POV-ray // Last edited on 2023-12-27 04:25:35 by stolfi 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 } } // ====================================================================== // MEMBRO #declare UNIT = 1; #declare OFFSET_MULTIPLIER = 1.1; #macro hand() cone { <0, 0, 0>, UNIT / 2 <0, UNIT, 0>, 0 texture { tx_plastico } } #end #macro elbow(hand_yaw) union { cylinder { <0, 0, 0>, <0, UNIT * 2, 0>, UNIT / 2 texture { tx_plastico } } object { hand() rotate <0, 0, -hand_yaw> translate <0, UNIT * 2, 0> } } #end #macro shoulder(elbow_yaw, hand_yaw) union { cylinder { <0, 0, 0>, <0, UNIT * 2, 0>, UNIT / 2 texture { tx_plastico } } object { elbow(hand_yaw) rotate <0, 0, -elbow_yaw> translate <0, UNIT * 2, 0> } } #end #macro member(shoulder_pitch, shoulder_yaw, elbow_yaw, hand_yaw) object { shoulder(elbow_yaw, hand_yaw) rotate } #end #macro head() cone { <0, 0, 0>, UNIT , 0 texture { tx_plastico } } #end #macro neck(head_pitch, head_roll) union { cylinder { <0, 0, 0>, <0, 0, UNIT * 2>, UNIT / 1.5 texture { tx_plastico } } object { head() rotate <0, head_pitch, -head_roll> translate <0, 0, UNIT * 2> * OFFSET_MULTIPLIER } } #end #macro spine(neck_pitch, head_pitch, head_roll) union { cylinder { <0, 0, 0>, <0, 0, UNIT>, UNIT / 1.5 texture { tx_plastico } } object { neck(head_pitch, head_roll) rotate <0, neck_pitch, 0> translate <0, 0, UNIT> * OFFSET_MULTIPLIER } } #end #macro upper(spine_roll, neck_pitch, head_pitch, head_roll) object { spine(neck_pitch, head_pitch, head_roll) rotate <0, 0, -spine_roll> } #end #declare PROPORTIONS = <1, 1.5, 2.5> * UNIT; #macro hip() box { -PROPORTIONS, PROPORTIONS texture { tx_plastico } } #end #macro sloth( shoulder_pitch1, shoulder_yaw1, elbow_yaw1, hand_yaw1, shoulder_pitch2, shoulder_yaw2, elbow_yaw2, hand_yaw2, shoulder_pitch3, shoulder_yaw3, elbow_yaw3, hand_yaw3, shoulder_pitch4, shoulder_yaw4, elbow_yaw4, hand_yaw4, spine_roll, neck_pitch, head_pitch, head_roll ) union { hip() object { member(shoulder_pitch1, shoulder_yaw1, elbow_yaw1, hand_yaw1) translate <0, PROPORTIONS.y, PROPORTIONS.z * 0.6> } object { member(shoulder_pitch2, shoulder_yaw2, elbow_yaw2, hand_yaw2) translate <0, PROPORTIONS.y, -PROPORTIONS.z * 0.6> } object { member(shoulder_pitch3, shoulder_yaw3, elbow_yaw3, hand_yaw3) translate <0, PROPORTIONS.y, PROPORTIONS.z * 0.6> scale <1.0, -1.0, 1.0> } object { member(shoulder_pitch4, shoulder_yaw4, elbow_yaw4, hand_yaw4) translate <0, PROPORTIONS.y, -PROPORTIONS.z * 0.6> scale <1.0, -1.0, 1.0> } object { upper(spine_roll, neck_pitch, head_pitch, head_roll) translate <0, 0, PROPORTIONS.z> } } #end #declare hands_start_keyframe = array[4] { 30 , 30, 15, 0 }; #declare hands_end_keyframe = array[4] { 45 , 65, 65, 35 }; #macro hands_animation(tt) #local angles = array[4]; #local current = 0; #while (current < 4) #if (tt < 0.4) #local normalized_time = tt / 0.4; #local angles[current] = hands_start_keyframe[current] * (1 - normalized_time) + hands_end_keyframe[current] * normalized_time; #end #if (tt >= 0.4 & tt <= 0.6) #local angles[current] = hands_end_keyframe[current]; #end #if (tt > 0.6) #local normalized_time = (tt - 0.6) / 0.4; #local angles[current] = hands_end_keyframe[current] * (1 - normalized_time) + hands_start_keyframe[current] * normalized_time; #end #local current = current + 1; #end angles #end #declare head_idle_keyframe = array[4] { 10, 15, 30, 0 }; #declare head_bob_amplitude = array[4] {0, 0, 0, 50}; #macro head_animation(tt) #local angles = array[4]; #local current = 0; #while (current < 4) #if (tt < 0.4 | tt > 0.6) #local angles[current] = head_idle_keyframe[current]; #else #local normalized_time = (tt - 0.4) / 0.2; #local angles[current] = head_bob_amplitude[current] * sin(normalized_time * 2 * pi) + head_idle_keyframe[current]; #end #local current = current + 1; #end angles #end #declare NP = 17; #declare NQ = 6; #declare TQ = array[NQ + 1]; #declare PQ = array[NQ + 1]; #macro empacota(BR_0, BR_1, BR_2, BR_3, BL_0, BL_1, BL_2, BL_3, TR_0, TR_1, TR_2, TR_3, TL_0, TL_1, TL_2, TL_3, dx) #local P = array[NP]; #local P[0] = BR_0; #local P[1] = BR_1; #local P[2] = BR_2; #local P[3] = BR_3; #local P[4] = BL_0; #local P[5] = BL_1; #local P[6] = BL_2; #local P[7] = BL_3; #local P[8] = TR_0; #local P[9] = TR_1; #local P[10] = TR_2; #local P[11] = TR_3; #local P[12] = TL_0; #local P[13] = TL_1; #local P[14] = TL_2; #local P[15] = TL_3; #local P[16] = dx; P #end #macro interpola_quadros(tt, ta, pa, tb, pb, BR_0, BR_1, BR_2, BR_3, BL_0, BL_1, BL_2, BL_3, TR_0, TR_1, TR_2, TR_3, TL_0, TL_1, TL_2, TL_3, dx) #local s = (tt - ta)/(tb - ta); #declare BR_0 = (1 - s) * pa[0] + s * pb[0]; #declare BR_1 = (1 - s) * pa[1] + s * pb[1]; #declare BR_2 = (1 - s) * pa[2] + s * pb[2]; #declare BR_3 = (1 - s) * pa[3] + s * pb[3]; #declare BL_0 = (1 - s) * pa[4] + s * pb[4]; #declare BL_1 = (1 - s) * pa[5] + s * pb[5]; #declare BL_2 = (1 - s) * pa[6] + s * pb[6]; #declare BL_3 = (1 - s) * pa[7] + s * pb[7]; #declare TR_0 = (1 - s) * pa[8] + s * pb[8]; #declare TR_1 = (1 - s) * pa[9] + s * pb[9]; #declare TR_2 = (1 - s) * pa[10] + s * pb[10]; #declare TR_3 = (1 - s) * pa[11] + s * pb[11]; #declare TL_0 = (1 - s) * pa[12] + s * pb[12]; #declare TL_1 = (1 - s) * pa[13] + s * pb[13]; #declare TL_2 = (1 - s) * pa[14] + s * pb[14]; #declare TL_3 = (1 - s) * pa[15] + s * pb[15]; #declare dx = (1 - s) * pa[16] + s * pb[16]; #end #declare TQ[0] = 0; #declare PQ[0] = empacota(-20, 30, 90, 10, -20, 30, 90, 10, -20, 30, 90, 10, -20, 30, 90, 10, 0); #declare TQ[1] = 0.2; #declare PQ[1] = empacota(-20, 30, 90, 10, -20, 30, 90, 10, 50, 45, 45, 30, -20, 30, 90, 10, 0); #declare TQ[2] = 0.4; #declare PQ[2] = empacota(-20, 30, 90, 10, -20, 30, 90, 10, 50, 45, 45, 30, 50, 45, 45, 30, 0); #declare TQ[3] = 0.6; #declare PQ[3] = empacota(-50, 45, 45, 30, -50, 45, 45, 30, -20, 30, 90, 10, -20, 30, 90, 10, 2); #declare TQ[4] = 0.8; #declare PQ[4] = empacota(-20, 30, 90, 10, -50, 45, 45, 30, -20, 30, 90, 10, -20, 30, 90, 10, 2); #declare TQ[5] = 1; #declare PQ[5] = empacota(-20, 30, 90, 10, -20, 30, 90, 10, -20, 30, 90, 10, -20, 30, 90, 10, 2); #declare TQ[6] = 2; #declare PQ[6] = empacota(-20, 30, 90, 10, -20, 30, 90, 10, -20, 30, 90, 10, -20, 30, 90, 10, 2); #macro acha_quadro(ttt) #local k = 0; #if (ttt <= 0) #local k = 1; #end #while (ttt > TQ[k]) #local k = k + 1; #end k - 1 #end #declare raio = 2.000; #include "eixos.inc" #include "galho-tr.inc" #local Lg = 2; // Deslocamento por ciclo -- Prof #macro cena(tt) #local TR_hands = hands_animation(tt); #local TL_hands = hands_animation(tt); #local head_angles = head_animation(tt); #local BR_0 = 0; #local BR_1 = 0; #local BR_2 = 0; #local BR_3 = 0; #local BL_0 = 0; #local BL_1 = 0; #local BL_2 = 0; #local BL_3 = 0; #local TR_0 = 0; #local TR_1 = 0; #local TR_2 = 0; #local TR_3 = 0; #local TL_0 = 0; #local TL_1 = 0; #local TL_2 = 0; #local TL_3 = 0; #local DX = 0; #local k = acha_quadro(tt); interpola_quadros(tt, TQ[k], PQ[k], TQ[k + 1], PQ[k + 1], BR_0, BR_1, BR_2, BR_3, BL_0, BL_1, BL_2, BL_3, TR_0, TR_1, TR_2, TR_3, TL_0, TL_1, TL_2, TL_3, DX) union{ object { sloth( TR_0, TR_1, TR_2, TR_3, // TR member BR_0, BR_1, BR_2, BR_3, // BR member TL_0, TL_1, TL_2, TL_3, // TL member BL_0, BL_1, BL_2, BL_3, // BR member head_angles[0], head_angles[1], head_angles[2], head_angles[3] // Head ) translate <0, 0, DX> } object{ galho( < 0, 0, -Lg/2 >, < 0, 0, +Lg/2 >, 2, 0) translate 4*x } // cylinder { // <4, 0, -100>, <4, 0, 100>, 2 // texture{ // pigment{ color rgb < 0.85, 0.95, 0.5 > filter 0.70 } // finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 } // } } #end // object{ eixos(10) } object{ cena(clock) } #include "camlight.inc" #declare centro_cena = < 3.00, 0.00, 2.00 > + clock*Lg*z; #declare raio_cena = 10.0; #declare dir_camera = < 1, 7, 3 >; #declare dist_camera = 7*raio_cena; #declare intens_luz = 1.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)