本文整理汇总了C++中UsdPrim::GetReferences方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdPrim::GetReferences方法的具体用法?C++ UsdPrim::GetReferences怎么用?C++ UsdPrim::GetReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdPrim
的用法示例。
在下文中一共展示了UsdPrim::GetReferences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeVariants
TfToken usdWriteJob::writeVariants(const UsdPrim &usdRootPrim)
{
// Init parameters for filtering and setting the active variant
std::string defaultModelingVariant;
// Get the usdVariantRootPrimPath (optionally filter by renderLayer prefix)
MayaPrimWriterPtr firstPrimWriterPtr = *mMayaPrimWriterList.begin();
std::string firstPrimWriterPathStr( firstPrimWriterPtr->getDagPath().fullPathName().asChar() );
std::replace( firstPrimWriterPathStr.begin(), firstPrimWriterPathStr.end(), '|', '/');
std::replace( firstPrimWriterPathStr.begin(), firstPrimWriterPathStr.end(), ':', '_'); // replace namespace ":" with "_"
SdfPath usdVariantRootPrimPath(firstPrimWriterPathStr);
usdVariantRootPrimPath = usdVariantRootPrimPath.GetPrefixes()[0];
// Create a new usdVariantRootPrim and reference the Base Model UsdRootPrim
// This is done for reasons as described above under mArgs.usdModelRootOverridePath
UsdPrim usdVariantRootPrim = mStage->DefinePrim(usdVariantRootPrimPath);
TfToken defaultPrim = usdVariantRootPrim.GetName();
usdVariantRootPrim.GetReferences().AppendInternalReference(usdRootPrim.GetPath());
usdVariantRootPrim.SetActive(true);
usdRootPrim.SetActive(false);
// Loop over all the renderLayers
for (unsigned int ir=0; ir < mRenderLayerObjs.length(); ++ir) {
SdfPathTable<bool> tableOfActivePaths;
MFnRenderLayer renderLayerFn( mRenderLayerObjs[ir] );
MString renderLayerName = renderLayerFn.name();
std::string variantName(renderLayerName.asChar());
// Determine default variant. Currently unsupported
//MPlug renderLayerDisplayOrderPlug = renderLayerFn.findPlug("displayOrder", true);
//int renderLayerDisplayOrder = renderLayerDisplayOrderPlug.asShort();
// The Maya default RenderLayer is also the default modeling variant
if (mRenderLayerObjs[ir] == MFnRenderLayer::defaultRenderLayer()) {
defaultModelingVariant=variantName;
}
// Make the renderlayer being looped the current one
MGlobal::executeCommand(MString("editRenderLayerGlobals -currentRenderLayer ")+
renderLayerName, false, false);
// == ModelingVariants ==
// Identify prims to activate
// Put prims and parent prims in a SdfPathTable
// Then use that membership to determine if a prim should be Active.
// It has to be done this way since SetActive(false) disables access to all child prims.
MObjectArray renderLayerMemberObjs;
renderLayerFn.listMembers(renderLayerMemberObjs);
std::vector< SdfPath > activePaths;
for (unsigned int im=0; im < renderLayerMemberObjs.length(); ++im) {
MFnDagNode dagFn(renderLayerMemberObjs[im]);
MDagPath dagPath;
dagFn.getPath(dagPath);
dagPath.extendToShape();
SdfPath usdPrimPath;
if (!TfMapLookup(mDagPathToUsdPathMap, dagPath, &usdPrimPath)) {
continue;
}
usdPrimPath = usdPrimPath.ReplacePrefix(usdPrimPath.GetPrefixes()[0], usdVariantRootPrimPath); // Convert base to variant usdPrimPath
tableOfActivePaths[usdPrimPath] = true;
activePaths.push_back(usdPrimPath);
//UsdPrim usdPrim = mStage->GetPrimAtPath(usdPrimPath);
//usdPrim.SetActive(true);
}
if (!tableOfActivePaths.empty()) {
{ // == BEG: Scope for Variant EditContext
// Create the variantSet and variant
UsdVariantSet modelingVariantSet = usdVariantRootPrim.GetVariantSets().AppendVariantSet("modelingVariant");
modelingVariantSet.AppendVariant(variantName);
modelingVariantSet.SetVariantSelection(variantName);
// Set the Edit Context
UsdEditTarget editTarget = modelingVariantSet.GetVariantEditTarget();
UsdEditContext editContext(mStage, editTarget);
// == Activate/Deactivate UsdPrims
UsdPrimRange it = UsdPrimRange::AllPrims(mStage->GetPseudoRoot());
std::vector<UsdPrim> primsToDeactivate;
for ( ; it; ++it) {
UsdPrim usdPrim = *it;
// For all xformable usdPrims...
if (usdPrim && usdPrim.IsA<UsdGeomXformable>()) {
bool isActive=false;
for (size_t j=0;j<activePaths.size();j++) {
//primPathD.HasPrefix(primPathA);
SdfPath activePath=activePaths[j];
if (usdPrim.GetPath().HasPrefix(activePath) || activePath.HasPrefix(usdPrim.GetPath())) {
isActive=true; break;
}
}
if (isActive==false) {
primsToDeactivate.push_back(usdPrim);
it.PruneChildren();
}
}
}
// Now deactivate the prims (done outside of the UsdPrimRange
// so not to modify the iterator while in the loop)
for ( UsdPrim const& prim : primsToDeactivate ) {
prim.SetActive(false);
}
} // == END: Scope for Variant EditContext
//.........这里部分代码省略.........