/* override */ MStatus offset::accessoryNodeSetup(MDagModifier& cmd) // // Description: // This method is called when the deformer is created by the // "deformer" command. You can add to the cmds in the MDagModifier // cmd in order to hook up any additional nodes that your node needs // to operate. // // In this example, we create a locator and attach its matrix attribute // to the matrix input on the offset node. The locator is used to // set the direction and scale of the random field. // // Description: // This method is optional. // { MStatus result; // hook up the accessory node // MObject objLoc = cmd.createNode(MString("locator"), MObject::kNullObj, &result); if (MS::kSuccess == result) { MFnDependencyNode fnLoc(objLoc); MString attrName; attrName.set("matrix"); MObject attrMat = fnLoc.attribute(attrName); result = cmd.connect(objLoc,attrMat,this->thisMObject(),offset::offsetMatrix); } return result; }
void atomImport::connectionFailedCallback(MPlug& srcPlug, MPlug& dstPlug, const MString& srcName, const MString& dstName, void* clientData) { // MString output = "Connection failed callback: "; // output += srcName; output += " "; output += dstName; // MGlobal::displayInfo(output); atomEditsHelper* helper = (NULL != clientData) ? (atomEditsHelper*)clientData : NULL; atomNodeNameReplacer* replacer = (NULL != helper) ? helper->fReplacer : NULL; atomTemplateReader* templateReader = (NULL != helper) ? helper->fTemplateReader : NULL; if (NULL != replacer && srcPlug.isNull()) { // Import of the edits didn't find a match for the source name, use the // replacer and see if that helps // if (replaceNameAndFindPlug(srcName,*replacer,srcPlug)) { if (!dstPlug.isNull()) { // we've found the proper source plug to use and we already // had a dest, so connect them up and we're done // MDagModifier mod; mod.connect(srcPlug,dstPlug); return; } } } if (NULL != replacer && dstPlug.isNull()) { // Import of the edits didn't find a match for the dest name, use the // replacer and see if that helps // if (replaceNameAndFindPlug(dstName,*replacer,dstPlug)) { MStringArray dstParts; dstName.split('.', dstParts); if (!checkPlugAgainstTemplate(dstParts[0],dstPlug,templateReader)) return; if (!srcPlug.isNull()) { // we've found the proper dest plug to use and we already // had a source, so connect them up and we're done // MDagModifier mod; mod.connect(srcPlug,dstPlug); return; } } } if (!dstPlug.isNull()) { MObject dstNode = dstPlug.node(); // Check whether the failed connection was to a setDrivenKey curve // if (dstNode.hasFn(MFn::kAnimCurveUnitlessToAngular) || dstNode.hasFn(MFn::kAnimCurveUnitlessToDistance) || dstNode.hasFn(MFn::kAnimCurveUnitlessToTime) || dstNode.hasFn(MFn::kAnimCurveUnitlessToUnitless)) { // If so, create a stand-in driver for that curve // MDagModifier mod; MObject locator = mod.createNode( "locator", MObject::kNullObj ); MFnDependencyNode fnLoc(locator); MStringArray nameParts; srcName.split('.', nameParts); MString leafAttr(nameParts[nameParts.length()-1]); MPlug leafPlug = fnLoc.findPlug(leafAttr); if (!leafPlug.isNull()) { mod.connect(leafPlug,dstPlug); // rename the locator to the name of the original source // so that any subsequent connections will work // fnLoc.setName(nameParts[0]); } } } }