本文整理汇总了Python中GafferScene类的典型用法代码示例。如果您正苦于以下问题:Python GafferScene类的具体用法?Python GafferScene怎么用?Python GafferScene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GafferScene类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAdaptors
def testAdaptors( self ) :
sphere = GafferScene.Sphere()
def a() :
result = GafferArnold.ArnoldAttributes()
result["attributes"]["matte"]["enabled"].setValue( True )
result["attributes"]["matte"]["value"].setValue( True )
return result
GafferScene.registerAdaptor( "Test", a )
sphere = GafferScene.Sphere()
render = GafferArnold.ArnoldRender()
render["in"].setInput( sphere["out"] )
render["mode"].setValue( render.Mode.SceneDescriptionMode )
render["fileName"].setValue( self.temporaryDirectory() + "/test.ass" )
render["task"].execute()
with IECoreArnold.UniverseBlock( writable = True ) :
arnold.AiASSLoad( self.temporaryDirectory() + "/test.ass" )
node = arnold.AiNodeLookUpByName( "/sphere" )
self.assertEqual( arnold.AiNodeGetBool( node, "matte" ), True )
示例2: test
def test( self ) :
sphere = GafferScene.Sphere()
plane = GafferScene.Plane()
group = GafferScene.Group()
group["in"][0].setInput( sphere["out"] )
group["in"][1].setInput( plane["out"] )
plane2 = GafferScene.Plane()
plane2["divisions"].setValue( IECore.V2i( 99, 99 ) ) # 10000 instances
instancer = GafferScene.Instancer()
instancer["in"].setInput( plane2["out"] )
instancer["parent"].setValue( "/plane" )
instancer["instance"].setInput( group["out"] )
filter = GafferScene.PathFilter()
filter["paths"].setValue( IECore.StringVectorData( [ "/plane/instances/*1/group/plane" ] ) )
matchingPaths = GafferScene.PathMatcher()
GafferScene.matchingPaths( filter, instancer["out"], matchingPaths )
self.assertEqual( len( matchingPaths.paths() ), 1000 )
self.assertEqual( matchingPaths.match( "/plane/instances/1/group/plane" ), GafferScene.Filter.Result.ExactMatch )
self.assertEqual( matchingPaths.match( "/plane/instances/1121/group/plane" ), GafferScene.Filter.Result.ExactMatch )
self.assertEqual( matchingPaths.match( "/plane/instances/1121/group/sphere" ), GafferScene.Filter.Result.NoMatch )
示例3: testDefaultCamera
def testDefaultCamera( self ) :
o = GafferScene.StandardOptions()
c1 = GafferScene.camera( o["out"] )
self.assertTrue( isinstance( c1, IECore.Camera ) )
o["options"]["renderCamera"]["enabled"].setValue( True )
c2 = GafferScene.camera( o["out"] )
self.assertEqual( c1, c2 )
示例4: testSetExists
def testSetExists( self ) :
plane = GafferScene.Plane()
plane["sets"].setValue( "A B" )
self.assertTrue( GafferScene.setExists( plane["out"], "A" ) )
self.assertTrue( GafferScene.setExists( plane["out"], "B" ) )
self.assertFalse( GafferScene.setExists( plane["out"], " " ) )
self.assertFalse( GafferScene.setExists( plane["out"], "" ) )
self.assertFalse( GafferScene.setExists( plane["out"], "C" ) )
示例5: testMatchingPathsWithPathMatcher
def testMatchingPathsWithPathMatcher( self ) :
s = GafferScene.Sphere()
g = GafferScene.Group()
g["in"][0].setInput( s["out"] )
g["in"][1].setInput( s["out"] )
g["in"][2].setInput( s["out"] )
f = GafferScene.PathMatcher( [ "/group/s*" ] )
m = GafferScene.PathMatcher()
GafferScene.matchingPaths( f, g["out"], m )
self.assertEqual( set( m.paths() ), { "/group/sphere", "/group/sphere1", "/group/sphere2" } )
示例6: testSetsNeedContextEntry
def testSetsNeedContextEntry( self ) :
script = Gaffer.ScriptNode()
script["light"] = GafferSceneTest.TestLight()
script["light"]["sets"].setValue( "A B C" )
script["expression"] = Gaffer.Expression()
script["expression"].setExpression(
"""parent["light"]["name"] = context["lightName"]"""
)
for i in range( 0, 100 ) :
with Gaffer.Context() as context :
context["lightName"] = "light%d" % i
GafferScene.sets( script["light"]["out"] )
示例7: testSets
def testSets( self ) :
light = GafferSceneTest.TestLight()
light["sets"].setValue( "A B C" )
sets = GafferScene.sets( light["out"] )
self.assertEqual( set( sets.keys() ), { "__lights", "A", "B", "C" } )
for n in sets.keys() :
self.assertEqual( sets[n], light["out"].set( n ) )
self.assertFalse( sets[n].isSame( light["out"].set( n, _copy = False ) ) )
sets = GafferScene.sets( light["out"], _copy = False )
self.assertEqual( set( sets.keys() ), { "__lights", "A", "B", "C" } )
for n in sets.keys() :
self.assertTrue( sets[n].isSame( light["out"].set( n, _copy = False ) ) )
示例8: testAdaptors
def testAdaptors( self ) :
s = Gaffer.ScriptNode()
s["s"] = GafferScene.Sphere()
def a() :
result = GafferScene.SceneProcessor()
result["__shader"], colorPlug = self._createConstantShader()
colorPlug.setValue( imath.Color3f( 1, 0, 0 ) )
result["__assignment"] = GafferScene.ShaderAssignment()
result["__assignment"]["in"].setInput( result["in"] )
result["__assignment"]["shader"].setInput( result["__shader"]["out"] )
result["out"].setInput( result["__assignment"]["out"] )
return result
GafferScene.registerAdaptor( "Test", a )
s["o"] = GafferScene.Outputs()
s["o"].addOutput(
"beauty",
IECoreScene.Display(
"test",
"ieDisplay",
"rgba",
{
"driverType" : "ImageDisplayDriver",
"handle" : "myLovelySphere",
}
)
)
s["o"]["in"].setInput( s["s"]["out"] )
s["r"] = self._createInteractiveRender()
s["r"]["in"].setInput( s["o"]["out"] )
s["r"]["state"].setValue( s["r"].State.Running )
time.sleep( 0.5 )
# Render red sphere
image = IECoreImage.ImageDisplayDriver.storedImage( "myLovelySphere" )
self.__assertColorsAlmostEqual( self.__color4fAtUV( image, imath.V2f( 0.5 ) ), imath.Color4f( 1, 0, 0, 1 ), delta = 0.01 )
示例9: __update
def __update( self ) :
self.__pendingUpdate = False
assert( len( self.__scenePlugs ) <= 2 )
if self.__targetPaths is not None :
paths = self.__targetPaths
else :
paths = self.getContext().get( "ui:scene:selectedPaths", [] )
paths = paths[:2] if len( self.__scenePlugs ) < 2 else paths[:1]
if not paths :
paths = [ "/" ]
targets = []
for scene in self.__scenePlugs :
for path in paths :
if not GafferScene.exists( scene, path ) :
# selection may not be valid for both scenes,
# and we can't inspect invalid paths.
path = None
targets.append( self.Target( scene, path ) )
if next( (target.path for target in targets if target.path is not None), None ) is None :
# all target paths have become invalid - if we're
# in a popup window then close it.
window = self.ancestor( _SectionWindow )
if window is not None :
window.parent().removeChild( window )
with self.getContext() :
for section in self.__sections :
section.update( targets )
return False # remove idle callback
示例10: test
def test( self ) :
sphere = GafferScene.Sphere()
adaptors = GafferScene.createAdaptors()
adaptors["in"].setInput( sphere["out"] )
self.assertScenesEqual( sphere["out"], adaptors["out"] )
self.assertSceneHashesEqual( sphere["out"], adaptors["out"] )
def a() :
r = GafferScene.StandardAttributes()
r["attributes"]["doubleSided"]["enabled"].setValue( True )
r["attributes"]["doubleSided"]["value"].setValue( False )
return r
GafferScene.registerAdaptor( "Test", a )
adaptors = GafferScene.createAdaptors()
adaptors["in"].setInput( sphere["out"] )
self.assertFalse( "doubleSided" in sphere["out"].attributes( "/sphere" ) )
self.assertTrue( "doubleSided" in adaptors["out"].attributes( "/sphere" ) )
self.assertEqual( adaptors["out"].attributes( "/sphere" )["doubleSided"].value, False )
GafferScene.deregisterAdaptor( "Test" )
adaptors = GafferScene.createAdaptors()
adaptors["in"].setInput( sphere["out"] )
self.assertScenesEqual( sphere["out"], adaptors["out"] )
self.assertSceneHashesEqual( sphere["out"], adaptors["out"] )
示例11: testSetFilter
def testSetFilter(self):
sphere = GafferScene.Sphere()
sphere["sets"].setValue("A")
filter = GafferScene.SetFilter()
filter["set"].setValue("A")
isolate = GafferScene.Isolate()
isolate["in"].setInput(sphere["out"])
isolate["filter"].setInput(filter["out"])
self.assertSceneValid(isolate["out"])
self.assertTrue(GafferScene.exists(isolate["out"], "/sphere"))
示例12: __selectAffected
def __selectAffected(node, context):
if isinstance(node, GafferScene.FilteredSceneProcessor):
filter = node["filter"]
scenes = [node["in"]]
else:
filter = node
scenes = []
def walkOutputs(plug):
for output in plug.outputs():
node = output.node()
if isinstance(node, GafferScene.FilteredSceneProcessor) and output.isSame(node["filter"]):
scenes.append(node["in"])
walkOutputs(output)
walkOutputs(filter["out"])
pathMatcher = GafferScene.PathMatcher()
with context:
for scene in scenes:
GafferScene.matchingPaths(filter, scene, pathMatcher)
context["ui:scene:selectedPaths"] = IECore.StringVectorData(pathMatcher.paths())
示例13: testExists
def testExists( self ) :
sphere = GafferScene.Sphere()
plane = GafferScene.Plane()
group = GafferScene.Group()
group["in"][0].setInput( sphere["out"] )
group["in"][1].setInput( plane["out"] )
self.assertTrue( GafferScene.exists( group["out"], "/" ) )
self.assertTrue( GafferScene.exists( group["out"], "/group" ) )
self.assertTrue( GafferScene.exists( group["out"], "/group/sphere" ) )
self.assertTrue( GafferScene.exists( group["out"], "/group/plane" ) )
self.assertFalse( GafferScene.exists( group["out"], "/a" ) )
self.assertFalse( GafferScene.exists( group["out"], "/group2" ) )
self.assertFalse( GafferScene.exists( group["out"], "/group/sphere2" ) )
self.assertFalse( GafferScene.exists( group["out"], "/group/plane/child" ) )
示例14: __sourceTarget
def __sourceTarget( self, target ) :
if isinstance( target.scene.node(), Gaffer.DependencyNode ) :
sourceScene = target.scene.node().correspondingInput( target.scene )
if sourceScene is None :
return None
sourceScene = sourceScene.source()
if sourceScene.node() == target.scene.node() :
return None
if not GafferScene.exists( sourceScene, target.path ) :
return None
return SceneInspector.Target( sourceScene, target.path )
return None
示例15: testVisible
def testVisible( self ) :
sphere = GafferScene.Sphere()
group = GafferScene.Group()
group["in"][0].setInput( sphere["out"] )
group2 = GafferScene.Group()
group2["in"][0].setInput( group["out"] )
visibleFilter = GafferScene.PathFilter()
attributes1 = GafferScene.StandardAttributes()
attributes1["attributes"]["visibility"]["enabled"].setValue( True )
attributes1["attributes"]["visibility"]["value"].setValue( True )
attributes1["in"].setInput( group2["out"] )
attributes1["filter"].setInput( visibleFilter["out"] )
invisibleFilter = GafferScene.PathFilter()
attributes2 = GafferScene.StandardAttributes()
attributes2["attributes"]["visibility"]["enabled"].setValue( True )
attributes2["attributes"]["visibility"]["value"].setValue( False )
attributes2["in"].setInput( attributes1["out"] )
attributes2["filter"].setInput( invisibleFilter["out"] )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group/group/sphere" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/" ) )
visibleFilter["paths"].setValue( IECore.StringVectorData( [ "/group" ] ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group/group/sphere" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/" ) )
invisibleFilter["paths"].setValue( IECore.StringVectorData( [ "/group/group" ] ) )
self.assertFalse( GafferScene.visible( attributes2["out"], "/group/group/sphere" ) )
self.assertFalse( GafferScene.visible( attributes2["out"], "/group/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/" ) )
visibleFilter["paths"].setValue( IECore.StringVectorData( [ "/group/group/sphere" ] ) )
self.assertFalse( GafferScene.visible( attributes2["out"], "/group/group/sphere" ) )
self.assertFalse( GafferScene.visible( attributes2["out"], "/group/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/group" ) )
self.assertTrue( GafferScene.visible( attributes2["out"], "/" ) )