void compute_matrix(t_mesh *mesh) { mesh->result = id_matrix(); transform_matrix(mesh->result, mesh->scale); transform_matrix(mesh->result, mesh->rot_x); transform_matrix(mesh->result, mesh->rot_y); transform_matrix(mesh->result, mesh->rot_z); transform_matrix(mesh->result, mesh->trans); }
/* all cpi and result must be aligned (have the same number of xforms, and have final xform in the same slot) */ void flam3_interpolate_n(flam3_genome *result, int ncp, flam3_genome *cpi, double *c, double stagger) { int i, j, k, numstd; if (flam3_palette_interpolation_hsv == cpi[0].palette_interpolation) { for (i = 0; i < 256; i++) { double t[3], s[4]; s[0] = s[1] = s[2] = s[3] = s[4] = 0.0; for (k = 0; k < ncp; k++) { rgb2hsv(cpi[k].palette[i].color, t); for (j = 0; j < 3; j++) s[j] += c[k] * t[j]; s[3] += c[k] * cpi[k].palette[i].color[3]; s[4] += c[k] * cpi[k].palette[i].index; } hsv2rgb(s, result->palette[i].color); result->palette[i].color[3] = s[3]; result->palette[i].index = s[4]; for (j = 0; j < 4; j++) { if (result->palette[i].color[j] < 0.0) result->palette[i].color[j] = 0.0; if (result->palette[i].color[j] > 1.0) result->palette[i].color[j] = 1.0; } if (result->palette[i].index < 0.0) result->palette[i].index = 0.0; if (result->palette[i].index > 255.0) result->palette[i].index = 255.0; } } else { /* Sweep - not the best option for float indices */ for (i = 0; i < 256; i++) { j = (i < (256 * c[0])) ? 0 : 1; result->palette[i] = cpi[j].palette[i]; } } result->palette_index = flam3_palette_random; result->symmetry = 0; result->spatial_filter_select = cpi[0].spatial_filter_select; result->temporal_filter_type = cpi[0].temporal_filter_type; result->palette_mode = cpi[0].palette_mode; result->interpolation_type = cpi[0].interpolation_type; INTERP(brightness); INTERP(contrast); INTERP(highlight_power); INTERP(gamma); INTERP(vibrancy); INTERP(hue_rotation); INTERI(width); INTERI(height); INTERI(spatial_oversample); INTERP(center[0]); INTERP(center[1]); INTERP(rot_center[0]); INTERP(rot_center[1]); INTERP(background[0]); INTERP(background[1]); INTERP(background[2]); INTERP(pixels_per_unit); INTERP(spatial_filter_radius); INTERP(temporal_filter_exp); INTERP(temporal_filter_width); INTERP(sample_density); INTERP(zoom); INTERP(rotate); INTERI(nbatches); INTERI(ntemporal_samples); INTERP(estimator); INTERP(estimator_minimum); INTERP(estimator_curve); INTERP(gam_lin_thresh); /* Interpolate the chaos array */ numstd = cpi[0].num_xforms - (cpi[0].final_xform_index >= 0); for (i=0;i<numstd;i++) { for (j=0;j<numstd;j++) { INTERP(chaos[i][j]); if (result->chaos[i][j]<0) result->chaos[i][j]=0; //chaos can be > 1 //if (result->chaos[i][j]>1) result->chaos[i][j]=1.0; } } /* Interpolate each xform */ for (i = 0; i < cpi[0].num_xforms; i++) { double csave[2]; double td; int all_id; int nx = cpi[0].num_xforms-(cpi[0].final_xform_index>=0); if (ncp==2 && stagger>0 && i!=cpi[0].final_xform_index) { csave[0] = c[0]; csave[1] = c[1]; c[0] = get_stagger_coef(csave[0],stagger,nx,i); c[1] = 1.0-c[0]; } INTERP(xform[i].density); td = result->xform[i].density; result->xform[i].density = (td < 0.0) ? 0.0 : td; INTERP(xform[i].color); if (result->xform[i].color<0) result->xform[i].color=0; if (result->xform[i].color>1) result->xform[i].color=1; INTERP(xform[i].opacity); INTERP(xform[i].color_speed); INTERP(xform[i].animate); INTERP(xform[i].blob_low); INTERP(xform[i].blob_high); INTERP(xform[i].blob_waves); INTERP(xform[i].pdj_a); INTERP(xform[i].pdj_b); INTERP(xform[i].pdj_c); INTERP(xform[i].pdj_d); INTERP(xform[i].fan2_x); INTERP(xform[i].fan2_y); INTERP(xform[i].rings2_val); INTERP(xform[i].perspective_angle); INTERP(xform[i].perspective_dist); INTERP(xform[i].julian_power); INTERP(xform[i].julian_dist); INTERP(xform[i].juliascope_power); INTERP(xform[i].juliascope_dist); INTERP(xform[i].radial_blur_angle); INTERP(xform[i].pie_slices); INTERP(xform[i].pie_rotation); INTERP(xform[i].pie_thickness); INTERP(xform[i].ngon_sides); INTERP(xform[i].ngon_power); INTERP(xform[i].ngon_circle); INTERP(xform[i].ngon_corners); INTERP(xform[i].curl_c1); INTERP(xform[i].curl_c2); INTERP(xform[i].rectangles_x); INTERP(xform[i].rectangles_y); INTERP(xform[i].amw_amp); INTERP(xform[i].disc2_rot); INTERP(xform[i].disc2_twist); INTERP(xform[i].super_shape_rnd); INTERP(xform[i].super_shape_m); INTERP(xform[i].super_shape_n1); INTERP(xform[i].super_shape_n2); INTERP(xform[i].super_shape_n3); INTERP(xform[i].super_shape_holes); INTERP(xform[i].flower_petals); INTERP(xform[i].flower_holes); INTERP(xform[i].conic_eccentricity); INTERP(xform[i].conic_holes); INTERP(xform[i].parabola_height); INTERP(xform[i].parabola_width); INTERP(xform[i].bent2_x); INTERP(xform[i].bent2_y); INTERP(xform[i].bipolar_shift); INTERP(xform[i].cell_size); INTERP(xform[i].cpow_r); INTERP(xform[i].cpow_i); INTERP(xform[i].cpow_power); INTERP(xform[i].curve_xamp); INTERP(xform[i].curve_yamp); INTERP(xform[i].curve_xlength); INTERP(xform[i].curve_ylength); INTERP(xform[i].escher_beta); INTERP(xform[i].lazysusan_x); INTERP(xform[i].lazysusan_y); INTERP(xform[i].lazysusan_twist); INTERP(xform[i].lazysusan_space); INTERP(xform[i].lazysusan_spin); INTERP(xform[i].modulus_x); INTERP(xform[i].modulus_y); INTERP(xform[i].oscope_separation); INTERP(xform[i].oscope_frequency); INTERP(xform[i].oscope_amplitude); INTERP(xform[i].oscope_damping); INTERP(xform[i].popcorn2_x); INTERP(xform[i].popcorn2_y); INTERP(xform[i].popcorn2_c); INTERP(xform[i].separation_x); INTERP(xform[i].separation_xinside); INTERP(xform[i].separation_y); INTERP(xform[i].separation_yinside); INTERP(xform[i].split_xsize); INTERP(xform[i].split_ysize); INTERP(xform[i].splits_x); INTERP(xform[i].splits_y); INTERP(xform[i].stripes_space); INTERP(xform[i].stripes_warp); INTERP(xform[i].wedge_angle); INTERP(xform[i].wedge_hole); INTERP(xform[i].wedge_count); INTERP(xform[i].wedge_swirl); INTERP(xform[i].wedge_julia_angle); INTERP(xform[i].wedge_julia_count); INTERP(xform[i].wedge_julia_power); INTERP(xform[i].wedge_julia_dist); INTERP(xform[i].wedge_sph_angle); INTERP(xform[i].wedge_sph_hole); INTERP(xform[i].wedge_sph_count); INTERP(xform[i].wedge_sph_swirl); INTERP(xform[i].whorl_inside); INTERP(xform[i].whorl_outside); INTERP(xform[i].waves2_scalex); INTERP(xform[i].waves2_scaley); INTERP(xform[i].waves2_freqx); INTERP(xform[i].waves2_freqy); for (j = 0; j < flam3_nvariations; j++) INTERP(xform[i].var[j]); if (flam3_inttype_log == cpi[0].interpolation_type) { double cxmag[4][2]; // XXX why only 4? should be ncp double cxang[4][2]; double cxtrn[4][2]; /* affine part */ clear_matrix(result->xform[i].c); convert_linear_to_polar(cpi,ncp,i,0,cxang,cxmag,cxtrn); interp_and_convert_back(c, ncp, i, cxang, cxmag, cxtrn,result->xform[i].c); /* post part */ all_id = 1; for (k=0; k<ncp; k++) all_id &= id_matrix(cpi[k].xform[i].post); clear_matrix(result->xform[i].post); if (all_id) { result->xform[i].post[0][0] = 1.0; result->xform[i].post[1][1] = 1.0; } else { convert_linear_to_polar(cpi,ncp,i,1,cxang,cxmag,cxtrn); interp_and_convert_back(c, ncp, i, cxang, cxmag, cxtrn,result->xform[i].post); } } else { /* Interpolate c matrix & post */ clear_matrix(result->xform[i].c); clear_matrix(result->xform[i].post); all_id = 1; for (k = 0; k < ncp; k++) { sum_matrix(c[k], cpi[k].xform[i].c, result->xform[i].c); sum_matrix(c[k], cpi[k].xform[i].post, result->xform[i].post); all_id &= id_matrix(cpi[k].xform[i].post); } if (all_id) { clear_matrix(result->xform[i].post); result->xform[i].post[0][0] = 1.0; result->xform[i].post[1][1] = 1.0; } } if (ncp==2 && stagger>0 && i!=cpi[0].final_xform_index) { c[0] = csave[0]; c[1] = csave[1]; } } }