MStatus blindDataMesh::initialize() { MFnTypedAttribute typedAttr; MStatus returnStatus; blindDataMesh::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus ); McheckErr(returnStatus, "ERROR creating blindDataMesh output attribute\n"); typedAttr.setStorable(false); returnStatus = addAttribute(blindDataMesh::outputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); MFnNumericAttribute numAttr; blindDataMesh::seed = numAttr.create( "randomSeed", "seed", MFnNumericData::kLong, 0, &returnStatus ); McheckErr(returnStatus, "ERROR creating blindDataMesh input attribute\n"); returnStatus = addAttribute(blindDataMesh::seed); McheckErr(returnStatus, "ERROR adding input attribute\n"); returnStatus = attributeAffects(blindDataMesh::seed, blindDataMesh::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }
MStatus fullLoft::initialize() { MStatus stat; MFnTypedAttribute typedAttr; inputCurve=typedAttr.create( "inputCurve", "in", MFnNurbsCurveData::kNurbsCurve, &stat ); PERRORfail("initialize create input attribute"); stat = typedAttr.setArray( true ); PERRORfail("initialize set input attribute array"); outputSurface=typedAttr.create( "outputSurface", "out", MFnNurbsSurfaceData::kNurbsSurface, &stat ); PERRORfail("initialize create output attribute"); stat = typedAttr.setStorable( false ); PERRORfail("initialize set output attribute storable"); stat = addAttribute( inputCurve ); PERRORfail("addAttribute(inputCurve)"); stat = addAttribute( outputSurface ); PERRORfail("addAttribute(outputSurface)"); stat = attributeAffects( inputCurve, outputSurface ); PERRORfail("attributeAffects(inputCurve, outputSurface)"); return MS::kSuccess; }
MStatus btSPHMgrNode::initialize() { _LogFunctionCall("btSPHMgrNode::initialize()"); MStatus status; MFnUnitAttribute uAttr; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; i_particleShape = nAttr.create(particleShape, ps, MFnNumericData::kInt, 0, &status); IfMErrorWarn(status); IfMErrorWarn(addAttribute(i_particleShape)); i_particlePPAttr = nAttr.create(particlePPAttr, pppa, MFnNumericData::kInt, 0, &status); IfMErrorWarn(status); IfMErrorWarn(addAttribute(i_particlePPAttr)); i_particleCount = nAttr.create( particleCount, pc, MFnNumericData::kInt, 300,&status); IfMErrorWarn(status); IfMErrorWarn(addAttribute( i_particleCount )); i_obstacleAABB = tAttr.create(obstacleBox, obox, MFnData::kMesh, MObject::kNullObj, &status); IfMErrorWarn(status); IfMErrorWarn(addAttribute(i_obstacleAABB)); i_initAABB = tAttr.create(initBox, ibox, MFnData::kMesh, MObject::kNullObj, &status); IfMErrorWarn(status); IfMErrorWarn(addAttribute(i_initAABB)); return MS::kSuccess; }
MStatus EntityInstanceNode::Initialize() { MAYA_START_EXCEPTION_HANDLING(); MStatus stat; // wtf is this - rachel MFnStringData dataFn; MObject stringData = dataFn.create( "" ); // fileName attribute MFnTypedAttribute tAttr; s_ArtFilePath = tAttr.create("ArtFilePath", "fn", MFnData::kString, &stat); tAttr.setDefault( stringData ); MCheckErr(stat, "Unable to create attr: ArtFilePath"); tAttr.setReadable(true); tAttr.setWritable(false); stat = addAttribute(s_ArtFilePath); MCheckErr(stat, "Unable to add attr: ArtFilePath"); MAYA_FINISH_EXCEPTION_HANDLING(); return MS::kSuccess; }
MStatus PushDeformer::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; //add bulge attribute which affects the output geom aAmount = nAttr.create("amount", "amt", MFnNumericData::kDouble, 0.0); nAttr.setKeyable(true); addAttribute(aAmount); aStressMap = tAttr.create("aStressMap", "stMap", MFnData::kDoubleArray); tAttr.setKeyable(true); tAttr.setWritable(true); tAttr.setStorable(true); addAttribute(aStressMap); aUseStress = nAttr.create("useStress", "useStress", MFnNumericData::kBoolean, 0); nAttr.setKeyable(true); nAttr.setStorable(true); addAttribute(aUseStress); aMultiThreadingType = nAttr.create("multiThreadingType", "multiThreadingType", MFnNumericData::kInt, 0); nAttr.setKeyable(true); addAttribute(aMultiThreadingType); attributeAffects(aAmount, outputGeom); attributeAffects(aStressMap, outputGeom); attributeAffects(aUseStress, outputGeom); attributeAffects(aMultiThreadingType, outputGeom); // make paintable deformer MGlobal::executeCommand("makePaintable -attrType multiFloat -sm deformer pushDeformer weights"); return MS::kSuccess; }
MStatus sgBulgeDeformer::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnMatrixAttribute mAttr; MFnCompoundAttribute cAttr; aBulgeWeight = nAttr.create(nameBulgeWeight, nameBulgeWeight, MFnNumericData::kFloat, 1.0); nAttr.setStorable(false); nAttr.setKeyable(true); addAttribute(aBulgeWeight); aBulgeRadius = nAttr.create(nameBulgeRadius, nameBulgeRadius, MFnNumericData::kDouble, 0); nAttr.setMin(0); nAttr.setStorable(false); nAttr.setKeyable(true); addAttribute(aBulgeRadius); aBulgeInputs = cAttr.create(nameBulgeInputs, nameBulgeInputs); aMatrix = mAttr.create(nameMatrix, nameMatrix); aMesh = tAttr.create(nameMesh, nameMesh, MFnData::kMesh ); cAttr.addChild(aMatrix); cAttr.addChild(aMesh); cAttr.setArray(true); addAttribute(aBulgeInputs); attributeAffects(aBulgeWeight, outputGeom); attributeAffects(aBulgeRadius, outputGeom); attributeAffects(aBulgeInputs, outputGeom); return status; }
MStatus SceneShape::initialize() { MStatus s = inheritAttributesFrom( "ieSceneShapeInterface" ); MFnTypedAttribute tAttr; // will need to check for sceneFile extensions aSceneFilePlug = tAttr.create( "file", "scf", MFnData::kString, &s ); assert( s ); s = addAttribute( aSceneFilePlug ); assert( s ); aSceneRootPlug = tAttr.create( "root", "scr", MFnData::kString, MFnStringData().create( "/" ), &s ); assert( s ); s = addAttribute( aSceneRootPlug ); assert( s ); attributeAffects( aSceneFilePlug, aTransform ); attributeAffects( aSceneFilePlug, aBound ); attributeAffects( aSceneFilePlug, aOutputObjects ); attributeAffects( aSceneFilePlug, aAttributes ); attributeAffects( aSceneRootPlug, aTransform ); attributeAffects( aSceneRootPlug, aBound ); attributeAffects( aSceneRootPlug, aOutputObjects ); attributeAffects( aSceneRootPlug, aAttributes ); return s; }
// // DESCRIPTION: MStatus OSLNode::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; color = nAttr.createColor("color", "color"); MAKE_INPUT(nAttr); CHECK_MSTATUS(addAttribute( color )); script = tAttr.create("script", "script", MFnNumericData::kString); MAKE_INPUT(tAttr); CHECK_MSTATUS(addAttribute( script )); outColor = nAttr.createColor("outColor", "outColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( outColor )); //---------------------------- automatically created attributes start ------------------------------------ //---------------------------- automatically created attributes end ------------------------------------ attributeAffects(color, outColor); attributeAffects(script, outColor); return MS::kSuccess; }
MStatus ClothSimMayaPlugin::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MStatus returnStatus; g_aTime = unitAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus); McheckErr(returnStatus, "ERROR creating time attribute\n"); g_aOutputMesh = typedAttr.create("outputMesh", "out", MFnData::kMesh, &returnStatus); McheckErr(returnStatus, "ERROR creating output attribute\n"); typedAttr.setStorable(false); returnStatus = addAttribute(g_aTime); McheckErr(returnStatus, "ERROR adding time attribute\n"); returnStatus = addAttribute(g_aOutputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = attributeAffects(g_aTime, g_aOutputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }
MStatus blendCurve::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnCompoundAttribute cAttr; aInputs = cAttr.create( "inputs", "inputs" ); aInputCurve = tAttr.create( "inputCurve", "inputCurve", MFnData::kNurbsCurve ); tAttr.setStorable( false ); aWeight = nAttr.create( "weight", "weight", MFnNumericData::kFloat, 1.0 ); nAttr.setMin( 0.0 ); nAttr.setMax( 1.0 ); nAttr.setKeyable( true ); aBlendPosition = nAttr.create( "blendPosition", "blendPosition", MFnNumericData::kFloat, 1.0 ); nAttr.setMin( 0.0 ); nAttr.setMax( 1.0 ); nAttr.setKeyable( true ); aBlendArea = nAttr.create( "blendArea", "blendArea", MFnNumericData::kFloat, 0.5 ); nAttr.setMin( 0.0 ); nAttr.setMax( 1.0 ); nAttr.setKeyable( true ); cAttr.addChild( aInputCurve ); cAttr.addChild( aWeight ); cAttr.addChild( aBlendPosition ); cAttr.addChild( aBlendArea ); cAttr.setArray( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputs ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputs, outputGeom ) ); return MS::kSuccess; }
//------------------------------------------------------------------------------ // MStatus AdskPrepareRenderGlobals::initialize() { MStatus stat; MFnStringData stringFn; MObject emptyStr = stringFn.create( &stat ); MObject* attrib[3]; attrib[0] = &aRepName; attrib[1] = &aRepLabel; attrib[2] = &aRepType; const char* longName[] = {"repName", "repLabel", "repType"}; const char* shortName[] = {"rna", "rla", "rty"}; MFnTypedAttribute stringAttrFn; for (int i = 0; i < 3; i++) { *attrib[i] = stringAttrFn.create(longName[i], shortName[i], MFnData::kString, emptyStr); stat = MPxNode::addAttribute(*attrib[i]); CHECK_MSTATUS_AND_RETURN_IT(stat); } MFnNumericAttribute boolAttrFn; aUseRegEx = boolAttrFn.create("useRegExp", "urx", MFnNumericData::kBoolean, 0); stat = MPxNode::addAttribute(aUseRegEx); CHECK_MSTATUS_AND_RETURN_IT(stat); return stat; }
MStatus sgBLocator_fromGeo::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; aOutputValue = nAttr.create( "outputValue", "outputValue", MFnNumericData::kInt, 1.0 ); nAttr.setStorable( false ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aOutputValue ) ); CHECK_MSTATUS_AND_RETURN_IT( status ); aInputCurve = tAttr.create( "inputCurve", "inputCurve", MFnData::kNurbsCurve ); tAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputCurve ) ); aLineWidth = nAttr.create( "lineWidth", "lineWidth", MFnNumericData::kInt, 1 ); nAttr.setMin( 1 ); nAttr.setKeyable( true ); nAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aLineWidth ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputCurve, aOutputValue ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aLineWidth, aOutputValue ) ); return MS::kSuccess; }
MStatus mapBlendShape::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; aBlendMesh = tAttr.create("blendMesh", "blendMesh", MFnData::kMesh); addAttribute(aBlendMesh); aBlendMap = nAttr.createColor("blendMap", "blendMap"); addAttribute(aBlendMap); aUseBlendMap = nAttr.create("useBlendMap", "useBlendMap", MFnNumericData::kBoolean); nAttr.setDefault(true); addAttribute(aUseBlendMap); aBlendMapMultiplier = nAttr.create("blendMapMultiplier", "blendMapMultiplier", MFnNumericData::kFloat); nAttr.setDefault(1.0); nAttr.setMin(0.0); addAttribute(aBlendMapMultiplier); attributeAffects(aBlendMesh, outputGeom); attributeAffects(aBlendMap, outputGeom); attributeAffects(aUseBlendMap, outputGeom); attributeAffects(aBlendMapMultiplier, outputGeom); MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer blendNode weights;" ); return MS::kSuccess; }
MStatus EntityNode::Initialize() { MAYA_START_EXCEPTION_HANDLING(); MStatus stat; //////////////////////////////////////////////////////////////////////////////////////////////////// // Create a string attribute "ArtFilePath" MFnTypedAttribute tAttr; s_ArtFilePath = tAttr.create("ArtFilePath", "afp", MFnData::kString, &stat); MCheckErr(stat, "Unable to create attr: ArtFilePath"); tAttr.setReadable(true); tAttr.setWritable(false); stat = addAttribute(s_ArtFilePath); MCheckErr(stat, "Unable to add attr: ArtFilePath"); //////////////////////////////////////////////////////////////////////////////////////////////////// // Create an array attribute "ImportNodes" MFnMessageAttribute mAttr; m_ImportNodes = mAttr.create( "ImortObjects", "ios", &stat ); MCheckErr(stat, "Unable to create attr: ImportNodes"); mAttr.setArray( true ); stat = addAttribute(m_ImportNodes); MCheckErr(stat, "Unable to add attr: ImportNodes"); MAYA_FINISH_EXCEPTION_HANDLING(); return MS::kSuccess; }
MStatus animCube::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MStatus returnStatus; animCube::time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus ); McheckErr(returnStatus, "ERROR creating animCube time attribute\n"); animCube::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus ); McheckErr(returnStatus, "ERROR creating animCube output attribute\n"); typedAttr.setStorable(false); returnStatus = addAttribute(animCube::time); McheckErr(returnStatus, "ERROR adding time attribute\n"); returnStatus = addAttribute(animCube::outputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = attributeAffects(animCube::time, animCube::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); 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; }
// maya plugin initialization MStatus CageDeformerNode::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; aCageMesh = tAttr.create( "cageMesh", "cm", MFnData::kMesh ); addAttribute( aCageMesh ); attributeAffects( aCageMesh, outputGeom ); aCageMode = eAttr.create( "cageMode", "cgm", 10 ); eAttr.addField( "vertex", 0 ); eAttr.addField( "vertexNormalized", 1 ); eAttr.addField( "vertex avg. normal", 5 ); eAttr.addField( "vertex avg. normal normalized", 6 ); eAttr.addField( "face", 10 ); eAttr.addField( "faceSymmetrized", 11 ); // eAttr.addField( "init", 99 ); addAttribute( aCageMode ); attributeAffects( aCageMode, outputGeom ); aConstraintMode = eAttr.create( "constraintMode", "constraint", 0 ); eAttr.addField( "none", 0 ); eAttr.addField( "allFaces", 1 ); addAttribute( aConstraintMode ); attributeAffects( aConstraintMode, outputGeom ); aConstraintWeight = nAttr.create("constraintWeight", "cw", MFnNumericData::kDouble, 1.0); nAttr.setStorable(true); addAttribute( aConstraintWeight ); attributeAffects( aConstraintWeight, outputGeom ); aBlendMode = eAttr.create( "blendMode", "bm", 0 ); eAttr.addField( "polarexp", 0 ); eAttr.addField( "polarexpSE", 1 ); eAttr.addField( "logmatrix3", 2 ); eAttr.addField( "logmatrix4", 3 ); eAttr.addField( "quaternion", 5 ); eAttr.addField( "linear", 10 ); eAttr.addField( "off", 99 ); addAttribute( aBlendMode ); attributeAffects( aBlendMode, outputGeom ); aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, 0 ); nAttr.setStorable(true); addAttribute( aRotationConsistency ); attributeAffects( aRotationConsistency, outputGeom ); aFrechetSum = nAttr.create( "frechetSum", "fs", MFnNumericData::kBoolean, 0 ); nAttr.setStorable(true); addAttribute( aFrechetSum ); attributeAffects( aFrechetSum, outputGeom ); return MS::kSuccess; }
// INIT ========================================= MStatus gear_uToPercentage::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MStatus stat; // Curve curve = tAttr.create("curve", "crv", MFnData::kNurbsCurve); stat = addAttribute( curve ); if (!stat) {stat.perror("addAttribute"); return stat;} // Sliders normalizedU = nAttr.create("normalizedU", "n", MFnNumericData::kBoolean, false); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( normalizedU ); if (!stat) {stat.perror("addAttribute"); return stat;} u = nAttr.create("u", "u", MFnNumericData::kFloat, .5, 0); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( u ); if (!stat) {stat.perror("addAttribute"); return stat;} steps = nAttr.create("steps", "s", MFnNumericData::kShort, 40); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( steps ); if (!stat) {stat.perror("addAttribute"); return stat;} // Outputs percentage = nAttr.create( "percentage", "p", MFnNumericData::kFloat, 0 ); nAttr.setWritable(false); nAttr.setStorable(false); nAttr.setReadable(true); nAttr.setKeyable(false); stat = addAttribute( percentage ); if (!stat) {stat.perror("addAttribute"); return stat;} // Connections stat = attributeAffects ( curve, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( steps, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( u, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( normalizedU, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus LSystemNode::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MFnNumericAttribute numericAttr; MStatus returnStatus; //(i)angle LSystemNode::angle = numericAttr.create("angle","ag",MFnNumericData::kDouble,90.0,&returnStatus); McheckErr(returnStatus, "ERROR creating LSystemNode angle attribute\n"); //(ii)size step = numericAttr.create("step","st",MFnNumericData::kDouble,1.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSystemNode step attribute\n");//(iv)time //(iii)grammar LSystemNode::grammar = typedAttr.create( "grammar", "grm", MFnData::kString, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode grammar attribute\n"); //(iv)time LSystemNode::time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode time attribute\n"); //(v)output LSystemNode::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode output attribute\n"); typedAttr.setStorable(false); //(i)angle returnStatus = addAttribute(LSystemNode::angle); McheckErr(returnStatus, "ERROR adding angle attribute\n"); //(ii)step returnStatus = addAttribute(LSystemNode::step); McheckErr(returnStatus, "ERROR adding step attribute\n"); //(iii)grammar returnStatus = addAttribute(LSystemNode::grammar); McheckErr(returnStatus, "ERROR adding grammar attribute\n"); //(iv)time returnStatus = addAttribute(LSystemNode::time); McheckErr(returnStatus, "ERROR adding time attribute\n"); //(v)output returnStatus = addAttribute(LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = attributeAffects(LSystemNode::angle,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); returnStatus = attributeAffects(LSystemNode::step,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); returnStatus = attributeAffects(LSystemNode::grammar,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); returnStatus = attributeAffects(LSystemNode::time,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }
MStatus inverseSkinCluster::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; MFnMessageAttribute msgAttr; MFnTypedAttribute tAttr; aInMesh = tAttr.create( "inMesh", "inMesh", MFnData::kMesh ); tAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInMesh ) ); aGeomMatrix = mAttr.create( "geomMatrix", "geomMatrix" ); tAttr.setCached( false ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGeomMatrix ) ); aMatrix = mAttr.create( "matrix", "matrix" ); mAttr.setArray( true ); mAttr.setStorable( true ); mAttr.setUsesArrayDataBuilder( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aMatrix ) ); aBindPreMatrix = mAttr.create( "bindPreMatrix", "bindPreMatrix" ); mAttr.setArray( true ); mAttr.setStorable( true ); mAttr.setUsesArrayDataBuilder( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aBindPreMatrix ) ); aUpdateMatrix = nAttr.create( "updateMatrix", "updateMatrix", MFnNumericData::kBoolean, false ); nAttr.setStorable( false ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aUpdateMatrix ) ); aTargetSkinCluster = msgAttr.create( "targetSkinCluster", "targetSkinCluster" ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aTargetSkinCluster ) ); aUpdateWeightList = nAttr.create( "updateWeightList", "updateWeightList", MFnNumericData::kBoolean, false ); nAttr.setStorable( false ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aUpdateWeightList ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInMesh, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGeomMatrix, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aMatrix, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aBindPreMatrix, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aUpdateMatrix, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aUpdateWeightList, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aTargetSkinCluster, outputGeom ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aMatrix, outputGeom ) ); return MS::kSuccess; }
MStatus CmpMeshModifierNode::initialize() { MFnTypedAttribute tAttr; inMesh = tAttr.create( "inMesh", "im", MFnData::kMesh ); outMesh = tAttr.create( "outMesh", "om", MFnData::kMesh ); tAttr.setStorable( false ); addAttribute( inMesh ); addAttribute( outMesh ); attributeAffects( inMesh, outMesh ); return MS::kSuccess; }
MStatus Maya::SetNodeID( const MObject& node, const Helium::TUID& id ) { MStatus status; MFnDependencyNode nodeFn (node); // make sure we have the dynamic attribute to store our id created MObject attr = nodeFn.attribute(MString (s_TUIDAttributeName), &status); if (status == MS::kFailure) { // check to see if we are a locked node bool nodeWasLocked = nodeFn.isLocked(); if ( nodeWasLocked ) { // turn off any node locking so an attribute can be added nodeFn.setLocked( false ); } // create the attribute MFnTypedAttribute attrFn; attr = attrFn.create(MString (s_TUIDAttributeName), MString (s_TUIDAttributeName), MFnData::kString); status = nodeFn.addAttribute(attr); // reset to the prior state of wasLocked if ( nodeWasLocked ) { nodeFn.setLocked( nodeWasLocked ); } // error check if (status == MS::kFailure) { MGlobal::displayError(MString ("Unable to create TUID attribute on maya node: ") + nodeFn.name()); return status; } } MPlug plug (node, nodeFn.attribute(MString (s_TUIDAttributeName))); plug.setLocked(false); tstring s; id.ToString(s); plug.setValue(MString(s.c_str())); plug.setLocked(true); return status; }
void MFnCompoundAttrAddString( MFnCompoundAttribute &attr, const char* full, const char* brief, const char* def ) { MStatus status; MFnTypedAttribute stringAttribute; MObject strinAttrObj = stringAttribute.create( full, brief, MFnData::kString, &status ); // Default strings don't get saved, so setting values for defaults in AddRenderContextAttribute //if( def != 0 ) //{ // MFnStringData defaultString; // MObject defaultStringObj = defaultString.create(def); // stringAttribute.setDefault(defaultStringObj); //} attr.addChild( strinAttrObj ); }
MStatus PRTAttrs::addStrParameter(MFnDependencyNode & node, MObject & attr, const MString & name, MString & value ) { MStatus stat; MStatus stat2; MFnStringData stringData; MFnTypedAttribute sAttr; attr = sAttr.create(longName(name), briefName(name), MFnData::kString, stringData.create(value, &stat2), &stat ); MCHECK(stat2); MCHECK(stat); MCHECK(addParameter(node, attr, sAttr)); MPlug plug(node.object(), attr); MCHECK(plug.setValue(value)); return MS::kSuccess; }
MStatus DynamicEnum::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnStringData sData; 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. // // Attribute Initialization: aFilePath = tAttr.create( "filepath", "file", MFnData::kString, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setKeyable( true ) ); CHECK_MSTATUS( tAttr.setStorable( true ) ); CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) ); aGridName = tAttr.create( "grid", "grd", MFnData::kString, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setKeyable( true ) ); CHECK_MSTATUS( tAttr.setStorable( true ) ); CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) ); aOutColor = nAttr.createColor( "outColor", "oc", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); // Next we will add the attributes we have defined to the node // CHECK_MSTATUS( addAttribute( aFilePath ) ); CHECK_MSTATUS( addAttribute( aGridName ) ); CHECK_MSTATUS( addAttribute( aOutColor ) ); // The attributeAffects() method is used to indicate when the input // attribute affects the output attribute. This knowledge allows Maya // to optimize dependencies in the graph in more complex nodes where // there may be several inputs and outputs, but not all the inputs // affect all the outputs. // CHECK_MSTATUS( attributeAffects( aFilePath, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aGridName, aOutColor ) ); return( MS::kSuccess ); }
MStatus splatDeformer::initialize() { // local attribute initialization MStatus status; MFnTypedAttribute mAttr; deformingMesh=mAttr.create( "deformingMesh", "dm", MFnMeshData::kMesh); mAttr.setStorable(true); // deformation attributes status = addAttribute( deformingMesh ); MCheckStatus(status, "ERROR in addAttribute\n"); status = attributeAffects( deformingMesh, outputGeom ); MCheckStatus(status, "ERROR in attributeAffects\n"); return MStatus::kSuccess; }
MStatus DucttapeMergeDeformer::initialize() { MStatus stat; MFnNumericAttribute numericFn; MFnTypedAttribute typedAttrFn; ainmesh = typedAttrFn.create("inMesh", "inm", MFnData::kMesh); typedAttrFn.setStorable(false); typedAttrFn.setWritable(true); typedAttrFn.setConnectable(true); addAttribute( ainmesh ); attributeAffects(ainmesh, outputGeom); MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer ducttapeMergeDeformer weights" ); 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 sgMeshIntersect::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnMatrixAttribute mAttr; aPointSourceX = nAttr.create( "pointSourceX", "psx", MFnNumericData::kDouble, 0.0 ); aPointSourceY = nAttr.create( "pointSourceY", "psy", MFnNumericData::kDouble, 0.0 ); aPointSourceZ = nAttr.create( "pointSourceZ", "psz", MFnNumericData::kDouble, 0.0 ); aPointSource = nAttr.create( "pointSource", "ps", aPointSourceX, aPointSourceY, aPointSourceZ ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aPointSource ) ); aPointDestX = nAttr.create( "pointDestX", "pdx", MFnNumericData::kDouble, 0.0 ); aPointDestY = nAttr.create( "pointDestY", "pdy", MFnNumericData::kDouble, 0.0 ); aPointDestZ = nAttr.create( "pointDestZ", "pdz", MFnNumericData::kDouble, 0.0 ); aPointDest = nAttr.create( "pointDest", "pd", aPointDestX, aPointDestY, aPointDestZ ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aPointDest ) ); aInputMesh = tAttr.create( "inputMesh", "inMesh", MFnData::kMesh ); tAttr.setCached( false ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputMesh ) ); aInputMeshMatrix = mAttr.create( "inputMeshMatrix", "inMatrix" ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputMeshMatrix ) ); aParentInverseMatrix = mAttr.create( "parentInverseMatrix", "pim" ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aParentInverseMatrix ) ); aOutPointX = nAttr.create( "outPointX", "opx", MFnNumericData::kDouble, 0.0 ); aOutPointY = nAttr.create( "outPointY", "opy", MFnNumericData::kDouble, 0.0 ); aOutPointZ = nAttr.create( "outPointZ", "opz", MFnNumericData::kDouble, 0.0 ); aOutPoint = nAttr.create( "outPoint", "op", aOutPointX, aOutPointY, aOutPointZ ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aOutPoint ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aPointSource, aOutPoint ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aPointDest, aOutPoint ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputMesh, aOutPoint ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputMeshMatrix, aOutPoint ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aParentInverseMatrix, aOutPoint ) ); m_nodeNumber = 0; return MS::kSuccess; }
MStatus arcLen::initialize() { MFnNumericAttribute numericAttr; MFnTypedAttribute typedAttr; MStatus status; inputCurve = typedAttr.create( "inputCurve", "in", MFnData::kNurbsCurve, &status ); if( !status ) { status.perror("ERROR creating arcLen curve attribute"); return status; } output = numericAttr.create( "output", "out", MFnNumericData::kDouble, 0.0, &status ); if( !status ) { status.perror("ERROR creating arcLen output attribute"); return status; } numericAttr.setWritable(false); status = addAttribute( inputCurve ); if( !status ) { status.perror("addAttribute(inputCurve)"); return status; } status = addAttribute( output ); if( !status ) { status.perror("addAttribute(output)"); return status; } status = attributeAffects( inputCurve, output ); if( !status ) { status.perror("attributeAffects(inputCurve, output)"); return status; } return MS::kSuccess; }