diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 21:35:20 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 21:35:20 +0400 |
commit | f3407e7d60d8000d71c66192d760bd5700345b21 (patch) | |
tree | 99930ebf3b63d48bff2def3d30d543acacd6f1b1 /source/blender/blenkernel | |
parent | 448731834839bbddee02558080dd9a5e586f6f21 (diff) |
Textures/Shaders: extend TexMapping to include projection options, and add a
ColorMapping struct for color manipulation of textures. These will be the
standard built-in texture node options for manipulating the incoming texture
coordinate and outgoing color.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 94 |
3 files changed, 84 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 7033a2e0cce..ac56cd02eb0 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 260 -#define BLENDER_SUBVERSION 1 +#define BLENDER_SUBVERSION 2 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index de72428b3d7..508fef8d9a4 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -103,9 +103,12 @@ void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex int has_current_material_texture(struct Material *ma); -struct TexMapping *add_mapping(void); -void init_mapping(struct TexMapping *texmap); +struct TexMapping *add_tex_mapping(void); +void default_tex_mapping(struct TexMapping *texmap); +void init_tex_mapping(struct TexMapping *texmap); +struct ColorMapping *add_color_mapping(void); +void default_color_mapping(struct ColorMapping *colormap); void BKE_free_envmapdata(struct EnvMap *env); void BKE_free_envmap(struct EnvMap *env); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 377eeef117e..c80b2880d12 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -202,33 +202,95 @@ void free_plugin_tex(PluginTex *pit) /* ****************** Mapping ******************* */ -TexMapping *add_mapping(void) +TexMapping *add_tex_mapping(void) { - TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "Tex map"); + TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "TexMapping"); + default_tex_mapping(texmap); + + return texmap; +} + +void default_tex_mapping(TexMapping *texmap) +{ + memset(texmap, 0, sizeof(TexMapping)); + texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f; texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f; unit_m4(texmap->mat); - - return texmap; + + texmap->projx= PROJ_X; + texmap->projy= PROJ_Y; + texmap->projz= PROJ_Z; + texmap->mapping= MTEX_FLAT; } -void init_mapping(TexMapping *texmap) +void init_tex_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); + float eul[3], 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 */ + eul[0]= DEG2RADF(texmap->rot[0]); + eul[1]= DEG2RADF(texmap->rot[1]); + eul[2]= DEG2RADF(texmap->rot[2]); + eul_to_mat3( rmat,eul); + + /* 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; + } +} + +ColorMapping *add_color_mapping(void) +{ + ColorMapping *colormap= MEM_callocN(sizeof(ColorMapping), "ColorMapping"); - mul_m3_m3m3(mat, rmat, smat); + default_color_mapping(colormap); - copy_m4_m3(texmap->mat, mat); - copy_v3_v3(texmap->mat[3], texmap->loc); + return colormap; +} + +void default_color_mapping(ColorMapping *colormap) +{ + memset(colormap, 0, sizeof(ColorMapping)); + + init_colorband(&colormap->coba, 1); + + colormap->bright= 1.0; + colormap->contrast= 1.0; + colormap->saturation= 1.0; + colormap->blend_color[0]= 0.8f; + colormap->blend_color[1]= 0.8f; + colormap->blend_color[2]= 0.8f; + colormap->blend_type= MA_RAMP_BLEND; + colormap->blend_factor= 0.0f; } /* ****************** COLORBAND ******************* */ |