diff options
author | Ton Roosendaal <ton@blender.org> | 2006-02-04 17:38:51 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-02-04 17:38:51 +0300 |
commit | 98a0768028a659b30bd1a576c0bbdf9c4893dcff (patch) | |
tree | c4905e03c606d555ec791c35909a5f9dd9f31b48 /source | |
parent | 3bb82a27fc61b787ab83145f9a7962c14e7ca769 (diff) |
Compositor: Added a basic "Time Node".
Just indicate start/end frame, and node outputs with Curve a value between
0.0 and 1.0.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node_composite.c | 33 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 2 | ||||
-rw-r--r-- | source/blender/src/drawnode.c | 31 | ||||
-rw-r--r-- | source/blender/src/editnode.c | 2 |
6 files changed, 71 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 80393db65c0..2b6a2f7f73f 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -769,6 +769,11 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup) node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); else if(type==CMP_NODE_CURVE_RGB) node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + else if(type==CMP_NODE_TIME) { + node->custom1= G.scene->r.sfra; + node->custom2= G.scene->r.efra; + node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + } else if(type==CMP_NODE_MAP_VALUE) node->storage= add_mapping(); else if(type==CMP_NODE_BLUR) @@ -927,7 +932,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node) MEM_freeN(node->storage); } else if(ntree->type==NTREE_COMPOSIT) { - if(node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB) + if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB)) curvemapping_free(node->storage); else MEM_freeN(node->storage); diff --git a/source/blender/blenkernel/intern/node_composite.c b/source/blender/blenkernel/intern/node_composite.c index 8a04f37bb3a..41fa770c3b9 100644 --- a/source/blender/blenkernel/intern/node_composite.c +++ b/source/blender/blenkernel/intern/node_composite.c @@ -950,6 +950,36 @@ static bNodeType cmp_node_normal= { }; +/* **************** CURVE Time ******************** */ + +/* custom1 = sfra, custom2 = efra */ +static bNodeSocketType cmp_node_time_out[]= { + { SOCK_VALUE, 0, "Fac", 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static void node_composit_exec_time(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + /* stack order output: fac */ + float fac= 0.0f; + + if(node->custom1 < node->custom2) + fac= (G.scene->r.cfra - node->custom1)/(float)(node->custom2-node->custom1); + + out[0]->vec[0]= curvemapping_evaluateF(node->storage, 0, fac); +} + +static bNodeType cmp_node_time= { + /* type code */ CMP_NODE_TIME, + /* name */ "Time", + /* width+range */ 140, 100, 320, + /* class+opts */ NODE_CLASS_GENERATOR, NODE_OPTIONS, + /* input sock */ NULL, + /* output sock */ cmp_node_time_out, + /* storage */ "CurveMapping", + /* execfunc */ node_composit_exec_time +}; + /* **************** CURVE VEC ******************** */ static bNodeSocketType cmp_node_curve_vec_in[]= { { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f}, @@ -2184,6 +2214,7 @@ bNodeType *node_all_composit[]= { &cmp_node_normal, &cmp_node_curve_vec, &cmp_node_curve_rgb, + &cmp_node_time, &cmp_node_image, &cmp_node_rresult, &cmp_node_alphaover, @@ -2222,5 +2253,7 @@ void ntreeCompositTagAnimated(bNodeTree *ntree) if(node->storage) NodeTagChanged(ntree, node); } + else if(node->type==CMP_NODE_TIME) + NodeTagChanged(ntree, node); } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 96828d0faa4..c3642b8de63 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1267,10 +1267,10 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) node->storage= newdataadr(fd, node->storage); if(node->storage) { - /* could be handlerized at some point, now only 1 exception still */ + /* could be handlerized at some point */ if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB)) direct_link_curvemapping(fd, node->storage); - else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)) + else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_TIME || node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)) direct_link_curvemapping(fd, node->storage); } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ccd9314d4fd..f00e238314b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -392,7 +392,7 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) /* could be handlerized at some point, now only 1 exception still */ if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB)) write_curvemapping(wd, node->storage); - else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)) + else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_TIME || node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)) write_curvemapping(wd, node->storage); else writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage); diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c index c510c34c9a1..d330d33a83e 100644 --- a/source/blender/src/drawnode.c +++ b/source/blender/src/drawnode.c @@ -774,13 +774,13 @@ static int node_composit_buts_blur(uiBlock *block, bNodeTree *ntree, bNode *node uiBlockBeginAlign(block); sprintf(str, "Filter Type%%t|Flat %%x%d|Tent %%x%d|Quad %%x%d|Cubic %%x%d|Gauss %%x%d|CatRom %%x%d|Mitch %%x%d", R_FILTER_BOX, R_FILTER_TENT, R_FILTER_QUAD, R_FILTER_CUBIC, R_FILTER_GAUSS, R_FILTER_CATROM, R_FILTER_MITCH); - uiDefButS(block, MENU, B_NODE_EXEC,str, + uiDefButS(block, MENU, B_NODE_EXEC+node->nr,str, butr->xmin, dy, dx3, 19, &nbd->filtertype, 0, 0, 0, 0, "Set sampling filter for blur"); - uiDefButC(block, TOG, B_NODE_EXEC, "Bokeh", + uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Bokeh", butr->xmin+dx3, dy, dx3, 19, &nbd->bokeh, 0, 0, 0, 0, "Uses circular filter, warning it's slow!"); - uiDefButC(block, TOG, B_NODE_EXEC, "Gamma", + uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Gamma", butr->xmin+2*dx3, dy, dx3, 19, &nbd->gamma, 0, 0, 0, 0, "Applies filter on gamma corrected values"); @@ -832,6 +832,28 @@ static int node_composit_buts_map_value(uiBlock *block, bNodeTree *ntree, bNode return 80; } +static int node_composit_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) +{ + if(block) { + short dx= (butr->xmax-butr->xmin)/2; + + uiDefBut(block, BUT_CURVE, B_NODE_EXEC+node->nr, "", + butr->xmin, butr->ymin+24, butr->xmax-butr->xmin, butr->ymax-butr->ymin-24, + node->storage, 0.0f, 1.0f, 0, 0, ""); + + uiBlockBeginAlign(block); + uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Sta:", + butr->xmin, butr->ymin, dx, 19, + &node->custom1, 1.0, 20000.0, 0, 0, "Start frame"); + uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "End:", + butr->xmin+dx, butr->ymin, dx, 19, + &node->custom2, 1.0, 20000.0, 0, 0, "End frame"); + + } + + return node->width-NODE_DY; +} + /* only once called */ static void node_composit_set_butfunc(bNodeType *ntype) @@ -876,6 +898,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_MAP_VALUE: ntype->butfunc= node_composit_buts_map_value; break; + case CMP_NODE_TIME: + ntype->butfunc= node_composit_buts_time; + break; default: ntype->butfunc= NULL; } diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c index 2aca3e7d4bc..3e4a66f30d0 100644 --- a/source/blender/src/editnode.c +++ b/source/blender/src/editnode.c @@ -1186,7 +1186,7 @@ static void node_add_menu(SpaceNode *snode) } else if(snode->treetype==NTREE_COMPOSIT) { /* compo menu, still hardcoded defines... solve */ - event= pupmenu("Add Node%t|Render Result %x221|Composite %x222|Viewer%x201|Image %x220|RGB Curves%x209|AlphaOver %x210|Blur %x211|Vector Blur %x215|Filter %x212|Value %x203|Color %x202|Mix %x204|ColorRamp %x205|Color to BW %x206|Map Value %x213|Normal %x207"); + event= pupmenu("Add Node%t|Render Result %x221|Composite %x222|Viewer%x201|Image %x220|RGB Curves%x209|AlphaOver %x210|Blur %x211|Vector Blur %x215|Filter %x212|Value %x203|Color %x202|Mix %x204|ColorRamp %x205|Color to BW %x206|Map Value %x213|Time %x214|Normal %x207"); if(event<1) return; } else return; |