Ejemplo n.º 1
0
static void node_reroute_init(bNodeTree *ntree, bNode *node)
{
	/* Note: Cannot use socket templates for this, since it would reset the socket type
	 * on each file read via the template verification procedure.
	 */
	nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, "Input", "Input");
	nodeAddStaticSocket(ntree, node, SOCK_OUT, SOCK_RGBA, PROP_NONE, "Output", "Output");
}
Ejemplo n.º 2
0
bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, const char *name, ImageFormatData *im_format)
{
	NodeImageMultiFile *nimf = node->storage;
	bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, name);
	
	/* create format data for the input socket */
	NodeImageMultiFileSocket *sockdata = MEM_callocN(sizeof(NodeImageMultiFileSocket), "socket image format");
	sock->storage = sockdata;
	
	BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path));
	ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_');
	BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer));
	ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_');
	
	if (im_format) {
		sockdata->format = *im_format;
		if (BKE_imtype_is_movie(sockdata->format.imtype)) {
			sockdata->format.imtype = R_IMF_IMTYPE_OPENEXR;
		}
	}
	else
		BKE_imformat_defaults(&sockdata->format);
	/* use node data format by default */
	sockdata->use_node_format = TRUE;
	
	nimf->active_input = BLI_findindex(&node->inputs, sock);
	
	return sock;
}
Ejemplo n.º 3
0
struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp, int in_out)
{
	bNodeSocket *sock = nodeAddStaticSocket(ntree, node, in_out, stemp->type, stemp->subtype, stemp->identifier, stemp->name);
	
	sock->flag |= stemp->flag;
	
	/* initialize default_value */
	switch (stemp->type) {
		case SOCK_FLOAT:
		{
			bNodeSocketValueFloat *dval = sock->default_value;
			dval->value = stemp->val1;
			dval->min = stemp->min;
			dval->max = stemp->max;
			break;
		}
		case SOCK_INT:
		{
			bNodeSocketValueInt *dval = sock->default_value;
			dval->value = (int)stemp->val1;
			dval->min = (int)stemp->min;
			dval->max = (int)stemp->max;
			break;
		}
		case SOCK_BOOLEAN:
		{
			bNodeSocketValueBoolean *dval = sock->default_value;
			dval->value = (int)stemp->val1;
			break;
		}
		case SOCK_VECTOR:
		{
			bNodeSocketValueVector *dval = sock->default_value;
			dval->value[0] = stemp->val1;
			dval->value[1] = stemp->val2;
			dval->value[2] = stemp->val3;
			dval->min = stemp->min;
			dval->max = stemp->max;
			break;
		}
		case SOCK_RGBA:
		{
			bNodeSocketValueRGBA *dval = sock->default_value;
			dval->value[0] = stemp->val1;
			dval->value[1] = stemp->val2;
			dval->value[2] = stemp->val3;
			dval->value[3] = stemp->val4;
			break;
		}
	}
	
	return sock;
}
Ejemplo n.º 4
0
static void cmp_node_image_add_multilayer_outputs(bNodeTree *ntree, bNode *node, RenderLayer *rl)
{
	bNodeSocket *sock;
	NodeImageLayer *sockdata;
	RenderPass *rpass;
	int index;
	int passflag = 0;
	for (rpass = rl->passes.first, index = 0; rpass; rpass = rpass->next, ++index) {
		int type;
		if (rpass->channels == 1)
			type = SOCK_FLOAT;
		else
			type = SOCK_RGBA;

		/* we only need one socket per type */
		if (passflag & rpass->passtype)
			continue;

		passflag |= rpass->passtype;

		sock = nodeAddStaticSocket(ntree, node, SOCK_OUT, type, PROP_NONE, rpass->internal_name, rpass->internal_name);
		/* extra socket info */
		sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
		sock->storage = sockdata;
		
		sockdata->pass_index = index;
		sockdata->pass_flag = rpass->passtype;

		if (STREQ(rpass->chan_id, "RGBA")) {
			sock = nodeAddStaticSocket(ntree, node, SOCK_OUT, SOCK_FLOAT, PROP_NONE, "Alpha", "Alpha");
			sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
			sock->storage = sockdata;
			sockdata->pass_index = index;
			sockdata->pass_flag = rpass->passtype;
		}
	}
}