Esempio n. 1
0
	def testSerialisation( self ) :

		s = Gaffer.ScriptNode()
		s["t"] = GafferScene.LightTweaks()
		s["t"]["tweaks"].addChild( GafferScene.LightTweaks.TweakPlug( "test", 1.0 ) )
		s["t"]["tweaks"].addChild( GafferScene.LightTweaks.TweakPlug( "test", IECore.Color3f( 1, 2, 3 ) ) )

		ss = Gaffer.ScriptNode()
		ss.execute( s.serialise() )

		for i in range( 0, len( s["t"]["tweaks"] ) ) :
			for n in s["t"]["tweaks"][i].keys() :
				self.assertEqual( ss["t"]["tweaks"][i][n].getValue(), s["t"]["tweaks"][i][n].getValue() )
Esempio n. 2
0
	def test( self ) :

		l = GafferSceneTest.TestLight()
		l["parameters"]["intensity"].setValue( IECore.Color3f( 1 ) )

		t = GafferScene.LightTweaks()
		t["in"].setInput( l["out"] )

		self.assertSceneValid( t["out"] )
		self.assertScenesEqual( t["out"], l["out"] )
		self.assertSceneHashesEqual( t["out"], l["out"] )
		self.assertEqual( l["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 1 ) )

		f = GafferScene.PathFilter()
		f["paths"].setValue( IECore.StringVectorData( [ "/light" ] ) )

		t["filter"].setInput( f["out"] )

		self.assertSceneValid( t["out"] )
		self.assertScenesEqual( t["out"], l["out"] )
		self.assertSceneHashesEqual( t["out"], l["out"] )

		intensityTweak = t.TweakPlug( "intensity", IECore.Color3f( 1, 0, 0 ) )
		t["tweaks"].addChild( intensityTweak )

		self.assertSceneValid( t["out"] )

		self.assertEqual( t["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 1, 0, 0 ) )

		intensityTweak["value"].setValue( IECore.Color3f( 100 ) )
		self.assertEqual( t["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 100 ) )

		intensityTweak["enabled"].setValue( False )
		self.assertEqual( t["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 1 ) )

		intensityTweak["enabled"].setValue( True )
		intensityTweak["mode"].setValue( intensityTweak.Mode.Add )
		self.assertEqual( t["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 101 ) )

		intensityTweak["mode"].setValue( intensityTweak.Mode.Subtract )
		intensityTweak["value"].setValue( IECore.Color3f( 0.1, 0.2, 0.3 ) )
		self.assertEqual( t["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 0.9, 0.8, 0.7 ) )

		intensityTweak["mode"].setValue( intensityTweak.Mode.Multiply )
		l["parameters"]["intensity"].setValue( IECore.Color3f( 2 ) )
		self.assertEqual( t["out"].attributes( "/light" )["light"][0].parameters["intensity"].value, IECore.Color3f( 0.2, 0.4, 0.6 ) )

		t["type"].setValue( "" )
		self.assertScenesEqual( t["out"], l["out"] )