示例#1
0
	def __init__( self, path ) :
			
		column = GafferUI.SplitContainer( GafferUI.SplitContainer.Orientation.Vertical )
		
		GafferUI.PathPreviewWidget.__init__( self, column, path )

		self.__script = Gaffer.ScriptNode( "scenePreview" )
		
		# for reading IECore.SceneInterface files (scc, lscc)
		self.__script["SceneReader"] = GafferScene.SceneReader()
		
		# for reading Alembic files (abc)
		self.__script["AlembicSource"] = GafferScene.AlembicSource()
		
		# for reading more generic single object files (cob, ptc, pdc, etc)
		## \todo: can we unify all file input to SceneReader by creating a SceneInterface that makes
		# single object scenes using Reader ops behind the scenes?
		self.__script["ObjectPreview"] = _ObjectPreview()
		
		# display points and curves GL style rather than disks and ribbons
		self.__script["OpenGLAttributes"] = GafferScene.OpenGLAttributes( "OpenGLAttributes" )
		self.__script["OpenGLAttributes"]["attributes"]["pointsPrimitiveUseGLPoints"]["value"].setValue( 'forAll' )
		self.__script["OpenGLAttributes"]["attributes"]["pointsPrimitiveUseGLPoints"]["enabled"].setValue( True )
		self.__script["OpenGLAttributes"]["attributes"]["curvesPrimitiveUseGLLines"]["enabled"].setValue( True )
		
		self.__script["camera"] = _Camera()
		self.__script["camera"]["in"].setInput( self.__script["OpenGLAttributes"]["out"] )
		
		self.__viewer = GafferUI.Viewer( self.__script )
		column.append( self.__viewer )
		column.append( GafferUI.Timeline( self.__script ) )
		
		self.__script.selection().add( self.__script["camera"] )

		self._updateFromPath()
示例#2
0
	def testSerialisation( self ) :

		s = Gaffer.ScriptNode()
		s["a"] = GafferScene.OpenGLAttributes()
		s["a"]["attributes"]["primitiveSolid"]["value"].setValue( False )
		names = s["a"]["attributes"].keys()

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

		self.assertEqual( s2["a"]["attributes"].keys(), names )
		self.assertTrue( "attributes1" not in s2["a"] )
		self.assertEqual( s2["a"]["attributes"]["primitiveSolid"]["value"].getValue(), False )
示例#3
0
	def test( self ) :

		p = GafferScene.Plane()

		a = GafferScene.OpenGLAttributes()
		a["in"].setInput( p["out"] )

		aa = a["out"].attributes( "/plane" )
		self.assertEqual( len( aa ), 0 )

		a["attributes"]["primitiveSolid"]["enabled"].setValue( True )
		a["attributes"]["primitiveSolid"]["value"].setValue( False )

		aa = a["out"].attributes( "/plane" )
		self.assertEqual( aa, IECore.CompoundObject( { "gl:primitive:solid" : IECore.BoolData( False ) } ) )