void IECoreAppleseed::ShadingState::addConnections( const std::string &shaderHandle, const CompoundDataMap ¶meters, asr::ShaderGroup *shaderGroup ) { for( CompoundDataMap::const_iterator it = parameters.begin(), eIt = parameters.end(); it != eIt; ++it ) { if( it->second->typeId() != StringDataTypeId ) { continue; } const std::string &value = static_cast<const StringData *>( it->second.get() )->readable(); if( boost::starts_with( value, "link:" ) ) { size_t dot_pos = value.find_first_of( '.' ); if( dot_pos == string::npos ) { msg( Msg::Warning, "AppleseedRenderer", boost::format( "Parameter \"%s\" has unexpected value \"%s\" - expected value of the form \"link:sourceShader.sourceParameter" ) % it->first.string() % value ); continue; } shaderGroup->add_connection( string( value, 5, dot_pos - 5 ).c_str(), string( value, dot_pos + 1).c_str(), shaderHandle.c_str(), it->first.c_str() ); } } }
static void declareParameters( const CompoundDataMap ¶meters, ShadingSystem *shadingSystem ) { for( CompoundDataMap::const_iterator it = parameters.begin(), eIt = parameters.end(); it != eIt; ++it ) { if( it->first == "__handle" ) { continue; } if( it->second->isInstanceOf( StringDataTypeId ) ) { const std::string &value = static_cast<const StringData *>( it->second.get() )->readable(); if( boost::starts_with( value, "link:" ) ) { // this will be handled in declareConnections() continue; } } const void *basePointer = 0; const TypeDesc typeDesc = typeDescFromData( it->second.get(), basePointer ); if( basePointer ) { shadingSystem->Parameter( it->first.c_str(), typeDesc, basePointer ); } else { msg( Msg::Warning, "OSLRenderer", boost::format( "Parameter \"%s\" has unsupported type \"%s\"" ) % it->first.string() % it->second->typeName() ); } } }
static void declareConnections( const std::string &shaderHandle, const CompoundDataMap ¶meters, ShadingSystem *shadingSystem ) { for( CompoundDataMap::const_iterator it = parameters.begin(), eIt = parameters.end(); it != eIt; ++it ) { if( it->second->typeId() != StringDataTypeId ) { continue; } const std::string &value = static_cast<const StringData *>( it->second.get() )->readable(); if( boost::starts_with( value, "link:" ) ) { vector<string> splitValue; split( splitValue, value, is_any_of( "." ), token_compress_on ); if( splitValue.size() != 2 ) { msg( Msg::Warning, "OSLRenderer", boost::format( "Parameter \"%s\" has unexpected value \"%s\" - expected value of the form \"link:sourceShader.sourceParameter" ) % it->first.string() % value ); continue; } shadingSystem->ConnectShaders( splitValue[0].c_str() + 5, splitValue[1].c_str(), shaderHandle.c_str(), it->first.c_str() ); } } }
asr::ParamArray IECoreAppleseed::convertParams( const CompoundDataMap ¶meters ) { asr::ParamArray result; for( CompoundDataMap::const_iterator it=parameters.begin(); it!=parameters.end(); ++it ) setParam( it->first.value(), it->second.get(), result ); return result; }
asr::ParamArray IECoreAppleseed::ShadingState::convertParameters( const CompoundDataMap ¶meters ) { asr::ParamArray params; for( CompoundDataMap::const_iterator it = parameters.begin(), eIt = parameters.end(); it != eIt; ++it ) { if( it->first == "__handle" ) { continue; } if( it->second->isInstanceOf( StringDataTypeId ) ) { const std::string &value = static_cast<const StringData *>( it->second.get() )->readable(); if( boost::starts_with( value, "link:" ) ) { // this will be handled in declareConnections() continue; } } std::stringstream ss; const Data *data = it->second.get(); switch( data->typeId() ) { case FloatDataTypeId : { const float *p = static_cast<const FloatData *>( data )->baseReadable(); ss << "float " << *p; } break; case IntDataTypeId : { const int *p = static_cast<const IntData *>( data )->baseReadable(); ss << "int " << *p; } break; case V3fDataTypeId : { const float *p = static_cast<const V3fData *>( data )->baseReadable(); ss << "vector " << p[0] << " " << p[1] << " " << p[2]; } break; case Color3fDataTypeId : { const float *p = static_cast<const Color3fData *>( data )->baseReadable(); ss << "color " << p[0] << " " << p[1] << " " << p[2]; } break; case StringDataTypeId : { const std::string *p = &(static_cast<const StringData *>( data )->readable() ); ss << "string " << *p; } break; default: msg( Msg::Warning, "AppleseedRenderer", boost::format( "Parameter \"%s\" has unsupported type \"%s\"" ) % it->first.string() % it->second->typeName() ); break; } if( !ss.str().empty() ) { params.insert( it->first.c_str(), ss.str() ); } } return params; }