本文整理汇总了C++中TfToken函数的典型用法代码示例。如果您正苦于以下问题:C++ TfToken函数的具体用法?C++ TfToken怎么用?C++ TfToken使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TfToken函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OptionVecVal
NdrOptionVec
OptionVecVal(const std::string& optionStr)
{
std::vector<std::string> tokens = TfStringSplit(optionStr, "|");
// The input string should be formatted as one of the following:
//
// list: "option1|option2|option3|..."
// mapper: "key1:value1|key2:value2|..."
//
// If it's a mapper, return the result as a list of key-value tuples to
// preserve order.
NdrOptionVec options;
for (const std::string& token : tokens) {
size_t colonPos = token.find(':');
if (colonPos != std::string::npos) {
options.emplace_back(std::make_pair(
TfToken(token.substr(0, colonPos)),
TfToken(token.substr(colonPos + 1)))
);
} else {
options.emplace_back(std::make_pair(
TfToken(token),
TfToken())
);
}
}
return options;
}
示例2: seDepNode
UsdPrim
PxrUsdMayaShadingModeExportContext::MakeStandardMaterialPrim(
const AssignmentVector& assignmentsToBind,
const std::string& name) const
{
UsdPrim ret;
std::string materialName = name;
if (materialName.empty()) {
MStatus status;
MFnDependencyNode seDepNode(_shadingEngine, &status);
if (!status) {
return ret;
}
MString seName = seDepNode.name();
materialName = MNamespace::stripNamespaceFromName(seName).asChar();
}
materialName = PxrUsdMayaUtil::SanitizeName(materialName);
UsdStageRefPtr stage = GetUsdStage();
if (UsdPrim materialParent = _GetMaterialParent(stage, assignmentsToBind)) {
SdfPath materialPath = materialParent.GetPath().AppendChild(
TfToken(materialName));
UsdShadeMaterial material = UsdShadeMaterial::Define(
GetUsdStage(), materialPath);
UsdPrim materialPrim = material.GetPrim();
// could use this to determine where we want to export.
TF_FOR_ALL(iter, assignmentsToBind) {
const SdfPath &boundPrimPath = iter->first;
const VtIntArray &faceIndices = iter->second;
UsdPrim boundPrim = stage->OverridePrim(boundPrimPath);
if (faceIndices.empty()) {
material.Bind(boundPrim);
} else if (TfGetEnvSetting(PIXMAYA_EXPORT_OLD_STYLE_FACESETS)) {
UsdGeomFaceSetAPI faceSet = material.CreateMaterialFaceSet(
boundPrim);
faceSet.AppendFaceGroup(faceIndices, materialPath);
} else {
// It might be worth adding a utility method for the following
// block of code in core.
UsdGeomSubset faceSubset =
UsdShadeMaterial::CreateMaterialBindFaceSubset(
UsdGeomImageable(boundPrim),
/* subsetName */ TfToken(materialName),
faceIndices);
material.Bind(faceSubset.GetPrim());
UsdShadeMaterial::SetMaterialBindFaceSubsetsFamilyType(
UsdGeomImageable(boundPrim),
UsdGeomSubset::FamilyType::Partition);
}
}
return materialPrim;
}
示例3: glslfx
Hd_PointsShaderKey::Hd_PointsShaderKey()
: glslfx(_tokens->baseGLSLFX)
{
VS[0] = _tokens->instancing;
VS[1] = _tokens->mainVS;
VS[2] = TfToken();
FS[0] = _tokens->mainFS;
FS[1] = TfToken();
}
示例4: _PropName
TfToken
UsdProperty::GetNamespace() const
{
std::string const &fullName = _PropName().GetString();
size_t delim = fullName.rfind(GetNamespaceDelimiter());
if (!TF_VERIFY(delim != fullName.size()-1))
return TfToken();
return ((delim == std::string::npos) ?
TfToken() :
TfToken(fullName.substr(0, delim)));
}
示例5: _GetMetadataUnchecked
static bool
_GetMetadataUnchecked(
const MFnDependencyNode& node,
const TfToken& key,
VtValue* value)
{
VtValue fallback = SdfSchema::GetInstance().GetFallback(key);
if (fallback.IsEmpty()) {
return false;
}
std::string mayaAttrName = _GetMayaAttrNameForMetadataKey(key);
MPlug plug = node.findPlug(mayaAttrName.c_str());
if (plug.isNull()) {
return false;
}
TfType ty = fallback.GetType();
VtValue result = UsdMayaWriteUtil::GetVtValue(plug, ty, TfToken());
if (result.IsEmpty()) {
TF_RUNTIME_ERROR(
"Cannot convert plug '%s' into metadata '%s' (%s)",
plug.name().asChar(),
key.GetText(),
ty.GetTypeName().c_str());
return false;
}
*value = result;
return true;
}
示例6: _MakeNamespaced
/* static */
TfToken
UsdGeomXformOp::GetOpName(
const Type opType,
const TfToken &opSuffix,
bool isInverseOp)
{
TfToken opName = _MakeNamespaced(GetOpTypeToken(opType));
if (!opSuffix.IsEmpty())
opName = TfToken(opName.GetString() + ":" + opSuffix.GetString());
if (isInverseOp)
opName = TfToken(_tokens->invertPrefix.GetString() + opName.GetString());
return opName;
}
示例7: TRACE_FUNCTION
SdfAttributeSpecHandle
SdfAttributeSpec::New(
const SdfPrimSpecHandle& owner,
const std::string& name,
const SdfValueTypeName& typeName,
SdfVariability variability,
bool custom)
{
TRACE_FUNCTION();
if (not owner) {
TF_CODING_ERROR("Cannot create an SdfAttributeSpec with a null owner");
return TfNullPtr;
}
if (not Sdf_ChildrenUtils<Sdf_AttributeChildPolicy>::IsValidName(name)) {
TF_CODING_ERROR(
"Cannot create attribute on %s with invalid name: %s",
owner->GetPath().GetText(), name.c_str());
return TfNullPtr;
}
SdfPath attributePath = owner->GetPath().AppendProperty(TfToken(name));
if (not attributePath.IsPropertyPath()) {
TF_CODING_ERROR(
"Cannot create attribute at invalid path <%s.%s>",
owner->GetPath().GetText(), name.c_str());
return TfNullPtr;
}
return _New(owner, attributePath, typeName, variability, custom);
}
示例8:
bool
SdfPropertySpec::CanSetName(const std::string &newName,
std::string *whyNot) const
{
return Sdf_ChildrenUtils<Sdf_PropertyChildPolicy>::CanRename(
*this, TfToken(newName)).IsAllowed(whyNot);
}
示例9: _lightingContext
PXR_NAMESPACE_OPEN_SCOPE
HdxSimpleLightingShader::HdxSimpleLightingShader()
: _lightingContext(GlfSimpleLightingContext::New())
, _bindingMap(TfCreateRefPtr(new GlfBindingMap()))
, _useLighting(true)
{
// TODO: robust binding from codegen
_bindingMap->GetUniformBinding(TfToken("GlobalUniform"));
_bindingMap->GetUniformBinding(TfToken("DrawDataBuffer"));
_lightingContext->InitUniformBlockBindings(_bindingMap);
_lightingContext->InitSamplerUnitBindings(_bindingMap);
_glslfx.reset(new GlfGLSLFX(HdxPackageSimpleLightingShader()));
}
示例10: TfToken
/* static */
TfToken
UsdGeomConstraintTarget::GetConstraintAttrName(
const std::string &constraintName)
{
return TfToken(_tokens->constraintTargets.GetString() + ":" +
constraintName);
}
示例11: GetPluginDescs
TfToken
HdxRendererPluginRegistry::GetDefaultPluginId()
{
// Get all the available plugins to see if any of them is supported on this
// platform and use the first one as the default.
//
// Important note, we want to avoid loading plugins as much as possible,
// we would prefer to only load plugins when the user asks for them. So
// we will only load plugins until we find the first one that works.
HfPluginDescVector pluginDescriptors;
GetPluginDescs(&pluginDescriptors);
for (const HfPluginDesc &desc : pluginDescriptors) {
HdxRendererPlugin *plugin = HdxRendererPluginRegistry::GetInstance().
GetRendererPlugin(desc.id);
// Important to bail out as soon as we found a plugin that works to
// avoid loading plugins unnecessary as that can be arbitrarily
// expensive.
if (plugin && plugin->IsSupported()) {
HdxRendererPluginRegistry::GetInstance().ReleasePlugin(plugin);
return desc.id;
}
HdxRendererPluginRegistry::GetInstance().ReleasePlugin(plugin);
}
return TfToken();
}
示例12: TfToken
TfToken
UsdGeomXformOp::GetOpName() const
{
return _isInverseOp ? TfToken(_tokens->invertPrefix.GetString() +
GetName().GetString())
: GetName();
}
示例13: TfToken
TfToken
UsdMayaAdaptor::GetUsdTypeName() const
{
if (!*this) {
return TfToken();
}
const TfType ty = GetUsdType();
const SdfPrimSpecHandle primDef = UsdSchemaRegistry::GetInstance()
.GetPrimDefinition(ty);
if (!primDef) {
return TfToken();
}
return primDef->GetNameToken();
}
示例14: _GetMaterialsScopeName
static
TfToken
_GetMaterialsScopeName(const std::string& materialsScopeName)
{
const TfToken defaultMaterialsScopeName = UsdUtilsGetMaterialsScopeName();
if (TfGetEnvSetting(USD_FORCE_DEFAULT_MATERIALS_SCOPE_NAME)) {
// If the env setting is set, make sure we don't allow the materials
// scope name to be overridden by a parameter value.
return defaultMaterialsScopeName;
}
if (SdfPath::IsValidIdentifier(materialsScopeName)) {
return TfToken(materialsScopeName);
}
TF_CODING_ERROR(
"'%s' value '%s' is not a valid identifier. Using default "
"value of '%s' instead.",
UsdMayaJobExportArgsTokens->materialsScopeName.GetText(),
materialsScopeName.c_str(),
defaultMaterialsScopeName.GetText());
return defaultMaterialsScopeName;
}
示例15: TfToken
bool MayaMeshWriter::_createUVPrimVar(
UsdGeomGprim &primSchema,
const TfToken& name,
const VtArray<GfVec2f>& data,
const TfToken& interpolation,
const VtArray<int>& assignmentIndices,
const int unassignedValueIndex)
{
unsigned int numValues = data.size();
if (numValues == 0) {
return false;
}
TfToken interp = interpolation;
if (numValues == 1 && interp == UsdGeomTokens->constant) {
interp = TfToken();
}
UsdGeomPrimvar primVar =
primSchema.CreatePrimvar(name,
SdfValueTypeNames->Float2Array,
interp);
primVar.Set(data);
if (!assignmentIndices.empty()) {
primVar.SetIndices(assignmentIndices);
if (unassignedValueIndex != primVar.GetUnauthoredValuesIndex()) {
primVar.SetUnauthoredValuesIndex(unassignedValueIndex);
}
}
return true;
}