本文整理汇总了C++中UsdPrim::CreateAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdPrim::CreateAttribute方法的具体用法?C++ UsdPrim::CreateAttribute怎么用?C++ UsdPrim::CreateAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdPrim
的用法示例。
在下文中一共展示了UsdPrim::CreateAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetValueTypeName
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
}
示例2: attrObj
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;
}
示例3:
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);
}
}
示例4:
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);
}
}
示例5:
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);
}
}
示例6: UsdSkelInbetweenShape
/* 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();
}
示例7:
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();
}
示例8: attrObj
/* 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;
}