예제 #1
0
ConstSceneInterfacePtr LinkedScene::expandLink( const StringData *fileName, const InternedStringVectorData *root, int &linkDepth )
{
	if ( fileName && root )
	{
		ConstSceneInterfacePtr l = 0;
		try
		{
			l = SharedSceneInterfaces::get( fileName->readable() );
		}
		catch ( IECore::Exception &e )
		{
			IECore::msg( IECore::MessageHandler::Error, "LinkedScene::expandLink", std::string( e.what() ) + " when expanding link from file \"" + m_mainScene->fileName() + "\"" );
			linkDepth = 0;
			return 0;
		}

		linkDepth = root->readable().size();
		l = l->scene(root->readable(), NullIfMissing);
		if ( !l )
		{
			// \todo Consider throwing or printing error message.
			linkDepth = 0;
		}
		return l;
	}
	linkDepth = 0;
	return 0;
}
예제 #2
0
ConstSceneInterfacePtr SceneCacheNode<BaseType>::scene( const std::string &fileName, const std::string &path )
{
	ConstSceneInterfacePtr result = 0;

	try
	{
		result = SharedSceneInterfaces::get( fileName );
		if ( path != SceneInterface::rootName.string() )
		{
			SceneInterface::Path p;
			SceneInterface::stringToPath( path, p );
			result = result->scene( p, SceneInterface::NullIfMissing );
		}
	}
	catch ( std::exception &e )
	{
		std::cerr << "Error loading \"" << fileName << "\" at location \"" << path << "\": " << e.what() << std::endl;
	}
	catch ( ... )
	{
		std::cerr << "Unknown error loading \"" << fileName << "\" at location \"" << path << "\": " << std::endl;
	}

	return result;
}
예제 #3
0
ConstSceneInterfacePtr SceneCacheNode<BaseType>::scene( const std::string &fileName, const std::string &path )
{
	ConstSceneInterfacePtr result = SharedSceneInterfaces::get( fileName );
	if ( path != SceneInterface::rootName.string() )
	{
		SceneInterface::Path p;
		SceneInterface::stringToPath( path, p );
		result = result->scene( p, SceneInterface::NullIfMissing );
	}
	
	return result;
}
예제 #4
0
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;
}
예제 #5
0
IECore::ConstInternedStringVectorDataPtr SceneReader::computeChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	std::string fileName = fileNamePlug()->getValue();
	if( !fileName.size() )
	{
		return parent->childNamesPlug()->defaultValue();
	}
	
	ConstSceneInterfacePtr s = SharedSceneInterfaces::get( fileName );
	s = s->scene( path );

	InternedStringVectorDataPtr result = new InternedStringVectorData;
	s->childNames( result->writable() );
	
	return result;
}
예제 #6
0
Imath::M44f SceneReader::computeTransform( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	std::string fileName = fileNamePlug()->getValue();
	if( !fileName.size() )
	{
		return M44f();
	}
	
	ConstSceneInterfacePtr s = SharedSceneInterfaces::get( fileName );
	s = s->scene( path );
	
	M44d t = s->readTransformAsMatrix( context->getFrame() / g_frameRate );
	
	return M44f(
		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]
	);
}
예제 #7
0
Imath::Box3f SceneReader::computeBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	std::string fileName = fileNamePlug()->getValue();
	if( !fileName.size() )
	{
		return Box3f();
	}
	
	ConstSceneInterfacePtr s = SharedSceneInterfaces::get( fileName );
	s = s->scene( path );
	
	Box3d b = s->readBound( context->getFrame() / g_frameRate );
	
	if( b.isEmpty() )
	{
		return Box3f();
	}
	
	return Box3f( b.min, b.max );
}
예제 #8
0
IECore::ConstObjectPtr SceneReader::computeObject( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	std::string fileName = fileNamePlug()->getValue();
	if( !fileName.size() )
	{
		return parent->objectPlug()->defaultValue();
	}
	
	ConstSceneInterfacePtr s = SharedSceneInterfaces::get( fileName );
	s = s->scene( path );
	
	ObjectPtr o;
	
	if( s->hasObject() )
	{
		ConstObjectPtr o = s->readObject( context->getFrame() / g_frameRate );
		return o ? o : ConstObjectPtr( parent->objectPlug()->defaultValue() );
	}
	
	return parent->objectPlug()->defaultValue();
}