#include "colors.inc" #include "shapes.inc" #include "camlight.inc" #include "eixos.inc" #declare component_color_red = texture { pigment { color rgb <0.7, 0.12, 0.12> } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #declare component_color_blue = texture { pigment { color rgb <0.12, 0.12, 0.7> } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #declare component_color_green = texture { pigment { color rgb <0.12, 0.7, 0.12> } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #declare component_color_yellow = texture { pigment { color rgb <0.12, 0.7, 0.7> } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #declare component_color_any = texture { pigment { color rgb <0.7, 0.12, 0.7> } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #declare SEGMENT_SIZE = <0, 1, 0>; #macro Segment(a1, a2, a3) union { sphere { 0.0, 0.25 } object { cylinder { <0, 0, 0>, SEGMENT_SIZE, 0.2 } rotate } } #end #macro Seg0(a) object { Segment(a, 0, 0) texture { component_color_blue } } #end #macro Seg1(a, b) union { object { Segment(a, 0, 0) texture { component_color_green } } object { Seg0(b) translate SEGMENT_SIZE rotate } } #end #macro Seg2(a, b, c) union { object { Segment(a, 0, 0) texture { component_color_red } } object { Seg1(b, c) translate SEGMENT_SIZE rotate } } #end #macro Seg3(a, b, c, d) union { object { Segment(a, 0, 0) texture { component_color_any } } object { Seg2(b, c, d) translate SEGMENT_SIZE rotate } } #end #macro Seg4(a, b, c, d, e) union { object { Segment(0, a, 0) texture { component_color_yellow } } object { Seg3(b, c, d, e) translate SEGMENT_SIZE rotate <0, a, 0> } } #end #macro DragaoMosquito(position, legs) union { //Body sphere { 0, 2 texture { component_color_red } } sphere { <0, 0, -2>, 1.5 texture { component_color_green } } sphere { <0, 0, 2>, 1.5 texture { component_color_blue } } //L0 object { Seg4(legs[0][0], legs[0][1], legs[0][2], legs[0][3], legs[0][4]) translate <0, 1.5, 2> scale <0, -1, 0> } //L1 object { Seg4(legs[1][0], legs[1][1], legs[1][2], legs[1][3], legs[1][4]) translate <0, 2, 0> scale <0, -1, 0> } //L2 object { Seg4(legs[2][0], legs[2][1], legs[2][2], legs[2][3], legs[2][4]) translate <0, 1.5, -2> scale <0, -1, 0> } //D0 object { Seg4(legs[3][0], legs[3][1], legs[3][2], legs[3][3], legs[3][4]) translate <0, 1.5, 2> } //D1 object { Seg4(legs[4][0], legs[4][1], legs[4][2], legs[4][3], legs[4][4]) translate <0, 2, 0> } //D2 object { Seg4(legs[5][0], legs[5][1], legs[5][2], legs[5][3], legs[5][4]) translate <0, 1.5, -2> } } #end // ANIMATION #declare KEYFRAMES_SIZE = 6; #declare keyframes = array[KEYFRAMES_SIZE]; #declare keyframes[0] = 0.0; #declare keyframes[1] = 0.2; #declare keyframes[2] = 0.4; #declare keyframes[3] = 0.6; #declare keyframes[4] = 0.8; #declare keyframes[5] = 1.0; #declare NP = 6; #declare NA = 5; #declare Q = array[KEYFRAMES_SIZE]; #declare Q[0] = array[NP][NA]; #declare Q[1] = array[NP][NA]; #declare Q[2] = array[NP][NA]; #declare Q[3] = array[NP][NA]; #declare Q[4] = array[NP][NA]; #declare Q[5] = array[NP][NA]; //Q0 #declare Q[0][0][0] = 15; #declare Q[0][0][1] = 15; #declare Q[0][0][2] = 15; #declare Q[0][0][3] = 15; #declare Q[0][0][4] = 15; #declare Q[0][1][0] = 15; #declare Q[0][1][1] = 15; #declare Q[0][1][2] = 15; #declare Q[0][1][3] = 15; #declare Q[0][1][4] = 15; #declare Q[0][2][0] = 15; #declare Q[0][2][1] = 15; #declare Q[0][2][2] = 15; #declare Q[0][2][3] = 15; #declare Q[0][2][4] = 15; #declare Q[0][3][0] = 15; #declare Q[0][3][1] = 15; #declare Q[0][3][2] = 15; #declare Q[0][3][3] = 15; #declare Q[0][3][4] = 15; #declare Q[0][4][0] = 15; #declare Q[0][4][1] = 15; #declare Q[0][4][2] = 15; #declare Q[0][4][3] = 15; #declare Q[0][4][4] = 15; #declare Q[0][5][0] = 15; #declare Q[0][5][1] = 15; #declare Q[0][5][2] = 15; #declare Q[0][5][3] = 15; #declare Q[0][5][4] = 15; //Q1 #declare Q[1][0][0] = 27.5; #declare Q[1][0][1] = 27.5; #declare Q[1][0][2] = 27.5; #declare Q[1][0][3] = 27.5; #declare Q[1][0][4] = 27.5; #declare Q[1][1][0] = 15; #declare Q[1][1][1] = 15; #declare Q[1][1][2] = 15; #declare Q[1][1][3] = 15; #declare Q[1][1][4] = 15; #declare Q[1][2][0] = 15; #declare Q[1][2][1] = 15; #declare Q[1][2][2] = 15; #declare Q[1][2][3] = 15; #declare Q[1][2][4] = 15; #declare Q[1][3][0] = 27.5; #declare Q[1][3][1] = 27.5; #declare Q[1][3][2] = 27.5; #declare Q[1][3][3] = 27.5; #declare Q[1][3][4] = 27.5; #declare Q[1][4][0] = 15; #declare Q[1][4][1] = 15; #declare Q[1][4][2] = 15; #declare Q[1][4][3] = 15; #declare Q[1][4][4] = 15; #declare Q[1][5][0] = 15; #declare Q[1][5][1] = 15; #declare Q[1][5][2] = 15; #declare Q[1][5][3] = 15; #declare Q[1][5][4] = 15; //Q2 #declare Q[2][0][0] = 45; #declare Q[2][0][1] = 45; #declare Q[2][0][2] = 45; #declare Q[2][0][3] = 45; #declare Q[2][0][4] = 45; #declare Q[2][1][0] = 27.5; #declare Q[2][1][1] = 27.5; #declare Q[2][1][2] = 27.5; #declare Q[2][1][3] = 27.5; #declare Q[2][1][4] = 27.5; #declare Q[2][2][0] = 15; #declare Q[2][2][1] = 15; #declare Q[2][2][2] = 15; #declare Q[2][2][3] = 15; #declare Q[2][2][4] = 15; #declare Q[2][3][0] = 45; #declare Q[2][3][1] = 45; #declare Q[2][3][2] = 45; #declare Q[2][3][3] = 45; #declare Q[2][3][4] = 45; #declare Q[2][4][0] = 27.5; #declare Q[2][4][1] = 27.5; #declare Q[2][4][2] = 27.5; #declare Q[2][4][3] = 27.5; #declare Q[2][4][4] = 27.5; #declare Q[2][5][0] = 15; #declare Q[2][5][1] = 15; #declare Q[2][5][2] = 15; #declare Q[2][5][3] = 15; #declare Q[2][5][4] = 15; //Q3 #declare Q[3][0][0] = 27.5; #declare Q[3][0][1] = 27.5; #declare Q[3][0][2] = 27.5; #declare Q[3][0][3] = 27.5; #declare Q[3][0][4] = 27.5; #declare Q[3][1][0] = 45; #declare Q[3][1][1] = 45; #declare Q[3][1][2] = 45; #declare Q[3][1][3] = 45; #declare Q[3][1][4] = 45; #declare Q[3][2][0] = 27.5; #declare Q[3][2][1] = 27.5; #declare Q[3][2][2] = 27.5; #declare Q[3][2][3] = 27.5; #declare Q[3][2][4] = 27.5; #declare Q[3][3][0] = 27.5; #declare Q[3][3][1] = 27.5; #declare Q[3][3][2] = 27.5; #declare Q[3][3][3] = 27.5; #declare Q[3][3][4] = 27.5; #declare Q[3][4][0] = 45; #declare Q[3][4][1] = 45; #declare Q[3][4][2] = 45; #declare Q[3][4][3] = 45; #declare Q[3][4][4] = 45; #declare Q[3][5][0] = 27.5; #declare Q[3][5][1] = 27.5; #declare Q[3][5][2] = 27.5; #declare Q[3][5][3] = 27.5; #declare Q[3][5][4] = 27.5; //Q4 #declare Q[4][0][0] = 15; #declare Q[4][0][1] = 15; #declare Q[4][0][2] = 15; #declare Q[4][0][3] = 15; #declare Q[4][0][4] = 15; #declare Q[4][1][0] = 27.5; #declare Q[4][1][1] = 27.5; #declare Q[4][1][2] = 27.5; #declare Q[4][1][3] = 27.5; #declare Q[4][1][4] = 27.5; #declare Q[4][2][0] = 35; #declare Q[4][2][1] = 35; #declare Q[4][2][2] = 35; #declare Q[4][2][3] = 35; #declare Q[4][2][4] = 35; #declare Q[4][3][0] = 15; #declare Q[4][3][1] = 15; #declare Q[4][3][2] = 15; #declare Q[4][3][3] = 15; #declare Q[4][3][4] = 15; #declare Q[4][4][0] = 27.5; #declare Q[4][4][1] = 27.5; #declare Q[4][4][2] = 27.5; #declare Q[4][4][3] = 27.5; #declare Q[4][4][4] = 27.5; #declare Q[4][5][0] = 35; #declare Q[4][5][1] = 35; #declare Q[4][5][2] = 35; #declare Q[4][5][3] = 35; #declare Q[4][5][4] = 35; //Q5 #declare Q[5][0][0] = 15; #declare Q[5][0][1] = 15; #declare Q[5][0][2] = 15; #declare Q[5][0][3] = 15; #declare Q[5][0][4] = 15; #declare Q[5][1][0] = 15; #declare Q[5][1][1] = 15; #declare Q[5][1][2] = 15; #declare Q[5][1][3] = 15; #declare Q[5][1][4] = 15; #declare Q[5][2][0] = 15; #declare Q[5][2][1] = 15; #declare Q[5][2][2] = 15; #declare Q[5][2][3] = 15; #declare Q[5][2][4] = 15; #declare Q[5][3][0] = 15; #declare Q[5][3][1] = 15; #declare Q[5][3][2] = 15; #declare Q[5][3][3] = 15; #declare Q[5][3][4] = 15; #declare Q[5][4][0] = 15; #declare Q[5][4][1] = 15; #declare Q[5][4][2] = 15; #declare Q[5][4][3] = 15; #declare Q[5][4][4] = 15; #declare Q[5][5][0] = 15; #declare Q[5][5][1] = 15; #declare Q[5][5][2] = 15; #declare Q[5][5][3] = 15; #declare Q[5][5][4] = 15; #macro search_initial_keyframe(cc, n, kfs) #local fkf = 0; #for (kf, 1, n-1, 1) #if (kfs[kf-1] < cc & cc < kfs[kf]) #declare fkf = kf - 1; #end #end fkf #end #macro interpolate1(v0, v1, t0, t1, tt) #local rr = (tt-t0)/(t1-t0); #local ss = 1 - rr; #local vv = ss * v0 + rr * v1; vv #end #macro interpolate1_matrix(matrix1, matrix2, matrix_L, matrix_C, c0, c1, cc) #local mr = array[matrix_L][matrix_C]; #for (i, 0, matrix_L-1, 1) #for (j, 0, matrix_C-1, 1) #declare mr[i][j] = interpolate1(matrix1[i][j], matrix2[i][j], c0, c1, cc); #end #end mr #end // SCENE #declare center = <4.00, 5.00, 2.00>; #declare scene_radius = 10.0; #declare camera_direction = <20.00, 20.00, 8.00>; #declare camera_distance = 5 * scene_radius; #declare light_intensity = 0.6; camlight( center, scene_radius, camera_direction, camera_distance, z, light_intensity ) background { color rgb <0.7, 0.7, 0.7> } #declare initial_key_frame = search_initial_keyframe(clock, KEYFRAMES_SIZE, keyframes); #declare final_key_frame = initial_key_frame + 1; #declare interpolated_q = interpolate1_matrix( Q[initial_key_frame], Q[final_key_frame], NP, NA, keyframes[initial_key_frame], keyframes[final_key_frame], clock ) DragaoMosquito(<0, 0, 0>, interpolated_q)