本文整理汇总了C++中UsdPrim::GetStage方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdPrim::GetStage方法的具体用法?C++ UsdPrim::GetStage怎么用?C++ UsdPrim::GetStage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdPrim
的用法示例。
在下文中一共展示了UsdPrim::GetStage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stageId
bool
GusdBoundsCache::_ComputeBound(
const UsdPrim &prim,
UsdTimeCode time,
const TfTokenVector &includedPurposes,
ComputeFunc boundFunc,
UT_BoundingBox &bounds )
{
if( !prim.IsValid() )
return false;
TfToken stageId( prim.GetStage()->GetRootLayer()->GetRealPath() );
MapType::accessor accessor;
if( !m_map.find( accessor, Key( stageId, includedPurposes ))) {
m_map.insert( accessor, Key( stageId, includedPurposes ) );
accessor->second = new Item( time, includedPurposes );
}
std::lock_guard<std::mutex> lock(accessor->second->lock);
UsdGeomBBoxCache& cache = accessor->second->bboxCache;
cache.SetTime( time );
// boundFunc is either ComputeWorldBound or ComputeLocalBound
GfBBox3d primBBox = (cache.*boundFunc)(prim);
if( !primBBox.GetRange().IsEmpty() )
{
const GfRange3d rng = primBBox.ComputeAlignedRange();
bounds =
UT_BoundingBox(
rng.GetMin()[0],
rng.GetMin()[1],
rng.GetMin()[2],
rng.GetMax()[0],
rng.GetMax()[1],
rng.GetMax()[2]);
return true;
}
return false;
}
示例2: 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]);
}
示例3:
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));
}
}
}
}
}
示例4: if
static
bool
_SetOrMergeOverOp(std::vector<int64_t> const &items, SdfListOpType op,
UsdPrim const &prim)
{
SdfInt64ListOp proposed, current;
UsdStagePtr stage = prim.GetStage();
UsdEditTarget editTarget = stage->GetEditTarget();
SdfPrimSpecHandle primSpec =
editTarget.GetPrimSpecForScenePath(prim.GetPath());
if (primSpec){
VtValue existingOp = primSpec->GetInfo(UsdGeomTokens->inactiveIds);
if (existingOp.IsHolding<SdfInt64ListOp>()){
current = existingOp.UncheckedGet<SdfInt64ListOp>();
}
}
proposed.SetItems(items, op);
if (current.IsExplicit()){
std::vector<int64_t> explicitItems = current.GetExplicitItems();
proposed.ApplyOperations(&explicitItems);
current.SetExplicitItems(explicitItems);
}
else {
// We can't use ApplyOperations on an extant, non-explicit listOp
// because the result is always flat and explicit.
current.ComposeOperations(proposed, op);
// ComposeOperations() is too narrow in functionality - it does not
// consider that if we "remove over" an existing set of added items,
// we need to additionally ensure the removed items get removed
// from the added in current, since when applying ops, we first
// remove, then add. Bug #139215 filed to track; when it gets fixed
// we can remove this code!
if (op == SdfListOpTypeDeleted){
std::vector<int64_t> addedItems = current.GetAddedItems();
if (!addedItems.empty()){
std::set<int64_t> toRemove(items.begin(), items.end());
std::vector<int64_t> newAdded;
newAdded.reserve(addedItems.size());
for (auto elt : addedItems){
if (!toRemove.count(elt))
newAdded.push_back(elt);
}
if (newAdded.size() != addedItems.size())
current.SetAddedItems(newAdded);
}
}
else if (op == SdfListOpTypeAdded){
std::vector<int64_t> deletedItems = current.GetDeletedItems();
if (!deletedItems.empty()){
std::set<int64_t> toAdd(items.begin(), items.end());
std::vector<int64_t> newDeleted;
newDeleted.reserve(deletedItems.size());
for (auto elt : deletedItems){
if (!toAdd.count(elt))
newDeleted.push_back(elt);
}
if (newDeleted.size() != deletedItems.size())
current.SetDeletedItems(newDeleted);
}
}
}
return prim.SetMetadata(UsdGeomTokens->inactiveIds, current);
}
示例5: cook
static void cook(FnKat::GeolibCookInterface &interface)
{
boost::shared_lock<boost::upgrade_mutex>
readerLock(UsdKatanaGetStageLock());
UsdPrim prim;
PxrUsdKatanaUsdInArgsRefPtr usdInArgs;
PxrUsdKatanaUsdInPrivateData* privateData =
static_cast<PxrUsdKatanaUsdInPrivateData*>(interface.getPrivateData());
FnKat::GroupAttribute opArgs = interface.getOpArg();
if (privateData) {
usdInArgs = privateData->GetUsdInArgs();
} else {
FnKat::GroupAttribute additionalOpArgs;
usdInArgs = InitUsdInArgs(interface, additionalOpArgs);
opArgs = FnKat::GroupBuilder()
.update(opArgs)
.deepUpdate(additionalOpArgs)
.build();
}
if (not usdInArgs) {
ERROR("Could not initialize PxrUsdIn usdInArgs.");
return;
}
if (interface.atRoot()) {
interface.stopChildTraversal();
prim = usdInArgs->GetRootPrim();
// XXX This info currently gets used to determine whether
// to correctively rotate cameras. The camera's zUp needs to be
// recorded until we have no more USD z-Up assets and the katana
// assets have no more prerotate camera nodes.
interface.setAttr("info.usd.stageIsZup",
FnKat::IntAttribute(UsdUtilsGetCamerasAreZup(usdInArgs->GetStage())));
// Construct the global camera list at the USD scene root.
//
FnKat::StringBuilder cameraListBuilder;
SdfPathVector cameraPaths = PxrUsdKatanaUtils::FindCameraPaths(prim.GetStage());
TF_FOR_ALL(cameraPathIt, cameraPaths)
{
const std::string path = (*cameraPathIt).GetString();
// only add cameras to the camera list that are beneath the isolate prim path
if (path.find(usdInArgs->GetIsolatePath()) != std::string::npos)
{
cameraListBuilder.push_back(
TfNormPath(usdInArgs->GetRootLocationPath()+"/"+
path.substr(usdInArgs->GetIsolatePath().size())));
}
}
FnKat::StringAttribute cameraListAttr = cameraListBuilder.build();
if (cameraListAttr.getNumberOfValues() > 0)
{
interface.setAttr("cameraList", cameraListAttr);
}
interface.setAttr("info.usdOpArgs", opArgs);
FnKat::GroupAttribute masterMapping =
opArgs.getChildByName("masterMapping");
if (masterMapping.isValid() && masterMapping.getNumberOfChildren())
{
FnGeolibServices::StaticSceneCreateOpArgsBuilder sscb(false);
for (size_t i = 0, e = masterMapping.getNumberOfChildren();
i != e; ++i)
{
std::string masterName = FnKat::DelimiterDecode(
masterMapping.getChildName(i));
std::string katanaPath = FnKat::StringAttribute(
masterMapping.getChildByIndex(i)
).getValue("", false);
if (katanaPath.empty())
{
continue;
}
sscb.createEmptyLocation(katanaPath, "instance source");
sscb.setAttrAtLocation(katanaPath,
"tabs.scenegraph.stopExpand", FnKat::IntAttribute(1));
sscb.setAttrAtLocation(katanaPath, "childPrimPath",
FnKat::StringAttribute(masterName));
}
interface.createChild(
"Masters",
//.........这里部分代码省略.........