Revision: 41630
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41630
Author:   blendix
Date:     2011-11-07 17:35:20 +0000 (Mon, 07 Nov 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenkernel/BKE_texture.h
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesdna/DNA_texture_types.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/makesrna/intern/rna_texture.c
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_mapValue.c
    trunk/blender/source/blender/nodes/shader/nodes/node_shader_mapping.c

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h       2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h       2011-11-07 
17:35:20 UTC (rev 41630)
@@ -42,7 +42,7 @@
  * 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

Modified: trunk/blender/source/blender/blenkernel/BKE_texture.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_texture.h       2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/blenkernel/BKE_texture.h       2011-11-07 
17:35:20 UTC (rev 41630)
@@ -103,9 +103,12 @@
 
 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);

Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c    2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c    2011-11-07 
17:35:20 UTC (rev 41630)
@@ -202,33 +202,95 @@
 
 /* ****************** 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];
+       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");
        
-       size_to_mat3( smat,texmap->size);
+       default_color_mapping(colormap);
        
-       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);
-       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 ******************* */

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c   2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c   2011-11-07 
17:35:20 UTC (rev 41630)
@@ -5991,7 +5991,7 @@
        if(id->flag & LIB_FAKEUSER) id->us= 1;
        else id->us= 0;
        id->icon_id = 0;
-       id->flag &= ~LIB_ID_RECALC;
+       id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
 
        /* this case cannot be direct_linked: it's just the ID part */
        if(bhead->code==ID_ID) {
@@ -7235,6 +7235,22 @@
        }
 }
 
+static void do_version_ntree_tex_mapping_260(void *UNUSED(data), ID 
*UNUSED(id), bNodeTree *ntree)
+{
+       bNode *node;
+
+       for(node=ntree->nodes.first; node; node=node->next) {
+               if(node->type == SH_NODE_MAPPING) {
+                       TexMapping *tex_mapping;
+
+                       tex_mapping= node->storage;
+                       tex_mapping->projx= PROJ_X;
+                       tex_mapping->projy= PROJ_Y;
+                       tex_mapping->projz= PROJ_Z;
+               }
+       }
+}
+
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
        /* WATCH IT!!!: pointers from libdata have not been converted */
@@ -12320,6 +12336,13 @@
                }
        }
 
+       if (main->versionfile < 260 || (main->versionfile == 260 && 
main->subversionfile < 2)) {
+               bNodeTreeType *ntreetype= ntreeGetType(NTREE_SHADER);
+
+               if(ntreetype && ntreetype->foreach_nodetree)
+                       ntreetype->foreach_nodetree(main, NULL, 
do_version_ntree_tex_mapping_260);
+       }
+
        /* put compatibility code here until next subversion bump */
        {
                {

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c  2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c  2011-11-07 
17:35:20 UTC (rev 41630)
@@ -95,6 +95,14 @@
        }
 }
 
+static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
+                                                         bNodeTree 
*UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
+                                                         const char 
*UNUSED(name), int x, int y, int width)
+{
+       uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 
0, 0, "");
+}
+
+
 static void node_socket_button_default(const bContext *C, uiBlock *block,
                                                                bNodeTree 
*ntree, bNode *node, bNodeSocket *sock,
                                                                const char 
*name, int x, int y, int width)
@@ -938,28 +946,28 @@
 
 static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), 
PointerRNA *ptr)
 {
+       PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping");
        uiLayout *row;
        
        uiItemL(layout, "Location:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "location", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "location", 0, "", ICON_NONE);
        
        uiItemL(layout, "Rotation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "rotation", 0, "", ICON_NONE);
        
        uiItemL(layout, "Scale:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "scale", 0, "", ICON_NONE);
        
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
-       uiItemR(row, ptr, "min", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "use_min", 0, "Min", ICON_NONE);
+       uiItemR(row, &mappingptr, "min", 0, "", ICON_NONE);
        
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
-       uiItemR(row, ptr, "max", 0, "", ICON_NONE);
-       
+       uiItemR(row, &mappingptr, "use_max", 0, "Max", ICON_NONE);
+       uiItemR(row, &mappingptr, "max", 0, "", ICON_NONE);
 }
 
 static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), 
PointerRNA *ptr)
@@ -2089,6 +2097,9 @@
                        case SOCK_RGBA:
                                stype->buttonfunc = node_socket_button_color;
                                break;
+                       case SOCK_SHADER:
+                               stype->buttonfunc = node_socket_button_label;
+                               break;
                        default:
                                stype->buttonfunc = NULL;
                        }

Modified: trunk/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_texture_types.h   2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/makesdna/DNA_texture_types.h   2011-11-07 
17:35:20 UTC (rev 41630)
@@ -267,11 +267,13 @@
        
 } Tex;
 
-/* used for mapping node. note: rot is in degrees */
+/* used for mapping and texture nodes. note: rot is in degrees */
 
 typedef struct TexMapping {
        float loc[3], rot[3], size[3];
        int flag;
+       char projx, projy, projz, mapping;
+       int pad;
        
        float mat[4][4];
        float min[3], max[3];
@@ -279,10 +281,24 @@
 
 } TexMapping;
 
+typedef struct ColorMapping {
+       struct ColorBand coba;
+
+       float bright, contrast, saturation;
+       int flag;
+
+       float blend_color[3];
+       float blend_factor;
+       int blend_type, pad[3];
+} ColorMapping;
+
 /* texmap->flag */
-#define TEXMAP_CLIP_MIN        1
-#define TEXMAP_CLIP_MAX        2
+#define TEXMAP_CLIP_MIN                1
+#define TEXMAP_CLIP_MAX                2
+#define TEXMAP_UNIT_MATRIX     4
 
+/* colormap->flag */
+#define COLORMAP_USE_RAMP 1
 
 /* **************** TEX ********************* */
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2011-11-07 
17:30:52 UTC (rev 41629)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2011-11-07 
17:35:20 UTC (rev 41630)
@@ -425,15 +425,6 @@
        *max = val->max;
 }
 
-static void rna_Node_mapping_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-       bNode *node= (bNode*)ptr->data;
-
-       init_mapping((TexMapping *)node->storage);
-       
-       rna_Node_update(bmain, scene, ptr);
-}
-
 static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA 
*ptr)
 {
        bNode *node= (bNode*)ptr->data;
@@ -1077,48 +1068,12 @@
 static void def_sh_mapping(StructRNA *srna)
 {
        PropertyRNA *prop;
-       

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to