本文整理汇总了C++中ConstCompoundObjectPtr::members方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstCompoundObjectPtr::members方法的具体用法?C++ ConstCompoundObjectPtr::members怎么用?C++ ConstCompoundObjectPtr::members使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstCompoundObjectPtr
的用法示例。
在下文中一共展示了ConstCompoundObjectPtr::members方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeProcessedMetadata
IECore::ConstCompoundObjectPtr CopyImageMetadata::computeProcessedMetadata( const Gaffer::Context *context, const IECore::CompoundObject *inputMetadata ) const
{
ConstCompoundObjectPtr copyFrom = copyFromPlug()->metadataPlug()->getValue();
if ( copyFrom->members().empty() )
{
return inputMetadata;
}
const std::string names = namesPlug()->getValue();
const bool invert = invertNamesPlug()->getValue();
if ( !invert && !names.size() )
{
return inputMetadata;
}
IECore::CompoundObjectPtr result = inputMetadata->copy();
for ( IECore::CompoundObject::ObjectMap::const_iterator it = copyFrom->members().begin(), eIt = copyFrom->members().end(); it != eIt; ++it )
{
bool copy = false;
if ( matchMultiple( it->first.c_str(), names.c_str() ) != invert )
{
copy = true;
}
if ( copy )
{
result->members()[it->first] = it->second;
}
}
return result;
}
示例2: computeGlobals
IECore::ConstCompoundObjectPtr Attributes::computeGlobals( const Gaffer::Context *context, const ScenePlug *parent ) const
{
ConstCompoundObjectPtr inputGlobals = inPlug()->globalsPlug()->getValue();
if( !globalPlug()->getValue() )
{
return inputGlobals;
}
const CompoundDataPlug *p = attributesPlug();
IECore::CompoundObjectPtr result = new CompoundObject;
// Since we're not going to modify any existing members (only add new ones),
// and our result becomes const on returning it, we can directly reference
// the input members in our result without copying. Be careful not to modify
// them though!
result->members() = inputGlobals->members();
std::string name;
for( CompoundDataPlug::MemberPlugIterator it( p ); !it.done(); ++it )
{
IECore::DataPtr d = p->memberDataAndName( it->get(), name );
if( d )
{
result->members()["attribute:" + name] = d;
}
}
return result;
}
示例3: computeAttributes
IECore::ConstCompoundObjectPtr OSLLight::computeAttributes( const SceneNode::ScenePath &path, const Gaffer::Context *context, const GafferScene::ScenePlug *parent ) const
{
IECore::CompoundObjectPtr result = new IECore::CompoundObject;
ConstCompoundObjectPtr shaderAttributes = shaderInPlug()->attributes();
result->members() = shaderAttributes->members();
attributesPlug()->fillCompoundObject( result->members() );
return result;
}
示例4: writeLocation
void SceneWriter::writeLocation( const GafferScene::ScenePlug *scene, const ScenePlug::ScenePath &scenePath, Context *context, IECore::SceneInterface *output, double time ) const
{
context->set( ScenePlug::scenePathContextName, scenePath );
ConstCompoundObjectPtr attributes = scene->attributesPlug()->getValue();
for( CompoundObject::ObjectMap::const_iterator it = attributes->members().begin(), eIt = attributes->members().end(); it != eIt; it++ )
{
output->writeAttribute( it->first, it->second.get(), time );
}
if( scenePath.empty() )
{
ConstCompoundObjectPtr globals = scene->globalsPlug()->getValue();
output->writeAttribute( "gaffer:globals", globals.get(), time );
}
ConstObjectPtr object = scene->objectPlug()->getValue();
if( object->typeId() != IECore::NullObjectTypeId && scenePath.size() > 0 )
{
output->writeObject( object.get(), time );
}
Imath::Box3f b = scene->boundPlug()->getValue();
output->writeBound( Imath::Box3d( Imath::V3f( b.min ), Imath::V3f( b.max ) ), time );
if( scenePath.size() )
{
Imath::M44f t = scene->transformPlug()->getValue();
Imath::M44d transform(
t[0][0], t[0][1], t[0][2], t[0][3],
t[1][0], t[1][1], t[1][2], t[1][3],
t[2][0], t[2][1], t[2][2], t[2][3],
t[3][0], t[3][1], t[3][2], t[3][3]
);
output->writeTransform( new IECore::M44dData( transform ), time );
}
ConstInternedStringVectorDataPtr childNames = scene->childNamesPlug()->getValue();
ScenePlug::ScenePath childScenePath = scenePath;
childScenePath.push_back( InternedString() );
for( vector<InternedString>::const_iterator it=childNames->readable().begin(); it!=childNames->readable().end(); it++ )
{
childScenePath[scenePath.size()] = *it;
SceneInterfacePtr outputChild = output->child( *it, SceneInterface::CreateIfMissing );
writeLocation( scene, childScenePath, context, outputChild.get(), time );
}
}
示例5: computeChildNames
IECore::ConstInternedStringVectorDataPtr CompoundObjectSource::computeChildNames( const ScenePath &path, const Gaffer::Context *context, const GafferScene::ScenePlug *parent ) const
{
ConstCompoundObjectPtr entry = entryForPath( path );
ConstCompoundObjectPtr children = entry->member<CompoundObject>( "children" );
if( !children )
{
return outPlug()->childNamesPlug()->defaultValue();
}
InternedStringVectorDataPtr result = new InternedStringVectorData;
for( CompoundObject::ObjectMap::const_iterator it = children->members().begin(); it!=children->members().end(); it++ )
{
result->writable().push_back( it->first.value() );
}
return result;
}
示例6: computeProcessedAttributes
ConstCompoundObjectPtr SetVisualiser::computeProcessedAttributes( const ScenePath &path, const Gaffer::Context *context, ConstCompoundObjectPtr inputAttributes ) const
{
CompoundObjectPtr result = new CompoundObject;
// Since we're not going to modify any existing members (only add a new one),
// and our result becomes const on returning it, we can directly reference
// the input members in our result without copying. Be careful not to modify
// them though!
result->members() = inputAttributes->members();
ConstCompoundDataPtr outSetsData = outSetsPlug()->getValue();
const InternedStringVectorData *setNamesData = outSetsData->member<InternedStringVectorData>( "names" );
const Color3fVectorData *setColorsData = outSetsData->member<Color3fVectorData>( "colors" );
int matchResult = PathMatcher::ExactMatch;
if( includeInheritedPlug()->getValue() )
{
matchResult |= PathMatcher::AncestorMatch;
}
ConstCompoundDataPtr targetSets = SceneAlgo::sets( inPlug(), setNamesData->readable() );
std::vector<Color3f> shaderColors;
size_t index = 0;
for( auto &setName : setNamesData->readable() )
{
const PathMatcherData *pathMatchData = targetSets->member<const PathMatcherData>( setName );
if( pathMatchData->readable().match( path ) & matchResult )
{
shaderColors.push_back( setColorsData->readable()[ index ] );
}
// We need to pass our colors to the shader as a fixed size array
if( shaderColors.size() == g_maxShaderColors )
{
break;
}
++index;
}
// Avoids shader compilation errors as its expecting g_maxShaderColors elements
const size_t numColorsUsed = shaderColors.size();
shaderColors.resize( g_maxShaderColors );
result->members()["gl:surface"] = stripeShader( stripeWidthPlug()->getValue(), numColorsUsed, shaderColors );
return result;
}
示例7: computeAttributes
//.........这里部分代码省略.........
else if( firstOutput && firstOutput->type == TypeDesc::TypeColor )
{
adaptedNetwork = shaderNetwork->copy();
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
InternedString emissionHandle = adaptedNetwork->addShader( "emission", std::move( emission ) );
adaptedNetwork->addConnection(
{ { adaptedNetwork->getOutput().shader, firstOutput->name.string() }, { emissionHandle, "Color" } }
);
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
InternedString materialHandle = adaptedNetwork->addShader( "material", std::move( material ) );
adaptedNetwork->addConnection(
{ { emissionHandle, "BSDF" }, { materialHandle, "BSDF" } }
);
adaptedNetwork->setOutput( materialHandle );
}
else if( firstOutput && ( firstOutput->type == TypeDesc::TypeFloat || firstOutput->type == TypeDesc::TypeInt ) )
{
adaptedNetwork = shaderNetwork->copy();
ShaderPtr colorBuild = new Shader( "color/as_color_build", "osl:shader" );
InternedString colorBuildHandle = adaptedNetwork->addShader( "colorBuild", std::move( colorBuild ) );
for( const auto &channel : { "R", "G", "B" } )
{
adaptedNetwork->addConnection(
{ { adaptedNetwork->getOutput().shader, firstOutput->name.string() }, { colorBuildHandle, channel } }
);
}
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
InternedString emissionHandle = adaptedNetwork->addShader( "emission", std::move( emission ) );
adaptedNetwork->addConnection(
{ { colorBuildHandle, "ColorOut" }, { emissionHandle, "Color" } }
);
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
InternedString materialHandle = adaptedNetwork->addShader( "material", std::move( material ) );
adaptedNetwork->addConnection(
{ { emissionHandle, "BSDF" }, { materialHandle, "BSDF" } }
);
adaptedNetwork->setOutput( materialHandle );
}
else if( firstOutput && firstOutput->type == TypeDesc::TypeVector )
{
adaptedNetwork = shaderNetwork->copy();
ShaderPtr vectorSplit = new Shader( "vector/as_vector_split", "osl:shader" );
InternedString vectorSplitHandle = adaptedNetwork->addShader( "vectorSplit", std::move( vectorSplit ) );
adaptedNetwork->addConnection(
{ { adaptedNetwork->getOutput().shader, firstOutput->name.string() }, { vectorSplitHandle, "Vector" } }
);
ShaderPtr colorBuild = new Shader( "color/as_color_build", "osl:shader" );
InternedString colorBuildHandle = adaptedNetwork->addShader( "colorBuild", std::move( colorBuild ) );
for( const auto &c : { make_pair( "X", "R" ), make_pair( "Y", "G" ), make_pair( "Z", "B" ) } )
{
adaptedNetwork->addConnection(
{ { vectorSplitHandle, c.first }, { colorBuildHandle, c.second } }
);
}
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
InternedString emissionHandle = adaptedNetwork->addShader( "emission", std::move( emission ) );
adaptedNetwork->addConnection(
{ { colorBuildHandle, "ColorOut" }, { emissionHandle, "Color" } }
);
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
InternedString materialHandle = adaptedNetwork->addShader( "material", std::move( material ) );
adaptedNetwork->addConnection(
{ { emissionHandle, "BSDF" }, { materialHandle, "BSDF" } }
);
adaptedNetwork->setOutput( materialHandle );
}
else
{
// Shader has no output, or an output we can't map sensibly.
// Make an "error" shader.
adaptedNetwork = new ShaderNetwork;
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
emission->parameters()["Color"] = new Color3fData( Imath::Color3f( 1, 0, 0 ) );
InternedString emissionHandle = adaptedNetwork->addShader( "emission", std::move( emission ) );
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
InternedString materialHandle = adaptedNetwork->addShader( "material", std::move( material ) );
adaptedNetwork->addConnection(
{ { emissionHandle, "BSDF" }, { materialHandle, "BSDF" } }
);
adaptedNetwork->setOutput( materialHandle );
}
// Place the new network into the "osl:surface" attribute
// and remove the "osl:shader" attribute.
CompoundObjectPtr outputAttributes = new CompoundObject;
outputAttributes->members() = inputAttributes->members(); // Shallow copy for speed - do not modify in place!
outputAttributes->members()[g_oslSurfaceAttributeName] = adaptedNetwork;
outputAttributes->members().erase( g_oslShaderAttributeName );
return outputAttributes;
}
示例8: computeAttributes
IECore::ConstCompoundObjectPtr AppleseedShaderAdaptor::computeAttributes( const ScenePath &path, const Gaffer::Context *context, const GafferScene::ScenePlug *parent ) const
{
ConstCompoundObjectPtr inputAttributes = inPlug()->attributesPlug()->getValue();
const ObjectVector *shaderNetwork = inputAttributes->member<const ObjectVector>( g_oslShaderAttributeName );
if( !shaderNetwork || shaderNetwork->members().empty() )
{
return inputAttributes;
}
const Shader *rootShader = runTimeCast<const Shader>( shaderNetwork->members().back().get() );
if( !rootShader )
{
return inputAttributes;
}
OSLQuery::Parameter *firstOutput = firstOutputParameter( rootShader->getName() );
// Build an adapter network if we can.
bool prependInputNetwork = true;
vector<ShaderPtr> adapters;
if( firstOutput && firstOutput->isclosure )
{
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
material->parameters()[g_bsdfParameterName] = new StringData( "link:adapterInputHandle." + firstOutput->name.string() );
adapters.push_back( material );
}
else if( firstOutput && firstOutput->type == TypeDesc::TypeColor )
{
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
emission->parameters()["Color"] = new StringData( "link:adapterInputHandle." + firstOutput->name.string() );
emission->parameters()[g_handleParameterName] = new StringData( "adapterEmissionHandle" );
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
material->parameters()[g_bsdfParameterName] = new StringData( "link:adapterEmissionHandle.BSDF" );
adapters.push_back( emission );
adapters.push_back( material );
}
else if( firstOutput && ( firstOutput->type == TypeDesc::TypeFloat || firstOutput->type == TypeDesc::TypeInt ) )
{
ShaderPtr colorBuild = new Shader( "color/as_color_build", "osl:shader" );
StringDataPtr colorLink = new StringData( "link:adapterInputHandle." + firstOutput->name.string() );
colorBuild->parameters()["R"] = colorLink;
colorBuild->parameters()["G"] = colorLink;
colorBuild->parameters()["B"] = colorLink;
colorBuild->parameters()[g_handleParameterName] = new StringData( "adapterColorBuildHandle" );
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
emission->parameters()["Color"] = new StringData( "link:adapterColorBuildHandle.ColorOut" );
emission->parameters()[g_handleParameterName] = new StringData( "adapterEmissionHandle" );
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
material->parameters()[g_bsdfParameterName] = new StringData( "link:adapterEmissionHandle.BSDF" );
adapters.push_back( colorBuild );
adapters.push_back( emission );
adapters.push_back( material );
}
else if( firstOutput && firstOutput->type == TypeDesc::TypeVector )
{
ShaderPtr vectorSplit = new Shader( "vector/as_vector_split", "osl:shader" );
vectorSplit->parameters()["Vector"] = new StringData( "link:adapterInputHandle." + firstOutput->name.string() );
vectorSplit->parameters()[g_handleParameterName] = new StringData( "adapterVectorSplit" );
ShaderPtr colorBuild = new Shader( "color/as_color_build", "osl:shader" );
colorBuild->parameters()["R"] = new StringData( "link:adapterVectorSplit.X" );
colorBuild->parameters()["G"] = new StringData( "link:adapterVectorSplit.Y" );
colorBuild->parameters()["B"] = new StringData( "link:adapterVectorSplit.Z" );
colorBuild->parameters()[g_handleParameterName] = new StringData( "adapterColorBuildHandle" );
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
emission->parameters()["Color"] = new StringData( "link:adapterColorBuildHandle.ColorOut" );
emission->parameters()[g_handleParameterName] = new StringData( "adapterEmissionHandle" );
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
material->parameters()[g_bsdfParameterName] = new StringData( "link:adapterEmissionHandle.BSDF" );
adapters.push_back( vectorSplit );
adapters.push_back( colorBuild );
adapters.push_back( emission );
adapters.push_back( material );
}
else
{
// Shader has no output, or an output we can't map sensibly.
// Make an "error" shader.
ShaderPtr emission = new Shader( "surface/as_emission_surface", "osl:shader" );
emission->parameters()["Color"] = new Color3fData( Imath::Color3f( 1, 0, 0 ) );
emission->parameters()[g_handleParameterName] = new StringData( "adapterEmissionHandle" );
ShaderPtr material = new Shader( "material/as_material_builder", "osl:surface" );
material->parameters()[g_bsdfParameterName] = new StringData( "link:adapterEmissionHandle.BSDF" );
adapters.push_back( emission );
adapters.push_back( material );
prependInputNetwork = false; // We don't need the original shaders at all
}
//.........这里部分代码省略.........
示例9: doOperation
ObjectPtr EnvMapSampler::doOperation( const CompoundObject * operands )
{
ImagePrimitivePtr image = static_cast<ImagePrimitive *>( imageParameter()->getValue() )->copy();
Box2i dataWindow = image->getDataWindow();
// find the rgb channels
ConstFloatVectorDataPtr redData = image->getChannel<float>( "R" );
ConstFloatVectorDataPtr greenData = image->getChannel<float>( "G" );
ConstFloatVectorDataPtr blueData = image->getChannel<float>( "B" );
if( !(redData && greenData && blueData) )
{
throw Exception( "Image does not contain valid RGB float channels." );
}
const vector<float> &red = redData->readable();
const vector<float> &green = greenData->readable();
const vector<float> &blue = blueData->readable();
// get a luminance channel
LuminanceOpPtr luminanceOp = new LuminanceOp();
luminanceOp->inputParameter()->setValue( image );
luminanceOp->copyParameter()->getTypedValue() = false;
luminanceOp->removeColorPrimVarsParameter()->getTypedValue() = false;
luminanceOp->operate();
// do the median cut thing to get some samples
MedianCutSamplerPtr sampler = new MedianCutSampler;
sampler->imageParameter()->setValue( image );
sampler->subdivisionDepthParameter()->setNumericValue( subdivisionDepthParameter()->getNumericValue() );
ConstCompoundObjectPtr samples = boost::static_pointer_cast<CompoundObject>( sampler->operate() );
const vector<V2f> ¢roids = boost::static_pointer_cast<V2fVectorData>( samples->members().find( "centroids" )->second )->readable();
const vector<Box2i> &areas = boost::static_pointer_cast<Box2iVectorData>( samples->members().find( "areas" )->second )->readable();
// get light directions and colors from the samples
V3fVectorDataPtr directionsData = new V3fVectorData;
Color3fVectorDataPtr colorsData = new Color3fVectorData;
vector<V3f> &directions = directionsData->writable();
vector<Color3f> &colors = colorsData->writable();
float radiansPerPixel = M_PI / (dataWindow.size().y + 1);
float angleAtTop = ( M_PI - radiansPerPixel ) / 2.0f;
for( unsigned i=0; i<centroids.size(); i++ )
{
const Box2i &area = areas[i];
Color3f color( 0 );
for( int y=area.min.y; y<=area.max.y; y++ )
{
int yRel = y - dataWindow.min.y;
float angle = angleAtTop - yRel * radiansPerPixel;
float weight = cosf( angle );
int index = (area.min.x - dataWindow.min.x) + (dataWindow.size().x + 1 ) * yRel;
for( int x=area.min.x; x<=area.max.x; x++ )
{
color[0] += weight * red[index];
color[1] += weight * green[index];
color[2] += weight * blue[index];
index++;
}
}
color /= red.size();
colors.push_back( color );
float phi = angleAtTop - (centroids[i].y - dataWindow.min.y) * radiansPerPixel;
V3f direction;
direction.y = sinf( phi );
float r = cosf( phi );
float theta = 2 * M_PI * lerpfactor( (float)centroids[i].x, (float)dataWindow.min.x, (float)dataWindow.max.x );
direction.x = r * cosf( theta );
direction.z = r * sinf( theta );
directions.push_back( -direction ); // negated so we output the direction the light shines in
}
// return the result
CompoundObjectPtr result = new CompoundObject;
result->members()["directions"] = directionsData;
result->members()["colors"] = colorsData;
return result;
}
示例10: outputLights
void Render::outputLights( const ScenePlug *scene, const IECore::CompoundObject *globals, IECore::Renderer *renderer ) const
{
const CompoundData *forwardDeclarations = globals->member<CompoundData>( "gaffer:forwardDeclarations" );
if( !forwardDeclarations )
{
return;
}
CompoundDataMap::const_iterator it, eIt;
for( it = forwardDeclarations->readable().begin(), eIt = forwardDeclarations->readable().end(); it != eIt; it++ )
{
const CompoundData *declaration = runTimeCast<const CompoundData>( it->second.get() );
if( !declaration )
{
continue;
}
const IECore::TypeId type = (IECore::TypeId)declaration->member<IntData>( "type", true )->readable();
if( type != IECore::LightTypeId )
{
continue;
}
ScenePlug::ScenePath path;
ScenePlug::stringToPath( it->first.string(), path );
IECore::ConstLightPtr constLight = runTimeCast<const IECore::Light>( scene->object( path ) );
if( !constLight )
{
continue;
}
ConstCompoundObjectPtr attributes = scene->fullAttributes( path );
const BoolData *visibilityData = attributes->member<BoolData>( "gaffer:visibility" );
if( visibilityData && !visibilityData->readable() )
{
continue;
}
M44f transform = scene->fullTransform( path );
LightPtr light = constLight->copy();
light->setHandle( it->first.string() );
{
AttributeBlock attributeBlock( renderer );
renderer->setAttribute( "name", new StringData( it->first ) );
CompoundObject::ObjectMap::const_iterator aIt, aeIt;
for( aIt = attributes->members().begin(), aeIt = attributes->members().end(); aIt != aeIt; aIt++ )
{
if( const Data *attribute = runTimeCast<const Data>( aIt->second.get() ) )
{
renderer->setAttribute( aIt->first.string(), attribute );
}
}
renderer->concatTransform( transform );
light->render( renderer );
}
renderer->illuminate( light->getHandle(), true );
}
}
示例11: computeGlobals
IECore::ConstCompoundObjectPtr BranchCreator::computeGlobals( const Gaffer::Context *context, const ScenePlug *parent ) const
{
ConstCompoundObjectPtr inputGlobals = inPlug()->globalsPlug()->getValue();
ConstCompoundDataPtr mapping = boost::static_pointer_cast<const CompoundData>( mappingPlug()->getValue() );
if( !mapping->readable().size() )
{
return inputGlobals;
}
const CompoundData *branchSets = NULL;
ConstCompoundObjectPtr branchGlobals = computeBranchGlobals( mapping->member<InternedStringVectorData>( g_parentKey )->readable(), context );
if( branchGlobals )
{
branchSets = branchGlobals->member<CompoundData>( "gaffer:sets", /* throwExceptions = */ false );
}
if( !branchSets )
{
return inputGlobals;
}
IECore::CompoundObjectPtr outputGlobals = new CompoundObject;
// Shallow copy of the input, because most of it will remain unchanged.
outputGlobals->members() = inputGlobals->members();
// Deep copy of the input sets, because we'll be modifying them.
const CompoundData *inputSets = inputGlobals->member<CompoundData>( "gaffer:sets", /* throwExeptions = */ false );
CompoundDataPtr outputSets = inputSets ? inputSets->copy() : new CompoundData;
outputGlobals->members()["gaffer:sets"] = outputSets;
const CompoundData *forwardMapping = mapping->member<CompoundData>( g_forwardMappingKey );
string parentString;
ScenePlug::pathToString( mapping->member<InternedStringVectorData>( g_parentKey )->readable(), parentString );
if( !boost::ends_with( parentString, "/" ) )
{
parentString += "/";
}
for( CompoundDataMap::const_iterator it = branchSets->readable().begin(), eIt = branchSets->readable().end(); it != eIt; ++it )
{
const PathMatcher &branchSet = static_cast<const PathMatcherData *>( it->second.get() )->readable();
PathMatcher &outputSet = outputSets->member<PathMatcherData>( it->first, /* throwExceptions = */ false, /* createIfMissing = */ true )->writable();
/// \todo If PathMatcher allowed us to rename nodes and merge in other PathMatchers, this could
/// be much more efficient.
vector<string> branchPaths;
branchSet.paths( branchPaths );
for( vector<string>::const_iterator pIt = branchPaths.begin(), peIt = branchPaths.end(); pIt != peIt; ++pIt )
{
const string &branchPath = *pIt;
const size_t secondSlashPos = branchPath.find( '/', 1 );
const std::string branchName( branchPath, 1, secondSlashPos - 1 );
const InternedStringData *outputName = forwardMapping->member<InternedStringData>( branchName );
if( !outputName )
{
// See comments in Group::computeGlobals().
continue;
}
std::string outputPath = parentString + outputName->readable().string();
if( secondSlashPos != string::npos )
{
outputPath += branchPath.substr( secondSlashPos );
}
outputSet.addPath( outputPath );
}
}
return outputGlobals;
}
示例12: render
void SceneProcedural::render( RendererPtr renderer ) const
{
Context::Scope scopedContext( m_context );
/// \todo See above.
try
{
// get all the attributes, and early out if we're not visibile
ConstCompoundObjectPtr attributes = m_scenePlug->attributesPlug()->getValue();
const BoolData *visibilityData = attributes->member<BoolData>( "gaffer:visibility" );
if( visibilityData && !visibilityData->readable() )
{
return;
}
// if we are visible then make an attribute block to contain everything, set the name
// and get on with generating things.
AttributeBlock attributeBlock( renderer );
std::string name = "";
for( ScenePlug::ScenePath::const_iterator it = m_scenePath.begin(), eIt = m_scenePath.end(); it != eIt; it++ )
{
name += "/" + it->string();
}
renderer->setAttribute( "name", new StringData( name ) );
// transform
std::set<float> transformTimes;
motionTimes( ( m_options.transformBlur && m_attributes.transformBlur ) ? m_attributes.transformBlurSegments : 0, transformTimes );
{
ContextPtr timeContext = new Context( *m_context );
Context::Scope scopedTimeContext( timeContext );
MotionBlock motionBlock( renderer, transformTimes, transformTimes.size() > 1 );
for( std::set<float>::const_iterator it = transformTimes.begin(), eIt = transformTimes.end(); it != eIt; it++ )
{
timeContext->setFrame( *it );
renderer->concatTransform( m_scenePlug->transformPlug()->getValue() );
}
}
// attributes
for( CompoundObject::ObjectMap::const_iterator it = attributes->members().begin(), eIt = attributes->members().end(); it != eIt; it++ )
{
if( const StateRenderable *s = runTimeCast<const StateRenderable>( it->second.get() ) )
{
s->render( renderer );
}
else if( const ObjectVector *o = runTimeCast<const ObjectVector>( it->second.get() ) )
{
for( ObjectVector::MemberContainer::const_iterator it = o->members().begin(), eIt = o->members().end(); it != eIt; it++ )
{
const StateRenderable *s = runTimeCast<const StateRenderable>( it->get() );
if( s )
{
s->render( renderer );
}
}
}
else if( const Data *d = runTimeCast<const Data>( it->second.get() ) )
{
renderer->setAttribute( it->first, d );
}
}
// object
std::set<float> deformationTimes;
motionTimes( ( m_options.deformationBlur && m_attributes.deformationBlur ) ? m_attributes.deformationBlurSegments : 0, deformationTimes );
{
ContextPtr timeContext = new Context( *m_context );
Context::Scope scopedTimeContext( timeContext );
unsigned timeIndex = 0;
for( std::set<float>::const_iterator it = deformationTimes.begin(), eIt = deformationTimes.end(); it != eIt; it++, timeIndex++ )
{
timeContext->setFrame( *it );
ConstObjectPtr object = m_scenePlug->objectPlug()->getValue();
if( const Primitive *primitive = runTimeCast<const Primitive>( object.get() ) )
{
if( deformationTimes.size() > 1 && timeIndex == 0 )
{
renderer->motionBegin( deformationTimes );
}
primitive->render( renderer );
if( deformationTimes.size() > 1 && timeIndex == deformationTimes.size() - 1 )
{
renderer->motionEnd();
}
}
else if( const Camera *camera = runTimeCast<const Camera>( object.get() ) )
{
//.........这里部分代码省略.........