本文整理汇总了C++中UsdAttribute类的典型用法代码示例。如果您正苦于以下问题:C++ UsdAttribute类的具体用法?C++ UsdAttribute怎么用?C++ UsdAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UsdAttribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetPrim
void
UsdRiStatementsAPI::SetScopedCoordinateSystem(const std::string &coordSysName)
{
UsdAttribute attr = GetPrim().CreateAttribute(_tokens->scopedCoordsys,
SdfValueTypeNames->String,
/* custom = */ false);
if (TF_VERIFY(attr)) {
attr.Set(coordSysName);
UsdPrim currPrim = GetPrim();
while (currPrim) {
if (currPrim.IsModel() && !currPrim.IsGroup() &&
currPrim.GetPath() != SdfPath::AbsoluteRootPath()) {
UsdRelationship rel =
currPrim.CreateRelationship(_tokens->modelScopedCoordsys,
/* custom = */ false);
if (TF_VERIFY(rel)) {
rel.AddTarget(GetPrim().GetPath());
}
break;
}
currPrim = currPrim.GetParent();
}
}
}
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:26,代码来源:statementsAPI.cpp
示例2: TRACE_FUNCTION
UsdGeomPrimvar
UsdGeomPrimvarsAPI::FindPrimvarWithInheritance(const TfToken &name) const
{
TRACE_FUNCTION();
const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
UsdPrim prim = GetPrim();
if (!prim) {
TF_CODING_ERROR("FindPrimvarWithInheritance called on invalid prim: %s",
UsdDescribe(prim).c_str());
return UsdGeomPrimvar();
}
UsdGeomPrimvar localPv = GetPrimvar(name);
if (localPv.HasAuthoredValue()){
return localPv;
}
for (prim = prim.GetParent(); prim && !prim.IsPseudoRoot();
prim = prim.GetParent()) {
UsdAttribute attr = prim.GetAttribute(attrName);
if (attr.HasAuthoredValue()) {
if (UsdGeomPrimvar pv = UsdGeomPrimvar(attr)) {
// Only constant primvars can be inherited.
if (pv.GetInterpolation() == UsdGeomTokens->constant) {
return pv;
} else {
// Non-constant interpolation blocks inheritance.
return UsdGeomPrimvar();
}
}
}
}
return localPv;
}
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:34,代码来源:primvarsAPI.cpp
示例3: getUsdPrimForWrite
void
GusdPrimWrapper::updateVisibilityFromGTPrim(
const GT_PrimitiveHandle& sourcePrim,
UsdTimeCode time)
{
// If we're tracking visibility, set this prim's default state to
// invisible. File-per-frame exports rely on this if the prim isn't
// persistent throughout the frame range.
UsdAttribute visAttr = getUsdPrimForWrite().GetVisibilityAttr();
if( visAttr.IsValid() )
visAttr.Set(UsdGeomTokens->invisible,
UsdTimeCode::Default());
GT_Owner attrOwner;
GT_DataArrayHandle houAttr
= sourcePrim->findAttribute("visible", attrOwner, 0);
if(houAttr) {
int visible = houAttr->getI32(0);
if(visible) {
setVisibility(UsdGeomTokens->inherited, time);
} else {
setVisibility(UsdGeomTokens->invisible, time);
}
}
else {
if(isVisible()) {
setVisibility(UsdGeomTokens->inherited, time);
} else {
setVisibility(UsdGeomTokens->invisible, time);
}
}
}
开发者ID:c64kernal,项目名称:USD,代码行数:31,代码来源:primWrapper.cpp
示例4: _CheckUsdTypeAndResizeArrays
static
bool
_CheckUsdTypeAndResizeArrays(
const UsdAttribute& usdAttr,
const TfType& expectedType,
const GfInterval& timeInterval,
std::vector<double>* timeSamples,
MTimeArray* timeArray,
MDoubleArray* valueArray)
{
// Validate that the attribute holds values of the expected type.
const TfType type = usdAttr.GetTypeName().GetType();
if (type != expectedType) {
TF_CODING_ERROR("Unsupported type name for USD attribute '%s': %s",
usdAttr.GetName().GetText(), type.GetTypeName().c_str());
return false;
}
if (!usdAttr.GetTimeSamplesInInterval(timeInterval, timeSamples)) {
return false;
}
size_t numTimeSamples = timeSamples->size();
if (numTimeSamples < 1) {
return false;
}
timeArray->setLength(numTimeSamples);
valueArray->setLength(numTimeSamples);
return true;
}
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:32,代码来源:translatorCamera.cpp
示例5: _GetMayaDictValue
static
bool _GetMayaDictValue(const UsdAttribute& attr, const TfToken& key, T* outVal)
{
VtValue data = attr.GetCustomDataByKey(_tokens->Maya);
if (!data.IsEmpty()) {
if (data.IsHolding<VtDictionary>()) {
VtValue val;
if (TfMapLookup(data.UncheckedGet<VtDictionary>(), key, &val)) {
if (val.IsHolding<T>()) {
*outVal = val.UncheckedGet<T>();
return true;
}
else {
TF_WARN("Unexpected type for %s[%s] on <%s>.",
_tokens->Maya.GetText(),
key.GetText(),
attr.GetPath().GetText());
}
}
}
else {
TF_WARN("Expected to get %s on <%s> to be a dictionary.",
_tokens->Maya.GetText(),
attr.GetPath().GetText());
}
}
return false;
}
开发者ID:lvxejay,项目名称:USD,代码行数:28,代码来源:roundTripUtil.cpp
示例6: TF_CODING_ERROR
bool
UsdGeomCollectionAPI::AppendTarget(
const SdfPath &target,
const VtIntArray &faceIndices /* =VtIntArray() */,
const UsdTimeCode &time /* =UsdTimeCode::Default() */) const
{
if (target.IsEmpty()) {
TF_CODING_ERROR("Cannot add empty target to collection '%s' on "
"prim <%s>.", _name.GetText(), GetPath().GetText());
return false;
}
bool hasFaceCountsAtTime = true;
if (time != UsdTimeCode::Default()) {
UsdAttribute targetFaceCountsAttr = GetTargetFaceCountsAttr();
double lower=0., upper=0.;
bool hasTimeSamples=false;
if (targetFaceCountsAttr.GetBracketingTimeSamples(time.GetValue(),
&lower, &upper, &hasTimeSamples))
{
hasFaceCountsAtTime = (lower==upper && lower==time.GetValue());
}
}
VtIntArray targetFaceCounts, targetFaceIndices;
if (hasFaceCountsAtTime) {
GetTargetFaceCounts(&targetFaceCounts, time);
GetTargetFaceIndices(&targetFaceIndices, time);
}
SdfPathVector targets;
GetTargets(&targets);
// If there are no existing face restrictions and no face-restriction is
// specified on the current target, simly add the target and return.
if (targetFaceCounts.empty() && targetFaceIndices.empty() &&
faceIndices.empty())
{
// We can simply add the target here to the relationship here since
// there are no companion non-list-edited integer arrays.
return CreateTargetsRel().AppendTarget(target);
}
if (targetFaceCounts.empty() && !targetFaceIndices.empty()) {
TF_CODING_ERROR("targetFaceCounts is empty, but targetFaceIndices "
"is not, for the collection '%s' belonging to prim <%s>.",
_name.GetText(), GetPath().GetText());
return false;
}
if (targetFaceCounts.empty() && !faceIndices.empty()) {
for (size_t i = 0 ; i < targets.size(); i++)
targetFaceCounts.push_back(0);
}
targetFaceCounts.push_back(faceIndices.size());
targetFaceIndices.reserve(targetFaceIndices.size() + faceIndices.size());
TF_FOR_ALL(it, faceIndices) {
targetFaceIndices.push_back(*it);
}
开发者ID:JT-a,项目名称:USD,代码行数:60,代码来源:collectionAPI.cpp
示例7: prim
UsdAttribute
UsdSchemaBase::_CreateAttr(TfToken const &attrName,
SdfValueTypeName const & typeName,
bool custom, SdfVariability variability,
VtValue const &defaultValue,
bool writeSparsely) const
{
UsdPrim prim(GetPrim());
if (writeSparsely && !custom){
// We are a builtin, and we're trying to be parsimonious.
// We only need to even CREATE a propertySpec if we are
// authoring a non-fallback default value
UsdAttribute attr = prim.GetAttribute(attrName);
VtValue fallback;
if (defaultValue.IsEmpty() ||
(!attr.HasAuthoredValueOpinion()
&& attr.Get(&fallback)
&& fallback == defaultValue)){
return attr;
}
}
UsdAttribute attr(prim.CreateAttribute(attrName, typeName,
custom, variability));
if (attr && !defaultValue.IsEmpty()) {
attr.Set(defaultValue);
}
return attr;
}
开发者ID:MWDD,项目名称:USD,代码行数:31,代码来源:schemaBase.cpp
示例8: _GetTargetFaceIndicesAttr
bool
UsdGeomCollectionAPI::GetTargetFaceIndices(
VtIntArray *targetFaceIndices,
const UsdTimeCode &time /* =UsdTimeCode::Default() */) const
{
UsdAttribute attr = _GetTargetFaceIndicesAttr();
return attr.Get(targetFaceIndices, time);
}
开发者ID:JT-a,项目名称:USD,代码行数:8,代码来源:collectionAPI.cpp
示例9: _GetPwAttr
/*
* Return a FloatAttribute for points. There are 4 floats per
* point, where the first 3 floats are the point's position,
* and the 4th float is the weight of the point.
*/
static FnKat::FloatAttribute
_GetPwAttr(
const UsdGeomNurbsPatch &nurbsPatch,
double currentTime,
const std::vector<double>& motionSampleTimes,
const bool isMotionBackward)
{
UsdAttribute weightsAttr = nurbsPatch.GetPointWeightsAttr();
UsdAttribute pointsAttr = nurbsPatch.GetPointsAttr();
if (!pointsAttr)
{
return FnKat::FloatAttribute();
}
FnKat::FloatBuilder pwBuilder(/* tupleSize = */ 4);
TF_FOR_ALL(iter, motionSampleTimes)
{
double relSampleTime = *iter;
double time = currentTime + relSampleTime;
// Eval points at this motion sample time
VtVec3fArray ptArray;
pointsAttr.Get(&ptArray, time);
// Eval Weights at this motion sample time
VtDoubleArray wtArray;
weightsAttr.Get(&wtArray, currentTime);
bool hasWeights = false;
if (ptArray.size() == wtArray.size())
{
hasWeights = true;
}
else if (wtArray.size() > 0)
{
FnLogWarn("Nurbs Patch "
<< nurbsPatch.GetPath().GetText()
<< " has mismatched weights array. Skipping.");
return FnKat::FloatAttribute();
}
// set the points data in katana at the give motion sample time
std::vector<float> &ptVec = pwBuilder.get(isMotionBackward ?
PxrUsdKatanaUtils::ReverseTimeSample(relSampleTime) : relSampleTime);
ptVec.resize(ptArray.size() * 4);
size_t count = 0;
for (size_t i = 0; i != ptArray.size(); ++i)
{
float weight = hasWeights ? wtArray[i] : 1.0f;
ptVec[count++] = ptArray[i][0]*weight;
ptVec[count++] = ptArray[i][1]*weight;
ptVec[count++] = ptArray[i][2]*weight;
// the 4th float is the weight of the point
ptVec[count++] = weight ;
}
}
开发者ID:MWDD,项目名称:USD,代码行数:63,代码来源:readNurbsPatch.cpp
示例10: _GatherRibAttributes
static bool
_GatherRibAttributes(
const UsdPrim &prim,
double currentTime,
FnKat::GroupBuilder& attrsBuilder)
{
bool hasAttrs = false;
// USD SHADING STYLE ATTRIBUTES
UsdRiStatements riStatements(prim);
if (riStatements) {
const std::vector<UsdProperty> props =
riStatements.GetRiAttributes();
std::string attrName;
TF_FOR_ALL(propItr, props) {
UsdProperty prop = *propItr;
if (!prop) continue;
std::string nameSpace =
riStatements.GetRiAttributeNameSpace(prop).GetString();
nameSpace = TfStringReplace(nameSpace, ":", ".") + ".";
attrName = nameSpace +
riStatements.GetRiAttributeName(prop).GetString();
VtValue vtValue;
UsdAttribute usdAttr = prim.GetAttribute(prop.GetName());
if (usdAttr) {
if (not usdAttr.Get(&vtValue, currentTime))
continue;
// XXX asShaderParam really means:
// "For arrays, as a single attr vs a type/value pair group"
// The type/value pair group is meaningful for attrs who don't
// have a formal type definition -- like a "user" RiAttribute.
//
// However, other array values (such as two-element shadingrate)
// are not expecting the type/value pair form and will not
// generate rib correctly. As such, we'll handle the "user"
// attribute as a special case.
bool asShaderParam = true;
if (nameSpace == "user.")
{
asShaderParam = false;
}
attrsBuilder.set(attrName, PxrUsdKatanaUtils::ConvertVtValueToKatAttr(vtValue,
asShaderParam) );
}
else {
UsdRelationship usdRel = prim.GetRelationship(prop.GetName());
attrsBuilder.set(attrName, PxrUsdKatanaUtils::ConvertRelTargetsToKatAttr(usdRel,
/* asShaderParam */ false) );
}
hasAttrs = true;
}
}
开发者ID:400dama,项目名称:USD,代码行数:58,代码来源:readPrim.cpp
示例11: TF_DEBUG
void
UsdImagingGprimAdapter::_DiscoverPrimvars(UsdGeomGprim const& gprim,
SdfPath const& cachePath,
UsdShadeShader const& shader,
UsdTimeCode time,
UsdImagingValueCache* valueCache)
{
// TODO: It might be convenient to implicitly wire up PtexFaceOffset and
// PtexFaceIndex primvars.
TF_DEBUG(USDIMAGING_SHADERS).Msg("\t Looking for <%s> primvars at <%s>\n",
gprim.GetPrim().GetPath().GetText(),
shader.GetPrim().GetPath().GetText());
for (UsdShadeParameter const& param : shader.GetParameters()) {
UsdShadeShader source;
TfToken outputName;
if (param.GetConnectedSource(&source, &outputName)) {
UsdAttribute attr = source.GetIdAttr();
TfToken id;
if (not attr or not attr.Get(&id)) {
continue;
}
TF_DEBUG(USDIMAGING_SHADERS).Msg("\t\t Param <%s> connected <%s>(%s)\n",
param.GetAttr().GetName().GetText(),
source.GetPath().GetText(),
id.GetText());
if (id == UsdHydraTokens->HwPrimvar_1) {
TfToken t;
VtValue v;
UsdGeomPrimvar primvarAttr;
if (UsdHydraPrimvar(source).GetVarnameAttr().Get(&t,
UsdTimeCode::Default())) {
primvarAttr = gprim.GetPrimvar(t);
if (primvarAttr.ComputeFlattened(&v, time)) {
TF_DEBUG(USDIMAGING_SHADERS).Msg("Found primvar %s\n",
t.GetText());
UsdImagingValueCache::PrimvarInfo primvar;
primvar.name = t;
primvar.interpolation = primvarAttr.GetInterpolation();
valueCache->GetPrimvar(cachePath, t) = v;
_MergePrimvar(primvar, &valueCache->GetPrimvars(cachePath));
} else {
TF_DEBUG(USDIMAGING_SHADERS).Msg(
"\t\t No primvar on <%s> named %s\n",
gprim.GetPath().GetText(),
t.GetText());
}
}
} else {
// Recursively look for more primvars
_DiscoverPrimvars(gprim, cachePath, source, time, valueCache);
}
}
}
}
开发者ID:400dama,项目名称:USD,代码行数:57,代码来源:gprimAdapter.cpp
示例12: GetAttribute
UsdAttribute
UsdPrim::CreateAttribute(const TfToken& name,
const SdfValueTypeName &typeName,
bool custom,
SdfVariability variability) const
{
UsdAttribute attr = GetAttribute(name);
attr._Create(typeName, custom, variability);
return attr;
}
开发者ID:lvxejay,项目名称:USD,代码行数:10,代码来源:prim.cpp
示例13: _GetIndicesAttr
bool
UsdGeomPrimvar::GetIndices(VtIntArray *indices,
UsdTimeCode time) const
{
UsdAttribute indicesAttr = _GetIndicesAttr(/*create*/ false);
if (indicesAttr)
return indicesAttr.Get(indices, time);
return false;
}
开发者ID:JT-a,项目名称:USD,代码行数:10,代码来源:primvar.cpp
示例14: _SetVec
bool
_SetVec(
const UsdAttribute& attr,
const T& val,
const UsdTimeCode& time) {
return attr.Set((attr.GetRoleName() == SdfValueRoleNames->Color)
? GfConvertDisplayToLinear(val)
: val,
time);
}
开发者ID:MWDD,项目名称:USD,代码行数:10,代码来源:writeUtil.cpp
示例15: GetPrim
PXR_NAMESPACE_OPEN_SCOPE
bool
UsdGeomModelAPI::GetExtentsHint(VtVec3fArray *extents,
const UsdTimeCode &time) const
{
UsdAttribute extentsHintAttr =
GetPrim().GetAttribute(UsdGeomTokens->extentsHint);
if (!extentsHintAttr)
return false;
return extentsHintAttr.Get(extents, time);
}
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:14,代码来源:modelAPI.cpp
示例16: GetXformOpOrderAttr
bool
UsdGeomXformable::_GetXformOpOrderValue(
VtTokenArray *xformOpOrder,
bool *hasAuthoredValue) const
{
UsdAttribute xformOpOrderAttr = GetXformOpOrderAttr();
if (not xformOpOrderAttr)
return false;
if (hasAuthoredValue)
*hasAuthoredValue = xformOpOrderAttr.HasAuthoredValueOpinion();
xformOpOrderAttr.Get(xformOpOrder, UsdTimeCode::Default());
return true;
}
开发者ID:ZeroCrunch,项目名称:USD,代码行数:15,代码来源:xformable.cpp
示例17: UsdModelAPI
/* static */
bool
UsdGeomConstraintTarget::IsValid(const UsdAttribute &attr)
{
if (not attr)
return false;
static TfType matrix4dType = TfType::Find<GfMatrix4d>();
return UsdModelAPI(attr.GetPrim()).IsModel() /* is this a model */
/* is it in the constraintTargets namespace */
and attr.SplitName().front() == _tokens->constraintTargets
/* is it matrix-typed */
and attr.GetTypeName().GetType() == matrix4dType;
}
开发者ID:ZeroCrunch,项目名称:USD,代码行数:17,代码来源:constraintTarget.cpp
示例18: _TranslateUsdAttributeToPlug
static
bool
_TranslateUsdAttributeToPlug(
const UsdAttribute& usdAttr,
const MFnCamera& cameraFn,
TfToken plugName,
const PxrUsdMayaPrimReaderArgs& args,
PxrUsdMayaPrimReaderContext* context,
bool millimetersToInches=false)
{
MStatus status;
MPlug plug = cameraFn.findPlug(plugName.GetText(), true, &status);
CHECK_MSTATUS_AND_RETURN(status, false);
// First check for and translate animation if there is any.
if (!_TranslateAnimatedUsdAttributeToPlug(usdAttr,
plug,
args,
context,
millimetersToInches)) {
// If that fails, then try just setting a static value.
UsdTimeCode timeCode = UsdTimeCode::EarliestTime();
float attrValue;
usdAttr.Get(&attrValue, timeCode);
if (millimetersToInches) {
attrValue = PxrUsdMayaUtil::ConvertMMToInches(attrValue);
}
status = plug.setFloat(attrValue);
CHECK_MSTATUS_AND_RETURN(status, false);
}
return true;
}
开发者ID:JT-a,项目名称:USD,代码行数:34,代码来源:translatorCamera.cpp
示例19: IsXformOp
/* static */
bool
UsdGeomXformOp::IsXformOp(const UsdAttribute &attr)
{
if (!attr)
return false;
return IsXformOp(attr.GetName());
}
开发者ID:JT-a,项目名称:USD,代码行数:9,代码来源:xformOp.cpp
示例20: _IsNamespaced
/* static */
bool
UsdGeomPrimvar::IsPrimvar(const UsdAttribute &attr)
{
if (!attr)
return false;
TfToken const &name = attr.GetName();
return _IsNamespaced(name) && !_ContainsExtraNamespaces(name);
}
开发者ID:JT-a,项目名称:USD,代码行数:10,代码来源:primvar.cpp
注:本文中的UsdAttribute类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论