本文整理汇总了C++中MFnNurbsCurve::setObject方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnNurbsCurve::setObject方法的具体用法?C++ MFnNurbsCurve::setObject怎么用?C++ MFnNurbsCurve::setObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnNurbsCurve
的用法示例。
在下文中一共展示了MFnNurbsCurve::setObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doIt
MStatus InstanceCallbackCmd::doIt( const MArgList& args )
{
MStatus status = MS::kSuccess;
// Draw a circle and get its dagPath
// using an iterator
MGlobal::executeCommand("circle");
MFnNurbsCurve circle;
MDagPath dagPath;
MItDependencyNodes iter( MFn::kNurbsCurve , &status);
for(iter.reset(); !iter.isDone() ; iter.next())
{
MObject item = iter.item();
if(item.hasFn(MFn::kNurbsCurve))
{
circle.setObject(item);
circle.getPath(dagPath);
MGlobal::displayInfo("DAG_PATH is " + dagPath.fullPathName());
if(dagPath.isValid())
{
// register callback for instance add AND remove
//
MDagMessage::addInstanceAddedCallback ( dagPath,addCallbackFunc, NULL, &status);
MDagMessage::addInstanceRemovedCallback ( dagPath,remCallbackFunc, NULL, &status);
MGlobal::displayInfo("CALLBACK ADDED FOR INSTANCE ADD/REMOVE");
}
}
}
if (status != MS::kSuccess)
{
MGlobal::displayInfo("STATUS RETURNED IS NOT SUCCESS");
}
return status;
}
示例2: iter
MStatus Posts1Cmd::doIt ( const MArgList & )
{
const int nPosts = 5;
const double radius = 0.5;
const double height = 5.0;
// Get a list of currently selected objects
MSelectionList selection;
MGlobal::getActiveSelectionList( selection );
MDagPath dagPath;
MFnNurbsCurve curveFn;
double heightRatio = height / radius;
// Iterate over the nurbs curves
MItSelectionList iter( selection, MFn::kNurbsCurve );
for ( ; !iter.isDone(); iter.next() )
{
// Get the curve and attach it to the function set
iter.getDagPath( dagPath );
curveFn.setObject( dagPath );
// Get the domain of the curve, i.e. its start and end parametric values
double tStart, tEnd;
curveFn.getKnotDomain( tStart, tEnd );
MPoint pt;
int i;
double t;
double tIncr = (tEnd - tStart) / (nPosts - 1);
for( i=0, t=tStart; i < nPosts; i++, t += tIncr )
{
// Get point along curve at parametric position t
curveFn.getPointAtParam( t, pt, MSpace::kWorld );
pt.y += 0.5 * height;
MGlobal::executeCommand( MString( "cylinder -pivot ") + pt.x + " " + pt.y + " " + pt.z
+ " -radius " + radius + " -axis 0 1 0 -heightRatio " + heightRatio );
}
}
return MS::kSuccess;
}
示例3: 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++)
//.........这里部分代码省略.........
示例4: preSolve
MStatus splineSolverNode::preSolve()
{
MStatus stat;
setRotatePlane(false);
setSingleChainOnly(true);
setPositionOnly(false);
//Get Handle
MIkHandleGroup * handle_group = handleGroup();
if (NULL == handle_group) {
return MS::kFailure;
}
MObject handle = handle_group->handle( 0 );
MDagPath handlePath = MDagPath::getAPathTo( handle );
fnHandle.setObject( handlePath );
//Get Curve
MPlug inCurvePlug = fnHandle.findPlug( "inCurve" );
MDataHandle curveHandle = inCurvePlug.asMDataHandle();
MObject inputCurveObject = curveHandle.asNurbsCurveTransformed();
curveFn.setObject( inputCurveObject );
float initCurveLength = curveFn.length();
MVector initNormal = curveFn.normal(0);
MVector initTangent = curveFn.tangent(0);
float stretchRatio = 1;
// Get the position of the end_effector
//
MDagPath effectorPath;
fnHandle.getEffector(effectorPath);
tran.setObject( effectorPath );
// Get the start joint position
//
MDagPath startJointPath;
fnHandle.getStartJoint( startJointPath );
joints.clear();
//Get Joints
while (true)
{
effectorPath.pop();
joints.push_back( effectorPath );
if (effectorPath == startJointPath)
break;
}
std::reverse(joints.begin(), joints.end());
if (!fnHandle.hasAttribute("str"))
{
//Add Custom Attributes to Handle
MFnNumericAttribute fnAttr;
MObject attr = fnAttr.create("stretchRatio", "str", MFnNumericData::kDouble, stretchRatio);
fnAttr.setKeyable(1);
fnAttr.setWritable(1);
fnAttr.setMin(0);
fnAttr.setMax(1);
fnAttr.setHidden(0);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("anchorPosition", "ancp", MFnNumericData::kDouble, 0.0);
fnAttr.setKeyable(1);
fnAttr.setWritable(1);
fnAttr.setMin(0);
fnAttr.setMax(1);
fnAttr.setHidden(0);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("curveLength", "cvLen", MFnNumericData::kDouble, initCurveLength);
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("initNormal", "norm", MFnNumericData::k3Double);
fnAttr.setDefault(initNormal.x, initNormal.y, initNormal.z);
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("initTangent", "tang", MFnNumericData::k3Double);
fnAttr.setDefault(initTangent.x, initTangent.y, initTangent.z);
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("jointsLength", "jsLen", MFnNumericData::kDouble, getJointsTotalLenght());
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("startTwist", "strtw", MFnNumericData::kDouble, 0.0);
fnAttr.setKeyable(1);
fnAttr.setWritable(1);
fnAttr.setHidden(0);
fnAttr.setStorable(1);
//.........这里部分代码省略.........