Ejemplo n.º 1
0
static SocketPair node_socket_map_pair(PtrNodeMap& node_map, BL::Node b_node, BL::NodeSocket b_socket)
{
	BL::Node::inputs_iterator b_input;
	BL::Node::outputs_iterator b_output;
	string name = b_socket.name();
	bool found = false;
	int counter = 0, total = 0;

	/* find in inputs */
	for(b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
		if(b_input->name() == name) {
			if(!found)
				counter++;
			total++;
		}

		if(b_input->ptr.data == b_socket.ptr.data)
			found = true;
	}

	if(!found) {
		/* find in outputs */
		found = false;
		counter = 0;
		total = 0;

		for(b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
			if(b_output->name() == name) {
				if(!found)
					counter++;
				total++;
			}

			if(b_output->ptr.data == b_socket.ptr.data)
				found = true;
		}
	}

	/* rename if needed */
	if(name == "Shader")
		name = "Closure";

	if(total > 1)
		name = string_printf("%s%d", name.c_str(), counter);

	return SocketPair(node_map[b_node.ptr.data], name);
}
static ShaderSocketType convert_socket_type(BL::NodeSocket b_socket)
{
	switch (b_socket.type()) {
		case BL::NodeSocket::type_VALUE:
			return SHADER_SOCKET_FLOAT;
		case BL::NodeSocket::type_INT:
			return SHADER_SOCKET_INT;
		case BL::NodeSocket::type_VECTOR:
			return SHADER_SOCKET_VECTOR;
		case BL::NodeSocket::type_RGBA:
			return SHADER_SOCKET_COLOR;
		case BL::NodeSocket::type_STRING:
			return SHADER_SOCKET_STRING;
		case BL::NodeSocket::type_SHADER:
			return SHADER_SOCKET_CLOSURE;
		
		default:
			return SHADER_SOCKET_UNDEFINED;
	}
}
Ejemplo n.º 3
0
static ShaderSocketType convert_osl_socket_type(OSL::OSLQuery& query,
                                                BL::NodeSocket& b_socket)
{
	ShaderSocketType socket_type = convert_socket_type(b_socket);
	if(socket_type == SHADER_SOCKET_VECTOR) {
		/* TODO(sergey): Do we need compatible_name() here? */
		const OSL::OSLQuery::Parameter *param = query.getparam(b_socket.name());
		assert(param != NULL);
		if(param != NULL) {
			if(param->type.vecsemantics == TypeDesc::POINT) {
				socket_type = SHADER_SOCKET_POINT;
			}
			else if(param->type.vecsemantics == TypeDesc::NORMAL) {
				socket_type = SHADER_SOCKET_NORMAL;
			}
		}
	}

	return socket_type;
}
static SocketType::Type convert_socket_type(BL::NodeSocket& b_socket)
{
	switch(b_socket.type()) {
		case BL::NodeSocket::type_VALUE:
			return SocketType::FLOAT;
		case BL::NodeSocket::type_INT:
			return SocketType::INT;
		case BL::NodeSocket::type_VECTOR:
			return SocketType::VECTOR;
		case BL::NodeSocket::type_RGBA:
			return SocketType::COLOR;
		case BL::NodeSocket::type_STRING:
			return SocketType::STRING;
		case BL::NodeSocket::type_SHADER:
			return SocketType::CLOSURE;
		
		default:
			return SocketType::UNDEFINED;
	}
}