本文整理汇总了C++中MFnMesh::addAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnMesh::addAttribute方法的具体用法?C++ MFnMesh::addAttribute怎么用?C++ MFnMesh::addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnMesh
的用法示例。
在下文中一共展示了MFnMesh::addAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSubD
MObject createSubD(double iFrame, SubDAndColors & iNode,
MObject & iParent)
{
Alembic::AbcGeom::ISubDSchema schema = iNode.mMesh.getSchema();
Alembic::AbcCoreAbstract::index_t index, ceilIndex;
getWeightAndIndex(iFrame, schema.getTimeSampling(),
schema.getNumSamples(), index, ceilIndex);
Alembic::AbcGeom::ISubDSchema::Sample samp;
schema.get(samp, Alembic::Abc::ISampleSelector(index));
MString name(iNode.mMesh.getName().c_str());
MFnMesh fnMesh;
MFloatPointArray pointArray;
Alembic::Abc::P3fArraySamplePtr emptyPtr;
fillPoints(pointArray, samp.getPositions(), emptyPtr, 0.0);
fillTopology(fnMesh, iParent, pointArray, samp.getFaceIndices(),
samp.getFaceCounts());
fnMesh.setName(iNode.mMesh.getName().c_str());
setInitialShadingGroup(fnMesh.partialPathName());
MObject obj = fnMesh.object();
setUVs(iFrame, fnMesh, schema.getUVsParam());
setColors(iFrame, fnMesh, iNode.mC3s, iNode.mC4s, true);
// add the mFn-specific attributes to fnMesh node
MFnNumericAttribute numAttr;
MString attrName("SubDivisionMesh");
MObject attrObj = numAttr.create(attrName, attrName,
MFnNumericData::kBoolean, 1);
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
if (samp.getInterpolateBoundary() > 0)
{
attrName = MString("interpolateBoundary");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getInterpolateBoundary());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getFaceVaryingInterpolateBoundary() > 0)
{
attrName = MString("faceVaryingInterpolateBoundary");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getFaceVaryingInterpolateBoundary());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getFaceVaryingPropagateCorners() > 0)
{
attrName = MString("faceVaryingPropagateCorners");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getFaceVaryingPropagateCorners());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
#if MAYA_API_VERSION >= 201100
Alembic::Abc::Int32ArraySamplePtr holes = samp.getHoles();
if (holes && !holes->size() == 0)
{
unsigned int numHoles = (unsigned int)holes->size();
MUintArray holeData(numHoles);
for (unsigned int i = 0; i < numHoles; ++i)
{
holeData[i] = (*holes)[i];
}
if (fnMesh.setInvisibleFaces(holeData) != MS::kSuccess)
{
MString warn = "Failed to set holes on: ";
warn += iNode.mMesh.getName().c_str();
printWarning(warn);
}
}
#endif
Alembic::Abc::FloatArraySamplePtr creases = samp.getCreaseSharpnesses();
if (creases && !creases->size() == 0)
{
Alembic::Abc::Int32ArraySamplePtr indices = samp.getCreaseIndices();
Alembic::Abc::Int32ArraySamplePtr lengths = samp.getCreaseLengths();
std::size_t numLengths = lengths->size();
//.........这里部分代码省略.........
示例2: createSubD
MObject createSubD(double iFrame, Alembic::AbcGeom::ISubD & iNode,
MObject & iParent, std::vector<std::string> & oSampledPropNameList)
{
Alembic::AbcGeom::ISubDSchema schema = iNode.getSchema();
int64_t index, ceilIndex;
double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(),
schema.getNumSamples(), index, ceilIndex);
Alembic::AbcGeom::ISubDSchema::Sample samp;
schema.get(samp, Alembic::Abc::ISampleSelector(index));
MString name(iNode.getName().c_str());
MFnMesh fnMesh;
MFloatPointArray pointArray;
Alembic::Abc::V3fArraySamplePtr emptyPtr;
fillPoints(pointArray, samp.getPositions(), emptyPtr, 0.0);
fillTopology(fnMesh, iParent, pointArray, samp.getFaceIndices(),
samp.getFaceCounts());
fnMesh.setName(iNode.getName().c_str());
setInitialShadingGroup(fnMesh.partialPathName());
MObject obj = fnMesh.object();
//addProperties(iFrame, iNode, obj, oSampledPropNameList);
setUVs(iFrame, fnMesh, schema.getUVs());
// add the mFn-specific attributes to fnMesh node
MFnNumericAttribute numAttr;
MString attrName("SubDivisionMesh");
MObject attrObj = numAttr.create(attrName, attrName,
MFnNumericData::kBoolean, 1);
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
if (samp.getInterpolateBoundary() > 0)
{
attrName = MString("interpolateBoundary");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getInterpolateBoundary());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getFaceVaryingInterpolateBoundary() > 0)
{
attrName = MString("faceVaryingInterpolateBoundary");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getFaceVaryingInterpolateBoundary());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getFaceVaryingPropagateCorners() > 0)
{
attrName = MString("faceVaryingPropagateCorners");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getFaceVaryingPropagateCorners());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getHoles() && !samp.getHoles()->size() == 0)
{
printWarning("Hole Poly Indices not yet supported.");
}
if (samp.getCreaseSharpnesses() &&
!samp.getCreaseSharpnesses()->size() == 0)
{
printWarning("Creases not yet supported.");
}
if (samp.getCornerSharpnesses() &&
!samp.getCornerSharpnesses()->size() == 0)
{
printWarning("Corners not yet supported.");
}
return obj;
}
示例3: createSubD
MObject createSubD(double iFrame, SubDAndFriends & iNode, MObject & iParent)
{
Alembic::AbcGeom::ISubDSchema schema = iNode.mMesh.getSchema();
Alembic::AbcCoreAbstract::index_t index, ceilIndex;
getWeightAndIndex(iFrame, schema.getTimeSampling(),
schema.getNumSamples(), index, ceilIndex);
Alembic::AbcGeom::ISubDSchema::Sample samp;
schema.get(samp, Alembic::Abc::ISampleSelector(index));
MString name(iNode.mMesh.getName().c_str());
MFnMesh fnMesh;
MFloatPointArray pointArray;
Alembic::Abc::P3fArraySamplePtr emptyPtr;
fillPoints(pointArray, samp.getPositions(), emptyPtr, 0.0);
fillTopology(fnMesh, iParent, pointArray, samp.getFaceIndices(),
samp.getFaceCounts());
fnMesh.setName(iNode.mMesh.getName().c_str());
setInitialShadingGroup(fnMesh.partialPathName());
MObject obj = fnMesh.object();
setColorsAndUVs(iFrame, fnMesh, schema.getUVsParam(),
iNode.mV2s, iNode.mC3s, iNode.mC4s, true);
// add the mFn-specific attributes to fnMesh node
MFnNumericAttribute numAttr;
MString attrName("SubDivisionMesh");
MObject attrObj = numAttr.create(attrName, attrName,
MFnNumericData::kBoolean, 1);
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
if (samp.getInterpolateBoundary() > 0)
{
attrName = MString("interpolateBoundary");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getInterpolateBoundary());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getFaceVaryingInterpolateBoundary() > 0)
{
attrName = MString("faceVaryingInterpolateBoundary");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getFaceVaryingInterpolateBoundary());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
if (samp.getFaceVaryingPropagateCorners() > 0)
{
attrName = MString("faceVaryingPropagateCorners");
attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
samp.getFaceVaryingPropagateCorners());
numAttr.setKeyable(true);
numAttr.setHidden(false);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
fillCreasesCornersAndHoles(fnMesh, iNode, samp);
return obj;
}
示例4: createPoly
MObject createPoly(double iFrame, Alembic::AbcGeom::IPolyMesh & iNode,
MObject & iParent, std::vector<std::string> & oSampledPropNameList)
{
Alembic::AbcGeom::IPolyMeshSchema schema = iNode.getSchema();
MString name(iNode.getName().c_str());
MStatus status = MS::kSuccess;
MFnMesh fnMesh;
MObject obj;
// add other properties
if (schema.getNumSamples() > 1)
{
MFloatPointArray emptyPt;
MIntArray emptyInt;
obj = fnMesh.create(0, 0, emptyPt, emptyInt, emptyInt, iParent);
fnMesh.setName(name);
}
else
{
int64_t index, ceilIndex;
double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(),
schema.getNumSamples(), index, ceilIndex);
Alembic::AbcGeom::IPolyMeshSchema::Sample samp;
schema.get(samp, Alembic::Abc::ISampleSelector(index));
MFloatPointArray ptArray;
Alembic::Abc::V3fArraySamplePtr ceilPoints;
if (index != ceilIndex)
{
Alembic::AbcGeom::IPolyMeshSchema::Sample ceilSamp;
schema.get(ceilSamp, Alembic::Abc::ISampleSelector(ceilIndex));
ceilPoints = ceilSamp.getPositions();
}
fillPoints(ptArray, samp.getPositions(), ceilPoints, alpha);
fillTopology(fnMesh, iParent, ptArray, samp.getIndices(),
samp.getCounts());
fnMesh.setName(iNode.getName().c_str());
setPolyNormals(iFrame, fnMesh, schema.getNormals());
setUVs(iFrame, fnMesh, schema.getUVs());
obj = fnMesh.object();
}
MString pathName = fnMesh.partialPathName();
setInitialShadingGroup(pathName);
if ( !schema.getNormals().valid() )
{
MFnNumericAttribute attr;
MString attrName("noNormals");
MObject attrObj = attr.create(attrName, attrName,
MFnNumericData::kBoolean, true, &status);
attr.setKeyable(true);
attr.setHidden(false);
MFnMesh fnMesh(obj);
fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
}
return obj;
}