MStatus liqLightNodeBehavior::connectNodeToAttr( MObject &sourceNode, MPlug &destinationPlug, bool force ) { //CM_TRACE_FUNC("liqLightNodeBehavior::connectNodeToAttr("<<sourceNode.apiTypeStr()<<","<< destinationPlug.name()<<","<<force<<")"); MStatus result = MS::kFailure; MFnDependencyNode src(sourceNode); /* if we are dragging from a liquidLight to a light then connect the assignedObjects plug to the plug being passed in */ if(destinationPlug.node().hasFn(MFn::kLight)) { if(src.typeName() == "liquidLight") { MPlug srcPlug = src.findPlug("assignedObjects"); MObject dstNode = destinationPlug.node(); MFnDependencyNode dst( dstNode ); MPlug dstPlug = dst.findPlug("liquidLightShaderNode"); if(!srcPlug.isNull() && !destinationPlug.isNull() && destinationPlug == dstPlug ) { //MString boolean = (force)? "true":"false"; MString cmd = "connectAttr "; //cmd += "-force " + boolean + " "; cmd += srcPlug.name() + " "; cmd += destinationPlug.name(); result = MGlobal::executeCommand(cmd); } } } else { /* in all of the other cases we do not need the plug just the node that it is on */ MObject destinationNode = destinationPlug.node(); result = connectNodeToNode(sourceNode, destinationNode, force); } return result; }
MStatus slopeShaderBehavior::connectNodeToAttr( MObject &sourceNode, MPlug &destinationPlug, bool force ) // // Description: // Overloaded function from MPxDragAndDropBehavior // this method will assign the correct output from the slope shader // onto the given attribute. // { MStatus result = MS::kFailure; MFnDependencyNode src(sourceNode); //if we are dragging from a slopeShader //to a shader than connect the outColor //plug to the plug being passed in // if(destinationPlug.node().hasFn(MFn::kLambert)) { if(src.typeName() == "slopeShader") { MPlug srcPlug = src.findPlug("outColor"); if(!srcPlug.isNull() && !destinationPlug.isNull()) { MString cmd = "connectAttr "; cmd += srcPlug.name() + " "; cmd += destinationPlug.name(); result = MGlobal::executeCommand(cmd); } } } else { //in all of the other cases we do not need the plug just the node //that it is on // MObject destinationNode = destinationPlug.node(); result = connectNodeToNode(sourceNode, destinationNode, force); } return result; }