Skip to content
David Millán Escrivá edited this page Feb 7, 2014 · 4 revisions

Involved Files

Add custom variables and UI buttons in nodes. views/feel:

This files define how to show in node view the custom variables or the different properties

/source/blender/makesrna/intern/rna_nodetree_types.h : 123
/source/blender/makesrna/intern/rna_nodetree.c : 2416
/source/blender/makesrna/RNA_access.h:175
/source/blender/editors/space_node/drawnode.c:1679 and 1834

This file define the draw function and data structure to use

/source/blender/makesrna/intern/rna_nodetree_types.h : 123
DefNode( CompositorNode, CMP_NODE_CVTHRESHOLD,    def_cmp_bocv_threshold, "CVTHRESHOLD",     CvThreshold,      "OpenCV - Threshold",       ""              )

For each node that need custom data this will be draw in the node and mapped to a variable. This is the purpose of this file.

/source/blender/makesrna/intern/rna_nodetree.c : 2416
static void def_cmp_bocv_threshold(StructRNA *srna)
{
...
} 

We must define the RNA drawing and structure function. as an extenr StructRNA

/source/blender/makesrna/RNA_access.h:175
extern StructRNA RNA_CompositorNodeCvThreshold;

And define in node space the buttons to use when the node is choosed.

/source/blender/editors/space_node/drawnode.c:1679 and 1834
static void node_composit_buts_cvthreshold(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{ 
	uiItemR(layout, ptr, "cvthreshold_type", 0, "", ICON_NONE);
}
...
/* only once called */
static void node_composit_set_butfunc(bNodeType *ntype)
{
	ntype->uifuncbut = NULL;
	switch(ntype->type) {
              ...
              case CMP_NODE_CVTHRESHOLD:
			ntype->uifunc=node_composit_buts_cvthreshold;
			break;
...

Register new node

Once the node is create we have to add the regiter node in next files:

blenkernel/intern/node.c:1816
blender/nodes/NOD_composite.h:123

And add to CMaleList.txt ( blender/nodes/CMakeLists.txt )