Example #1
0
IECore::DataPtr Shader::parameterValue( const Gaffer::Plug *parameterPlug, NetworkBuilder &network ) const
{
	const Plug *inputPlug = parameterPlug->source<Plug>();
	if( inputPlug != parameterPlug )
	{
		const Shader *n = IECore::runTimeCast<const Shader>( inputPlug->node() );
		if( n && ( inputPlug == n->outPlug() || n->outPlug()->isAncestorOf( inputPlug ) ) )
		{
			const std::string &shaderHandle = network.shaderHandle( n );
			if( !shaderHandle.size() )
			{
				return NULL;
			}
			std::string result = "link:" + shaderHandle;
			if( n->outPlug()->isAncestorOf( inputPlug ) )
			{
				result += "." + inputPlug->relativeName( n->outPlug() );
			}
			return new IECore::StringData( result );
		}
		// fall through to use plug value
	}

	if( const Gaffer::ValuePlug *valuePlug = IECore::runTimeCast<const Gaffer::ValuePlug>( parameterPlug ) )
	{
		return Gaffer::CompoundDataPlug::extractDataFromPlug( valuePlug );
	}

	return NULL;
}
Example #2
0
IECore::DataPtr RenderManShader::parameterValue( const Gaffer::Plug *parameterPlug, NetworkBuilder &network ) const
{
	if( parameterPlug->typeId() == Plug::staticTypeId() )
	{
		// coshader parameter
		const Plug *inputPlug = parameterPlug->source<Plug>();
		if( inputPlug && inputPlug != parameterPlug )
		{
			const RenderManShader *inputShader = inputPlug->parent<RenderManShader>();
			if( inputShader )
			{
				const std::string &handle = network.shaderHandle( inputShader );
				if( handle.size() )
				{
					return new StringData( handle );
				}
			}
		}
	}
	else if( parameterPlug->isInstanceOf( ArrayPlug::staticTypeId() ) )
	{
		// coshader array parameter
		StringVectorDataPtr value = new StringVectorData();
		for( InputPlugIterator cIt( parameterPlug ); cIt != cIt.end(); ++cIt )
		{
			const Plug *inputPlug = (*cIt)->source<Plug>();
			const RenderManShader *inputShader = inputPlug && inputPlug != *cIt ? inputPlug->parent<RenderManShader>() : 0;
			if( inputShader )
			{
				value->writable().push_back( network.shaderHandle( inputShader ) );
			}
			else
			{
				value->writable().push_back( "" );
			}
		}
		return value;
	}
	
	return Shader::parameterValue( parameterPlug, network );
}
Example #3
0
IECore::DataPtr ArnoldShader::parameterValue( const Gaffer::Plug *plug, NetworkBuilder &network ) const
{
	const Plug *inputPlug = plug->getInput<Plug>();
	if( inputPlug )
	{
		const ArnoldShader *n = IECore::runTimeCast<const ArnoldShader>( inputPlug->node() );
		if( n && inputPlug == n->outPlug() )
		{
			const std::string &shaderHandle = network.shaderHandle( n );
			if( shaderHandle.size() )
			{
				return new IECore::StringData( "link:" + shaderHandle );
			}
			return 0;
		}
	}

	return Shader::parameterValue( plug, network );
}