Example #1
0
void Shader::NetworkBuilder::parameterValueWalk( const Shader *shaderNode, const Gaffer::Plug *parameterPlug, const IECore::InternedString &parameterName, IECore::CompoundDataMap &values )
{
	for( InputPlugIterator it( parameterPlug ); it != it.end(); ++it )
	{
		IECore::InternedString childParameterName;
		if( parameterName.string().size() )
		{
			childParameterName = parameterName.string() + "." + (*it)->getName().string();
		}
		else
		{
			childParameterName = (*it)->getName();
		}

		if( (*it)->typeId() == CompoundPlug::staticTypeId() )
		{
			parameterValueWalk( shaderNode, it->get(), childParameterName, values );
		}
		else
		{
			if( IECore::DataPtr value = shaderNode->parameterValue( it->get(), *this ) )
			{
				values[childParameterName] = value;
			}
		}
	}
}
Example #2
0
		void addParameterWalk( const Gaffer::Plug *parameter, const IECore::InternedString &parameterName, IECoreScene::Shader *shader, vector<IECoreScene::ShaderNetwork::Connection> &connections )
		{
			if( !isLeafParameter( parameter ) || parameter->parent<Node>() )
			{
				// Compound parameter - recurse
				for( InputPlugIterator it( parameter ); !it.done(); ++it )
				{
					IECore::InternedString childParameterName;
					if( parameterName.string().size() )
					{
						childParameterName = parameterName.string() + "." + (*it)->getName().string();
					}
					else
					{
						childParameterName = (*it)->getName();
					}

					addParameterWalk( it->get(), childParameterName, shader, connections );
				}
			}
			else if( const Gaffer::ArrayPlug *array = IECore::runTimeCast<const Gaffer::ArrayPlug>( parameter ) )
			{
				int i = 0;
				for( InputPlugIterator it( array ); !it.done(); ++it, ++i )
				{
					IECore::InternedString childParameterName = parameterName.string() + "[" + std::to_string( i ) + "]";
					addParameter( it->get(), childParameterName, shader, connections );
				}
			}
			else
			{
				addParameter( parameter, parameterName, shader, connections );
			}
		}
Example #3
0
void Path::checkName( const IECore::InternedString &name ) const
{
	if( name.string().find( '/' ) != string::npos )
	{
		throw IECore::Exception( "Path name contains '/'." );
	}

	if( name.string().empty() )
	{
		throw IECore::Exception( "Path name is empty." );
	}
}
Example #4
0
void NoduleLayout::nodeMetadataChanged( IECore::TypeId nodeTypeId, IECore::InternedString key, const Gaffer::Node *node )
{
	const Node *typedParent = runTimeCast<const Node>( m_parent.get() );
	if( !typedParent || !affectedByChange( typedParent, nodeTypeId, node ) )
	{
		return;
	}

	if( affectsSpacing( key, m_section ) )
	{
		updateSpacing();
	}
	if( affectsDirection( key, m_section ) )
	{
		updateDirection();
	}
	if( affectsOrientation( key, m_section ) )
	{
		updateOrientation();
	}
	if( boost::starts_with( key.string(), "noduleLayout:customGadget" ) )
	{
		updateLayout();
	}
}
Example #5
0
		void addParameterComponentConnections( const Gaffer::Plug *parameter, const IECore::InternedString &parameterName, vector<IECoreScene::ShaderNetwork::Connection> &connections )
		{
			if( !isCompoundNumericPlug( parameter ) )
			{
				return;
			}
			for( InputPlugIterator it( parameter ); !it.done(); ++it )
			{
				const Gaffer::Plug *effectiveParameter = this->effectiveParameter( it->get() );
				if( effectiveParameter && isOutputParameter( effectiveParameter ) )
				{
					const Shader *effectiveShader = static_cast<const Shader *>( effectiveParameter->node() );
					IECore::InternedString outputName;
					if( effectiveShader->outPlug()->isAncestorOf( effectiveParameter ) )
					{
						outputName = effectiveParameter->relativeName( effectiveShader->outPlug() );
					}
					IECore::InternedString inputName = parameterName.string() + "." + (*it)->getName().string();
					connections.push_back( {
						{ this->handle( effectiveShader ), outputName },
						{ IECore::InternedString(), inputName }
					} );
				}
			}
		}
