Example #1
0
File: path.cpp Project: lvxejay/USD
static SdfPath
_AppendNode(const SdfPath &path, const Sdf_PathNodeConstRefPtr &node) {

    switch (node->GetNodeType()) {
        case Sdf_PathNode::PrimNode:
            return path.AppendChild(node->GetName());
        case Sdf_PathNode::PrimPropertyNode:
            return path.AppendProperty(node->GetName());
        case Sdf_PathNode::PrimVariantSelectionNode:
        {
            const Sdf_PathNode::VariantSelectionType& selection =
                node->GetVariantSelection();
            return path.AppendVariantSelection(selection.first.GetString(),
                                               selection.second.GetString());
        }
        case Sdf_PathNode::TargetNode:
            return path.AppendTarget( node->GetTargetPath());
        case Sdf_PathNode::RelationalAttributeNode:
            return path.AppendRelationalAttribute(node->GetName());
        case Sdf_PathNode::MapperNode:
            return path.AppendMapper(node->GetTargetPath());
        case Sdf_PathNode::MapperArgNode:
            return path.AppendMapperArg(node->GetName());
        case Sdf_PathNode::ExpressionNode:
            return path.AppendExpression();
        default:
            // CODE_COVERAGE_OFF
            // Should never get here.  All reasonable cases are
            // handled above.
            TF_CODING_ERROR("Unexpected node type %i", node->GetNodeType());
            return SdfPath::EmptyPath();
            // CODE_COVERAGE_ON
    }
}
Example #2
0
bool
UsdRiMaterialAPI::SetSurfaceSource(const SdfPath &surfacePath) const
{
    if (UsdShadeUtils::WriteNewEncoding()) {
        UsdShadeOutput surfaceOutput(CreateSurfaceAttr());
        return UsdShadeConnectableAPI::ConnectToSource(
            surfaceOutput, surfacePath.IsPropertyPath() ? surfacePath :
                surfacePath.AppendProperty(_tokens->defaultOutputName));
    } else if (UsdRelationship surfaceRel = GetPrim().CreateRelationship(
                    _tokens->riLookSurface, /*custom*/ false)) {
        return surfaceRel.SetTargets(std::vector<SdfPath>{surfacePath});
    }
    return false;
}
Example #3
0
bool
UsdRiMaterialAPI::SetBxdfSource(const SdfPath &bxdfPath) const
{
    if (UsdShadeUtils::WriteNewEncoding()) {
        UsdShadeOutput bxdfOutput(CreateBxdfAttr());
        return UsdShadeConnectableAPI::ConnectToSource(
            bxdfOutput, bxdfPath.IsPropertyPath() ? 
                bxdfPath :
                bxdfPath.AppendProperty(_tokens->defaultOutputName));
    } else if (UsdRelationship bxdfRel = GetPrim().CreateRelationship(
                    _tokens->riLookBxdf, /*custom*/ false)) {
        return bxdfRel.SetTargets(std::vector<SdfPath>{bxdfPath});
    }
    return false;
}
Example #4
0
bool
UsdRiMaterialAPI::SetVolumeSource(const SdfPath &volumePath) const
{
    if (UsdShadeUtils::WriteNewEncoding()) {
        UsdShadeOutput volumeOutput(CreateVolumeAttr());
        return UsdShadeConnectableAPI::ConnectToSource(
            volumeOutput, volumePath.IsPropertyPath() ? 
                volumePath :
                volumePath.AppendProperty(_tokens->defaultOutputName));
    } else if (UsdRelationship volumeRel = GetPrim().CreateRelationship(
                    _tokens->riLookVolume, /*custom*/ false)) {
        return volumeRel.SetTargets(std::vector<SdfPath>{volumePath});
    }
    return false;
}
Example #5
0
bool
UsdRiMaterialAPI::SetDisplacementSource(const SdfPath &displacementPath) const
{
    if (UsdShadeUtils::WriteNewEncoding()) {
        UsdShadeOutput displacementOutput(CreateDisplacementAttr());
        return UsdShadeConnectableAPI::ConnectToSource(
            displacementOutput, displacementPath.IsPropertyPath() ? 
                displacementPath :
                displacementPath.AppendProperty(_tokens->defaultOutputName));
    } else if (UsdRelationship displacementRel = GetPrim().CreateRelationship(
                    _tokens->riLookDisplacement, /*custom*/ false)) {
        return displacementRel.SetTargets(
            std::vector<SdfPath>{displacementPath});
    }
    return false;
}