void init_mapping(TexMapping *texmap) { float eul[3], smat[3][3], rmat[3][3], mat[3][3]; size_to_mat3( smat,texmap->size); eul[0]= DEG2RADF(texmap->rot[0]); eul[1]= DEG2RADF(texmap->rot[1]); eul[2]= DEG2RADF(texmap->rot[2]); eul_to_mat3( rmat,eul); mul_m3_m3m3(mat, rmat, smat); copy_m4_m3(texmap->mat, mat); VECCOPY(texmap->mat[3], texmap->loc); }
void init_tex_mapping(TexMapping *texmap) { float smat[3][3], rmat[3][3], mat[3][3], proj[3][3]; if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z && is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { unit_m4(texmap->mat); texmap->flag |= TEXMAP_UNIT_MATRIX; } else { /* axis projection */ zero_m3(proj); if (texmap->projx != PROJ_N) proj[texmap->projx - 1][0] = 1.0f; if (texmap->projy != PROJ_N) proj[texmap->projy - 1][1] = 1.0f; if (texmap->projz != PROJ_N) proj[texmap->projz - 1][2] = 1.0f; /* scale */ size_to_mat3(smat, texmap->size); /* rotation */ /* TexMapping rotation are now in radians. */ eul_to_mat3(rmat, texmap->rot); /* compose it all */ mul_m3_m3m3(mat, rmat, smat); mul_m3_m3m3(mat, proj, mat); /* translation */ copy_m4_m3(texmap->mat, mat); copy_v3_v3(texmap->mat[3], texmap->loc); texmap->flag &= ~TEXMAP_UNIT_MATRIX; } }