// The initialize routine is called after the node has been created. // It sets up the input and output attributes and adds them to the // node. Finally the dependencies are arranged so that when the // inputs change Maya knowns to call compute to recalculate the output // value. // MStatus stringFormat::initialize() { MFnNumericAttribute numAttr; MFnTypedAttribute typedAttr; MFnStringData stringData; MStatus stat; MStatus stat2; // Setup the input attributes // attrFormat = typedAttr.create("format", "f", MFnData::kString, stringData.create(&stat2), &stat); CHECK_MSTATUS( stat2 ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( typedAttr.setStorable( true ) ); CHECK_MSTATUS( typedAttr.setKeyable( true ) ); attrValues = numAttr.create("values", "v", MFnNumericData::kDouble, 0, &stat); CHECK_MSTATUS( stat ); CHECK_MSTATUS( numAttr.setArray( true ) ); CHECK_MSTATUS( numAttr.setReadable( false ) ); CHECK_MSTATUS( numAttr.setIndexMatters( true ) ); CHECK_MSTATUS( numAttr.setStorable( true ) ); CHECK_MSTATUS( numAttr.setKeyable( true ) ); attrOutput = typedAttr.create( "output", "o", MFnData::kString, stringData.create(&stat2), &stat); CHECK_MSTATUS( stat2 ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( typedAttr.setWritable( false ) ); CHECK_MSTATUS( typedAttr.setStorable( false ) ); // Add the attributes to the node // CHECK_MSTATUS( addAttribute( attrFormat ) ); CHECK_MSTATUS( addAttribute( attrValues ) ); CHECK_MSTATUS( addAttribute( attrOutput ) ); // Set the attribute dependencies // CHECK_MSTATUS( attributeAffects( attrFormat, attrOutput ) ); CHECK_MSTATUS( attributeAffects( attrValues, attrOutput ) ); return MS::kSuccess; }
MStatus snapDeformer::initialize() { MStatus stat; MFnNumericAttribute FnNumeric; MFnNumericAttribute FnNumericA; MFnTypedAttribute FnTyped; MFnEnumAttribute FnEnum; //weight weight = FnNumeric.create("weight", "we", MFnNumericData::kFloat); FnNumeric.setKeyable(true); FnNumeric.setStorable(true); FnNumeric.setReadable(true); FnNumeric.setWritable(true); FnNumeric.setDefault( 1.0 ); addAttribute( weight ); ///space target space = FnEnum.create("space", "sp", 0); FnEnum.addField("world",0); FnEnum.addField("object",1); FnEnum.setStorable(true); FnEnum.setKeyable(true); addAttribute(space); ///space source spaceSource = FnEnum.create("spaceSource", "sps", 0); FnEnum.addField("world",0); FnEnum.addField("object",1); FnEnum.setStorable(true); FnEnum.setKeyable(true); addAttribute(spaceSource); //pointlist pointList = FnNumericA.create("pointList", "pl", MFnNumericData::kInt); FnNumericA.setArray( true ); FnNumericA.setKeyable(false); FnNumericA.setStorable(true); FnNumericA.setReadable(true); FnNumericA.setWritable(true); FnNumericA.setIndexMatters(true); addAttribute( pointList ); //snapMesh snapMesh = FnTyped.create("snapMesh", "sm", MFnData::kMesh); FnTyped.setArray( false ); FnTyped.setReadable(true); FnTyped.setWritable(true); addAttribute( snapMesh ); attributeAffects(snapMesh, outputGeom); attributeAffects(pointList, outputGeom); attributeAffects(space, outputGeom); attributeAffects(spaceSource, outputGeom); attributeAffects(weight, outputGeom); return stat; }