コード例 #1
0
    def test_XInclude(self):
        """
        Verify documents referenced via XInclude statements are read
        properly.
        """
        stage = UsdMtlx._TestFile('include/Include.mtlx')
        stage.GetRootLayer().Export('Include.usda')

        stage = UsdMtlx._TestFile('include/Include.usdz[Include.mtlx]')
        stage.GetRootLayer().Export('Include_From_Usdz.usda')
コード例 #2
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_DuplicateName(self):
     """
     Verify that a MaterialX file with duplicate element names fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('''<?xml version="1.0" ?>
                <materialx version="1.35">
                    <typedef name="type1">
                    <typedef name="type1">
                </materialx>
             ''')
コード例 #3
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_Cycle(self):
     """
     Verify that a MaterialX file with an inherits cycle fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('''<?xml version="1.0" ?>
                <materialx version="1.35">
                    <nodedef name="n1" type="float" node="test" inherit="n2">
                    <nodedef name="n2" type="float" node="test" inherit="n1">
                </materialx>
             ''')
コード例 #4
0
 def test_DuplicateName(self):
     """
     Verify that a MaterialX file with duplicate element names fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString(
             '''<?xml version="1.0" ?>
                <materialx version="1.35">
                    <typedef name="type1">
                    <typedef name="type1">
                </materialx>
             ''')
コード例 #5
0
 def test_Cycle(self):
     """
     Verify that a MaterialX file with an inherits cycle fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString(
             '''<?xml version="1.0" ?>
                <materialx version="1.35">
                    <nodedef name="n1" type="float" node="test" inherit="n2">
                    <nodedef name="n2" type="float" node="test" inherit="n1">
                </materialx>
             ''')
コード例 #6
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
    def test_MultiBindInputs(self):
        """
        Test MaterialX conversion with mutliple bind inputs.
        """

        stage = UsdMtlx._TestFile('MultiBindInputs.mtlx')

        # Get the node graph and make sure there are exactly 3 inputs
        nodeGraph = UsdShade.NodeGraph.Get(
            stage, Sdf.Path('/MaterialX/Materials/layered/ND_layerShader'))
        inputs = nodeGraph.GetInputs()
        self.assertEqual(len(inputs), 3)

        # Make sure each input is connected as expected
        inputToSource = {
            'weight_1':
            '/MaterialX/Materials/layered/NodeGraphs/layered_layer1_gradient',
            'weight_2':
            '/MaterialX/Materials/layered/NodeGraphs/layered_layer2_gradient',
            'weight_3':
            '/MaterialX/Materials/layered/NodeGraphs/layered_layer3_gradient'
        }
        for inputName, source in inputToSource.iteritems():
            input = nodeGraph.GetInput(inputName)
            self.assertEqual(input.HasConnectedSource(), True)
            self.assertEqual(input.GetConnectedSource()[0].GetPath(), source)
コード例 #7
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: abucior/USD
    def test_Looks(self):
        """
        Test general MaterialX look conversions.
        """

        stage = UsdMtlx._TestFile('Looks.mtlx')
        stage.GetRootLayer().Export('Looks.usda')
コード例 #8
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: abucior/USD
    def test_NodeGraphs(self):
        """
        Test general MaterialX node graph conversions.
        """

        stage = UsdMtlx._TestFile('NodeGraphs.mtlx', nodeGraphs=True)
        stage.GetRootLayer().Export('NodeGraphs.usda')
コード例 #9
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
    def test_NodeGraphs(self):
        """
        Test general MaterialX node graph conversions.
        """

        stage = UsdMtlx._TestFile('NodeGraphs.mtlx', nodeGraphs=True)
        with open('NodeGraphs.usda', 'w') as f:
            print >> f, stage.GetRootLayer().ExportToString()
コード例 #10
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
    def test_Looks(self):
        """
        Test general MaterialX look conversions.
        """

        stage = UsdMtlx._TestFile('Looks.mtlx')
        with open('Looks.usda', 'w') as f:
            print >> f, stage.GetRootLayer().ExportToString()
コード例 #11
0
    def test_Looks(self):
        """
        Test general MaterialX look conversions.
        """

        stage = UsdMtlx._TestFile('Looks.mtlx')
        with open('Looks.usda', 'w') as f:
            print >>f, stage.GetRootLayer().ExportToString()
