本文整理汇总了C++中MDataHandle::asNurbsCurveTransformed方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::asNurbsCurveTransformed方法的具体用法?C++ MDataHandle::asNurbsCurveTransformed怎么用?C++ MDataHandle::asNurbsCurveTransformed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::asNurbsCurveTransformed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute
MStatus arcLen::compute( const MPlug& plug, MDataBlock& data )
{
MStatus status;
if( plug == output )
{
MDataHandle inputData = data.inputValue( inputCurve, &status );
if( !status ) {
status.perror("ERROR getting data");
} else {
MObject curve = inputData.asNurbsCurveTransformed();
MFnNurbsCurve curveFn( curve, &status );
if( !status ) {
status.perror("ERROR creating curve function set");
} else {
double result = curveFn.length();
MDataHandle outputHandle = data.outputValue( arcLen::output );
outputHandle.set( result );
data.setClean(plug);
}
}
} else {
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
示例2: 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);
//.........这里部分代码省略.........
示例3: compute
MStatus multiCurve::compute( const MPlug& plug, MDataBlock& data )
{
MStatus stat;
if ( plug == outputCurves )
{
MDataHandle numCurvesHandle = data.inputValue(numCurves, &stat);
PERRORfail(stat, "multiCurve::compute getting numCurves");
int num = numCurvesHandle.asLong();
MDataHandle curveOffsetHandle = data.inputValue(curveOffset, &stat);
PERRORfail(stat, "multiCurve::compute getting curveOffset");
double baseOffset = curveOffsetHandle.asDouble();
MDataHandle inputCurveHandle = data.inputValue(inputCurve, &stat);
PERRORfail(stat, "multiCurve::compute getting inputCurve");
MObject inputCurveObject ( inputCurveHandle.asNurbsCurveTransformed() );
MFnNurbsCurve inCurveFS ( inputCurveObject );
MArrayDataHandle outputArray = data.outputArrayValue(outputCurves,
&stat);
PERRORfail(stat, "multiCurve::compute getting output data handle");
// Create an array data build that is preallocated to hold just
// the number of curves we plan on creating. When this builder
// is set in to the MArrayDataHandle at the end of the compute
// method, the new array will replace the existing array in the
// scene.
//
// If the number of elements of the multi does not change between
// compute cycles, then one can reuse the space allocated on a
// previous cycle by extracting the existing builder from the
// MArrayDataHandle:
// MArrayDataBuilder builder( outputArray.builder(&stat) );
// this later form of the builder will allow you to rewrite elements
// of the array, and to grow it, but the array can only be shrunk by
// explicitly removing elements with the method
// MArrayDataBuilder::removeElement(unsigned index);
//
MArrayDataBuilder builder(outputCurves, num, &stat);
PERRORfail(stat, "multiCurve::compute creating builder");
for (int curveNum = 0; curveNum < num; curveNum++) {
MDataHandle outHandle = builder.addElement(curveNum);
MFnNurbsCurveData dataCreator;
MObject outCurveData = dataCreator.create();
MObject outputCurve = inCurveFS.copy(inputCurveObject,
outCurveData, &stat);
PERRORfail(stat, "multiCurve::compute copying curve");
MFnNurbsCurve outCurveFS ( outputCurve );
MPointArray cvs;
double offset = baseOffset * (curveNum+1);
outCurveFS.getCVs ( cvs, MSpace::kWorld );
int numCVs = cvs.length();
for (int i = 0; i < numCVs; i++) {
cvs[i].x += offset;
}
outCurveFS.setCVs ( cvs );
outHandle.set(outCurveData);
}
// Set the builder back into the output array. This statement
// is always required, no matter what constructor was used to
// create the builder.
stat = outputArray.set(builder);
PERRORfail(stat, "multiCurve::compute setting the builder");
// Since we compute all the elements of the array, instead of
// just marking the plug we were asked to compute as clean, mark
// every element of the array as clean to prevent further calls
// to this compute method during this DG evaluation cycle.
stat = outputArray.setAllClean();
PERRORfail(stat, "multiCurve::compute cleaning outputCurves");
} else {
return MS::kUnknownParameter;
}
return stat;
}