def materialIn():
    archive = Abc.IArchive("MaterialAssignment.abc")
    root = archive.getTop()
    assert root.getNumChildren() == 2

    materials = Abc.IObject(root, "materials")
    geometry = Abc.IObject(root, "geometry")

    materialA = AbcMaterial.IMaterial(materials, "materialA")
    ms = materialA.getSchema()
    assert ms.getShader("prman", "surface") == "paintedplastic"
    cp = ms.getShaderParameters("prman", "surface")
    kd = cp.getProperty('Kd')
    rg = cp.getProperty('roughness')
    assert kd.getNumSamples() == rg.getNumSamples() == 1
    assert almostEqual(kd.samples[0], 0.5)
    assert almostEqual(rg.samples[0], 0.1)

    materialB = AbcMaterial.IMaterial(materialA, "materialB")
    ms = materialB.getSchema()
    assert ms.getShader("prman", "displacement") == "knobby"
    cp = ms.getShaderParameters("prman", "surface")
    rg = cp.getProperty('roughness')
    assert rg.getNumSamples() == 1
    assert almostEqual(rg.samples[0], 0.2)

    geoA = Abc.IObject(geometry, "geoA")
    geoB = Abc.IObject(geometry, "geoB")
    geoC = Abc.IObject(geometry, "geoC")

    assert AbcMaterial.getMaterialAssignmentPath(
        geoA) == '/materials/materialA'
    assert AbcMaterial.getMaterialAssignmentPath(
        geoB) == '/materials/materialA/materialB'
    assert AbcMaterial.getMaterialAssignmentPath(
        geoC) == '/materials/materialA/materialB'

    matC = AbcMaterial.hasMaterial(geoC)
    cp = matC.getShaderParameters("prman", "surface")
    rg = cp.getProperty("roughness")
    assert rg.getNumSamples() == 1
    assert almostEqual(rg.samples[0], 0.3)
def materialIn():
    archive = Abc.IArchive("MaterialAssignment.abc")
    root = archive.getTop()
    assert root.getNumChildren() == 2

    materials = Abc.IObject(root, "materials")
    geometry = Abc.IObject(root, "geometry")

    materialA = AbcMaterial.IMaterial(materials, "materialA")
    ms = materialA.getSchema()
    assert ms.getShader("prman", "surface") == "paintedplastic"
    cp = ms.getShaderParameters("prman", "surface")
    kd = cp.getProperty('Kd')
    rg = cp.getProperty('roughness')
    assert kd.getNumSamples() == rg.getNumSamples() == 1
    assert almostEqual(kd.samples[0], 0.5)
    assert almostEqual(rg.samples[0], 0.1)

    materialB = AbcMaterial.IMaterial(materialA, "materialB")
    ms = materialB.getSchema()
    assert ms.getShader("prman", "displacement") == "knobby"
    cp = ms.getShaderParameters("prman", "surface")
    rg = cp.getProperty('roughness')
    assert rg.getNumSamples() == 1
    assert almostEqual(rg.samples[0], 0.2)

    geoA = Abc.IObject(geometry, "geoA")
    geoB = Abc.IObject(geometry, "geoB")
    geoC = Abc.IObject(geometry, "geoC")

    assert AbcMaterial.getMaterialAssignmentPath(geoA) == '/materials/materialA'
    assert AbcMaterial.getMaterialAssignmentPath(geoB) == '/materials/materialA/materialB'
    assert AbcMaterial.getMaterialAssignmentPath(geoC) == '/materials/materialA/materialB'

    matC = AbcMaterial.hasMaterial(geoC)
    cp = matC.getShaderParameters("prman", "surface")
    rg = cp.getProperty("roughness")
    assert rg.getNumSamples() == 1
    assert almostEqual(rg.samples[0], 0.3)
Ejemplo n.º 3
0
    def testMaterialImport(self):
        archive = Abc.IArchive("MaterialAssignment.abc")
        root = archive.getTop()
        self.assertEqual(root.getNumChildren(), 2)

        materials = Abc.IObject(root, "materials")
        geometry = Abc.IObject(root, "geometry")

        materialA = AbcMaterial.IMaterial(materials, "materialA")
        ms = materialA.getSchema()
        self.assertEqual(ms.getShader("prman", "surface"), "paintedplastic")
        cp = ms.getShaderParameters("prman", "surface")
        kd = cp.getProperty('Kd')
        rg = cp.getProperty('roughness')
        self.assertTrue(kd.getNumSamples() == rg.getNumSamples() == 1)
        self.assertAlmostEqual(kd.samples[0], 0.5)
        self.assertAlmostEqual(rg.samples[0], 0.1)

        materialB = AbcMaterial.IMaterial(materialA, "materialB")
        ms = materialB.getSchema()
        self.assertEqual(ms.getShader("prman", "displacement"), "knobby")
        cp = ms.getShaderParameters("prman", "surface")
        rg = cp.getProperty('roughness')
        self.assertEqual(rg.getNumSamples(), 1)
        self.assertAlmostEqual(rg.samples[0], 0.2)

        geoA = Abc.IObject(geometry, "geoA")
        geoB = Abc.IObject(geometry, "geoB")
        geoC = Abc.IObject(geometry, "geoC")

        self.assertEqual(AbcMaterial.getMaterialAssignmentPath(geoA), '/materials/materialA')
        self.assertEqual(AbcMaterial.getMaterialAssignmentPath(geoB), '/materials/materialA/materialB')
        self.assertEqual(AbcMaterial.getMaterialAssignmentPath(geoC), '/materials/materialA/materialB')

        matC = AbcMaterial.hasMaterial(geoC)
        cp = matC.getShaderParameters("prman", "surface")
        rg = cp.getProperty("roughness")
        self.assertEqual(rg.getNumSamples(), 1)
        self.assertAlmostEqual(rg.samples[0], 0.3)