Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-07 21:35:20 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-07 21:35:20 +0400
commitf3407e7d60d8000d71c66192d760bd5700345b21 (patch)
tree99930ebf3b63d48bff2def3d30d543acacd6f1b1 /source/blender/blenkernel/intern/texture.c
parent448731834839bbddee02558080dd9a5e586f6f21 (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/intern/texture.c')
-rw-r--r--source/blender/blenkernel/intern/texture.c94
1 files changed, 78 insertions, 16 deletions
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 ******************* */