示例#1
0
文件: prim.cpp 项目: lvxejay/USD
UsdPrim
UsdPrim::GetFilteredNextSibling(const Usd_PrimFlagsPredicate &inPred) const
{
    Usd_PrimDataConstPtr sibling = get_pointer(_Prim());
    SdfPath siblingPath = _ProxyPrimPath();
    const Usd_PrimFlagsPredicate pred = 
        Usd_CreatePredicateForTraversal(sibling, siblingPath, inPred);

    if (Usd_MoveToNextSiblingOrParent(sibling, siblingPath, pred)) {
        return UsdPrim();
    }
    return UsdPrim(sibling, siblingPath);
}
示例#2
0
文件: prim.cpp 项目: lvxejay/USD
UsdPrim
UsdPrim::GetMaster() const
{
    Usd_PrimDataConstPtr masterPrimData = 
        _GetStage()->_GetMasterForInstance(get_pointer(_Prim()));
    return UsdPrim(masterPrimData, SdfPath());
}
static UsdPrim
_GetMaterialParent(const UsdStageRefPtr& stage,
               const PxrUsdMayaShadingModeExportContext::AssignmentVector& assignments)
{
    SdfPath commonAncestor;
    TF_FOR_ALL(iter, assignments) {
        const SdfPath& assn = iter->first;
        if (stage->GetPrimAtPath(assn)) {
            if (commonAncestor.IsEmpty()) {
                commonAncestor = assn;
            }
            else {
                commonAncestor = commonAncestor.GetCommonPrefix(assn);
            }
        }
    }

    if (commonAncestor.IsEmpty()) {
        return UsdPrim();
    }

    if (commonAncestor == SdfPath::AbsoluteRootPath()) {
        return stage->GetPseudoRoot();
    }

    SdfPath shaderExportLocation = commonAncestor;
    while (!shaderExportLocation.IsRootPrimPath()) {
        shaderExportLocation = shaderExportLocation.GetParentPath();
    }
    shaderExportLocation = shaderExportLocation.AppendChild(TfToken("Looks"));

    return UsdGeomScope::Define(stage, shaderExportLocation).GetPrim();
}
示例#4
0
文件: animQuery.cpp 项目: lvxejay/USD
PXR_NAMESPACE_OPEN_SCOPE


UsdPrim
UsdSkelAnimQuery::GetPrim() const
{
    return _impl ? _impl->GetPrim() : UsdPrim();
}
示例#5
0
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
0
文件: USD_Proxy.cpp 项目: JT-a/USD
UsdPrim
GusdUSD_StageProxy::Accessor::GetPrimAtPath(const SdfPath& path,
                                            GusdUT_ErrorContext* err) const
{
    UT_ASSERT_P(_proxy);

    if(UsdPrim prim = GetStage()->GetPrimAtPath(path))
        return prim;
    if(err) {
        UT_WorkBuffer buf;
        buf.sprintf("Invalid prim <%s>", path.GetString().c_str());
        err->AddError(buf.buffer());
    }
    return UsdPrim();
}
示例#7
0
//virtual 
UsdPrim MayaMeshWriter::write(const UsdTimeCode &usdTime)
{

    if ( !isMeshValid() ) {
        return UsdPrim();
    }

    // Get schema
    UsdGeomMesh primSchema = UsdGeomMesh::Define(getUsdStage(), getUsdPath());
    TF_AXIOM(primSchema);
    UsdPrim meshPrim = primSchema.GetPrim();
    TF_AXIOM(meshPrim);

    // Write the attrs
    writeMeshAttrs(usdTime, primSchema);
    return meshPrim;
}
 /// Construct a Usd_TestDerived on UsdPrim \p prim .
 /// Equivalent to Usd_TestDerived::Get(prim.GetStage(), prim.GetPath())
 /// for a \em valid \p prim, but will not immediately throw an error for
 /// an invalid \p prim
 explicit Usd_TestDerived(const UsdPrim& prim=UsdPrim())
     : Usd_TestBase(prim)
 {
     foo = TEST_DERIVED_INIT;
     printf("called Usd_Derived(const UsdPrim& prim=UsdPrim())\n");
 }
 /// Construct a Usd_TestBase on UsdPrim \p prim .
 /// Equivalent to Usd_TestBase::Get(prim.GetStage(), prim.GetPath())
 /// for a \em valid \p prim, but will not immediately throw an error for
 /// an invalid \p prim
 explicit Usd_TestBase(const UsdPrim& prim=UsdPrim())
     : UsdSchemaBase(prim)
     , foo(TEST_BASE_INIT)
 {
     printf("called Usd_TestBase(const UsdPrim& prim=UsdPrim())\n");
 }