Beispiel #1
0
    def testMaterialExport(self):
        archive = Abc.OArchive("MaterialAssignment.abc")
        root = archive.getTop()
        materials = Abc.OObject(root, "materials")
        geometry = Abc.OObject(root, "geometry")

        # parent material
        materialA = AbcMaterial.OMaterial(materials, "materialA")
        materialA.getSchema().setShader("prman", "surface", "paintedplastic")
        setFloatParameter(materialA.getSchema(),
            "prman", "surface", "Kd", 0.5)
        setFloatParameter(materialA.getSchema(),
            "prman", "surface", "roughness", 0.1)

        # child material
        materialB = AbcMaterial.OMaterial(materialA, "materialB")
        materialB.getSchema().setShader("prman", "displacement", "knobby")
        setFloatParameter(materialB.getSchema(),
            "prman", "surface", "roughness", 0.2)

        geoA = Abc.OObject(geometry, "geoA")
        AbcMaterial.addMaterialAssignment(geoA, "/materials/materialA")

        geoB = Abc.OObject(geometry, "geoB");
        AbcMaterial.addMaterialAssignment(geoB, "/materials/materialA/materialB")

        geoC = Abc.OObject(geometry, "geoC");
        AbcMaterial.addMaterialAssignment(geoC, "/materials/materialA/materialB")
        geoCMat = AbcMaterial.addMaterial(geoC);
        setFloatParameter(geoCMat, "prman", "surface", "roughness", 0.3)
def materialOut():
    archive = Abc.OArchive("MaterialAssignment.abc")
    root = archive.getTop()
    materials = Abc.OObject(root, "materials")
    geometry = Abc.OObject(root, "geometry")

    # parent material
    materialA = AbcMaterial.OMaterial(materials, "materialA")
    materialA.getSchema().setShader("prman", "surface", "paintedplastic")
    setFloatParameter(materialA.getSchema(), 
            "prman", "surface", "Kd", 0.5)
    setFloatParameter(materialA.getSchema(), 
            "prman", "surface", "roughness", 0.1)

    # child material
    materialB = AbcMaterial.OMaterial(materialA, "materialB")
    materialB.getSchema().setShader("prman", "displacement", "knobby")
    setFloatParameter(materialB.getSchema(), 
            "prman", "surface", "roughness", 0.2)

    geoA = Abc.OObject(geometry, "geoA")
    AbcMaterial.addMaterialAssignment(geoA, "/materials/materialA")

    geoB = Abc.OObject(geometry, "geoB");
    AbcMaterial.addMaterialAssignment(geoB, "/materials/materialA/materialB")

    geoC = Abc.OObject(geometry, "geoC");
    AbcMaterial.addMaterialAssignment(geoC, "/materials/materialA/materialB")
    geoCMat = AbcMaterial.addMaterial(geoC);
    setFloatParameter(geoCMat, "prman", "surface", "roughness", 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)
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)
Beispiel #5
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)