本文整理汇总了C++中MFnNurbsCurve::degree方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnNurbsCurve::degree方法的具体用法?C++ MFnNurbsCurve::degree怎么用?C++ MFnNurbsCurve::degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnNurbsCurve
的用法示例。
在下文中一共展示了MFnNurbsCurve::degree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void MayaNurbsCurveWriter::write()
{
Alembic::AbcGeom::OCurvesSchema::Sample samp;
samp.setBasis(Alembic::AbcGeom::kBsplineBasis);
MStatus stat;
mCVCount = 0;
// if inheritTransform is on and the curve group is animated,
// bake the cv positions in the world space
MMatrix exclusiveMatrixInv = mRootDagPath.exclusiveMatrixInverse(&stat);
std::size_t numCurves = 1;
if (mIsCurveGrp)
numCurves = mNurbsCurves.length();
std::vector<Alembic::Util::int32_t> nVertices(numCurves);
std::vector<float> points;
std::vector<float> width;
std::vector<float> knots;
std::vector<Alembic::Util::uint8_t> orders(numCurves);
MMatrix transformMatrix;
bool useConstWidth = false;
MFnDependencyNode dep(mRootDagPath.transform());
MPlug constWidthPlug = dep.findPlug("width");
if (!constWidthPlug.isNull())
{
useConstWidth = true;
width.push_back(constWidthPlug.asFloat());
}
for (unsigned int i = 0; i < numCurves; i++)
{
MFnNurbsCurve curve;
if (mIsCurveGrp)
{
curve.setObject(mNurbsCurves[i]);
MMatrix inclusiveMatrix = mNurbsCurves[i].inclusiveMatrix(&stat);
transformMatrix = inclusiveMatrix*exclusiveMatrixInv;
}
else
{
curve.setObject(mRootDagPath.node());
}
if (i == 0)
{
if (curve.form() == MFnNurbsCurve::kOpen)
{
samp.setWrap(Alembic::AbcGeom::kNonPeriodic);
}
else
{
samp.setWrap(Alembic::AbcGeom::kPeriodic);
}
if (curve.degree() == 3)
{
samp.setType(Alembic::AbcGeom::kCubic);
}
else if (curve.degree() == 1)
{
samp.setType(Alembic::AbcGeom::kLinear);
}
else
{
samp.setType(Alembic::AbcGeom::kVariableOrder);
}
}
else
{
if (curve.form() == MFnNurbsCurve::kOpen)
{
samp.setWrap(Alembic::AbcGeom::kNonPeriodic);
}
if ((samp.getType() == Alembic::AbcGeom::kCubic &&
curve.degree() != 3) ||
(samp.getType() == Alembic::AbcGeom::kLinear &&
curve.degree() != 1))
{
samp.setType(Alembic::AbcGeom::kVariableOrder);
}
}
orders[i] = static_cast<Alembic::Util::uint8_t>(curve.degree() + 1);
Alembic::Util::int32_t numCVs = curve.numCVs(&stat);
MPointArray cvArray;
stat = curve.getCVs(cvArray, MSpace::kObject);
mCVCount += numCVs;
nVertices[i] = numCVs;
for (Alembic::Util::int32_t j = 0; j < numCVs; j++)
//.........这里部分代码省略.........
示例2: doPrimitiveConversion
IECore::PrimitivePtr FromMayaCurveConverter::doPrimitiveConversion( MFnNurbsCurve &fnCurve ) const
{
// decide on the basis and periodicity
int mDegree = fnCurve.degree();
IECore::CubicBasisf basis = IECore::CubicBasisf::linear();
if( m_linearParameter->getTypedValue()==false && mDegree==3 )
{
basis = IECore::CubicBasisf::bSpline();
}
bool periodic = false;
if( fnCurve.form()==MFnNurbsCurve::kPeriodic )
{
periodic = true;
}
// get the points and convert them
MPointArray mPoints;
fnCurve.getCVs( mPoints, space() );
if( periodic )
{
// maya duplicates the first points at the end, whereas we just wrap around.
// remove the duplicates.
mPoints.setLength( mPoints.length() - mDegree );
}
bool duplicateEnds = false;
if( !periodic && mDegree==3 )
{
// there's an implicit duplication of the end points that we need to make explicit
duplicateEnds = true;
}
IECore::V3fVectorDataPtr pointsData = new IECore::V3fVectorData;
std::vector<Imath::V3f> &points = pointsData->writable();
std::vector<Imath::V3f>::iterator transformDst;
if( duplicateEnds )
{
points.resize( mPoints.length() + 4 );
transformDst = points.begin();
*transformDst++ = IECore::convert<Imath::V3f>( mPoints[0] );
*transformDst++ = IECore::convert<Imath::V3f>( mPoints[0] );
}
else
{
points.resize( mPoints.length() );
transformDst = points.begin();
}
std::transform( MArrayIter<MPointArray>::begin( mPoints ), MArrayIter<MPointArray>::end( mPoints ), transformDst, IECore::VecConvert<MPoint, V3f>() );
if( duplicateEnds )
{
points[points.size()-1] = IECore::convert<Imath::V3f>( mPoints[mPoints.length()-1] );
points[points.size()-2] = IECore::convert<Imath::V3f>( mPoints[mPoints.length()-1] );
}
// make and return the curve
IECore::IntVectorDataPtr vertsPerCurve = new IECore::IntVectorData;
vertsPerCurve->writable().push_back( points.size() );
return new IECore::CurvesPrimitive( vertsPerCurve, basis, periodic, pointsData );
}