Example #6
0
void CameraTool::contextChanged( const IECore::InternedString &name )
{
	if( !boost::starts_with( name.string(), "ui:" ) )
	{
		m_cameraSelectionDirty = true;
		view()->viewportGadget()->renderRequestSignal()( view()->viewportGadget() );
	}
}
Example #7
0
void ImageGadget::contextChanged( const IECore::InternedString &name )
{
	if( !boost::starts_with( name.string(), "ui:" ) )
	{
		m_dirtyFlags = AllDirty;
		requestRender();
	}
}
Example #8
0
IECore::ConstInternedStringVectorDataPtr ObjectSource::computeSetNames( const Gaffer::Context *context, const ScenePlug *parent ) const
{
	IECore::InternedStringVectorDataPtr result = new IECore::InternedStringVectorData;
	Gaffer::tokenize( setsPlug()->getValue(), ' ', result->writable() );
	IECore::InternedString n = standardSetName();
	if( n.string().size() )
	{
		result->writable().push_back( n );
	}
	return result;
}
Example #9
0
void Set::hashSet( const IECore::InternedString &setName, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	const std::string allSets = " " + namePlug()->getValue() + " ";
	const std::string setNameToFind = " " + setName.string() + " ";
	if( allSets.find( setNameToFind ) == std::string::npos )
	{
		h = inPlug()->setPlug()->hash();
		return;
	}

	FilteredSceneProcessor::hashSet( setName, context, parent, h );
	inPlug()->setPlug()->hash( h );
	modePlug()->hash( h );
	pathMatcherPlug()->hash( h );
}
Example #10
0
InteractiveRender::InteractiveRender( const IECore::InternedString &rendererType, const std::string &name )
	:	Node( name ),
		m_state( Stopped )
{
	storeIndexOfNextChild( g_firstPlugIndex );
	addChild( new ScenePlug( "in" ) );
	addChild( new StringPlug( rendererType.string().empty() ? "renderer" : "__renderer", Plug::In, rendererType.string() ) );
	addChild( new IntPlug( "state", Plug::In, Stopped, Stopped, Paused, Plug::Default & ~Plug::Serialisable ) );
	addChild( new ScenePlug( "out", Plug::Out, Plug::Default & ~Plug::Serialisable ) );
	addChild( new ScenePlug( "__adaptedIn", Plug::In, Plug::Default & ~Plug::Serialisable ) );

	SceneProcessorPtr adaptors = RendererAlgo::createAdaptors();
	setChild( "__adaptors", adaptors );
	adaptors->inPlug()->setInput( inPlug() );
	adaptedInPlug()->setInput( adaptors->outPlug() );

	outPlug()->setInput( inPlug() );

	plugDirtiedSignal().connect( boost::bind( &InteractiveRender::plugDirtied, this, ::_1 ) );
}
Example #11
0
GafferScene::ConstPathMatcherDataPtr Set::computeSet( const IECore::InternedString &setName, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	const std::string allSets = " " + namePlug()->getValue() + " ";
	const std::string setNameToFind = " " + setName.string() + " ";
	if( allSets.find( setNameToFind ) == std::string::npos )
	{
		return inPlug()->setPlug()->getValue();
	}

	ConstPathMatcherDataPtr pathMatcher = pathMatcherPlug()->getValue();
	switch( modePlug()->getValue() )
	{
		case Add : {
			ConstPathMatcherDataPtr inputSet = inPlug()->setPlug()->getValue();
			if( !inputSet->readable().isEmpty() )
			{
				PathMatcherDataPtr result = inputSet->copy();
				result->writable().addPaths( pathMatcher->readable() );
				return result;
			}
			// Input set empty - fall through to create mode.
		}
		case Create : {
			return pathMatcher;
		}
		case Remove :
		default : {
			ConstPathMatcherDataPtr inputSet = inPlug()->setPlug()->getValue();
			if( inputSet->readable().isEmpty() )
			{
				return inputSet;
			}
			PathMatcherDataPtr result = inputSet->copy();
			result->writable().removePaths( pathMatcher->readable() );
			return result;
		}
	}
}
Example #12
0
void NoduleLayout::plugMetadataChanged( IECore::TypeId nodeTypeId, const Gaffer::MatchPattern &plugPath, IECore::InternedString key, const Gaffer::Plug *plug )
{
	if( childAffectedByChange( m_parent.get(), nodeTypeId, plugPath, plug ) )
	{
		if(
			key == g_sectionKey || key == g_indexKey || key == g_visibleKey ||
			key == g_noduleTypeKey ||
			key == g_nodulePositionKey || key == g_noduleIndexKey
		)
		{
			updateLayout();
		}
	}

	if( const Plug *typedParent = runTimeCast<const Plug>( m_parent.get() ) )
	{
		if( affectedByChange( typedParent, nodeTypeId, plugPath, plug ) )
		{
			if( affectsSpacing( key, m_section ) )
			{
				updateSpacing();
			}
			if( affectsDirection( key, m_section ) )
			{
				updateDirection();
			}
			if( affectsOrientation( key, m_section ) )
			{
				updateOrientation();
			}
			if( boost::starts_with( key.string(), "noduleLayout:customGadget" ) )
			{
				updateLayout();
			}
		}
	}
}
Example #13
0
			const std::string &handleKey() const { return handle.string(); }
