本文整理汇总了C++中UsdRelationship::GetForwardedTargets方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdRelationship::GetForwardedTargets方法的具体用法?C++ UsdRelationship::GetForwardedTargets怎么用?C++ UsdRelationship::GetForwardedTargets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdRelationship
的用法示例。
在下文中一共展示了UsdRelationship::GetForwardedTargets方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPrim
UsdVolVolume::FieldMap
UsdVolVolume::GetFieldPaths() const
{
std::map<TfToken, SdfPath> fieldMap;
const UsdPrim &prim = GetPrim();
if (prim) {
std::vector<UsdProperty> fieldProps =
prim.GetPropertiesInNamespace(_tokens->fieldPrefix);
for (const UsdProperty &fieldProp : fieldProps) {
UsdRelationship fieldRel = fieldProp.As<UsdRelationship>();
SdfPathVector targets;
// All relationships starting with "field:" should point to
// UsdVolFieldBase primitives.
if (fieldRel && fieldRel.GetForwardedTargets(&targets)) {
if (targets.size() == 1 &&
targets.front().IsPrimPath()) {
fieldMap.emplace(fieldRel.GetBaseName(), targets.front());
}
}
}
}
return fieldMap;
}
示例2:
static SdfPathVector
_GetForwardedTargets(const UsdRelationship &self,
bool forwardToObjectsInMasters)
{
SdfPathVector result;
self.GetForwardedTargets(&result, forwardToObjectsInMasters);
return result;
}
示例3: GetPrim
bool
UsdRiStatementsAPI::GetModelScopedCoordinateSystems(SdfPathVector *targets) const
{
if (GetPrim().IsModel()) {
UsdRelationship rel =
GetPrim().GetRelationship(_tokens->modelScopedCoordsys);
return rel && rel.GetForwardedTargets(targets);
}
return true;
}
示例4: EmptyPath
SdfPath
UsdVolVolume::GetFieldPath(const TfToken &name) const
{
UsdRelationship fieldRel = GetPrim().GetRelationship(_MakeNamespaced(name));
SdfPathVector targets;
if (fieldRel && fieldRel.GetForwardedTargets(&targets)) {
if (targets.size() == 1 &&
targets.front().IsPrimPath()) {
return targets.front();
}
}
return SdfPath::EmptyPath();
}
示例5: UsdPrim
PXR_NAMESPACE_OPEN_SCOPE
// TODO: We should centralize this logic in a UsdImaging ShaderAdapter.
/*static*/
UsdPrim
UsdImaging_MaterialStrategy::GetTargetedShader(UsdPrim const& materialPrim,
UsdRelationship const& materialRel)
{
SdfPathVector targets;
if (!materialRel.GetForwardedTargets(&targets))
return UsdPrim();
if (targets.size() != 1) {
// XXX: This should really be a validation error once USD gets that
// feature.
TF_WARN("We expect only one target on relationship %s of prim <%s>, "
"but got %zu.",
materialRel.GetName().GetText(),
materialPrim.GetPath().GetText(),
targets.size());
return UsdPrim();
}
if (!targets[0].IsPrimPath()) {
// XXX: This should really be a validation error once USD gets that
// feature.
TF_WARN("We expect the target of the relationship %s of prim <%s> "
"to be a prim, instead it is <%s>.",
materialRel.GetName().GetText(),
materialPrim.GetPath().GetText(),
targets[0].GetText());
return UsdPrim();
}
return materialPrim.GetStage()->GetPrimAtPath(targets[0]);
}
示例6: sourcesBldr
//.........这里部分代码省略.........
else
{
_PathToPrimMap::const_iterator pcIt = primCache.find(protoPath);
const UsdPrim &protoPrim = pcIt->second;
if (!protoPrim) {
continue;
}
// Determine where (what path) to start building the prototype prim
// such that its material bindings will be preserved. This could be
// the prototype path itself or an ancestor path.
//
SdfPathVector commonPrefixes;
UsdRelationship materialBindingsRel =
UsdShadeMaterial::GetBindingRel(protoPrim);
auto assetAPI = UsdModelAPI(protoPrim);
std::string assetName;
bool isReferencedModelPrim =
assetAPI.IsModel() and assetAPI.GetAssetName(&assetName);
if (!materialBindingsRel or isReferencedModelPrim)
{
// The prim has no material bindings or is a referenced model
// prim (meaning that materials are defined below it); start
// building at the prototype path.
//
commonPrefixes.push_back(protoPath);
}
else
{
SdfPathVector materialPaths;
materialBindingsRel.GetForwardedTargets(&materialPaths);
for (auto materialPath : materialPaths)
{
const SdfPath &commonPrefix =
protoPath.GetCommonPrefix(materialPath);
if (commonPrefix.GetString() == "/")
{
// XXX Unhandled case.
// The prototype prim and its material are not under the
// same parent; start building at the prototype path
// (although it is likely that bindings will be broken).
//
commonPrefixes.push_back(protoPath);
}
else
{
// Start building at the common ancestor between the
// prototype prim and its material.
//
commonPrefixes.push_back(commonPrefix);
}
}
}
// XXX Unhandled case.
// We'll use the first common ancestor even if there is more than
// one (which shouldn't appen if the prototype prim and its bindings
// are under the same parent).
//
SdfPath::RemoveDescendentPaths(&commonPrefixes);
const std::string buildPath = commonPrefixes[0].GetString();
// See if the path is a child of the point instancer. If so, we'll
示例7: Attribute
static FnKat::Attribute
_GetMaterialAssignAttr(
const UsdPrim& prim,
const PxrUsdKatanaUsdInPrivateData& data)
{
if (not prim or prim.GetPath() == SdfPath::AbsoluteRootPath()) {
// Special-case to pre-empt coding errors.
return FnKat::Attribute();
}
UsdRelationship usdRel = UsdShadeLook::GetBindingRel(prim);
if (usdRel) {
// USD shading binding
SdfPathVector targetPaths;
usdRel.GetForwardedTargets(&targetPaths);
if (targetPaths.size() > 0) {
if (not targetPaths[0].IsPrimPath()) {
FnLogWarn("Target path " << prim.GetPath().GetString() <<
" is not a prim");
return FnKat::Attribute();
}
// This is a copy as it could be modified below.
SdfPath targetPath = targetPaths[0];
UsdPrim targetPrim = data.GetUsdInArgs()->GetStage()->GetPrimAtPath(targetPath);
// If the target is inside a master, then it needs to be re-targeted
// to the instance.
//
// XXX remove this special awareness once GetMasterWithContext is
// is available as the provided prim will automatically
// retarget (or provide enough context to retarget without
// tracking manually).
if (targetPrim and targetPrim.IsInMaster()) {
if (not data.GetInstancePath().IsEmpty() and
not data.GetMasterPath().IsEmpty()) {
// Check if the source and the target of the relationship
// belong to the same master.
// If they do, we have the context necessary to do the
// re-mapping.
if (data.GetMasterPath().GetCommonPrefix(targetPath).
GetPathElementCount() > 0) {
targetPath = data.GetInstancePath().AppendPath(
targetPath.ReplacePrefix(targetPath.GetPrefixes()[0],
SdfPath::ReflexiveRelativePath()));
} else {
// Warn saying the target of relationship isn't within
// the same master as the source.
FnLogWarn("Target path " << prim.GetPath().GetString()
<< " isn't within the master " << data.GetMasterPath());
return FnKat::Attribute();
}
} else {
// XXX
// When loading beneath a master via an isolatePath
// opArg, we can encounter targets which are within masters
// but not within the context of a material.
// While that would be an error according to the below
// warning, it produces the expected results.
// This case can occur when expanding pointinstancers as
// the sources are made via execution of PxrUsdIn again
// at the sub-trees.
// Warn saying target of relationship is in a master,
// but the associated instance path is unknown!
// FnLogWarn("Target path " << prim.GetPath().GetString()
// << " is within a master, but the associated "
// "instancePath is unknown.");
// return FnKat::Attribute();
}
}
// Convert the target path to the equivalent katana location.
// XXX: Looks may have an atypical USD->Katana
// path mapping
std::string location =
PxrUsdKatanaUtils::ConvertUsdLookPathToKatLocation(targetPath, data);
// XXX Looks containing only display terminals are causing issues
// with katana material manipulation workflows.
// For now: exclude any material assign which doesn't include
// /Looks/ in the path
if (location.find(UsdKatanaTokens->katanaLooksScopePathSubstring)
== std::string::npos)
{
return FnKat::Attribute();
}
// location = TfStringReplace(location, "/Looks/", "/Materials/");
// XXX handle multiple assignments
return FnKat::StringAttribute(location);
}
}
return FnKat::Attribute();
}