我想通过MEL脚本在Maya中创建NURBS曲线,将其绑定到我的插件并简单地更新插件中的CV(以及视口中)。问题是我认为不可能读取和写入相同的形状。这是MEL代码:
curve -p 0 10 0 -p 5 0 0 -p 5 0 5 -p 0 0 5;
createNode FurrySystemNode -n furry;
connectAttr time1.outTime furry.time;
connectAttr curveShape1.local furry.input_curve;
connectAttr furry.output_curve curveShape1.create
其中input_curve
和output_curve
是插件中的类型属性。尝试创建MFnNurbsCurve
时失败,因为curve_obj
为空。如果我写另一个形状作为输出它可以正常工作。
MStatus FurrySystemNode::compute(const MPlug& plug, MDataBlock& data) {
if (plug == output_curve) {
cout << "Computing input_curve\n";
MStatus stat;
MDataHandle handle = data.inputValue(input_curve, &stat);
MDataHandle output_handle = data.outputValue(output_curve, &stat);
McheckErr(stat, "Failed at getting data.inputValue\n");
MObject curve_obj = handle.data();
MFnNurbsCurve curve_fn(curve_obj, &stat);
McheckErr(stat, "Failed at creating the MFnNurbsCurve function set\n"); // Fails here
MPointArray cvs;
stat = curve_fn.getCVs(cvs, MSpace::kWorld);
for (int i = 0; i < cvs.length(); i++) {
cvs[i] += MPoint(i, 0, 0);
}
curve_fn.setCVs(cvs, MSpace::kWorld);
curve_fn.updateCurve(); // Don't think this one is needed
output_handle.set(curve_obj);
stat = data.setClean(plug);
McheckErr(stat, "Failed at cleaning data\n");
}
return MS::kSuccess;
}
有什么想法吗?