当前位置: 首页>>代码示例>>C++>>正文


C++ UsdPrim::GetRelationship方法代码示例

本文整理汇总了C++中UsdPrim::GetRelationship方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdPrim::GetRelationship方法的具体用法?C++ UsdPrim::GetRelationship怎么用?C++ UsdPrim::GetRelationship使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UsdPrim的用法示例。


在下文中一共展示了UsdPrim::GetRelationship方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: riStatements

static bool
_GatherRibAttributes(
        const UsdPrim &prim, 
        double currentTime,
        FnKat::GroupBuilder& attrsBuilder)
{
    bool hasAttrs = false;

    // USD SHADING STYLE ATTRIBUTES
    UsdRiStatements riStatements(prim);
    if (riStatements) {
        const std::vector<UsdProperty> props = 
            riStatements.GetRiAttributes();
        std::string attrName;
        TF_FOR_ALL(propItr, props) {
            UsdProperty prop = *propItr;
            if (!prop) continue;

            std::string nameSpace = 
                riStatements.GetRiAttributeNameSpace(prop).GetString();
            nameSpace = TfStringReplace(nameSpace, ":", ".") + ".";

            attrName = nameSpace +
                riStatements.GetRiAttributeName(prop).GetString();

            VtValue vtValue;
            UsdAttribute usdAttr = prim.GetAttribute(prop.GetName());
            if (usdAttr) {
                if (not usdAttr.Get(&vtValue, currentTime)) 
                    continue;

                // XXX asShaderParam really means:
                // "For arrays, as a single attr vs a type/value pair group"
                // The type/value pair group is meaningful for attrs who don't
                // have a formal type definition -- like a "user" RiAttribute.
                // 
                // However, other array values (such as two-element shadingrate)
                // are not expecting the type/value pair form and will not
                // generate rib correctly. As such, we'll handle the "user"
                // attribute as a special case.
                bool asShaderParam = true;
                
                if (nameSpace == "user.")
                {
                    asShaderParam = false;
                }

                attrsBuilder.set(attrName, PxrUsdKatanaUtils::ConvertVtValueToKatAttr(vtValue,
                    asShaderParam) );
            }
            else {
                UsdRelationship usdRel = prim.GetRelationship(prop.GetName());
                attrsBuilder.set(attrName, PxrUsdKatanaUtils::ConvertRelTargetsToKatAttr(usdRel,
                    /* asShaderParam */ false) );
            }
            hasAttrs = true;
        }
    }
开发者ID:400dama,项目名称:USD,代码行数:58,代码来源:readPrim.cpp

示例2:

std::vector<UsdShadeParameter>
UsdShadeInterfaceAttribute::GetRecipientParameters(
        const TfToken& renderTarget) const
{
    UsdPrim prim = _attr.GetPrim();
    std::vector<UsdShadeParameter> ret;
    if (UsdRelationship rel = prim.GetRelationship(
                _GetInterfaceAttributeRelName(renderTarget, *this))) {
        std::vector<SdfPath> targets;
        rel.GetTargets(&targets);
        TF_FOR_ALL(targetIter, targets) {
            const SdfPath& target = *targetIter;
            if (target.IsPropertyPath()) {
                if (UsdPrim targetPrim = prim.GetStage()->GetPrimAtPath(
                            target.GetPrimPath())) {
                    if (UsdAttribute attr = targetPrim.GetAttribute(
                                target.GetNameToken())) {
                        ret.push_back(UsdShadeParameter(attr));
                    }
                }
            }
        }
    }
开发者ID:400dama,项目名称:USD,代码行数:23,代码来源:interfaceAttribute.cpp


注:本文中的UsdPrim::GetRelationship方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。