IECoreGL::ConstRenderablePtr StandardLightVisualiser::visualise( const IECore::InternedString &attributeName, const IECore::ObjectVector *shaderVector, IECoreGL::ConstStatePtr &state ) const
{
    if( !shaderVector || shaderVector->members().size() == 0 )
    {
        return NULL;
    }

    IECore::InternedString metadataTarget;
    const IECore::CompoundData *shaderParameters = NULL;
    if( const IECore::Shader *shader = IECore::runTimeCast<const IECore::Shader>( shaderVector->members().back().get() ) )
    {
        metadataTarget = attributeName.string() + ":" + shader->getName();
        shaderParameters = shader->parametersData();
    }
    else if( const IECore::Light *light = IECore::runTimeCast<const IECore::Light>( shaderVector->members().back().get() ) )
    {
        /// \todo Remove once all Light node derived classes are
        /// creating only shaders.
        metadataTarget = attributeName.string() + ":" + light->getName();
        shaderParameters = light->parametersData().get();
    }

    if( !shaderParameters )
    {
        return NULL;
    }

    ConstStringDataPtr type = Metadata::value<StringData>( metadataTarget, "type" );
    ConstM44fDataPtr orientation = Metadata::value<M44fData>( metadataTarget, "visualiserOrientation" );

    const Color3f color = parameter<Color3f>( metadataTarget, shaderParameters, "colorParameter", Color3f( 1.0f ) );
    const float intensity = parameter<float>( metadataTarget, shaderParameters, "intensityParameter", 1 );
    const float exposure = parameter<float>( metadataTarget, shaderParameters, "exposureParameter", 0 );

    const Color3f finalColor = color * intensity * pow( 2.0f, exposure );

    if( type && type->readable() == "area" )
    {
        const std::string textureName = parameter<std::string>( metadataTarget, shaderParameters, "textureNameParameter", "" );
        const bool flipNormal = parameter<bool>( metadataTarget, shaderParameters, "flipNormalParameter", 0 );
        const bool doubleSided = parameter<bool>( metadataTarget, shaderParameters, "doubleSidedParameter", 0 );
        const bool sphericalProjection = parameter<bool>( metadataTarget, shaderParameters, "sphericalProjectionParameter", 0 );

        M44f projectionTransform = parameter<M44f>( metadataTarget, shaderParameters, "projectionTransformParameter", M44f() );
        const std::vector<float> projectionTransformVector = parameter<std::vector<float> >( metadataTarget, shaderParameters, "projectionTransformParameter", std::vector<float>() );
        if( projectionTransformVector.size() == 16 )
        {
            projectionTransform = M44f( (float(*)[4])(&projectionTransformVector[0]) );
        }
        addAreaLightVisualiser( state, finalColor, textureName, flipNormal, doubleSided,
                                sphericalProjection, projectionTransform );
        return NULL;
    }

    GroupPtr result = new Group;

    const float locatorScale = parameter<float>( metadataTarget, shaderParameters, "locatorScaleParameter", 1 );
    Imath::M44f topTrans;
    if( orientation )
    {
        topTrans = orientation->readable();
    }
    topTrans.scale( V3f( locatorScale ) );
    result->setTransform( topTrans );

    if( type && type->readable() == "environment" )
    {
        const std::string textureName = parameter<std::string>( metadataTarget, shaderParameters, "textureNameParameter", "" );
        addEnvLightVisualiser( result, finalColor, textureName );
    }
    else
    {
        float coneAngle = parameter<float>( metadataTarget, shaderParameters, "coneAngleParameter", 0.0f );
        float penumbraAngle = parameter<float>( metadataTarget, shaderParameters, "penumbraAngleParameter", 0.0f );

        if( ConstStringDataPtr angleUnit = Metadata::value<StringData>( metadataTarget, "angleUnit" ) )
        {
            if( angleUnit->readable() == "radians" )
            {
                coneAngle *= 180.0 / M_PI;
                penumbraAngle *= 180 / M_PI;
            }
        }

        const std::string *penumbraType = NULL;
        ConstStringDataPtr penumbraTypeData = Metadata::value<StringData>( metadataTarget, "penumbraType" );
        if( penumbraTypeData )
        {
            penumbraType = &penumbraTypeData->readable();
        }


        float lensRadius = 0.0f;
        if( parameter<bool>( metadataTarget, shaderParameters, "lensRadiusEnableParameter", true ) )
        {
            lensRadius = parameter<float>( metadataTarget, shaderParameters, "lensRadiusParameter", 0.0f );
        }

        addBasicLightVisualiser( type, result, finalColor, coneAngle, penumbraAngle, penumbraType, lensRadius / locatorScale );
    }
    return result;
}