Exemplo n.º 1
0
Arquivo: xformOp.cpp Projeto: JT-a/USD
UsdGeomXformOp::UsdGeomXformOp(
    UsdPrim const& prim, 
    UsdGeomXformOp::Type const opType,
    UsdGeomXformOp::Precision const precision, 
    TfToken const &opSuffix,
    bool isInverseOp)
    : _opType(opType)
    , _isInverseOp(isInverseOp)
{
    // Determine the typeName of the xformOp attribute to be created.
    const SdfValueTypeName &typeName = GetValueTypeName(opType, precision);

    if (!typeName) { 
        TF_CODING_ERROR("Invalid xform-op: incompatible combination of "
            "opType (%s) and precision (%s).", 
            TfEnum::GetName(opType).c_str(),
            TfEnum::GetName(precision).c_str());
        return;
    } 

    TfToken attrName = UsdGeomXformOp::GetOpName(opType, opSuffix, 
        // isInverseOp is handled below
        /*isInverseOp*/ false);

    // attrName can never be empty.
    TF_VERIFY(!attrName.IsEmpty());

    // Create an  attribute in the xformOp: namespace with the
    // computed typeName.
    _attr = prim.CreateAttribute(attrName, typeName, /* custom */ false);

    // If a problem occurred, an error should already have been issued,
    // and _attr will be invalid, which is what we want
}
Exemplo n.º 2
0
UsdAttribute
PxrUsdMayaWriteUtil::GetOrCreateUsdAttr(
    const MPlug& plg,
    const UsdPrim& usdPrim,
    const std::string &attrName,
    bool custom)
{
    MObject attrObj(plg.attribute());

    TfToken usdAttrName(attrName);
    if (usdAttrName.IsEmpty()) {
        printf("Invalid attrName '%s' for %s\n",
               attrName.c_str(),
               plg.name().asChar());
        return UsdAttribute();
    }

    // See if usdAttr already exists.  If so, return.
    UsdAttribute usdAttr = usdPrim.GetAttribute(usdAttrName);
    if (usdAttr) {
        return usdAttr;
    }

    SdfValueTypeName attrType = PxrUsdMayaWriteUtil::GetUsdTypeName(plg);

    // ---------------------
    // CreateAttribute on USD Prim if specified above
    if (attrType) {
        usdAttr = usdPrim.CreateAttribute(usdAttrName, attrType, custom);
    }
    else {
        // Skipping.  Unsupported type.
    }
    return usdAttr;
}
Exemplo n.º 3
0
UsdShadeParameter::UsdShadeParameter(
        UsdPrim prim,
        TfToken const &name,
        SdfValueTypeName const &typeName)
{
    // XXX what do we do if the type name doesn't match and it exists already?

    _attr = prim.GetAttribute(name);
    if (!_attr) {
        _attr = prim.CreateAttribute(name, typeName, /* custom = */ false);
    }
}
Exemplo n.º 4
0
UsdShadeInterfaceAttribute::UsdShadeInterfaceAttribute(
        const UsdPrim& prim,
        TfToken const& interfaceAttrName,
        SdfValueTypeName const& typeName)
    : _name(interfaceAttrName)
{
    TfToken attrName = _GetName(interfaceAttrName);
    _attr = prim.GetAttribute(attrName);
    if (not _attr) {
        _attr = prim.CreateAttribute(attrName, typeName, /* custom = */ false);
    }
}
Exemplo n.º 5
0
Arquivo: output.cpp Projeto: JT-a/USD
UsdShadeOutput::UsdShadeOutput(
    UsdPrim prim,
    TfToken const &name,
    SdfValueTypeName const &typeName)
{
    // XXX what do we do if the type name doesn't match and it exists already?
    TfToken attrName = _GetOutputAttrName(name);
    _prop = prim.GetAttribute(attrName);
    if (!_prop) {
        _prop = prim.CreateAttribute(attrName, typeName, /* custom = */ false);
    }
}
Exemplo n.º 6
0
/* static */
UsdSkelInbetweenShape
UsdSkelInbetweenShape::_Create(const UsdPrim& prim, const TfToken& name)
{
    if(TF_VERIFY(prim)) {
        TfToken attrName = _MakeNamespaced(name);

        if(!attrName.IsEmpty()) {
            return UsdSkelInbetweenShape(
                prim.CreateAttribute(attrName, SdfValueTypeNames->Point3fArray,
                                     /*custom*/ false, SdfVariabilityUniform));
        }
    }
    return UsdSkelInbetweenShape();
}
Exemplo n.º 7
0
Arquivo: primvar.cpp Projeto: JT-a/USD
UsdGeomPrimvar::UsdGeomPrimvar(const UsdPrim& prim, 
                               const TfToken& baseName,
                               const SdfValueTypeName &typeName,
                               bool custom)
{
    TF_VERIFY(prim);

    TfToken attrName = _MakeNamespaced(baseName);

    if (!attrName.IsEmpty()){
        _attr = prim.CreateAttribute(attrName, typeName, custom);
    }
    // If a problem occurred, an error should already have been issued,
    // and _attr will be invalid, which is what we want

    _SetIdTargetRelName();
}
Exemplo n.º 8
0
/* static */
UsdAttribute
PxrUsdMayaWriteUtil::GetOrCreateUsdAttr(
        const MPlug& attrPlug,
        const UsdPrim& usdPrim,
        const std::string& attrName,
        const bool custom,
        const bool translateMayaDoubleToUsdSinglePrecision)
{
    UsdAttribute usdAttr;

    if (!usdPrim) {
        return usdAttr;
    }

    MObject attrObj(attrPlug.attribute());

    TfToken usdAttrNameToken(attrName);
    if (usdAttrNameToken.IsEmpty()) {
        MGlobal::displayError(
            TfStringPrintf("Invalid USD attribute name '%s' for Maya plug '%s'",
                           attrName.c_str(),
                           attrPlug.name().asChar()).c_str());
        return usdAttr;
    }

    // See if the USD attribute already exists. If so, return it.
    usdAttr = usdPrim.GetAttribute(usdAttrNameToken);
    if (usdAttr) {
        return usdAttr;
    }

    const SdfValueTypeName& typeName =
        PxrUsdMayaWriteUtil::GetUsdTypeName(attrPlug,
                                            translateMayaDoubleToUsdSinglePrecision);
    if (typeName) {
        usdAttr = usdPrim.CreateAttribute(usdAttrNameToken, typeName, custom);
    }

    return usdAttr;
}