コード例 #12
0
    def test_NodeGraphs(self):
        """
        Test general MaterialX node graph conversions.
        """

        stage = UsdMtlx._TestFile('NodeGraphs.mtlx', nodeGraphs=True)
        with open('NodeGraphs.usda', 'w') as f:
            print >>f, stage.GetRootLayer().ExportToString()
コード例 #13
0
    def test_EmbedInUSDZ(self):
        """
        Verify that a MaterialX file can be read from within a .usdz file.
        """

        stage = UsdMtlx._TestFile(
            'usd_preview_surface_gold.usdz[usd_preview_surface_gold.mtlx]')
        stage.GetRootLayer().Export('usd_preview_surface_gold.usda')
コード例 #14
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_EmptyMaterialXDocument(self):
     """
     Verify that a file with an empty a materialx element is okay.
     """
     stage = UsdMtlx._TestString('''<?xml version="1.0" ?>
            <materialx version="1.35">
            </materialx>
         ''')
     self.assertEqual(stage.GetRootLayer().ExportToString(), _EmptyLayer())
コード例 #15
0
 def test_EmptyMaterialXDocument(self):
     """
     Verify that a file with an empty a materialx element is okay.
     """
     stage = UsdMtlx._TestString(
         '''<?xml version="1.0" ?>
            <materialx version="1.35">
            </materialx>
         ''')
     self.assertEqual(stage.GetRootLayer().ExportToString(),
                      _EmptyLayer())
コード例 #16
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: abucior/USD
    def test_StdlibShaderRefs(self):
        """
        Test that we can use a shader nodedef from the MaterialX stdlib.
        """

        stage = UsdMtlx._TestFile('usd_preview_surface_gold.mtlx')
        # check stage contents
        mprim = stage.GetPrimAtPath("/MaterialX/Materials/USD_Gold")
        self.assertTrue(mprim)
        material = UsdShade.Material(mprim)
        self.assertTrue(material)
        input = material.GetInput("specularColor")
        self.assertTrue(input)
        self.assertEqual(input.GetFullName(),"inputs:specularColor")
コード例 #17
0
    def test_MultiOutputNodes(self):
        """
        Test MaterialX nodes with multiple outputs
        """

        stage = UsdMtlx._TestFile('MultiOutputNode.mtlx')
        testInfo = [('/MaterialX/Materials/test_m/test_ng/specular',
                     'artistic_ior', 'extinction'),
                    ('/MaterialX/Materials/test_m/test_ng/ior', 'artistic_ior',
                     'ior')]

        for path, connNodeName, connectionName in testInfo:
            node = UsdShade.Shader.Get(stage, path)
            conn = node.GetInput('in').GetConnectedSource()
            self.assertEqual(conn[0].GetPrim().GetPath().name, connNodeName)
            self.assertEqual(conn[1], connectionName)
コード例 #18
0
 def test_EmptyFile(self):
     """
     Verify that an empty MaterialX document fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('')
コード例 #19
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_BadMagic(self):
     """
     Verify that a MaterialX file with a bad XML header fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('''<?not_xml version="1.0" ?>''')
コード例 #20
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_EmptyXMLDocument(self):
     """
     Verify that a MaterialX file with only an XML header fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('''<?xml version="1.0" ?>''')
コード例 #21
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_MissingFile(self):
     """
     Verify that a missing MaterialX file fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestFile('non-existent-file.xml')
コード例 #22
0
ファイル: testUsdMtlxFileFormat.py プロジェクト: zxwzxw/USD
 def test_EmptyFile(self):
     """
     Verify that an empty MaterialX document fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('')
コード例 #23
0
 def test_MissingFile(self):
     """
     Verify that a missing MaterialX file fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestFile('non-existent-file.xml')
コード例 #24
0
 def test_BadMagic(self):
     """
     Verify that a MaterialX file with a bad XML header fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('''<?not_xml version="1.0" ?>''')
コード例 #25
0
 def test_EmptyXMLDocument(self):
     """
     Verify that a MaterialX file with only an XML header fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestString('''<?xml version="1.0" ?>''')