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:
authorTon Roosendaal <ton@blender.org>2006-01-04 15:13:13 +0300
committerTon Roosendaal <ton@blender.org>2006-01-04 15:13:13 +0300
commit3153a238b38573e77fd277abca927d77c8bcce4a (patch)
treebb4c628956e9c67851e6a4e6fd37cfc06ba975a6 /source/blender
parentbd26fe8f94dd0f8ee558df1e7c877eba3db912be (diff)
Orange: more Node goodies;
- New Node: "Mapping". Allows input vector to be translated, rotated and scaled. And optional be clipped to a range. Works for colors too! - The button "Normal" now allows incremental input, so a click in the button won't change the normal anymore - Connecting wires now show selection state for Nodes, with nice blended colors. Both colors were added in Themes, but default to black and white
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_node.h1
-rw-r--r--source/blender/blenkernel/BKE_texture.h4
-rw-r--r--source/blender/blenkernel/intern/node.c4
-rw-r--r--source/blender/blenkernel/intern/node_shaders.c244
-rw-r--r--source/blender/blenkernel/intern/texture.c31
-rw-r--r--source/blender/makesdna/DNA_node_types.h1
-rw-r--r--source/blender/makesdna/DNA_texture_types.h17
-rw-r--r--source/blender/src/drawnode.c82
-rw-r--r--source/blender/src/editnode.c2
-rw-r--r--source/blender/src/interface.c31
-rw-r--r--source/blender/src/resources.c5
-rw-r--r--source/blender/src/usiblender.c1
12 files changed, 302 insertions, 121 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index f6dcebe86f4..7253a0cc95a 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -158,6 +158,7 @@ struct ShadeResult;
#define SH_NODE_TEXTURE 106
#define SH_NODE_NORMAL 107
#define SH_NODE_GEOMETRY 108
+#define SH_NODE_MAPPING 109
/* custom defines: options for Material node */
#define SH_NODE_MAT_DIFF 1
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 4db98599206..033de758c7b 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -40,6 +40,7 @@ struct PluginTex;
struct LampRen;
struct ColorBand;
struct HaloRen;
+struct TexMapping;
/* in ColorBand struct */
#define MAXCOLORBAND 16
@@ -61,5 +62,8 @@ void make_local_texture(struct Tex *tex);
void autotexname(struct Tex *tex);
struct Tex *give_current_texture(struct Object *ob, int act);
+struct TexMapping *add_mapping(void);
+void init_mapping(struct TexMapping *texmap);
+
#endif
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index c526bc36d15..7aec48edd83 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -692,8 +692,10 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
if(ntree->type==NTREE_SHADER) {
if(type==SH_NODE_MATERIAL)
node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC;
- else if(node->type==SH_NODE_VALTORGB)
+ else if(type==SH_NODE_VALTORGB)
node->storage= add_colorband(1);
+ else if(type==SH_NODE_MAPPING)
+ node->storage= add_mapping();
}
return node;
diff --git a/source/blender/blenkernel/intern/node_shaders.c b/source/blender/blenkernel/intern/node_shaders.c
index b5b68b25fbb..6bc3045c139 100644
--- a/source/blender/blenkernel/intern/node_shaders.c
+++ b/source/blender/blenkernel/intern/node_shaders.c
@@ -66,7 +66,21 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(ShadeInput *, ShadeResult
}
-/* **************** output node ************ */
+/* ******************************************************** */
+/* ********* Shader Node type definitions ***************** */
+/* ******************************************************** */
+
+/* SocketType syntax:
+ socket type, max connections (0 is no limit), name, 4 values for default, 2 values for range */
+
+/* Verification rule: If name changes, a saved socket and its links will be removed! Type changes are OK */
+
+/* **************** OUTPUT ******************** */
+static bNodeSocketType sh_node_output_in[]= {
+ { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
@@ -85,7 +99,7 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN
if(node->flag & NODE_DO_OUTPUT) {
ShadeResult *shr= ((ShaderCallData *)data)->shr;
-
+
VECCOPY(shr->diff, col);
col[0]= col[1]= col[2]= 0.0f;
VECCOPY(shr->spec, col);
@@ -96,96 +110,6 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN
}
}
-
-/* **************** texture node ************ */
-
-static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
-{
- if(data && node->id) {
- ShadeInput *shi= ((ShaderCallData *)data)->shi;
- TexResult texres;
- float *vec, nor[3]={0.0f, 0.0f, 0.0f};
- int retval;
-
- /* out: value, color, normal */
-
- /* we should find out if a normal as output is needed, for now we do all */
- texres.nor= nor;
-
- if(in[0]->hasinput) {
- vec= in[0]->vec;
-
- if(in[0]->datatype==NS_OSA_VECTORS) {
- float *fp= in[0]->data;
- retval= multitex((Tex *)node->id, vec, fp, fp+3, shi->osatex, &texres);
- }
- else if(in[0]->datatype==NS_OSA_VALUES) {
- float *fp= in[0]->data;
- float dxt[3], dyt[3];
-
- dxt[0]= fp[0]; dxt[1]= dxt[2]= 0.0f;
- dyt[0]= fp[1]; dyt[1]= dyt[2]= 0.0f;
- retval= multitex((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres);
- }
- else
- retval= multitex((Tex *)node->id, vec, NULL, NULL, 0, &texres);
- }
- else { /* only for previewrender, so we see stuff */
- vec= shi->lo;
- retval= multitex((Tex *)node->id, vec, NULL, NULL, 0, &texres);
- }
-
- /* stupid exception */
- if( ((Tex *)node->id)->type==TEX_STUCCI) {
- texres.tin= 0.5f + 0.7f*texres.nor[0];
- CLAMP(texres.tin, 0.0f, 1.0f);
- }
-
- /* intensity and color need some handling */
- if(texres.talpha)
- out[0]->vec[0]= texres.ta;
- else
- out[0]->vec[0]= texres.tin;
-
- if((retval & TEX_RGB)==0) {
- out[1]->vec[0]= out[0]->vec[0];
- out[1]->vec[1]= out[0]->vec[0];
- out[1]->vec[2]= out[0]->vec[0];
- out[1]->vec[3]= 1.0f;
- }
- else {
- out[1]->vec[0]= texres.tr;
- out[1]->vec[1]= texres.tg;
- out[1]->vec[2]= texres.tb;
- out[1]->vec[3]= 1.0f;
- }
-
- VECCOPY(out[2]->vec, nor);
-
- if(shi->do_preview)
- nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys);
-
- }
-}
-
-
-
-/* ******************************************************** */
-/* ********* Shader Node type definitions ***************** */
-/* ******************************************************** */
-
-/* SocketType syntax:
- socket type, max connections (0 is no limit), name, 4 values for default, 2 values for range */
-
-/* Verification rule: If name changes, a saved socket and its links will be removed! Type changes are OK */
-
-/* **************** OUTPUT ******************** */
-static bNodeSocketType sh_node_output_in[]= {
- { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
- { -1, 0, "" }
-};
-
static bNodeType sh_node_output= {
/* type code */ SH_NODE_OUTPUT,
/* name */ "Output",
@@ -194,7 +118,7 @@ static bNodeType sh_node_output= {
/* input sock */ sh_node_output_in,
/* output sock */ NULL,
/* storage */ "",
- /* execfunc */ node_shader_exec_output,
+ /* execfunc */ node_shader_exec_output
};
@@ -259,7 +183,7 @@ static bNodeType sh_node_geom= {
/* input sock */ NULL,
/* output sock */ sh_node_geom_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_geom,
+ /* execfunc */ node_shader_exec_geom
};
@@ -373,7 +297,7 @@ static bNodeType sh_node_material= {
/* input sock */ sh_node_material_in,
/* output sock */ sh_node_material_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_material,
+ /* execfunc */ node_shader_exec_material
};
@@ -389,6 +313,75 @@ static bNodeSocketType sh_node_texture_out[]= {
{ -1, 0, "" }
};
+static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ if(data && node->id) {
+ ShadeInput *shi= ((ShaderCallData *)data)->shi;
+ TexResult texres;
+ float *vec, nor[3]={0.0f, 0.0f, 0.0f};
+ int retval;
+
+ /* out: value, color, normal */
+
+ /* we should find out if a normal as output is needed, for now we do all */
+ texres.nor= nor;
+
+ if(in[0]->hasinput) {
+ vec= in[0]->vec;
+
+ if(in[0]->datatype==NS_OSA_VECTORS) {
+ float *fp= in[0]->data;
+ retval= multitex((Tex *)node->id, vec, fp, fp+3, shi->osatex, &texres);
+ }
+ else if(in[0]->datatype==NS_OSA_VALUES) {
+ float *fp= in[0]->data;
+ float dxt[3], dyt[3];
+
+ dxt[0]= fp[0]; dxt[1]= dxt[2]= 0.0f;
+ dyt[0]= fp[1]; dyt[1]= dyt[2]= 0.0f;
+ retval= multitex((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres);
+ }
+ else
+ retval= multitex((Tex *)node->id, vec, NULL, NULL, 0, &texres);
+ }
+ else { /* only for previewrender, so we see stuff */
+ vec= shi->lo;
+ retval= multitex((Tex *)node->id, vec, NULL, NULL, 0, &texres);
+ }
+
+ /* stupid exception */
+ if( ((Tex *)node->id)->type==TEX_STUCCI) {
+ texres.tin= 0.5f + 0.7f*texres.nor[0];
+ CLAMP(texres.tin, 0.0f, 1.0f);
+ }
+
+ /* intensity and color need some handling */
+ if(texres.talpha)
+ out[0]->vec[0]= texres.ta;
+ else
+ out[0]->vec[0]= texres.tin;
+
+ if((retval & TEX_RGB)==0) {
+ out[1]->vec[0]= out[0]->vec[0];
+ out[1]->vec[1]= out[0]->vec[0];
+ out[1]->vec[2]= out[0]->vec[0];
+ out[1]->vec[3]= 1.0f;
+ }
+ else {
+ out[1]->vec[0]= texres.tr;
+ out[1]->vec[1]= texres.tg;
+ out[1]->vec[2]= texres.tb;
+ out[1]->vec[3]= 1.0f;
+ }
+
+ VECCOPY(out[2]->vec, nor);
+
+ if(shi->do_preview)
+ nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys);
+
+ }
+}
+
static bNodeType sh_node_texture= {
/* type code */ SH_NODE_TEXTURE,
/* name */ "Texture",
@@ -397,7 +390,53 @@ static bNodeType sh_node_texture= {
/* input sock */ sh_node_texture_in,
/* output sock */ sh_node_texture_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_texture,
+ /* execfunc */ node_shader_exec_texture
+
+};
+
+/* **************** MAPPING ******************** */
+static bNodeSocketType sh_node_mapping_in[]= {
+ { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketType sh_node_mapping_out[]= {
+ { SOCK_VECTOR, 0, "Vector", 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+/* do the regular mapping options for blender textures */
+static void node_shader_exec_mapping(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ TexMapping *texmap= node->storage;
+ float *vec= out[0]->vec;
+
+ /* stack order input: vector */
+ /* stack order output: vector */
+ VECCOPY(vec, in[0]->vec);
+ Mat4MulVecfl(texmap->mat, vec);
+
+ if(texmap->flag & TEXMAP_CLIP_MIN) {
+ if(vec[0]<texmap->min[0]) vec[0]= texmap->min[0];
+ if(vec[1]<texmap->min[1]) vec[1]= texmap->min[1];
+ if(vec[2]<texmap->min[2]) vec[2]= texmap->min[2];
+ }
+ if(texmap->flag & TEXMAP_CLIP_MAX) {
+ if(vec[0]>texmap->max[0]) vec[0]= texmap->max[0];
+ if(vec[1]>texmap->max[1]) vec[1]= texmap->max[1];
+ if(vec[2]>texmap->max[2]) vec[2]= texmap->max[2];
+ }
+}
+
+static bNodeType sh_node_mapping= {
+ /* type code */ SH_NODE_MAPPING,
+ /* name */ "Mapping",
+ /* width+range */ 240, 160, 320,
+ /* class+opts */ NODE_CLASS_OPERATOR, NODE_OPTIONS,
+ /* input sock */ sh_node_mapping_in,
+ /* output sock */ sh_node_mapping_out,
+ /* storage */ "TexMapping",
+ /* execfunc */ node_shader_exec_mapping
};
@@ -433,7 +472,7 @@ static bNodeType sh_node_normal= {
/* input sock */ sh_node_normal_in,
/* output sock */ sh_node_normal_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_normal,
+ /* execfunc */ node_shader_exec_normal
};
@@ -458,7 +497,7 @@ static bNodeType sh_node_value= {
/* input sock */ NULL,
/* output sock */ sh_node_value_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_value,
+ /* execfunc */ node_shader_exec_value
};
@@ -483,7 +522,7 @@ static bNodeType sh_node_rgb= {
/* input sock */ NULL,
/* output sock */ sh_node_rgb_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_rgb,
+ /* execfunc */ node_shader_exec_rgb
};
@@ -521,7 +560,7 @@ static bNodeType sh_node_mix_rgb= {
/* input sock */ sh_node_mix_rgb_in,
/* output sock */ sh_node_mix_rgb_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_mix_rgb,
+ /* execfunc */ node_shader_exec_mix_rgb
};
@@ -556,7 +595,7 @@ static bNodeType sh_node_valtorgb= {
/* input sock */ sh_node_valtorgb_in,
/* output sock */ sh_node_valtorgb_out,
/* storage */ "ColorBand",
- /* execfunc */ node_shader_exec_valtorgb,
+ /* execfunc */ node_shader_exec_valtorgb
};
@@ -588,7 +627,7 @@ static bNodeType sh_node_rgbtobw= {
/* input sock */ sh_node_rgbtobw_in,
/* output sock */ sh_node_rgbtobw_out,
/* storage */ "",
- /* execfunc */ node_shader_exec_rgbtobw,
+ /* execfunc */ node_shader_exec_rgbtobw
};
@@ -607,6 +646,7 @@ bNodeType *node_all_shaders[]= {
&sh_node_texture,
&sh_node_normal,
&sh_node_geom,
+ &sh_node_mapping,
NULL
};
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 123298c723a..902b3a5edfe 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -197,6 +197,37 @@ void free_plugin_tex(PluginTex *pit)
MEM_freeN(pit);
}
+/* ****************** Mapping ******************* */
+
+TexMapping *add_mapping(void)
+{
+ TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "Tex map");
+
+ texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f;
+ texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f;
+ Mat4One(texmap->mat);
+
+ return texmap;
+}
+
+void init_mapping(TexMapping *texmap)
+{
+ float eul[3], smat[3][3], rmat[3][3], mat[3][3];
+
+ SizeToMat3(texmap->size, smat);
+
+ eul[0]= (M_PI/180.0f)*texmap->rot[0];
+ eul[1]= (M_PI/180.0f)*texmap->rot[1];
+ eul[2]= (M_PI/180.0f)*texmap->rot[2];
+ EulToMat3(eul, rmat);
+
+ Mat3MulMat3(mat, rmat, smat);
+
+ Mat4CpyMat3(texmap->mat, mat);
+ VECCOPY(texmap->mat[3], texmap->loc);
+
+}
+
/* ****************** COLORBAND ******************* */
ColorBand *add_colorband(int rangetype)
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 9ebadb6b86d..85db0887f51 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -171,5 +171,6 @@ typedef struct bNodeTree {
#define NTREE_TYPE_INIT 1
#define NTREE_EXEC_INIT 2
+
#endif
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 21ae86ea68a..3cb37dff29e 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -163,6 +163,23 @@ typedef struct Tex {
} Tex;
+/* used for mapping node. note: rot is in degrees */
+
+typedef struct TexMapping {
+ float loc[3], rot[3], size[3];
+ int flag;
+
+ float mat[4][4];
+ float min[3], max[3];
+ struct Object *ob;
+
+} TexMapping;
+
+/* texmap->flag */
+#define TEXMAP_CLIP_MIN 1
+#define TEXMAP_CLIP_MAX 2
+
+
/* **************** TEX ********************* */
/* type */
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index 4d0fe588d21..c98975f2300 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -51,6 +51,7 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
+#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
@@ -255,6 +256,13 @@ static void node_new_mat_cb(void *ntree_v, void *node_v)
}
+static void node_texmap_cb(void *texmap_v, void *unused_v)
+{
+ init_mapping(texmap_v);
+}
+
+
+
static int node_shader_buts_material(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
@@ -344,6 +352,55 @@ static int node_shader_buts_normal(uiBlock *block, bNodeTree *ntree, bNode *node
return (int)(node->width-NODE_DY);
}
+static int node_shader_buts_mapping(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block && (node->flag & NODE_OPTIONS)) {
+ TexMapping *texmap= node->storage;
+ short dx= (short)((butr->xmax-butr->xmin)/7.0f);
+ short dy= (short)(butr->ymax-19);
+
+ uiBlockSetFunc(block, node_texmap_cb, texmap, NULL); /* all buttons get this */
+
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->loc, -1000.0f, 1000.0f, 10, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->loc+1, -1000.0f, 1000.0f, 10, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->loc+2, -1000.0f, 1000.0f, 10, 2, "");
+ dy-= 19;
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->rot, -1000.0f, 1000.0f, 1000, 1, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->rot+1, -1000.0f, 1000.0f, 1000, 1, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->rot+2, -1000.0f, 1000.0f, 1000, 1, "");
+ dy-= 19;
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->size, -1000.0f, 1000.0f, 10, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->size+1, -1000.0f, 1000.0f, 10, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->size+2, -1000.0f, 1000.0f, 10, 2, "");
+ dy-= 25;
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->min, -10.0f, 10.0f, 100, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->min+1, -10.0f, 10.0f, 100, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->min+2, -10.0f, 10.0f, 100, 2, "");
+ dy-= 19;
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+dx, dy, 2*dx, 19, texmap->max, -10.0f, 10.0f, 10, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+3*dx, dy, 2*dx, 19, texmap->max+1, -10.0f, 10.0f, 10, 2, "");
+ uiDefButF(block, NUM, B_NODE_EXEC, "", butr->xmin+5*dx, dy, 2*dx, 19, texmap->max+2, -10.0f, 10.0f, 10, 2, "");
+ uiBlockEndAlign(block);
+
+ /* labels/options */
+
+ dy= (short)(butr->ymax-19);
+ uiDefBut(block, LABEL, B_NOP, "Loc", butr->xmin, dy, dx, 19, NULL, 0.0f, 0.0f, 0, 0, "");
+ dy-= 19;
+ uiDefBut(block, LABEL, B_NOP, "Rot", butr->xmin, dy, dx, 19, NULL, 0.0f, 0.0f, 0, 0, "");
+ dy-= 19;
+ uiDefBut(block, LABEL, B_NOP, "Size", butr->xmin, dy, dx, 19, NULL, 0.0f, 0.0f, 0, 0, "");
+ dy-= 25;
+ uiDefButBitI(block, TOG, TEXMAP_CLIP_MIN, B_NODE_EXEC, "Min", butr->xmin, dy, dx-4, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
+ dy-= 19;
+ uiDefButBitI(block, TOG, TEXMAP_CLIP_MAX, B_NODE_EXEC, "Max", butr->xmin, dy, dx-4, 19, &texmap->flag, 0.0f, 0.0f, 0, 0, "");
+
+ }
+ return 5*19 + 6;
+}
+
static int node_shader_buts_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
@@ -430,6 +487,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_NORMAL:
ntype->butfunc= node_shader_buts_normal;
break;
+ case SH_NODE_MAPPING:
+ ntype->butfunc= node_shader_buts_mapping;
+ break;
case SH_NODE_VALUE:
ntype->butfunc= node_shader_buts_value;
break;
@@ -1053,7 +1113,7 @@ void node_draw_link(SpaceNode *snode, bNodeLink *link)
{
float vec[4][3];
float dist, spline_step, mx=0.0f, my=0.0f;
- int curve_res;
+ int curve_res, do_shaded= 1, th_col1= TH_WIRE, th_col2= TH_WIRE;
if(link->fromnode==NULL && link->tonode==NULL)
return;
@@ -1063,19 +1123,27 @@ void node_draw_link(SpaceNode *snode, bNodeLink *link)
short mval[2];
getmouseco_areawin(mval);
areamouseco_to_ipoco(G.v2d, mval, &mx, &my);
-
BIF_ThemeColor(TH_WIRE);
+ do_shaded= 0;
}
else {
/* a bit ugly... but thats how we detect the internal group links */
- if(link->fromnode==link->tonode)
+ if(link->fromnode==link->tonode) {
BIF_ThemeColorBlend(TH_BACK, TH_WIRE, 0.25f);
+ do_shaded= 0;
+ }
else {
/* check cyclic */
- if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF)
- BIF_ThemeColor(TH_WIRE);
- else
+ if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) {
+ if(link->fromnode->flag & SELECT)
+ th_col1= TH_EDGE_SELECT;
+ if(link->tonode->flag & SELECT)
+ th_col2= TH_EDGE_SELECT;
+ }
+ else {
BIF_ThemeColor(TH_REDALERT);
+ do_shaded= 0;
+ }
}
}
@@ -1120,6 +1188,8 @@ void node_draw_link(SpaceNode *snode, bNodeLink *link)
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
glBegin(GL_LINE_STRIP);
while (spline_step < 1.000001f) {
+ if(do_shaded)
+ BIF_ThemeColorBlend(th_col1, th_col2, spline_step);
glEvalCoord1f(spline_step);
spline_step += dist;
}
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c
index b2cb11875e4..27862890a5a 100644
--- a/source/blender/src/editnode.c
+++ b/source/blender/src/editnode.c
@@ -1020,7 +1020,7 @@ static void node_add_menu(SpaceNode *snode)
short event, mval[2];
/* shader menu, still hardcoded defines... solve */
- event= pupmenu("Add Node%t|Output%x1|Geometry%x108|Material%x100|Texture%x106|Normal%x107|Value %x102|Color %x101|Mix Color %x103|ColorRamp %x104|Color to BW %x105");
+ event= pupmenu("Add Node%t|Output%x1|Geometry%x108|Material%x100|Texture%x106|Mapping%x109|Normal%x107|Value %x102|Color %x101|Mix Color %x103|ColorRamp %x104|Color to BW %x105");
if(event<1) return;
getmouseco_areawin(mval);
diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c
index 3fd015ec500..8d62b64b854 100644
--- a/source/blender/src/interface.c
+++ b/source/blender/src/interface.c
@@ -3268,12 +3268,26 @@ static int ui_do_but_NORMAL(uiBut *but)
{
float dx, dy, rad, radsq, mrad, *fp= (float *)but->poin;
int firsttime=1;
- short mval[2], mvalo[2];
+ short mval[2], mvalo[2], mvals[2], mvaldx, mvaldy;
- rad= 0.5f*(but->x2 - but->x1);
+ rad= (but->x2 - but->x1);
radsq= rad*rad;
+ if(fp[2]>0.0f) {
+ mvaldx= (rad*fp[0]);
+ mvaldy= (rad*fp[1]);
+ }
+ else if(fp[2]> -1.0f) {
+ mrad= rad/sqrt(fp[0]*fp[0] + fp[1]*fp[1]);
+
+ mvaldx= 2.0f*mrad*fp[0] - (rad*fp[0]);
+ mvaldy= 2.0f*mrad*fp[1] - (rad*fp[1]);
+ }
+ else mvaldx= mvaldy= 0;
+
uiGetMouse(mywinget(), mvalo);
+ mvals[0]= mvalo[0];
+ mvals[1]= mvalo[1];
while(get_mbut() & L_MOUSE) {
@@ -3282,8 +3296,8 @@ static int ui_do_but_NORMAL(uiBut *but)
if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1] || firsttime) {
firsttime= 0;
- dx= -but->x1-rad + (float)mval[0];
- dy= -but->y1-rad + (float)mval[1];
+ dx= (float)(mval[0]+mvaldx-mvals[0]);
+ dy= (float)(mval[1]+mvaldy-mvals[1]);
mrad= dx*dx+dy*dy;
if(mrad < radsq) { /* inner circle */
@@ -3292,14 +3306,11 @@ static int ui_do_but_NORMAL(uiBut *but)
fp[2]= sqrt( radsq-dx*dx-dy*dy );
}
else { /* outer circle */
- float norx, nory;
- mrad= sqrt(mrad); // veclen
- norx= dx/mrad;
- nory= dy/mrad;
+ mrad= rad/sqrt(mrad); // veclen
- dx= norx*(2.0f*rad - mrad);
- dy= nory*(2.0f*rad - mrad);
+ dx*= (2.0f*mrad - 1.0f);
+ dy*= (2.0f*mrad - 1.0f);
mrad= dx*dx+dy*dy;
if(mrad < radsq) {
diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c
index 6056e0f2bd4..a5dbe1a5ba2 100644
--- a/source/blender/src/resources.c
+++ b/source/blender/src/resources.c
@@ -480,6 +480,7 @@ void BIF_InitTheme(void)
/* space node, re-uses syntax color storage */
btheme->tnode= btheme->tv3d;
+ SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
SETCOL(btheme->tnode.syntaxn, 95, 110, 145, 255); /* in/output */
SETCOL(btheme->tnode.syntaxb, 135, 125, 120, 255); /* operator */
@@ -614,8 +615,10 @@ char *BIF_ThemeColorsPup(int spacetype)
sprintf(str, "Grid %%x%d|", TH_GRID); strcat(cp, str);
}
else if(spacetype==SPACE_NODE) {
+ sprintf(str, "Wires %%x%d|", TH_WIRE); strcat(cp, str);
+ sprintf(str, "Wires Select %%x%d|", TH_EDGE_SELECT); strcat(cp, str);
strcat(cp,"%l|");
- sprintf(str, "Node backdrop %%x%d|", TH_NODE); strcat(cp, str);
+ sprintf(str, "Node Backdrop %%x%d|", TH_NODE); strcat(cp, str);
sprintf(str, "In/Out Node %%x%d|", TH_NODE_IN_OUT); strcat(cp, str);
sprintf(str, "Generator Node %%x%d|", TH_NODE_GENERATOR); strcat(cp, str);
sprintf(str, "Operator Node %%x%d|", TH_NODE_OPERATOR); strcat(cp, str);
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index 343dd2a0003..90a8c8cc78c 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -275,6 +275,7 @@ static void init_userdef_file(void)
if(btheme->tnode.syntaxn[3]==0) {
/* re-uses syntax color storage */
btheme->tnode= btheme->tv3d;
+ SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
SETCOL(btheme->tnode.syntaxn, 95, 110, 145, 255); /* in/output */
SETCOL(btheme->tnode.syntaxb, 135, 125, 120, 255); /* operator */