本文整理汇总了C++中UsdGeomPrimvar::SetIndices方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdGeomPrimvar::SetIndices方法的具体用法?C++ UsdGeomPrimvar::SetIndices怎么用?C++ UsdGeomPrimvar::SetIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdGeomPrimvar
的用法示例。
在下文中一共展示了UsdGeomPrimvar::SetIndices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _createUVPrimVar
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;
}
示例2: _createRGBAPrimVar
bool MayaMeshWriter::_createRGBAPrimVar(
UsdGeomGprim &primSchema,
const TfToken& name,
const VtArray<GfVec3f>& rgbData,
const VtArray<float>& alphaData,
const TfToken& interpolation,
const VtArray<int>& assignmentIndices,
const int unassignedValueIndex,
bool clamped)
{
unsigned int numValues = rgbData.size();
if (numValues == 0 || numValues != alphaData.size()) {
return false;
}
TfToken interp = interpolation;
if (numValues == 1 && interp == UsdGeomTokens->constant) {
interp = TfToken();
}
UsdGeomPrimvar primVar =
primSchema.CreatePrimvar(name,
SdfValueTypeNames->Color4fArray,
interp);
VtArray<GfVec4f> rgbaData(numValues);
for (size_t i = 0; i < rgbaData.size(); ++i) {
rgbaData[i] = GfVec4f(rgbData[i][0], rgbData[i][1], rgbData[i][2],
alphaData[i]);
}
primVar.Set(rgbaData);
if (!assignmentIndices.empty()) {
primVar.SetIndices(assignmentIndices);
if (unassignedValueIndex != primVar.GetUnauthoredValuesIndex()) {
primVar.SetUnauthoredValuesIndex(unassignedValueIndex);
}
}
if (clamped) {
PxrUsdMayaRoundTripUtil::MarkPrimvarAsClamped(primVar);
}
return true;
}
示例3: _createRGBPrimVar
bool MayaMeshWriter::_createRGBPrimVar(
UsdGeomGprim &primSchema,
const TfToken& name,
const VtArray<GfVec3f>& data,
const TfToken& interpolation,
const VtArray<int>& assignmentIndices,
const int unassignedValueIndex,
bool clamped)
{
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->Color3fArray,
interp);
primVar.Set(data);
if (!assignmentIndices.empty()) {
primVar.SetIndices(assignmentIndices);
if (unassignedValueIndex != primVar.GetUnauthoredValuesIndex()) {
primVar.SetUnauthoredValuesIndex(unassignedValueIndex);
}
}
if (clamped) {
PxrUsdMayaRoundTripUtil::MarkPrimvarAsClamped(primVar);
}
return true;
}
示例4: _addDisplayPrimvars
bool MayaMeshWriter::_addDisplayPrimvars(
UsdGeomGprim &primSchema,
const MFnMesh::MColorRepresentation colorRep,
const VtArray<GfVec3f>& RGBData,
const VtArray<float>& AlphaData,
const TfToken& interpolation,
const VtArray<int>& assignmentIndices,
const int unassignedValueIndex,
const bool clamped,
const bool authored)
{
// If we already have an authored value, don't try to write a new one.
UsdAttribute colorAttr = primSchema.GetDisplayColorAttr();
if (!colorAttr.HasAuthoredValueOpinion() && !RGBData.empty()) {
UsdGeomPrimvar displayColor = primSchema.CreateDisplayColorPrimvar();
if (interpolation != displayColor.GetInterpolation()) {
displayColor.SetInterpolation(interpolation);
}
displayColor.Set(RGBData);
if (!assignmentIndices.empty()) {
displayColor.SetIndices(assignmentIndices);
if (unassignedValueIndex != displayColor.GetUnauthoredValuesIndex()) {
displayColor.SetUnauthoredValuesIndex(unassignedValueIndex);
}
}
bool authRGB = authored;
if (colorRep == MFnMesh::kAlpha) {
authRGB = false;
}
if (authRGB) {
if (clamped) {
PxrUsdMayaRoundTripUtil::MarkPrimvarAsClamped(displayColor);
}
}
else {
PxrUsdMayaRoundTripUtil::MarkAttributeAsMayaGenerated(colorAttr);
}
}
UsdAttribute alphaAttr = primSchema.GetDisplayOpacityAttr();
if (!alphaAttr.HasAuthoredValueOpinion() && !AlphaData.empty()) {
// we consider a single alpha value that is 1.0 to be the "default"
// value. We only want to write values that are not the "default".
bool hasDefaultAlpha = AlphaData.size() == 1 && GfIsClose(AlphaData[0], 1.0, 1e-9);
if (!hasDefaultAlpha) {
UsdGeomPrimvar displayOpacity = primSchema.CreateDisplayOpacityPrimvar();
if (interpolation != displayOpacity.GetInterpolation()) {
displayOpacity.SetInterpolation(interpolation);
}
displayOpacity.Set(AlphaData);
if (!assignmentIndices.empty()) {
displayOpacity.SetIndices(assignmentIndices);
if (unassignedValueIndex != displayOpacity.GetUnauthoredValuesIndex()) {
displayOpacity.SetUnauthoredValuesIndex(unassignedValueIndex);
}
}
bool authAlpha = authored;
if (colorRep == MFnMesh::kRGB) {
authAlpha = false;
}
if (authAlpha) {
if (clamped) {
PxrUsdMayaRoundTripUtil::MarkPrimvarAsClamped(displayOpacity);
}
}
else {
PxrUsdMayaRoundTripUtil::MarkAttributeAsMayaGenerated(alphaAttr);
}
}
}
return true;
}