本文整理汇总了Python中GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal方法的典型用法代码示例。如果您正苦于以下问题:Python GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal方法的具体用法?Python GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal怎么用?Python GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GafferSceneTest
的用法示例。
在下文中一共展示了GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testLoadReferenceAndGIL
# 需要导入模块: import GafferSceneTest [as 别名]
# 或者: from GafferSceneTest import connectTraverseSceneToPlugDirtiedSignal [as 别名]
def testLoadReferenceAndGIL( self ) :
script = Gaffer.ScriptNode()
script["plane"] = GafferScene.Plane()
script["plane"]["divisions"].setValue( imath.V2i( 20 ) )
script["sphere"] = GafferScene.Sphere()
script["expression"] = Gaffer.Expression()
script["expression"].setExpression( "parent['sphere']['radius'] = 0.1 + context.getFrame() + float( context['instancer:id'] )" )
script["instancer"] = GafferScene.Instancer()
script["instancer"]["in"].setInput( script["plane"]["out"] )
script["instancer"]["instance"].setInput( script["sphere"]["out"] )
script["instancer"]["parent"].setValue( "/plane" )
script["box"] = Gaffer.Box()
script["box"]["in"] = GafferScene.ScenePlug( flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic )
script["box"]["out"] = GafferScene.ScenePlug( direction = Gaffer.Plug.Direction.Out, flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic )
script["box"]["out"].setInput( script["box"]["in"] )
script["box"].exportForReference( self.temporaryDirectory() + "/test.grf" )
script["reference"] = Gaffer.Reference()
script["reference"].load( self.temporaryDirectory() + "/test.grf" )
script["reference"]["in"].setInput( script["instancer"]["out"] )
script["attributes"] = GafferScene.CustomAttributes()
script["attributes"]["in"].setInput( script["reference"]["out"] )
traverseConnection = Gaffer.ScopedConnection( GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal( script["attributes"]["out"] ) )
with Gaffer.Context() as c :
script["reference"].load( self.temporaryDirectory() + "/test.grf" )
示例2: testDynamicPlugsAndGIL
# 需要导入模块: import GafferSceneTest [as 别名]
# 或者: from GafferSceneTest import connectTraverseSceneToPlugDirtiedSignal [as 别名]
def testDynamicPlugsAndGIL( self ) :
script = Gaffer.ScriptNode()
script["plane"] = GafferScene.Plane()
script["plane"]["divisions"].setValue( imath.V2i( 20 ) )
script["sphere"] = GafferScene.Sphere()
script["expression"] = Gaffer.Expression()
script["expression"].setExpression( "parent['sphere']['radius'] = context.getFrame() + float( context['instancer:id'] )" )
script["instancer"] = GafferScene.Instancer()
script["instancer"]["in"].setInput( script["plane"]["out"] )
script["instancer"]["instance"].setInput( script["sphere"]["out"] )
script["instancer"]["parent"].setValue( "/plane" )
script["attributes"] = GafferScene.CustomAttributes()
script["attributes"]["in"].setInput( script["instancer"]["out"] )
script["outputs"] = GafferScene.Outputs()
script["outputs"]["in"].setInput( script["attributes"]["out"] )
# Simulate an InteractiveRender or Viewer traversal of the scene
# every time it is dirtied. If the GIL isn't released when dirtiness
# is signalled, we'll end up with a deadlock as the traversal enters
# python on another thread to evaluate the expression. We increment the frame
# between each test to ensure the expression result is not cached and
# we do truly enter python.
traverseConnection = Gaffer.ScopedConnection( GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal( script["outputs"]["out"] ) )
with Gaffer.Context() as c :
c.setFrame( 1 )
script["attributes"]["attributes"].addMember( "test1", IECore.IntData( 10 ) )
c.setFrame( 2 )
script["attributes"]["attributes"].addOptionalMember( "test2", IECore.IntData( 20 ) )
c.setFrame( 3 )
script["attributes"]["attributes"].addMembers(
IECore.CompoundData( {
"test3" : 30,
"test4" : 40,
} )
)
c.setFrame( 4 )
p = script["attributes"]["attributes"][0]
del script["attributes"]["attributes"][p.getName()]
c.setFrame( 5 )
script["attributes"]["attributes"].addChild( p )
c.setFrame( 6 )
script["attributes"]["attributes"].removeChild( p )
c.setFrame( 7 )
script["attributes"]["attributes"].setChild( p.getName(), p )
c.setFrame( 8 )
script["attributes"]["attributes"].removeChild( p )
c.setFrame( 9 )
script["attributes"]["attributes"][p.getName()] = p
c.setFrame( 10 )
script["outputs"].addOutput( "test", IECoreScene.Output( "beauty.exr", "exr", "rgba" ) )