PXR_NAMESPACE_OPEN_SCOPE


/* static */
MObject
UsdMayaTranslatorMaterial::Read(
        const TfToken& shadingMode,
        const UsdShadeMaterial& shadeMaterial,
        const UsdGeomGprim& boundPrim,
        UsdMayaPrimReaderContext* context)
{
    if (shadingMode == UsdMayaShadingModeTokens->none) {
        return MObject();
    }

    UsdMayaShadingModeImportContext c(shadeMaterial, boundPrim, context);

    MObject shadingEngine;

    if (c.GetCreatedObject(shadeMaterial.GetPrim(), &shadingEngine)) {
        return shadingEngine;
    }

    if (UsdMayaShadingModeImporter importer =
            UsdMayaShadingModeRegistry::GetImporter(shadingMode)) {
        shadingEngine = importer(&c);
    }

    if (!shadingEngine.isNull()) {
        c.AddCreatedObject(shadeMaterial.GetPrim(), shadingEngine);
    }

    return shadingEngine;
}
Пример #2
0
MObject slopeShaderBehavior::findShadingEngine(MObject &node)
//
//	Description:
//		Given the material MObject this method will
//	return the shading group that it is assigned to.
//	if there is no shading group associated with
//	the material than a null MObject is apssed back.
//
{
	MFnDependencyNode nodeFn(node);
	MPlug srcPlug = nodeFn.findPlug("outColor");
	MPlugArray nodeConnections;
	srcPlug.connectedTo(nodeConnections, false, true);
	//loop through the connections
	//and find the shading engine node that
	//it is connected to
	//
	for(unsigned i = 0; i < nodeConnections.length(); i++)
	{
		if(nodeConnections[i].node().hasFn(MFn::kShadingEngine))
			return nodeConnections[i].node();
	}

	//no shading engine associated so return a
	//null MObject
	//
	return MObject();
}
Пример #3
0
MObject
PxrUsdMayaShadingModeExportContext::GetSurfaceShader() const
{
    MStatus status;
    MFnDependencyNode seDepNode(_shadingEngine, &status);
    if (!status) {
        return MObject();
    }

    MPlug ssPlug = seDepNode.findPlug("surfaceShader", true, &status);
    if (!status) {
        return MObject();
    }

    MObject ss(ssPlug.asMObject());
    if (ss.isNull()) {
        return MObject();
    }

    return PxrUsdMayaUtil::GetConnected(ssPlug).node();
}