本文整理汇总了C++中UsdRelationship::AddTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdRelationship::AddTarget方法的具体用法?C++ UsdRelationship::AddTarget怎么用?C++ UsdRelationship::AddTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdRelationship
的用法示例。
在下文中一共展示了UsdRelationship::AddTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPrim
void
UsdRiStatementsAPI::SetCoordinateSystem(const std::string &coordSysName)
{
UsdAttribute attr = GetPrim().CreateAttribute(_tokens->coordsys,
SdfValueTypeNames->String,
/* custom = */ false);
if (TF_VERIFY(attr)) {
attr.Set(coordSysName);
UsdPrim currPrim = GetPrim();
while (currPrim && currPrim.GetPath() != SdfPath::AbsoluteRootPath()) {
if (currPrim.IsModel() && !currPrim.IsGroup() &&
currPrim.GetPath() != SdfPath::AbsoluteRootPath()) {
UsdRelationship rel =
currPrim.CreateRelationship(_tokens->modelCoordsys,
/* custom = */ false);
if (TF_VERIFY(rel)) {
// Order should not matter, since these are a set,
// but historically we have appended these.
rel.AddTarget(GetPrim().GetPath());
}
break;
}
currPrim = currPrim.GetParent();
}
}
}
示例2: dagNode
bool
PxrUsdTranslators_InstancerWriter::writeInstancerAttrs(
const UsdTimeCode& usdTime,
const UsdGeomPointInstancer& instancer)
{
MStatus status = MS::kSuccess;
MFnDagNode dagNode(GetDagPath(), &status);
CHECK_MSTATUS_AND_RETURN(status, false);
// Note: In this function, we don't read instances using the provided
// MFnInstancer API. One reason is that it breaks up prototypes into their
// constituent shapes, and there's no way to figure out which hierarchy
// they came from. Another reason is that it only provides computed matrices
// and not separate position, rotation, scale attrs.
const SdfPath prototypesGroupPath =
instancer.GetPrim().GetPath().AppendChild(_tokens->Prototypes);
// At the default time, setup all the prototype instances.
if (usdTime.IsDefault()) {
const MPlug inputHierarchy = dagNode.findPlug("inputHierarchy", true,
&status);
CHECK_MSTATUS_AND_RETURN(status, false);
// Note that the "Prototypes" prim needs to be a model group to ensure
// contiguous model hierarchy.
const UsdPrim prototypesGroupPrim = GetUsdStage()->DefinePrim(
prototypesGroupPath);
UsdModelAPI(prototypesGroupPrim).SetKind(KindTokens->group);
_modelPaths.push_back(prototypesGroupPath);
UsdRelationship prototypesRel = instancer.CreatePrototypesRel();
const unsigned int numElements = inputHierarchy.numElements();
for (unsigned int i = 0; i < numElements; ++i) {
const MPlug plug = inputHierarchy[i];
const MPlug source(UsdMayaUtil::GetConnected(plug));
if (source.isNull()) {
TF_WARN("Cannot read prototype: the source plug %s was null",
plug.name().asChar());
return false;
}
MFnDagNode sourceNode(source.node(), &status);
CHECK_MSTATUS_AND_RETURN(status, false);
MDagPath prototypeDagPath;
sourceNode.getPath(prototypeDagPath);
// Prototype names are guaranteed unique by virtue of having a
// unique numerical suffix _# indicating the prototype index.
const TfToken prototypeName(
TfStringPrintf("%s_%d", sourceNode.name().asChar(), i));
const SdfPath prototypeUsdPath = prototypesGroupPrim.GetPath()
.AppendChild(prototypeName);
UsdPrim prototypePrim = GetUsdStage()->DefinePrim(
prototypeUsdPath);
_modelPaths.push_back(prototypeUsdPath);
// Try to be conservative and only create an intermediary xformOp
// with the instancerTranslate if we can ensure that we don't need
// to compensate for the translation on the prototype root.
//
// XXX: instancerTranslate does not behave well when added to a
// reference that has an existing transform on the far side of the
// reference. However, its behavior at least matches the
// behavior in UsdMayaTranslatorModelAssembly. If we fix the
// behavior there, we need to make sure that this is also
// fixed to match.
bool instancerTranslateAnimated = false;
if (_NeedsExtraInstancerTranslate(
prototypeDagPath, &instancerTranslateAnimated)) {
UsdGeomXformable xformable(prototypePrim);
UsdGeomXformOp newOp = xformable.AddTranslateOp(
UsdGeomXformOp::PrecisionDouble,
_tokens->instancerTranslate);
_instancerTranslateOps.push_back(
{prototypeDagPath, newOp, instancerTranslateAnimated});
}
// Two notes:
// (1) We don't un-instance here, because it's OK for the prototype
// to just be a reference to an instance master if the prototype
// participates in Maya native instancing.
// (2) The prototype root must be visible to match Maya's behavior,
// which always vis'es the prototype root, even if it is marked
// hidden.
_writeJobCtx.CreatePrimWriterHierarchy(
prototypeDagPath,
prototypeUsdPath,
/*forceUninstance*/ false,
/*exportRootVisibility*/ false,
&_prototypeWriters);
prototypesRel.AddTarget(prototypeUsdPath);
}
_numPrototypes = numElements;
}
// If there aren't any prototypes, fail and don't export on subsequent
//.........这里部分代码省略.........