MStatus sgIkSmoothStretch::initialize() { MStatus stat; MFnNumericAttribute nAttr; aInputDistance = nAttr.create( "inputDistance", "in", MFnNumericData::kDouble, 0.0 ); nAttr.setArray( true ); nAttr.setUsesArrayDataBuilder( true ); nAttr.setStorable( true ); aInPositionX = nAttr.create( "inPositionX", "ipx", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aInPositionY = nAttr.create( "inPositionY", "ipy", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aInPositionZ = nAttr.create( "inPositionZ", "ipz", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aInPosition = nAttr.create( "inPosition", "ip", aInPositionX, aInPositionY, aInPositionZ ); aOutputDistance = nAttr.create( "outputDistance", "out", MFnNumericData::kDouble, 0,0 ); nAttr.setArray( true ); nAttr.setUsesArrayDataBuilder( true ); nAttr.setStorable( false ); nAttr.setWritable( false ); aSmoothArea = nAttr.create( "smoothArea", "smoothArea", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aStretchAble = nAttr.create( "stretchAble", "sa", MFnNumericData::kFloat, 1.0 ); nAttr.setStorable( true ); nAttr.setMin( 0.0 ); nAttr.setMax( 1 ); stat = addAttribute( aInputDistance ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aInPosition ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aOutputDistance ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aStretchAble ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aSmoothArea ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = attributeAffects( aInputDistance, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aInPosition, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aStretchAble, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aSmoothArea, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus BCIViz::initialize() { MFnNumericAttribute numFn; MFnMatrixAttribute matAttr; MStatus stat; ainput = matAttr.create( "input", "in", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setConnectable(true); addAttribute(ainput); atargets = matAttr.create( "target", "tgt", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setArray(true); matAttr.setConnectable(true); addAttribute(atargets); outValue = numFn.create( "outValue", "ov", MFnNumericData::kDouble ); numFn.setStorable(false); numFn.setWritable(false); numFn.setReadable(true); numFn.setArray(true); numFn.setUsesArrayDataBuilder( true ); addAttribute(outValue); attributeAffects(ainput, outValue); attributeAffects(atargets, outValue); return MS::kSuccess; }
MStatus weightList::initialize() { MStatus status; MFnNumericAttribute numAtt; aBias = numAtt.create( "bias", "b", MFnNumericData::kFloat); addAttribute(aBias); aWeights = numAtt.create("weights", "w", MFnNumericData::kFloat, -1000.0, &status); numAtt.setKeyable(true); numAtt.setArray(true); numAtt.setReadable(true); numAtt.setUsesArrayDataBuilder(true); // setIndexMatters() will only affect array attributes with setReadable set to false, // i.e. destination attributes. We have set the default value to an unlikely value // to guarantee an entry is created regardless of its value. // numAtt.setIndexMatters(true); addAttribute(aWeights); MFnCompoundAttribute cmpAttr; aWeightsList = cmpAttr.create("weightsList", "wl", &status); cmpAttr.setArray(true); cmpAttr.addChild(aWeights); cmpAttr.setReadable(true); cmpAttr.setUsesArrayDataBuilder(true); // cmpAttr.setIndexMatters(true); addAttribute(aWeightsList); attributeAffects(aBias, aWeightsList); return MStatus::kSuccess; }
MStatus VolumePushCollider::initialize() { MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; // inCollider aInCollider = mAttr.create("inCollider", "col"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(aInCollider)); // inVolume aInVolume = mAttr.create("inVolume", "vol"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(aInVolume)); // output aOutput = nAttr.create("output", "out", MFnNumericData::kDouble, 0.0); nAttr.setArray(true); nAttr.setReadable(true); nAttr.setWritable(true); nAttr.setHidden(true); CHECK_MSTATUS(addAttribute(aOutput)); attributeAffects(aInCollider, aOutput); attributeAffects(aInVolume, aOutput); return MS::kSuccess; }
MStatus clusterControledCurve::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; MFnTypedAttribute tAttr; MFnCompoundAttribute cAttr; aInputCurve = tAttr.create( "inputCurve", "inputCurve", MFnData::kNurbsCurve ); tAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aInputCurve ) ); aInputCurveMatrix = mAttr.create( "inputCurveMatrix", "inputCurveMatrix" ); mAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aInputCurveMatrix ) ); aDumyMatrix = mAttr.create( "dumyMatrix", "dumyMatrix" ); mAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aDumyMatrix ) ); aBindPreMatrix = mAttr.create( "bindPreMatrix", "bindPreMatrix" ); mAttr.setStorable( true ); mAttr.setArray( true ); nAttr.setUsesArrayDataBuilder( true ); CHECK_MSTATUS( addAttribute( aBindPreMatrix ) ); aMatrix = mAttr.create( "matrix", "matrix" ); mAttr.setStorable( true ); mAttr.setArray( true ); CHECK_MSTATUS( addAttribute( aMatrix ) ); aWeightList = cAttr.create( "weightList", "weightList" ); aWeights = nAttr.create( "weights", "weights", MFnNumericData::kFloat, 0.0 ); nAttr.setArray( true ); nAttr.setUsesArrayDataBuilder( true ); cAttr.addChild( aWeights ); cAttr.setArray( true ); cAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aWeightList ) ); aUpdate = nAttr.create( "update", "update", MFnNumericData::kBoolean, false ); nAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aUpdate ) ); aOutputCurve = tAttr.create( "outputCurve", "outputCurve", MFnData::kNurbsCurve ); CHECK_MSTATUS( addAttribute( aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aInputCurve, aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aInputCurveMatrix, aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aDumyMatrix, aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aBindPreMatrix, aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aMatrix, aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aWeightList, aOutputCurve ) ); CHECK_MSTATUS( attributeAffects( aUpdate, aOutputCurve ) ); return MS::kSuccess; }
// init of plugin MStatus weightControllerNode::initialize(){ MFnNumericAttribute nAttr; aOutputs = nAttr.create("outputs", "out", MFnNumericData::kFloat, 0.0); nAttr.setArray(true); nAttr.setUsesArrayDataBuilder(true); addAttribute(aOutputs); aLocator = nAttr.create("locator", "lc", MFnNumericData::k3Float); addAttribute(aLocator); attributeAffects( aLocator, aOutputs ); aVertices = nAttr.create("vertices", "v", MFnNumericData::k3Float); nAttr.setArray(true); nAttr.setUsesArrayDataBuilder(true); addAttribute(aVertices); attributeAffects( aVertices, aOutputs); return MS::kSuccess; }
// 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 TestDeformer::initialize() { MFnNumericAttribute numericAttr; MFnTypedAttribute polyMeshAttr; MFnEnumAttribute enumAttr; MStatus status; // Status will be used to hold the MStatus value // vertSnapInput driver_mesh = polyMeshAttr.create( "vertSnapInput", "vsnpin", MFnData::kMesh, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( polyMeshAttr.setStorable( false ) ); CHECK_MSTATUS( polyMeshAttr.setArray(true) ); CHECK_MSTATUS( polyMeshAttr.setConnectable( true ) ); CHECK_MSTATUS( addAttribute(driver_mesh) ); CHECK_MSTATUS( attributeAffects(driver_mesh, outputGeom) ); // initialize is used to mark this node's state initialized_data = enumAttr.create( "initialize", "inl", 0/*default*/, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( enumAttr.addField( "Off", 0) ); CHECK_MSTATUS( enumAttr.addField( "Re-Set Bind", 1) ); CHECK_MSTATUS( enumAttr.addField( "Bound", 2) ); CHECK_MSTATUS( enumAttr.setKeyable(true) ); CHECK_MSTATUS( enumAttr.setStorable(true) ); CHECK_MSTATUS( enumAttr.setReadable(true) ); CHECK_MSTATUS( enumAttr.setWritable(true) ); CHECK_MSTATUS( enumAttr.setDefault(0) ); CHECK_MSTATUS( addAttribute( initialized_data ) ); CHECK_MSTATUS( attributeAffects( initialized_data, outputGeom ) ); // hold the vertex index mapping vert_map = numericAttr.create( "vtxIndexMap", "vtximp", MFnNumericData::kLong, 0/*default*/, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( numericAttr.setKeyable(false) ); CHECK_MSTATUS( numericAttr.setArray(true) ); CHECK_MSTATUS( numericAttr.setStorable(true) ); CHECK_MSTATUS( numericAttr.setReadable(true) ); CHECK_MSTATUS( numericAttr.setWritable(true) ); CHECK_MSTATUS( addAttribute( vert_map ) ); CHECK_MSTATUS( attributeAffects( vert_map, outputGeom ) ); CHECK_MSTATUS( MGlobal::executePythonCommand("import maya.cmds; maya.cmds.makePaintable('"+TestDeformer::cTypeName()+"', 'weights', attrType='multiFloat')") ); return( MS::kSuccess ); }
MStatus vixo_visImport::initialize() { MFnNumericAttribute nAttr; vis=nAttr.create("visibility","vis",MFnNumericData::kBoolean,1); nAttr.setArray(true); MFnUnitAttribute uAttr; time=uAttr.create("time","t",MFnUnitAttribute::Type::kTime,1); MFnTypedAttribute tAttr; file=tAttr.create("file","f",MFnData::kString); tAttr.setStorable(true); addAttribute(time); addAttribute(file); addAttribute(vis); attributeAffects(time,vis); attributeAffects(file,vis); 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; }
MStatus n_tentacle::initialize() { MFnNumericAttribute numericAttr; MFnMatrixAttribute matrixAttr; MFnTypedAttribute typedAttr; MFnUnitAttribute unitAttribute; MFnEnumAttribute enumAttr; MStatus stat; stretch = numericAttr.create("stretch", "st", MFnNumericData::kDouble, 0.0); numericAttr.setMin(0.0); numericAttr.setMax(1.0); globalScale = numericAttr.create("globalScale", "gs", MFnNumericData::kDouble, 1.0); numericAttr.setMin(0.00001); numericAttr.setMax(10.0); iniLength = numericAttr.create("iniLength", "iln", MFnNumericData::kDouble, 0.01); parameter = numericAttr.create("parameter", "prm", MFnNumericData::kDouble, 0.0); numericAttr.setArray(true); blendRot = numericAttr.create("blendRot", "blr", MFnNumericData::kDouble, 0.0); numericAttr.setArray(true); interval = numericAttr.create("interval", "itv", MFnNumericData::kInt, 0); numericAttr.setArray(true); matrix = matrixAttr.create("matrix", "mtx"); matrixAttr.setArray(true); matrixAttr.setHidden(true); curve = typedAttr.create("curve", "crv", MFnData::kNurbsCurve); outTranslate = numericAttr.create("outTranslate", "ot", MFnNumericData::k3Double); numericAttr.setArray(true); numericAttr.setHidden(true); numericAttr.setUsesArrayDataBuilder(true); numericAttr.setHidden(true); outRotateX = unitAttribute.create("outRotateX", "orx", MFnUnitAttribute::kAngle); outRotateY = unitAttribute.create("outRotateY", "ory", MFnUnitAttribute::kAngle); outRotateZ = unitAttribute.create("outRotateZ", "orz", MFnUnitAttribute::kAngle); outRotate = numericAttr.create("outRotate", "or",outRotateX, outRotateY, outRotateZ); numericAttr.setArray(true); numericAttr.setHidden(true); numericAttr.setUsesArrayDataBuilder(true); numericAttr.setHidden(true); tangentAxis = enumAttr.create("tangentAxis", "tga", 1); enumAttr.addField("X", 0); enumAttr.addField("Y", 1); enumAttr.addField("Z", 2); enumAttr.addField("negativeX", 3); enumAttr.addField("negativeY", 4); enumAttr.addField("negativeZ", 5); // Add the attributes we have created to the node // stat = addAttribute( parameter ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( blendRot ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( interval ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( stretch ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( globalScale ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( iniLength ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( matrix ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( curve ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( outTranslate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( outRotate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( tangentAxis ); if (!stat) { stat.perror("addAttribute"); return stat;} attributeAffects( parameter, outTranslate ); attributeAffects( blendRot, outTranslate ); attributeAffects( interval, outTranslate ); attributeAffects( stretch, outTranslate ); attributeAffects( globalScale, outTranslate ); attributeAffects( iniLength, outTranslate ); attributeAffects( matrix, outTranslate ); attributeAffects( curve, outTranslate ); attributeAffects( tangentAxis, outTranslate ); attributeAffects( parameter, outRotate ); attributeAffects( blendRot, outRotate ); attributeAffects( interval, outRotate ); attributeAffects( stretch, outRotate ); attributeAffects( globalScale, outRotate ); attributeAffects( iniLength, outRotate ); attributeAffects( matrix, outRotate ); attributeAffects( curve, outRotate ); attributeAffects( tangentAxis, outRotate ); attributeAffects( parameter, outRotateX ); attributeAffects( blendRot, outRotateX ); attributeAffects( interval, outRotateX ); attributeAffects( stretch, outRotateX ); attributeAffects( globalScale, outRotateX ); attributeAffects( iniLength, outRotateX ); attributeAffects( matrix, outRotateX ); attributeAffects( curve, outRotateX ); attributeAffects( tangentAxis, outRotateX ); attributeAffects( parameter, outRotateY ); attributeAffects( blendRot, outRotateY ); attributeAffects( interval, outRotateY ); attributeAffects( stretch, outRotateY ); attributeAffects( globalScale, outRotateY ); attributeAffects( iniLength, outRotateY ); attributeAffects( matrix, outRotateY ); attributeAffects( curve, outRotateY ); attributeAffects( tangentAxis, outRotateY ); attributeAffects( parameter, outRotateZ ); attributeAffects( blendRot, outRotateZ ); attributeAffects( interval, outRotateZ ); attributeAffects( stretch, outRotateZ ); attributeAffects( globalScale, outRotateZ ); attributeAffects( iniLength, outRotateZ ); attributeAffects( matrix, outRotateZ ); attributeAffects( curve, outRotateZ ); attributeAffects( tangentAxis, outRotateZ ); return MS::kSuccess; }
MStatus curveColliderLocator::initialize() { MFnNumericAttribute nAttr; MStatus stat; colliderRadiusIn = nAttr.create( "radius", "rd", MFnNumericData::kDouble ); nAttr.setDefault(1.0); nAttr.setMin(0); nAttr.setKeyable(true); nAttr.setArray(true); nAttr.setStorable(true); nAttr.setWritable(true); stat = addAttribute(colliderRadiusIn); if (!stat) { stat.perror("Could not add colliderRadiusIn attribute"); return stat; } // CREATE AND ADD ".inCurve" ATTRIBUTE: MFnTypedAttribute inCurveAttrFn; colliderCurveIn = inCurveAttrFn.create("colliderCurve", "ic", MFnData::kNurbsCurve); inCurveAttrFn.setStorable(true); inCurveAttrFn.setKeyable(false); inCurveAttrFn.setReadable(true); inCurveAttrFn.setWritable(true); inCurveAttrFn.setCached(false); stat = addAttribute(colliderCurveIn); if (!stat) { stat.perror("Could not add colliderCurveIn attribute"); return stat; } MFnMatrixAttribute mAttr; colliderXform =mAttr.create("colliderXfm", "cx"); mAttr.setReadable(false); mAttr.setKeyable(false); mAttr.setConnectable(true); stat = addAttribute( colliderXform ); if (!stat) { stat.perror("Could not add colliderXform attribute"); return stat; } colliderColorR = nAttr.create( "colorR", "clr", MFnNumericData::kFloat ); nAttr.setDefault(0.2f); nAttr.setMin(0.0f); nAttr.setMax(1.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setReadable(true); nAttr.setWritable(true); stat = addAttribute(colliderColorR); if (!stat) { stat.perror("Could not add colliderColorR attribute"); return stat; } colliderColorG = nAttr.create( "colorG", "clg", MFnNumericData::kFloat ); nAttr.setDefault(0.2f); nAttr.setMin(0.0f); nAttr.setMax(1.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setReadable(true); nAttr.setWritable(true); stat = addAttribute(colliderColorG); if (!stat) { stat.perror("Could not add colliderColorG attribute"); return stat; } colliderColorB = nAttr.create( "colorB", "clb", MFnNumericData::kFloat ); nAttr.setDefault(0.8f); nAttr.setMin(0.0f); nAttr.setMax(1.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setReadable(true); nAttr.setWritable(true); stat = addAttribute(colliderColorB); if (!stat) { stat.perror("Could not add colliderColorB attribute"); return stat; } colliderTransparency = nAttr.create( "colorT", "clt", MFnNumericData::kFloat ); nAttr.setDefault(1.0f); nAttr.setMin(0.0f); nAttr.setMax(1.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setReadable(true); nAttr.setWritable(true); stat = addAttribute(colliderTransparency); if (!stat) { stat.perror("Could not add colliderTransparency attribute"); return stat; } return MS::kSuccess; }
MStatus AlembicNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; // add the input attributes: time, file, sequence time mTimeAttr = uAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = addAttribute(mTimeAttr); // input file name MFnStringData fileFnStringData; MObject fileNameDefaultObject = fileFnStringData.create(""); mAbcFileNameAttr = tAttr.create("abc_File", "fn", MFnData::kString, fileNameDefaultObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = addAttribute(mAbcFileNameAttr); // playback speed mSpeedAttr = nAttr.create("speed", "sp", MFnNumericData::kDouble, 1.0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mSpeedAttr); // frame offset mOffsetAttr = nAttr.create("offset", "of", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mOffsetAttr); // cycle type mCycleTypeAttr = eAttr.create("cycleType", "ct", 0, &status ); status = eAttr.addField("Hold", PLAYTYPE_HOLD); status = eAttr.addField("Loop", PLAYTYPE_LOOP); status = eAttr.addField("Reverse", PLAYTYPE_REVERSE); status = eAttr.addField("Bounce", PLAYTYPE_BOUNCE); status = eAttr.setWritable(true); status = eAttr.setStorable(true); status = eAttr.setKeyable(true); status = addAttribute(mCycleTypeAttr); // Regex Filter // This is a hidden variable to preserve a regexIncludefilter string // into a .ma file. mIncludeFilterAttr = tAttr.create("regexIncludeFilter", "ift", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mIncludeFilterAttr); // Regex Filter // This is a hidden variable to preserve a regexExcludefilter string // into a .ma file. mExcludeFilterAttr = tAttr.create("regexExcludeFilter", "eft", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mExcludeFilterAttr); // sequence min and max in frames mStartFrameAttr = nAttr.create("startFrame", "sf", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mStartFrameAttr); mEndFrameAttr = nAttr.create("endFrame", "ef", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mEndFrameAttr); // add the output attributes // sampled subD mesh MFnMeshData fnMeshData; MObject meshDefaultObject = fnMeshData.create(&status); mOutSubDArrayAttr = tAttr.create("outSubDMesh", "osubd", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutSubDArrayAttr); // sampled poly mesh mOutPolyArrayAttr = tAttr.create("outPolyMesh", "opoly", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPolyArrayAttr); // sampled nurbs surface MFnNurbsSurfaceData fnNSData; MObject nsDefaultObject = fnNSData.create(&status); mOutNurbsSurfaceArrayAttr = tAttr.create("outNSurface", "ons", MFnData::kNurbsSurface, nsDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsSurfaceArrayAttr); // sampled nurbs curve group MFnNurbsCurveData fnNCData; MObject ncDefaultObject = fnNCData.create(&status); mOutNurbsCurveGrpArrayAttr = tAttr.create("outNCurveGrp", "onc", MFnData::kNurbsCurve, ncDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsCurveGrpArrayAttr); // sampled locator mOutLocatorPosScaleArrayAttr = nAttr.create("outLoc", "olo", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutLocatorPosScaleArrayAttr); // sampled transform operations mOutTransOpArrayAttr = nAttr.create("transOp", "to", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutTransOpArrayAttr); // sampled camera // assume the boolean variables cannot be keyed mOutCameraArrayAttr = nAttr.create("outCamera", "ocam", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutCameraArrayAttr); // sampled custom-attributes mOutPropArrayAttr = gAttr.create("prop", "pr", &status); status = gAttr.addNumericDataAccept(MFnNumericData::kBoolean); status = gAttr.addNumericDataAccept(MFnNumericData::kByte); status = gAttr.addNumericDataAccept(MFnNumericData::kShort); status = gAttr.addNumericDataAccept(MFnNumericData::k2Short); status = gAttr.addNumericDataAccept(MFnNumericData::k3Short); status = gAttr.addNumericDataAccept(MFnNumericData::kInt); status = gAttr.addNumericDataAccept(MFnNumericData::k2Int); status = gAttr.addNumericDataAccept(MFnNumericData::k3Int); status = gAttr.addNumericDataAccept(MFnNumericData::kFloat); status = gAttr.addNumericDataAccept(MFnNumericData::k2Float); status = gAttr.addNumericDataAccept(MFnNumericData::k3Float); status = gAttr.addNumericDataAccept(MFnNumericData::kDouble); status = gAttr.addNumericDataAccept(MFnNumericData::k2Double); status = gAttr.addNumericDataAccept(MFnNumericData::k3Double); status = gAttr.addNumericDataAccept(MFnNumericData::k4Double); status = gAttr.addDataAccept(MFnData::kString); status = gAttr.addDataAccept(MFnData::kIntArray); status = gAttr.addDataAccept(MFnData::kDoubleArray); status = gAttr.addDataAccept(MFnData::kVectorArray); status = gAttr.addDataAccept(MFnData::kPointArray); status = gAttr.setWritable(false); status = gAttr.setKeyable(false); status = gAttr.setArray(true); status = gAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPropArrayAttr); // set up affection relationships status = attributeAffects(mTimeAttr, mOutSubDArrayAttr); status = attributeAffects(mTimeAttr, mOutPolyArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mTimeAttr, mOutTransOpArrayAttr); status = attributeAffects(mTimeAttr, mOutCameraArrayAttr); status = attributeAffects(mTimeAttr, mOutPropArrayAttr); status = attributeAffects(mTimeAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mSpeedAttr, mOutSubDArrayAttr); status = attributeAffects(mSpeedAttr, mOutPolyArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mSpeedAttr, mOutTransOpArrayAttr); status = attributeAffects(mSpeedAttr, mOutCameraArrayAttr); status = attributeAffects(mSpeedAttr, mOutPropArrayAttr); status = attributeAffects(mSpeedAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mOffsetAttr, mOutSubDArrayAttr); status = attributeAffects(mOffsetAttr, mOutPolyArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mOffsetAttr, mOutTransOpArrayAttr); status = attributeAffects(mOffsetAttr, mOutCameraArrayAttr); status = attributeAffects(mOffsetAttr, mOutPropArrayAttr); status = attributeAffects(mOffsetAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutSubDArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPolyArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutTransOpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutCameraArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPropArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutLocatorPosScaleArrayAttr); MGlobal::executeCommand( UITemplateMELScriptStr ); return status; }
// plugin (un)initialiser MStatus nwayDeformerNode::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnMatrixAttribute mAttr; aBlendMesh = tAttr.create("blendMesh", "mesh", MFnData::kMesh); tAttr.setArray(true); tAttr.setUsesArrayDataBuilder(true); addAttribute(aBlendMesh); attributeAffects( aBlendMesh, outputGeom ); aWeight = nAttr.create("blendWeight", "bw", MFnNumericData::kDouble, 0.0); nAttr.setArray(true); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setUsesArrayDataBuilder(true); addAttribute(aWeight); attributeAffects( aWeight, outputGeom ); aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, false ); nAttr.setStorable(true); addAttribute( aRotationConsistency ); attributeAffects( aRotationConsistency, outputGeom ); aInitRotation = nAttr.create("initRotation", "ir", MFnNumericData::kDouble); addAttribute(aInitRotation); attributeAffects( aInitRotation, outputGeom ); aVisualiseEnergy = nAttr.create( "visualiseEnergy", "ve", MFnNumericData::kBoolean, false ); nAttr.setStorable(true); addAttribute( aVisualiseEnergy ); attributeAffects( aVisualiseEnergy, outputGeom ); aVisualisationMultiplier = nAttr.create("visualisationMultiplier", "vmp", MFnNumericData::kDouble, 1.0); nAttr.setStorable(true); addAttribute( aVisualisationMultiplier ); attributeAffects( aVisualisationMultiplier, outputGeom ); aBlendMode = eAttr.create( "blendMode", "bm", BM_SRL ); eAttr.addField( "expSO+expSym", BM_SRL ); eAttr.addField( "logmatrix3", BM_LOG3 ); eAttr.addField( "quat+linear", BM_SQL ); eAttr.addField( "expSO+linear", BM_SlRL ); eAttr.addField( "linear", BM_AFF ); eAttr.addField( "off", BM_OFF ); addAttribute( aBlendMode ); attributeAffects( aBlendMode, outputGeom ); aTetMode = eAttr.create( "tetMode", "tm", TM_FACE ); eAttr.addField( "face", TM_FACE ); eAttr.addField( "edge", TM_EDGE ); eAttr.addField( "vertex", TM_VERTEX ); eAttr.addField( "vface", TM_VFACE ); addAttribute( aTetMode ); attributeAffects( aTetMode, outputGeom ); aIteration = nAttr.create("iteration", "it", MFnNumericData::kShort, 1); addAttribute(aIteration); attributeAffects(aIteration, outputGeom); // this shouldn't affect outputGeom aEnergy = nAttr.create("energy", "energy", MFnNumericData::kDouble, 0.0); nAttr.setArray(true); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setUsesArrayDataBuilder(true); addAttribute(aEnergy); // Make the deformer weights paintable MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer nwayBlender weights;" ); return MS::kSuccess; }
// add some additional inputs MStatus HRBFSkinCluster::initialize() { std::cout << "called initialize" << std::endl; MFnNumericAttribute numAttr; MFnTypedAttribute typedAttr; //MFnCompoundAttribute cmpdAttr; MStatus returnStatus; HRBFSkinCluster::rebuildHRBF = numAttr.create("RebuildHRBF", "rbld", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating rbld attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::rebuildHRBF); McheckErr(returnStatus, "ERROR adding rbld attribute\n"); HRBFSkinCluster::exportComposition = numAttr.create("ExportComp", "exprtC", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating exprtC attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::exportComposition); McheckErr(returnStatus, "ERROR adding exprtC attribute\n"); HRBFSkinCluster::exportHRBFSamples = typedAttr.create("ExportHRBFs", "exprtS", MFnNumericData::kString, &returnStatus); McheckErr(returnStatus, "ERROR creating exprtS attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::exportHRBFSamples); McheckErr(returnStatus, "ERROR adding exprtS attribute\n"); HRBFSkinCluster::exportHRBFValues = typedAttr.create("ExportHRBFv", "exprtV", MFnNumericData::kString, &returnStatus); McheckErr(returnStatus, "ERROR creating exprtV attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::exportHRBFValues); McheckErr(returnStatus, "ERROR adding exprtV attribute\n"); HRBFSkinCluster::useDQ = numAttr.create("UseDualQuaternions", "useDQ", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating useDQ attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::useDQ); McheckErr(returnStatus, "ERROR adding useDQ attribute\n"); HRBFSkinCluster::useHRBF = numAttr.create("UseHRBFCorrection", "useHRBF", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating useHRBF attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::useHRBF); McheckErr(returnStatus, "ERROR adding useHRBF attribute\n"); HRBFSkinCluster::checkHRBFAt = numAttr.create("checkHRBFAt", "chkHRBF", MFnNumericData::k3Double, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating checkHRBFAt attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::checkHRBFAt); McheckErr(returnStatus, "ERROR adding checkHRBFAt attribute\n"); // hierarchy information // http://download.autodesk.com/us/maya/2011help/API/weight_list_node_8cpp-example.html#a15 HRBFSkinCluster::jointParentIdcs = numAttr.create("parentJointIDCS", "pJIDCS", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating pIDCS attribute\n"); numAttr.setArray(true); returnStatus = addAttribute(HRBFSkinCluster::jointParentIdcs); McheckErr(returnStatus, "ERROR adding pIDCS attribute\n"); // joint names HRBFSkinCluster::jointNames = typedAttr.create("jointNames", "jNms", MFnData::kString, &returnStatus); McheckErr(returnStatus, "ERROR creating pIDCS attribute\n"); typedAttr.setArray(true); returnStatus = addAttribute(HRBFSkinCluster::jointNames); McheckErr(returnStatus, "ERROR adding jNms attribute\n"); // set up affects returnStatus = attributeAffects(HRBFSkinCluster::rebuildHRBF, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with rebuildHRBF\n"); returnStatus = attributeAffects(HRBFSkinCluster::exportComposition, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with exportComposition\n"); returnStatus = attributeAffects(HRBFSkinCluster::exportHRBFSamples, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with exportHRBFSamples\n"); returnStatus = attributeAffects(HRBFSkinCluster::exportHRBFValues, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with exportHRBFValues\n"); returnStatus = attributeAffects(HRBFSkinCluster::useDQ, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with useDQ\n"); returnStatus = attributeAffects(HRBFSkinCluster::useHRBF, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with useHRBF\n"); returnStatus = attributeAffects(HRBFSkinCluster::jointParentIdcs, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with jointParentIdcs\n"); returnStatus = attributeAffects(HRBFSkinCluster::checkHRBFAt, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with checkHRBFAt\n"); return returnStatus; }
bool DXMAnchor::AddAnchor(MObject& site, const MString& longAnchorName, const MString& shortAnchorName, DXMAnchor* anchor) { DXCC_ASSERT( DXMAnchor::GetAnchor(site, shortAnchorName) == NULL ); DXCC_ASSERT(anchor != NULL); DXCC_ASSERT(anchor->GetSite().isNull()); DXCC_ASSERT(anchor->GetPoint().length() == 0); DXCC_ASSERT(longAnchorName.length() > 0); DXCC_ASSERT(shortAnchorName.length() > 0); DXCC_ASSERT(!site.isNull()); MFnDependencyNode depNode(site); MString name= depNode.name(); #ifdef DEBUG anchor->Name= name.asChar(); #endif if( g_DebugBasic ) { DXCC_DPFA_REPORT("%s", name.asChar()); } //this attribute may exist if you had asked for this node to be duplicated or instanced :( if( depNode.attribute( shortAnchorName ).isNull() ) { MFnNumericAttribute numeric; MObject anchorAttrib= numeric.create(longAnchorName, shortAnchorName, MFnNumericData::kInt, 0); numeric.setReadable(false); numeric.setWritable(false); numeric.setConnectable(false); numeric.setStorable(false); numeric.setCached(true); numeric.setArray(false); numeric.setKeyable(false); numeric.setHidden(true); numeric.setUsedAsColor(false); numeric.setIndeterminant(true); numeric.setRenderSource(false); numeric.setInternal(false); DXCC_ASSERT(!anchorAttrib.isNull()); DXCHECK_MSTATUS( depNode.addAttribute(anchorAttrib) ); } MPlug anchorPlug= depNode.findPlug( shortAnchorName ); DXCC_ASSERT(!anchorPlug.isNull()); anchorPlug.setValue( *reinterpret_cast<int*>(&anchor) ); anchor->AnchorSite= site; anchor->AnchorPoint= shortAnchorName; // anchor->NodeDestroyedCID= MNodeMessage::addNodeDestroyedCallback(site, DXMAnchor::DispatchNodeDestroyed, anchor); // anchor->AboutToDeleteCID= MNodeMessage::addNodeAboutToDeleteCallback(site, DXMAnchor::DispatchAboutToDelete, anchor); anchor->OnPostAddAnchor(longAnchorName, shortAnchorName); return true; }
MStatus Layered::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; // Status will be used to hold the MStatus value // returned by each api function call. It is important // to check the status returned by a call to aid in // debugging. Failed API calls can result in subtle // errors that can be difficult to track down, you may // wish to use the CHECK_MSTATUS macro for any API // call where you do not need to provide your own // error handling. // baseShader = nAttr.createColor("baseShader", "baseShader"); CHECK_MSTATUS(addAttribute(baseShader)); layerWeight = nAttr.create("layerWeight", "layerWeight", MFnNumericData::kFloat, 0, &status); nAttr.setArray(true); CHECK_MSTATUS(addAttribute(layerWeight)); layerTexture = mAttr.create("layerTexture", "layerTexture"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(layerTexture)); layerShader = nAttr.createColor("layerShader", "layerShader"); nAttr.setArray(true); CHECK_MSTATUS(addAttribute(layerShader)); outColor = nAttr.createColor("outColor", "outColor"); CHECK_MSTATUS(addAttribute(outColor)); //---------------------------- automatically created attributes start ------------------------------------ //---------------------------- automatically created attributes end ------------------------------------ aTranslucenceCoeff = nAttr.create("translucenceCoeff", "tc", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f)); aDiffuseReflectivity = nAttr.create("diffuseReflectivity", "drfl", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(0.8f)); aColor = nAttr.createColor("color", "c", &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.58824f, 0.644f)); aIncandescence = nAttr.createColor("incandescence", "ic", &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.0f, 0.0f)); aInTransparency = nAttr.createColor("transparency", "it", &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.0f, 0.0f)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); aOutTransparency = nAttr.createColor("outTransparency", "ot", &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); // Camera Normals // aNormalCameraX = nAttr.create("normalCameraX", "nx", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aNormalCameraY = nAttr.create("normalCameraY", "ny", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aNormalCameraZ = nAttr.create("normalCameraZ", "nz", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aNormalCamera = nAttr.create("normalCamera", "n", aNormalCameraX, aNormalCameraY, aNormalCameraZ, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f)); CHECK_MSTATUS(nAttr.setHidden(true)); // Light Direction // aLightDirectionX = nAttr.create("lightDirectionX", "ldx", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightDirectionY = nAttr.create("lightDirectionY", "ldy", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightDirectionZ = nAttr.create("lightDirectionZ", "ldz", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightDirection = nAttr.create("lightDirection", "ld", aLightDirectionX, aLightDirectionY, aLightDirectionZ, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f)); // Light Intensity // aLightIntensityR = nAttr.create("lightIntensityR", "lir", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightIntensityG = nAttr.create("lightIntensityG", "lig", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightIntensityB = nAttr.create("lightIntensityB", "lib", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightIntensity = nAttr.create("lightIntensity", "li", aLightIntensityR, aLightIntensityG, aLightIntensityB, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f)); // Light // aLightAmbient = nAttr.create("lightAmbient", "la", MFnNumericData::kBoolean, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(true)); aLightDiffuse = nAttr.create("lightDiffuse", "ldf", MFnNumericData::kBoolean, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(true)); aLightSpecular = nAttr.create("lightSpecular", "ls", MFnNumericData::kBoolean, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(false)); aLightShadowFraction = nAttr.create("lightShadowFraction", "lsf", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aPreShadowIntensity = nAttr.create("preShadowIntensity", "psi", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); aLightBlindData = nAttr.createAddr("lightBlindData", "lbld", &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); aLightData = lAttr.create("lightDataArray", "ltd", aLightDirection, aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, aLightShadowFraction, aPreShadowIntensity, aLightBlindData, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(lAttr.setArray(true)); CHECK_MSTATUS(lAttr.setStorable(false)); CHECK_MSTATUS(lAttr.setHidden(true)); CHECK_MSTATUS(lAttr.setDefault(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, true, true, false, 1.0f, 1.0f, NULL)); // Next we will add the attributes we have defined to the node // CHECK_MSTATUS(addAttribute(aTranslucenceCoeff)); CHECK_MSTATUS(addAttribute(aDiffuseReflectivity)); CHECK_MSTATUS(addAttribute(aColor)); CHECK_MSTATUS(addAttribute(aIncandescence)); CHECK_MSTATUS(addAttribute(aInTransparency)); CHECK_MSTATUS(addAttribute(outColor)); CHECK_MSTATUS(addAttribute(aOutTransparency)); CHECK_MSTATUS(addAttribute(aNormalCamera)); // Only add the parent of the compound CHECK_MSTATUS(addAttribute(aLightData)); CHECK_MSTATUS(attributeAffects(layerTexture, outColor)); CHECK_MSTATUS(attributeAffects(layerWeight, outColor)); CHECK_MSTATUS(attributeAffects(aTranslucenceCoeff, outColor)); CHECK_MSTATUS(attributeAffects(aDiffuseReflectivity, outColor)); CHECK_MSTATUS(attributeAffects(aColor, outColor)); CHECK_MSTATUS(attributeAffects(aInTransparency, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aInTransparency, outColor)); CHECK_MSTATUS(attributeAffects(aIncandescence, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensityR, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensityB, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensityG, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensity, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCameraX, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCameraY, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCameraZ, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCamera, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirectionX, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirectionY, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirectionZ, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirection, outColor)); CHECK_MSTATUS(attributeAffects(aLightAmbient, outColor)); CHECK_MSTATUS(attributeAffects(aLightSpecular, outColor)); CHECK_MSTATUS(attributeAffects(aLightDiffuse, outColor)); CHECK_MSTATUS(attributeAffects(aLightShadowFraction, outColor)); CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, outColor)); CHECK_MSTATUS(attributeAffects(aLightBlindData, outColor)); CHECK_MSTATUS(attributeAffects(aLightData, outColor)); return( MS::kSuccess ); }
// INIT ========================================= MStatus gear_rollSplineKine::initialize() { MFnMatrixAttribute mAttr; MFnNumericAttribute nAttr; MStatus stat; // Inputs Matrices ctlParent = mAttr.create( "ctlParent", "ctlp", MFnMatrixAttribute::kDouble ); mAttr.setStorable(true); mAttr.setReadable(false); mAttr.setIndexMatters(false); mAttr.setArray(true); addAttribute( ctlParent ); inputs = mAttr.create( "inputs", "in", MFnMatrixAttribute::kDouble ); mAttr.setStorable(true); mAttr.setReadable(false); mAttr.setIndexMatters(false); mAttr.setArray(true); addAttribute( inputs ); inputsRoll = nAttr.create ( "inputsRoll", "inr", MFnNumericData::kFloat, 0.0 ); nAttr.setArray(true); nAttr.setStorable(true); addAttribute ( inputsRoll ); outputParent = mAttr.create( "outputParent", "outp" ); mAttr.setStorable(true); mAttr.setKeyable(true); mAttr.setConnectable(true); stat = addAttribute( outputParent ); if (!stat) {stat.perror("addAttribute"); return stat;} // Inputs Sliders u = nAttr.create("u", "u", MFnNumericData::kFloat, 0.0); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMin(0); nAttr.setMax(1); stat = addAttribute( u ); if (!stat) {stat.perror("addAttribute"); return stat;} resample = nAttr.create("resample", "re", MFnNumericData::kBoolean, false); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( resample ); if (!stat) {stat.perror("addAttribute"); return stat;} subdiv = nAttr.create("subdiv", "sd", MFnNumericData::kShort, 10); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMin(3); stat = addAttribute( subdiv ); if (!stat) {stat.perror("addAttribute"); return stat;} absolute = nAttr.create("absolute", "abs", MFnNumericData::kBoolean, false); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( absolute ); if (!stat) {stat.perror("addAttribute"); return stat;} // Outputs output = mAttr.create( "output", "out" ); mAttr.setStorable(false); mAttr.setKeyable(false); mAttr.setConnectable(true); stat = addAttribute( output ); if (!stat) {stat.perror("addAttribute"); return stat;} // Connections stat = attributeAffects ( ctlParent, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( inputs, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( inputsRoll, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( outputParent, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( u, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( resample, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( subdiv, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( absolute, output ); if (!stat) {stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
// create attributes MStatus probeDeformerARAPNode::initialize(){ MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnMatrixAttribute mAttr; MRampAttribute rAttr; // this attr will be dirtied when ARAP recomputation is needed aARAP = nAttr.create( "arap", "arap", MFnNumericData::kBoolean, true ); nAttr.setStorable(false); nAttr.setKeyable(false); nAttr.setHidden(true); addAttribute( aARAP ); // this attr will be dirtied when weight recomputation is needed aComputeWeight = nAttr.create( "computeWeight", "computeWeight", MFnNumericData::kBoolean, true ); nAttr.setStorable(false); nAttr.setKeyable(false); nAttr.setHidden(true); addAttribute( aComputeWeight ); aMatrix = mAttr.create("probeMatrix", "pm"); mAttr.setStorable(false); mAttr.setHidden(true); mAttr.setArray(true); mAttr.setUsesArrayDataBuilder(true); mAttr.setDisconnectBehavior(MFnMatrixAttribute::kDelete); addAttribute(aMatrix); attributeAffects( aMatrix, outputGeom ); aInitMatrix = mAttr.create("initProbeMatrix", "ipm"); mAttr.setHidden(true); mAttr.setArray(true); mAttr.setStorable(true); mAttr.setUsesArrayDataBuilder(true); addAttribute(aInitMatrix); attributeAffects( aInitMatrix, outputGeom ); aBlendMode = eAttr.create( "blendMode", "bm", BM_SRL ); eAttr.addField( "expSO+expSym", BM_SRL ); eAttr.addField( "expSE+expSym", BM_SSE ); eAttr.addField( "logmatrix3", BM_LOG3 ); eAttr.addField( "logmatrix4", BM_LOG4 ); eAttr.addField( "quat+linear", BM_SQL ); eAttr.addField( "linear", BM_AFF ); eAttr.addField( "off", BM_OFF ); eAttr.setStorable(true); eAttr.setKeyable(false); addAttribute( aBlendMode ); attributeAffects( aBlendMode, outputGeom ); aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, false ); nAttr.setKeyable(false); nAttr.setStorable(true); addAttribute( aRotationConsistency ); attributeAffects( aRotationConsistency, outputGeom ); aFrechetSum = nAttr.create( "frechetSum", "fs", MFnNumericData::kBoolean, false ); nAttr.setKeyable(false); nAttr.setStorable(true); addAttribute( aFrechetSum ); attributeAffects( aFrechetSum, outputGeom ); aNormaliseWeight = eAttr.create( "normaliseWeight", "nw", NM_LINEAR ); eAttr.addField( "NONE", NM_NONE ); eAttr.addField( "Linear", NM_LINEAR ); eAttr.addField( "Softmax", NM_SOFTMAX ); eAttr.setStorable(true); addAttribute( aNormaliseWeight ); attributeAffects( aNormaliseWeight, outputGeom ); attributeAffects( aNormaliseWeight, aComputeWeight ); aWeightMode = eAttr.create( "weightMode", "wtm", WM_HARMONIC_COTAN ); eAttr.addField( "inverse", WM_INV_DISTANCE ); eAttr.addField( "cut-off", WM_CUTOFF_DISTANCE ); eAttr.addField( "draw", WM_DRAW ); // eAttr.addField( "harmonic-arap", WM_HARMONIC_ARAP); eAttr.addField( "harmonic-cotan", WM_HARMONIC_COTAN); eAttr.setStorable(true); eAttr.setKeyable(false); addAttribute( aWeightMode ); attributeAffects( aWeightMode, outputGeom ); attributeAffects( aWeightMode, aComputeWeight ); aConstraintMode = eAttr.create( "constraintMode", "ctm", CONSTRAINT_CLOSEST ); eAttr.addField( "neighbour", CONSTRAINT_NEIGHBOUR); eAttr.addField( "closestFace", CONSTRAINT_CLOSEST ); eAttr.setStorable(true); eAttr.setKeyable(false); addAttribute( aConstraintMode ); attributeAffects( aConstraintMode, outputGeom ); attributeAffects( aConstraintMode, aARAP); aTetMode = eAttr.create( "tetMode", "tm", TM_FACE ); eAttr.addField( "face", TM_FACE ); eAttr.addField( "edge", TM_EDGE ); eAttr.addField( "vertex", TM_VERTEX ); eAttr.addField( "vface", TM_VFACE ); eAttr.setStorable(true); eAttr.setKeyable(false); addAttribute( aTetMode ); attributeAffects( aTetMode, outputGeom ); attributeAffects( aTetMode, aARAP ); attributeAffects( aTetMode, aComputeWeight ); aWorldMode = nAttr.create( "worldMode", "wrldmd", MFnNumericData::kBoolean, true ); nAttr.setStorable(true); nAttr.setKeyable(false); addAttribute( aWorldMode ); attributeAffects( aWorldMode, outputGeom ); attributeAffects( aWorldMode, aARAP ); aEffectRadius = nAttr.create("effectRadius", "er", MFnNumericData::kDouble, 8.0); nAttr.setMin( EPSILON ); nAttr.setStorable(true); addAttribute( aEffectRadius ); attributeAffects( aEffectRadius, outputGeom ); attributeAffects( aEffectRadius, aComputeWeight ); aTransWeight = nAttr.create("translationWeight", "tw", MFnNumericData::kDouble, 1e-20); nAttr.setStorable(true); addAttribute( aTransWeight ); attributeAffects( aTransWeight, outputGeom ); attributeAffects( aTransWeight, aARAP ); aAreaWeighted = nAttr.create( "areaWeighted", "aw", MFnNumericData::kBoolean, false ); nAttr.setStorable(true); addAttribute( aAreaWeighted ); attributeAffects( aAreaWeighted, outputGeom ); attributeAffects( aAreaWeighted, aARAP ); aNeighbourWeighting = nAttr.create( "neighbourWeighting", "nghbrw", MFnNumericData::kBoolean, false ); nAttr.setStorable(true); addAttribute( aNeighbourWeighting ); attributeAffects( aNeighbourWeighting, outputGeom ); attributeAffects( aNeighbourWeighting, aComputeWeight ); attributeAffects( aNeighbourWeighting, aARAP ); aConstraintWeight = nAttr.create("constraintWeight", "cw", MFnNumericData::kDouble, 1.0); nAttr.setStorable(true); addAttribute( aConstraintWeight ); attributeAffects( aConstraintWeight, outputGeom ); attributeAffects( aConstraintWeight, aARAP ); aNormExponent = nAttr.create("normExponent", "ne", MFnNumericData::kDouble, 1.0); nAttr.setStorable(true); addAttribute( aNormExponent ); attributeAffects( aNormExponent, outputGeom ); attributeAffects( aNormExponent, aARAP ); attributeAffects( aNormExponent, aComputeWeight ); aIteration = nAttr.create("iteration", "it", MFnNumericData::kShort, 1); nAttr.setStorable(true); addAttribute(aIteration); attributeAffects(aIteration, outputGeom); aConstraintRadius = nAttr.create("constraintRadius", "cr", MFnNumericData::kDouble, 1.0); nAttr.setStorable(true); addAttribute( aConstraintRadius ); attributeAffects( aConstraintRadius, outputGeom ); attributeAffects( aConstraintRadius, aARAP ); aVisualisationMode = eAttr.create( "visualisationMode", "vm", VM_OFF ); eAttr.addField( "off", VM_OFF ); eAttr.addField( "energy", VM_ENERGY ); eAttr.addField( "effect", VM_EFFECT ); eAttr.addField( "constraint", VM_CONSTRAINT ); eAttr.addField( "stiffness", VM_STIFFNESS ); eAttr.setStorable(true); addAttribute( aVisualisationMode ); attributeAffects( aVisualisationMode, outputGeom ); aVisualisationMultiplier = nAttr.create("visualisationMultiplier", "vmp", MFnNumericData::kDouble, 1.0); nAttr.setStorable(true); addAttribute( aVisualisationMultiplier ); attributeAffects( aVisualisationMultiplier, outputGeom ); aStiffness = eAttr.create( "stiffnessMode", "stfm", SM_NONE ); eAttr.addField( "off", SM_NONE ); eAttr.addField( "painted weight", SM_PAINT ); eAttr.addField( "learn", SM_LEARN ); eAttr.setStorable(true); addAttribute( aStiffness ); attributeAffects( aStiffness, outputGeom ); attributeAffects( aStiffness, aARAP ); aSupervisedMesh = tAttr.create("supervisedMesh", "svmesh", MFnData::kMesh); tAttr.setStorable(true); tAttr.setArray(true); tAttr.setUsesArrayDataBuilder(true); addAttribute(aSupervisedMesh); attributeAffects( aSupervisedMesh, outputGeom ); attributeAffects( aSupervisedMesh, aARAP ); aProbeWeight = nAttr.create("probeWeight", "prw", MFnNumericData::kDouble, 1.0); nAttr.setArray(true); nAttr.setStorable(true); nAttr.setUsesArrayDataBuilder(true); addAttribute(aProbeWeight); attributeAffects( aProbeWeight, outputGeom ); attributeAffects( aProbeWeight, aComputeWeight ); aProbeConstraintRadius = nAttr.create("probeConstraintRadius", "prcr", MFnNumericData::kDouble, 1.0); nAttr.setArray(true); nAttr.setStorable(true); nAttr.setUsesArrayDataBuilder(true); addAttribute(aProbeConstraintRadius); attributeAffects( aProbeConstraintRadius, outputGeom ); attributeAffects( aProbeConstraintRadius, aARAP ); //ramp aWeightCurveR = rAttr.createCurveRamp( "weightCurveRotation", "wcr" ); addAttribute( aWeightCurveR ); attributeAffects( aWeightCurveR, outputGeom ); attributeAffects( aWeightCurveR, aComputeWeight ); aWeightCurveS = rAttr.createCurveRamp( "weightCurveShear", "wcs" ); addAttribute( aWeightCurveS ); attributeAffects( aWeightCurveS, outputGeom ); attributeAffects( aWeightCurveS, aComputeWeight ); aWeightCurveL = rAttr.createCurveRamp( "weightCurveTranslation", "wcl" ); addAttribute( aWeightCurveL ); attributeAffects( aWeightCurveL, outputGeom ); attributeAffects( aWeightCurveL, aComputeWeight ); // Make the deformer weights paintable MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer probeDeformerARAP weights;" ); return MS::kSuccess; }
// initialize // ------------ //! Initialises the Attributes on the node, and set the evaluation dependencies MStatus NBuddySurfaceToBodyNode::initialize() { MStatus status; //Function sets needed MFnStringData stringData; MFnPluginData dataFn; MFnMatrixData matrixFn; MFnGenericAttribute genFn; MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MFnMatrixAttribute mAttr; //Attribute that specifies if the object should be converted to worldspace or localspace _useTransform = numAttr.create( "useTransform", "ut", MFnNumericData::kBoolean, true, &status ); NM_CheckMStatus(status, "ERROR creating useWorldSpace attribute.\n"); status = addAttribute( _useTransform ); //The input transform for the object _inTransform = mAttr.create("inTransform","it", MFnMatrixAttribute::kDouble, &status); mAttr.setStorable( true ); mAttr.setConnectable(true); NM_CheckMStatus(status, "ERROR creating inTransform attribute.\n"); status = addAttribute( _inTransform ); NM_CheckMStatus(status, "ERROR adding inTransform attribute.\n"); //Create the inSurface plug _inSurface = genFn.create( "inSurface", "surf", &status); NM_CheckMStatus( status, "Failed to create inSurface GenericAttribute"); genFn.addAccept(MFnData::kNurbsSurface); genFn.addAccept(MFnData::kMesh); genFn.addAccept(MFnData::kSubdSurface); genFn.setStorable(false); genFn.setCached(false); status = addAttribute( _inSurface ); NM_CheckMStatus(status, "ERROR adding inSurface attribute.\n"); // Create the attribute for the body output _outBody = typedAttr.create("outBody","ob" , naiadBodyData::id , MObject::kNullObj , &status); NM_CheckMStatus(status, "ERROR creating outBody attribute.\n"); typedAttr.setKeyable( false ); typedAttr.setWritable( false ); typedAttr.setReadable( true ); typedAttr.setStorable( false ); status = addAttribute( _outBody ); NM_CheckMStatus(status, "ERROR adding outBody attribute.\n"); // Create the attribute for the body name _bodyName = typedAttr.create( "bodyName", "bn", MFnData::kString ,stringData.create( MString("mesh-body") ), &status); NM_CheckMStatus( status, "Failed to create bodyName attribute"); typedAttr.setStorable( true ); typedAttr.setArray( false ); status = addAttribute( _bodyName ); NM_CheckMStatus( status, "Failed to add bodyName plug"); //Tesselation settings _subDivide = numAttr.create( "subDivide", "td", MFnNumericData::kInt , 0, &status); NM_CheckMStatus( status, "Failed to create subDivide attribute"); numAttr.setStorable( true ); numAttr.setArray( false ); status = addAttribute( _subDivide ); NM_CheckMStatus( status, "Failed to add bodyName plug"); // Attribute affects attributeAffects( _bodyName, _outBody ); attributeAffects( _subDivide, _outBody ); attributeAffects( _inSurface, _outBody ); attributeAffects( _useTransform, _outBody ); attributeAffects( _inTransform, _outBody ); return MS::kSuccess; }