void SceneShape::sceneShapeAttributeNames( const MDagPath &p, SceneInterface::NameList &attributeNames ) { MDagPath dagPath; SceneShape *sceneShape = findScene( p, false, &dagPath ); if ( !sceneShape ) { return; } SceneInterface::NameList sceneAttrNames; ConstSceneInterfacePtr scene = sceneShape->getSceneInterface(); if ( !scene ) { return; } scene->attributeNames( sceneAttrNames ); attributeNames.insert( attributeNames.end(), sceneAttrNames.begin(), sceneAttrNames.end() ); MFnDagNode fnChildDag( dagPath ); if( !fnChildDag.isIntermediateObject() && hasSceneShapeLink( p ) ) { attributeNames.push_back( LinkedScene::linkAttribute ); } }
IECore::ConstCompoundObjectPtr SceneReader::computeAttributes( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const { ConstSceneInterfacePtr s = scene( path ); if( !s ) { return parent->attributesPlug()->defaultValue(); } // read attributes SceneInterface::NameList nameList; s->attributeNames( nameList ); CompoundObjectPtr result = new CompoundObject; for( SceneInterface::NameList::iterator it = nameList.begin(); it != nameList.end(); ++it ) { // these internal attributes should be ignored: if( *it == SceneCache::animatedObjectTopologyAttribute ) { continue; } if( *it == SceneCache::animatedObjectPrimVarsAttribute ) { continue; } // the const cast is ok, because we're only using it to put the object into a CompoundObject that will // be treated as forever const after being returned from this function. result->members()[ std::string( *it ) ] = boost::const_pointer_cast<Object>( s->readAttribute( *it, context->getTime() ) ); } return result; }
IECore::ConstCompoundObjectPtr SceneReader::computeAttributes( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const { std::string fileName = fileNamePlug()->getValue(); if( !fileName.size() ) { return parent->attributesPlug()->defaultValue(); } ConstSceneInterfacePtr s = SharedSceneInterfaces::get( fileName ); s = s->scene( path ); // read attributes SceneInterface::NameList nameList; s->attributeNames( nameList ); CompoundObjectPtr result = new CompoundObject; for( SceneInterface::NameList::iterator it = nameList.begin(); it != nameList.end(); ++it ) { // these internal attributes should be ignored: if( *it == SceneCache::animatedObjectTopologyAttribute ) { continue; } if( *it == SceneCache::animatedObjectPrimVarsAttribute ) { continue; } // the const cast is ok, because we're only using it to put the object into a CompoundObject that will // be treated as forever const after being returned from this function. result->members()[ std::string( *it ) ] = constPointerCast<Object>( s->readAttribute( *it, context->getFrame() / g_frameRate ) ); } // read tags and turn them into attributes of the form "user:tag:tagName" nameList.clear(); s->readTags( nameList, IECore::SceneInterface::LocalTag ); for( SceneInterface::NameList::const_iterator it = nameList.begin(); it != nameList.end(); ++it ) { if( it->string().compare( 0, 11, "ObjectType:" ) == 0 ) { continue; } result->members()["user:tag:"+it->string()] = g_trueBoolData; } return result; }
void SceneReader::hashAttributes( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const { ConstSceneInterfacePtr s = scene( path ); if( !s ) { h = parent->attributesPlug()->defaultValue()->Object::hash(); return; } SceneInterface::NameList attributeNames; s->attributeNames( attributeNames ); SceneInterface::NameList tagNames; s->readTags( tagNames, IECore::SceneInterface::LocalTag ); if( !attributeNames.size() && !tagNames.size() ) { h = parent->attributesPlug()->defaultValue()->Object::hash(); return; } FileSource::hashAttributes( path, context, parent, h ); bool animated = false; const SampledSceneInterface *ss = runTimeCast<const SampledSceneInterface>( s.get() ); if( !ss ) { animated = true; } else { for( SceneInterface::NameList::iterator it = attributeNames.begin(); it != attributeNames.end(); ++it ) { if( ss->numAttributeSamples( *it ) > 1 ) { animated = true; break; } } } if( animated ) { h.append( context->getFrame() ); } }
void OBJ_SceneCacheTransform::attributeNames( const OP_Node *node, SceneInterface::NameList &attrs ) { // make sure its a SceneCacheNode if ( !node->hasParm( pFile.getToken() ) || !node->hasParm( pRoot.getToken() ) ) { return; } const SceneCacheNode<OP_Node> *sceneNode = reinterpret_cast< const SceneCacheNode<OP_Node>* >( node ); /// \todo: do we need to ensure the file exists first? ConstSceneInterfacePtr scene = OBJ_SceneCacheTransform::scene( sceneNode->getFile(), sceneNode->getPath() ); if ( !scene ) { return; } scene->attributeNames( attrs ); const char *expanded = pExpanded.getToken(); if ( node->hasParm( expanded ) && !node->evalInt( expanded, 0, 0 ) ) { attrs.push_back( LinkedScene::linkAttribute ); } }